[Kde-pim] Q: virtual / unread email collections; flags; drop data

Thomas McGuire mcguire at kde.org
Wed Jul 21 19:38:53 BST 2010


On Tuesday 20 July 2010 13:21:26 Sebastian Kügler wrote:
> Now I need to touch new ground. I can show a collection, get change
> notifications and all that, but it's still just a normal collection. What
> I'd like (need), is:
> 
> - a collection showing unread emails in the inbox (easiest case)
> - a collection showing unread emails from folder A, B, C (poweruser case)
> - a collection showing emails marked as important
> 
> My guess would be that I need a suitable SPARQL query to setup the 'virtual
> collection', and a sortproxymodel to massage it into an ordered list I can
> work with. I know next to nothing about SPARQL (but some SQL), so if
> someone had an example I could modify, that would be most helpful. An
> example how I'd setup a virtual folder based on a SPARQL query would be
> very useful as well.

Indeed, all your 3 examples above can be handled by the appropriate SPARQL 
query.
What you can do is create a search and KMail and then see what query is sent 
to Akonadi by using the debugger in akonadiconsole. 
For example, I searched for all unread mail in all folders, and this is the 
query that was generated:
"select distinct ?r ?reqProp1 where { { ?r 
<http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#isRead> 
\"false\"^^<http://www.w3.org/2001/XMLSchema#boolean> . ?r a ?v1 . ?v1 
<http://www.w3.org/2000/01/rdf-schema#subClassOf> 
<http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email> . } . ?r 
<http://akonadi-project.org/ontologies/aneo#akonadiItemId> ?reqProp1 . graph 
?v3 { ?r a ?v2 . } . { ?v3 a 
<http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#InstanceBase> . } 
UNION { ?v3 a 
<http://www.semanticdesktop.org/ontologies/2007/08/15/nrl#DiscardableInstanceBase> 
. } . }"

The important bit is probably 
?r <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#isRead> 
\"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>
which finds all triples where the nmo:isRead property is false (NMO=Nepomuk 
mail ontology). Not sure how much of the other stuff in this SPARQL query is 
needed, I've not seen the DiscardableInstanceBase or the InstanceBase stuff 
before.
However, that particular query doesn't seem to work well here, it finds many 
read mails as well.
As others said, try to use Akonadi::SearchCreateJob to create virtual 
collections.
Note that the Nepomuk properties are not the same as the flags stored in 
Akonadi. As you saw, unread mails in Nepomuk have isRead set to false, while 
in Akonadi, they simply have no \SEEN flag. For SPARQL queries, always use the 
Nepomuk properties, you can find them at 
http://www.semanticdesktop.org/ontologies/nmo/.

Using SPARQL queries for finding all unread mails in all folders has the 
advantage that it doesn't need to load all items, like Steve's ETM example 
does, and has the disadvantage that it (right now) doesn't work.

> Then, drag & drop. What I'm doing right now is put a URL list into the drop
> data, but that doesn't seem to be accepted as valid drop data by KMail.
> What's the right way to go about this? I can sift through the kmail code
> base, but if anyone here knows off-hand, that would save me some time I'd
> rather spend at the swimming pool. :-)

Depends on the situation. Which part of KMail should handle the drop? What 
kind of data is actually dragged (URL list of what?)

Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100721/5f1ee575/attachment.sig>
-------------- next part --------------
_______________________________________________
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