Something strange going on with Tags
Closed, ResolvedPublic

Description

After debugging https://bugs.kde.org/show_bug.cgi?id=352015 here are my findings:

  • tagmodel_p.cpp completely ignores tags with an invalid parent (parentId == -1)
  • All tags created through TagCreateJob create a tag with invalid parent
  • In the database, the table tagtable has no value for parentId column, it's empty

So, should tagmodel be made smarter, or the problem is the creation ?

smartins created this task.Aug 30 2015, 7:42 PM
smartins updated the task description. (Show Details)
smartins raised the priority of this task from to High.
smartins assigned this task to dvratil.
smartins added a project: KDE PIM.
smartins added a subscriber: smartins.

imho, the root should be an invalid tag, -1, just like QModelIndex() is the root of a tree model

dvratil moved this task from Backlog to In Progress on the KDE PIM board.Aug 31 2015, 10:48 AM

commit 64f9ea3740bb631f20c15e907f18f47a2afef07e
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:18:39 2015 +0200

TagModel: fix removing of tags from the model

Removing Tags with no parent was broken as the code considered such tags
broken and aborted prematurely.

commit 564d524728166be52d0080761b5108ab07e29af4
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:17:23 2015 +0200

TagModel: correctly populated tag tree deeper than 2

The original algorithm would only attach direct pending descendants of the newly
added parent, but would not recurse to attach grand-descendats.

Discovered by TagModelTest.

commit 5344b40b2cfa3809d392e344bc0a20188df84bb1
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:16:05 2015 +0200

Fix TagModel ignoring tags without parent due to mismatch in ID of invalid parent

By default invalid Tag has ID -1, the TagModel was expecting 0, so Tags that had
invalid parent were never attached to the root Tag and so the model was never
correctly populated (how come nobody noticed this?)

Discovered by Sergio and confirmed by TagModelTest.

commit aa3b25e5270fac57345a4c3cf82813f8b0973581
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:13:50 2015 +0200

Fix Tag::setParent() not allowing to reset parent to empty

Tags can now be correctly reparented to no (invalid) parent.

commit 4c2d34bd41ca153f6c75455e9166f6568ba4eee0
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:12:29 2015 +0200

Add proper ModelSpy-based TagModelTest (based on ETMTest)

This extends FakeServerData and FakeAkonadiServerCommand to support fake Tag
events in addition to Collection and Item events.

commit b9f9a0513e6d8f1a981f3754b037370c3c8cd790
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:08:24 2015 +0200

Fix behaviour of Tag::operator==()

Invalid tags without GID are equal, invalid tags with identical GIDs are equal,
valid tags with the same ID are equal. All other cases are not equal. Implement
this behaviour properly and add a unit-test for it.

commit 921db8e87fd8d4435bde06e27862114c73205d38
Author: Dan Vrátil <dvratil@redhat.com>
Date: Thu Sep 3 00:06:03 2015 +0200

Fix ProtocolHelper::parseTagFetchResult() not populating tag parent

Add a unittest to verify the method is parsing the Response correctly.
smartins closed this task as Resolved.Sep 3 2015, 7:45 AM

great stuff!

dvratil moved this task from In Progress to Done on the KDE PIM board.Sep 3 2015, 8:47 AM