SVN commit 1211207 by tokoe: Improve updates in mobile UI mode In mobile UI mode we do not insert new items as soon as ItemFetchJob reports them via the itemsRetrieved() signal, but wait until the ItemFetchJob has finished and then we'll insert all items in one go. This prevents rowsInserted() signals of the model, which will cause unnecessary (and expensive) updates in the proxy stack above. M +1 -0 entitytreemodel.h M +27 -1 entitytreemodel_p.cpp M +3 -1 entitytreemodel_p.h --- trunk/KDE/kdepimlibs/akonadi/entitytreemodel.h #1211206:1211207 @@ -633,6 +633,7 @@ Q_PRIVATE_SLOT( d_func(), void firstFetchJobDone( KJob *job ) ) Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) ) + Q_PRIVATE_SLOT( d_func(), void itemsFetched( KJob* ) ) Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) ) Q_PRIVATE_SLOT( d_func(), void firstCollectionsFetched( Akonadi::Collection::List ) ) Q_PRIVATE_SLOT( d_func(), void collectionListFetched( Akonadi::Collection::List ) ) --- trunk/KDE/kdepimlibs/akonadi/entitytreemodel_p.cpp #1211206:1211207 @@ -204,8 +204,13 @@ QMetaObject::invokeMethod(const_cast(q), "changeFetchState", Qt::QueuedConnection, Q_ARG(Akonadi::Collection, parent)); } +#ifdef KDEPIM_MOBILE_UI + q->connect( itemFetchJob, SIGNAL( result( KJob* ) ), + q, SLOT( itemsFetched( KJob* ) ) ); +#else q->connect( itemFetchJob, SIGNAL( itemsReceived( const Akonadi::Item::List& ) ), q, SLOT( itemsFetched( const Akonadi::Item::List& ) ) ); +#endif q->connect( itemFetchJob, SIGNAL( result( KJob* ) ), q, SLOT( fetchJobDone( KJob* ) ) ); ifDebug(kDebug() << "collection:" << parent.name(); jobTimeTracker[itemFetchJob].start();) @@ -427,10 +432,31 @@ void EntityTreeModelPrivate::itemsFetched( const Akonadi::Item::List& items ) { Q_Q( EntityTreeModel ); - QObject *job = q->sender(); + KJob *job = qobject_cast( q->sender() ); + Q_ASSERT( job ); + itemsFetched( job, items ); +} + +void EntityTreeModelPrivate::itemsFetched( KJob *job ) +{ + Q_ASSERT( job ); + + if ( job->error() ) + return; + + ItemFetchJob *fetchJob = qobject_cast( job ); + const Akonadi::Item::List items = fetchJob->items(); + + itemsFetched( job, items ); +} + +void EntityTreeModelPrivate::itemsFetched( KJob *job, const Akonadi::Item::List &items ) +{ + Q_Q( EntityTreeModel ); + const Collection::Id collectionId = job->property( FetchCollectionId() ).value(); Item::List itemsToInsert; --- trunk/KDE/kdepimlibs/akonadi/entitytreemodel_p.h #1211206:1211207 @@ -83,7 +83,9 @@ void collectionsFetched( const Akonadi::Collection::List& ); void firstCollectionsFetched( const Akonadi::Collection::List& ); void collectionListFetched( const Akonadi::Collection::List& ); - void itemsFetched( const Akonadi::Item::List& ); + void itemsFetched( KJob* ); + void itemsFetched( const Akonadi::Item::List &items ); + void itemsFetched( KJob *job, const Akonadi::Item::List &items ); void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ); void monitoredCollectionRemoved( const Akonadi::Collection& );