Cache tags by name instead of gid
ClosedPublic

Authored by dkurz on Aug 13 2016, 12:51 PM.

Details

Summary

To set and retrieve category colors, a TagCache is used, where tags are stored by gid. So far, the utf8 encoding of a tag's name was used to retrieve a tag from the cache. In general, however, the gid of a tag is not the same as its name. Since the gid may be unknown when looking for a tag's color, this change switches to the tags' names for keys.

Fixes Bug 333754

Diff Detail

Repository
R75 PIM: Calendar Support
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dkurz updated this revision to Diff 5891.Aug 13 2016, 12:51 PM
dkurz retitled this revision from to Cache tags by name instead of gid.
dkurz updated this object.
dkurz edited the test plan for this revision. (Show Details)
dkurz added a reviewer: KDE PIM.
dkurz set the repository for this revision to R75 PIM: Calendar Support.
Restricted Application added a project: KDE PIM. · View Herald TranscriptAug 13 2016, 12:51 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
knauss added a subscriber: knauss.Aug 14 2016, 9:50 AM

I don't think that iti si a good idea to change the API from getTagByGid -> getTagByName, because also other applications use this.

My suggestion to add a Method called getTagByGidOrName. we ( kolab) have written one based at 4.13:

https://git.kolab.org/rKPddc2f877ac219ac7a29ba8778b50f40f1093a9cc

That way you don't break old code.

dkurz updated this revision to Diff 5906.Aug 14 2016, 10:35 AM

The original methods of TagCache were restored in order not to break old code that relies on it. In order to avoid name-gid collisions and because of the fact that clients know whether they want to match gids or names, we maintain separate methods for the tag name and gid caches.

knauss added inline comments.Aug 14 2016, 11:22 AM
src/tagcache.h
58

I would suggest QHash<QString, Akonadi::Tag::Id>, becuase the name is actually a QString, so no need to convert it to/from a QString.

dkurz updated this revision to Diff 5950.Aug 15 2016, 3:22 PM

It seems QString is just as hashable as QByteArray :-)

dkurz marked an inline comment as done.Aug 15 2016, 3:23 PM

i have tested this form a user perspective on fresh tags and it works without any problems so far. categories keep their color.

dvratil requested changes to this revision.Aug 23 2016, 8:15 PM
dvratil added a reviewer: dvratil.
dvratil added a subscriber: dvratil.

Looks good, two minor nitpicks:

As this introduces new public API, you have to bump PIM_VERSION in CMakeLists.txt.

src/tagcache.h
45

The argument should be called name

This revision now requires changes to proceed.Aug 23 2016, 8:15 PM
dkurz updated this revision to Diff 6204.Aug 24 2016, 6:37 AM
dkurz edited edge metadata.

Fix what was asked for. I assume it is sufficient to change the PIM_VERSION in the CMakeFile.txt of calendarsupport only, since PIM_VERSIONs between pim modules are already diverging.

Please note that I do not have commit access, so reviewers, go ahead :-)

dkurz marked an inline comment as done.Aug 24 2016, 6:39 AM

Marked inline comment as done

dvratil accepted this revision.Aug 26 2016, 1:10 PM
dvratil edited edge metadata.
This revision is now accepted and ready to land.Aug 26 2016, 1:10 PM
This revision was automatically updated to reflect the committed changes.