How to get Akonadi notes onto Plasma?

Stephen Kelly steveire at
Mon Oct 26 18:05:06 CET 2009

Sebastian Kügler wrote:

> Hey Steve,
> On Friday 23 October 2009 20:01:17 Stephen Kelly wrote:
>> Any more thoughts on the plan and intentions above?
> What you probably want is to be able to display interesting collections of
> notes, for example an itemview with notes with some specific tag, and
> being able to display notes separately as individual applets. I'm not sure
> if extenders is what you actually want here. Slapping 20 extenders on top
> of each other is visual overkill. Also, dragging an extender from a group
> (popup applet in the panel, for example) should probably not remove it
> from that list.

I'm experimenting with this at the moment. I can create new extenderitems, 
but when I try to move them about the screen, they pop back into the applet.

> Here's what came to my mind, partly based how I've done things in Lion
> Mail, including question marks I've run into...
> The most flexible way to display a collection of notes is using the models
> akonadi already provides, that gives searching and sorting goodness. Think
> for example of a listview of (expandable) notes on your desktop. You might
> have separate "notes collection" applets there, or on different
> activities. Notes should be draggable. The nicest way I've found to do
> that was using akonadi:/ URLs pointing to an item.

Yes, I plan to try to make this kind of thing possible.

> This way, you can just
> drag and drop notes, also across applications (think of dragging a note
> from kontact/kjots onto plasma). A quick way to create such an applet is
> do use a Plasma::PopupApplet and putting a (QWidget-based) listview onto
> Plasma using a QGraphicsProxyWidget. Longer term, it probably makes more
> sense to use Plasma Widgets and QGraphicsWidgets for that, but ...

Yes, I do something like that for the kjots plasmoid.

> Something I've been wondering, and maybe someone here shed some light on
> it, is how we can generally map models onto Plasma. Is creating separate
> QGraphicsItems on a QGraphicsScene smart? I've heard that QGraphicsView is
> optimized for many items, but slapping 5000 email widgets into a
> popupapplet (most of them never ever visible) just doesn't sound right to
> me. I think the itemviews used in kmail re-use the delegates, right?

I don't know much about GraphicsView yet, so I can't really say. What I have 
currently is a filtered model. When new rows are inserted into the model, I 
create a new ExtenderItem for it.

> Adding support for the notes in the dataengine would be useful, it
> supports email, contact and microblogging right now. It's not using
> EntityTreeModel yet though, but it could be cool if it offered search for
> notes by, for example requesting "Notes- MyLittleTag", "Notes-Recent10" or
> something like that. 

These kinds of things should be fairly easy with virtual collections. It 
just needs a nice config UI.

> The big benefit here is that this makes it easy to
> display notes, it's not quite suitable for editing though.
> (Plasma::Service might help here). Supporting notes in the dataengine
> means that scripted applets can easily access the data without needing to
> know about akonadi specifically (or have bindings to akonadi libs).

Yes, that would be nice in the future, but from the information I got in IRC 
it would be better to have just one applet with extenders. One reason I 
think is that when plasma gets a notification that a new note was added to 
akonadi and must be displayed in plasma, there isn't really anything that 
can create a new applet for the new note. Currently, there I have one applet 
that contains an EntityTreeModel. when the model says a new note from 
akonadi should be shown, it is put into the extender. From looking at the 
api, I should also be able to react to removes and data changes.

> Another interesting thing is styling of the notes. You'll likely want
> different stylesheets for displaying notes content on Plasma than on
> KJots, and I assume you're using GrantLee for that :)). I've written a
> small class that gets the Plasma::Theme's color palette and puts those
> colors into a stylesheet. This is actually something that would be very
> useful for Plasma, I'm thinking of a Plasma::StyleSheet here, which
> provides a basic stylesheet in plasma coloring. That's basically what the
> stylesheet class in lion mail does, no fancy templating though. We could
> probably brush this up and put it into libplasma, if it's of any interest.

I'm not certain Grantlee will be used for the sticky notes, but for other 
uses, that looks like a good approach. The only things that should be 
available in the stickynotes is: edit the text and title, and change the 
background colour.

> In 4.4, you can drag and drop URLs onto Plasma, and it will try to find
> the mimetype using KIO and offer an applet based on that (the URL is
> passed as argument to the applet), the applet defines in its .desktop file
> which mimetype it accepts. I'm not sure if the mimetype of a note
> (text/html? text/plain) will tell you "this is an akonadi note, that's
> something we haven't solved yet). As a kludge, I have just special-cased
> dropped akonadi:/ URLs in kdelibs/plasma/containment.cpp to add an email
> applet. That's not committed to KDE SVN though, if you want I can try to
> find that small patch.

I think we can come back to that when more of the basic stuff is in place. 
Is it possible to have a drop on a containment cause a particular applet to 
create a new extenderItem? If it can only create new applets, I might have 
to do without that feature for the beginning.

> If you want to re-use the existing notes applet, that makes sense IMO for
> displaying and editing individual notes. Currently, the notes applet
> stores its contents in the config file, which is quite ugly IMO. It would
> make a lot of sense if those notes were transparantly stored in akonadi.

Yep, I'm making a solution which uses akonadi, and hopefully I can merge 
together with the existing applet when the basics needed from an akonadi POV 
are in place.

> That means that when you create a new note, a new akonadi note item is
> created. Closing the note applet won't delete it (just closes this view on
> the note), but there could be a separate "delete this note" option. For
> the Notes applet, it might make sense to not use the dataengine, btw.
> Hooking this up using the akonadi libs makes it much easier.
> I hope this is not too much information at a time. If you've questions,
> just ask. :)

I have just put a WIP into branches/work/akoports/kdepim/kjots/plasmoid. It 
probably shouldn't be in the kjots dir, and it has hardcoded paths that only 
work on my filesystem, and instead of fetching notes for one particular 
collection, it fetches all notes in all collections. Forget all that for 

When I run it in a Xephyr session in a panel and try to drag an extenderItem  
out of the applet, it just pops back in again. Is there something I have to 
do to make that work?

All the best,


More information about the Plasma-devel mailing list