[Kde-pim] Dragging akonadi items

Robin Atwood robin at binro.org
Sun Feb 21 15:34:30 GMT 2010


On Sunday 21 February 2010, Ingo Klöcker wrote:
> On Sunday 21 February 2010, Robin Atwood wrote:
> > On Sunday 21 February 2010, Ingo Klöcker wrote:
> > > On Sunday 21 February 2010, Robin Atwood wrote:
> > > > If I drag a kaddressbook item to kwrite, the akonadi: URL is
> > > > resolved and I can see the VCS entry in the editor. If I drag it
> > > > to my KLineEdit widget I just get the URL despite that I have
> > > > the UrlDropsEnabled property set. What am I missing? (A lot, I
> > > > suspect!)
> > > 
> > > I think you misunderstand the UrlDropsEnabled property.
> > 
> > That was my impression also. :)
> > 
> > > IMO resolving of URLs cannot be handled by a plain vanilla
> > > KLineEdit because what the URL should be resolved to depends on
> > > the context. An akonadi-URL representing a contact could be
> > > resolved to the contact's name, the contact's email address, the
> > > contact's phone number, etc., depending on the context (i.e. does
> > > the line edit expect a name, an email address, a phone number,
> > > etc.).
> > 
> > This is what I want. I guess my question is how to do the decoding
> > without getting too involved with akonadi internals; KWrite seems to
> > do it automatically.
> 
> KWrite simply uses the corresponding kioslave to load the data
> referenced by the URL. All applications supporting KIO can do this. For
> a line edit this approach doesn't work because putting a complete vCard
> into a line edit doesn't make much sense.
> 
> Nevertheless, you might not have to get in touch with Akonadi at all.
> KMail's line edit does the following:
> 
> void KMLineEdit::dropEvent(QDropEvent *event)
> {
>   const QMimeData *md = event->mimeData();
> 
>   // Case one: The user dropped a text/directory (i.e. vcard), so decode
> its
>   //           contents
>   if ( KPIM::KVCardDrag::canDecode( md ) ) {
>     KABC::Addressee::List list;
>     KPIM::KVCardDrag::fromMimeData( md, list );
> 
>     KABC::Addressee::List::Iterator ait;
>     for ( ait = list.begin(); ait != list.end(); ++ait ){
>       insertEmails( (*ait).emails() );
>     }
>   }
> 
>   [...]
> }
> 
> The only problem is that KPIM::KVCardDrag lives in kdepim/libkdepim,
> i.e. it's not public API. If you want to use it outside or kdepim you
> might have to copy it.

Thanks Ingo, I'll check it out.

Cheers
-Robin
-- 
----------------------------------------------------------------------
Robin Atwood.

"Ship me somewheres east of Suez, where the best is like the worst,
 Where there ain't no Ten Commandments an' a man can raise a thirst"
         from "Mandalay" by Rudyard Kipling
----------------------------------------------------------------------








_______________________________________________
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