[Kde-pim] Question about itemfetchscope

Stephen Kelly steveire at gmail.com
Fri Nov 6 11:33:47 GMT 2009


laurent Montel wrote:

> Hi,
> In kmail I got item:
> 
> 
>   Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mTemplateFolder
>   ); job->fetchScope().fetchFullPayload();
>   Akonadi::Item::List items;
>   if ( job->exec() ) {
>     items = job->items();
>   }
>   for ( int idx = 0; idx < items.count(); ++idx ) {
>     qDebug()<<" items.at(idx).parentCollection() :"<<items.at( idx
> ).parentCollection();
>     KMime::Message::Ptr msg = KMail::Util::message( items.at( idx ) );
>     if ( msg ) {
>       ....
>    }
> }
> 
> it works fine it's not a pb.
> But when I test parentCollection it returns invalid parent !
> I don't understand.
> Why after an itemfetchjob parentcollection is invalid ?
> 
> What I am missing ?

You need to explicitly ask to fetch the parents too.

job->fetchScope().setAncestorRetrieval( ItemFetchScope::Parent ); for just 
one parent collection, and ::All for all ancestors up to Collection::root.

That's @since 4.4  and I've needed to use it in most cases, so we should 
probably make it the default...

> 
> Regards
> 



_______________________________________________
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