How to get Akonadi notes onto Plasma?

Sebastian Kügler sebas at kde.org
Mon Oct 26 00:39:14 CET 2009


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. 

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. 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 ...

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?

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. 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).

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.

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.

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. 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. :)
-- 
sebas

 http://www.kde.org | http://vizZzion.org |  GPG Key ID: 9119 0EF9 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20091026/1643a8a3/attachment.sig 


More information about the Plasma-devel mailing list