[Kde-pim] Review Request: Add collection access methods to Akonadi::Item*Job classes

Tobias Koenig tokoe at kde.org
Tue Sep 29 10:23:37 BST 2009


On Thu, Sep 24, 2009 at 01:38:05PM -0000, David Jarvie wrote:
Hej David,

> This patch provides access to the collection specified (in the constructor or elsewhere) in Akonadi::Item*Job classes.
> It enables the collection to be identified when a progress or completion slot is called by the job.
> This can be necessary to distinguish between jobs if multiple jobs for different collections are
> in progress at the same time.
Is that a so often use case to justify such a (as Volker pointed out) ambiguously API change?
If you really need the collection in the slot, you can pass the data as out-band data:

  Collection collection = ...;

  ItemFetchJob *job = new ItemFetchJob( collection );
  job->setProperty( "collection", QVariant::fromValue( collection ) );
  connect( job, SIGNAL( result( KJob* ) ), this, SLOT( fetched( KJob* ) ) );

  ...

  MyClass::fetched( KJob *job )
  {
    if ( job->error() )
      return;

    ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob*>( job );
    if ( !fetchJob )
      return;

    const Collection collection = fetchJob->property( "collection" ).value<Collection>();

    const Item::List items = fetchJob->items();
    foreach ( const Item &item, items ) {
      qDebug() << "Fetched item" << item.id() << "from collection" << collection.id();
    }
  }

Ciao,
Tobias
-- 
Separate politics from religion and economy!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090929/679f8a01/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