D29602: Add field "Folder" to theme content items and to message tool tip

Daniel Vrátil noreply at phabricator.kde.org
Wed May 13 08:19:10 BST 2020


dvratil requested changes to this revision.
dvratil added a comment.
This revision now requires changes to proceed.


  `collectionForId` is a good name, I think.

INLINE COMMENTS

> storagemodel.cpp:263
> +    }
> +    mi->setFolder(folder);
>  

This will use a ton of memory and will make populating the model slow - for each single email you will need to resolve the real parent collection, traverse the collection parent chain and assemble the string.

I suggest you add a `QHash<Collection::Id, QString>` lookup table into the StorageModel and try to look up the path by the collection ID there first, then fallback to building the path and inserting it into the hash map. This way we will make use of the implicit QString sharing so all items from the same collection will share the same single string with the path reducing memory footprint, and  we will avoid assembling the string every time, which is more costly than a hash map lookup.

Remember to clear the hash map when the selected folder is changed.

> storagemodel.cpp:506
> +    // get index in EntityTreeModel
> +    const QModelIndex idx = EntityTreeModel::modelIndexForCollection(etm, Collection(colId));
> +    Q_ASSERT(idx.isValid());

You can pass the `d->mChildrenFilterModel` here instead of the `etm`, the code inside is clever enough to find the ETM source model.

REPOSITORY
  R94 PIM: Message Library

REVISION DETAIL
  https://phabricator.kde.org/D29602

To: gordin, #vdg, dvratil
Cc: dvratil, kde-pim, jamesth, fbampaloukas, dvasin, hrouis, rodsevich, ach, winterz, vkrause, mlaurent, knauss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20200513/aff29d31/attachment.htm>


More information about the kde-pim mailing list