[Kde-pim] KJots on Akonadi. Help needed.

Stephen Kelly steveire at gmail.com
Thu Oct 2 16:27:04 BST 2008


Hi,

I've made a little bit of progress porting kjots to akonadi, but I've hit
several roadblocks that I'd like some help with. I've put the code in
playground along with some test data:

http://websvn.kde.org/trunk/playground/pim/kjotsrewrite/

You can check it out and cmakekde, followed by plasmoidviewer kjots-plasmoid
to see the kjots plasmoid.

My first issue is that in kjots, books and pages are represented in a tree
where books and pages can be siblings (ie, books contain pages and can be
nested). I thought I would represent this in akonadi by using Collection
for books and Item for pages (an item has a payload of a KJotsPage).

However, even though collections can contain collections, I don't think
there's any way in akonadi for collections and items to be an ordered list
of siblings. To get around that, I thought I'd have an additional item in
the collections, a KJotsBook, which would just be a placeholder with a
remoteId equal a collection remoteId. To build the kjots item tree I could
then look through the items in each collection, and if I find a KJotsBook,
retrieve the collection with that remoteId etc. If you view the kjots
bookshelf in akonadiconsole, you will see both books and items in the
browser tab when clicking a book with a nested book inside.

As CollectionModel contains only Collections and not Items, I somehow need
to get collections and items into the same tree. I thought I could some
kind of ProxyModel that could do that work, but not having enough
experience with interview and akonadi is getting in the way. Is what I want
to do possible at all? I have some attempts and experiments in playground
now.

KJotsBookshelfModel is a wrapper around a Akonadi::CollectionFilterModel. I
thought that if I could get that to work, I could examine the indexes
before forwarding them, and conditionally retrieve items to put in the
model instead. However, that seems to be an invalid model. It might be
because I'm trying to return QModelIndexs from proxy. I might have better
luck if I use createIndex() instead to create valid indexes for the
KJotsBookshelfModel. Does anyone know?

Another attempt is KJotsProxyModel, which is a subclass of
Akonadi::CollectionFilterModel. I think that I might be able to reimplement
mapFromSource and mapToSource to return either a QModelIndex from the
collection, or create a new one for an item. Again I haven't done this
before, so I don't even know if it's possible. Most ProxyModel use seems to
be for sorting/filtering rather than adding new items to the model.

Another option which I have not yet attempted is writing my own model from
scratch or forking Akonadi::CollectionModel as KJotsModel and adding the
items to it in its internal handling. That sounds like the most work to me
right now.

Can someone with more experience with Interview (vkrause? till?) give some
help/guidance on this?

My second issue is about the serializer and resource, and what their
responsibilities are. Currently SerializerPluginKJots::deserialize and
KJotsResource::retrieveItem do almost the same thing. That seems wrong, but
I'm not sure how to make the resource use the serializer method, or if
that's even the right thing to do.

Can someone give more information on whether I need to change what these
methods are doing?

Also, What do I need to do to make the item data appear in the Payload tab
in the browser? The data appears fine in the raw_payload tab already. (At
least it did until today. It doesn't now, and I don't know why).


Thanks for any help with this.

Steve.


_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list