diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index 5568b9a58..95e2b8ef7 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -4676,11 +4676,28 @@ void KMMainWidget::slotCollectionPropertiesContinued( KJob* job ) void KMMainWidget::showCollectionPropertiesContinued( const QString &pageToShow ) { - Akonadi::CollectionFetchJob fetch( mCurrentFolder->collection(), Akonadi::CollectionFetchJob::Base ); - fetch.fetchScope().setIncludeStatistics( true ); - fetch.exec(); + Akonadi::CollectionFetchJob *fetch = new Akonadi::CollectionFetchJob( mCurrentFolder->collection(), + Akonadi::CollectionFetchJob::Base ); + fetch->fetchScope().setIncludeStatistics( true ); + fetch->setProperty( "pageToShow", pageToShow ); + connect( fetch, SIGNAL(result(KJob*)), + this, SLOT(slotCollectionPropertiesFinished(KJob*)) ); +} - const Akonadi::Collection collection = fetch.collections().first(); +void KMMainWidget::slotCollectionPropertiesFinished( KJob *job ) +{ + if ( !job ) + return; + + Akonadi::CollectionFetchJob *fetch = dynamic_cast( job ); + Q_ASSERT( fetch ); + if ( fetch->collections().isEmpty() ) + { + kWarning() << "no collection"; + return; + } + + const Akonadi::Collection collection = fetch->collections().first(); const QStringList pages = QStringList() << QLatin1String( "MailCommon::CollectionGeneralPage" ) << QLatin1String( "KMail::CollectionViewPage" ) @@ -4694,6 +4711,8 @@ void KMMainWidget::showCollectionPropertiesContinued( const QString &pageToShow Akonadi::CollectionPropertiesDialog *dlg = new Akonadi::CollectionPropertiesDialog( collection, pages, this ); dlg->setCaption( i18nc( "@title:window", "Properties of Folder %1", collection.name() ) ); dlg->resize( 500, 400 ); + + const QString pageToShow = fetch->property( "pageToShow" ).toString(); if ( !pageToShow.isEmpty() ) { // show a specific page dlg->setCurrentPage( pageToShow ); } diff --git a/kmmainwidget.h b/kmmainwidget.h index 5eefaa775..27f1d0592 100644 --- a/kmmainwidget.h +++ b/kmmainwidget.h @@ -527,6 +527,7 @@ class KMAIL_EXPORT KMMainWidget : public QWidget void itemsFetchDone( KJob *job ); void slotCollectionPropertiesContinued( KJob* job ); + void slotCollectionPropertiesFinished( KJob *job ); void slotDeletionCollectionResult(KJob* job); void slotServerSideSubscription(); void slotFetchItemsForFolderDone(KJob*job);