Question about itemfetchscope

View: New views
4 Messages — Rating Filter:   Alert me  

Question about itemfetchscope

by laurent Montel-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 ?

Regards

--
Laurent Montel | laurent@... | KDE/Qt Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
_______________________________________________
KDE PIM mailing list kde-pim@...
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/

Re: Question about itemfetchscope

by Stephen Kelly-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/

Re: Question about itemfetchscope

by Stephen Kelly-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stephen Kelly wrote:

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

Apparently it would be too expensive to be on all the time, so it's not
really a big deal.


_______________________________________________
KDE PIM mailing list kde-pim@...
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/

Re: Question about itemfetchscope

by laurent Montel-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Le vendredi 6 novembre 2009 12:33:47, Stephen Kelly a écrit :

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

Ok thanks for info.

Regards

> > Regards
>
> _______________________________________________
> KDE PIM mailing list kde-pim@...
> https://mail.kde.org/mailman/listinfo/kde-pim
> KDE PIM home page at http://pim.kde.org/
>

--
Laurent Montel | laurent@... | KDE/Qt Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
_______________________________________________
KDE PIM mailing list kde-pim@...
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/