Use Akonadi::CollectionPropertiesDialog instead of

KMCollectionPropertiesDialog

svn path=/trunk/KDE/kdepim/kmail/; revision=1199968
wilder-work
Tobias Koenig 16 years ago
parent cfa5fc25e6
commit 54055a3c94
  1. 1
      CMakeLists.txt
  2. 2
      collectionaclpage.cpp
  3. 2
      collectionaclpage.h
  4. 1
      collectiongeneralpage.cpp
  5. 1
      collectiongeneralpage.h
  6. 1
      collectionmaintenancepage.cpp
  7. 2
      collectionmaintenancepage.h
  8. 1
      collectionquotapage.cpp
  9. 1
      collectionquotapage.h
  10. 1
      collectiontemplatespage.cpp
  11. 2
      collectiontemplatespage.h
  12. 1
      collectionviewpage.cpp
  13. 1
      collectionviewpage.h
  14. 93
      kmcollectionpropertiesdialog.cpp
  15. 50
      kmcollectionpropertiesdialog.h
  16. 43
      kmmainwidget.cpp

@ -56,7 +56,6 @@ add_subdirectory(kcm_kpimidentities)
if (NOT WINCE AND KDEPIM_BUILD_DESKTOP)
set(kmailprivate_LIB_SRCS
kmcollectionpropertiesdialog.cpp
collectionpane.cpp
collectionannotationsattribute.cpp
collectiontemplatespage.cpp

@ -96,6 +96,8 @@ CollectionAclPage::CollectionAclPage( QWidget *parent )
mAclManager( new MailCommon::AclManager( this ) ),
mChanged( false )
{
setObjectName( QLatin1String( "KMail::CollectionAclPage" ) );
setPageTitle( i18n( "Access Control" ) );
init();
}

@ -72,4 +72,6 @@ class CollectionAclPage : public Akonadi::CollectionPropertiesPage
bool mChanged;
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionAclPageFactory, CollectionAclPage )
#endif

@ -50,6 +50,7 @@ using namespace MailCommon;
CollectionGeneralPage::CollectionGeneralPage( QWidget *parent )
: CollectionPropertiesPage( parent ), mFolderCollection( 0 )
{
setObjectName( QLatin1String( "KMail::CollectionGeneralPage" ) );
setPageTitle( i18nc( "@title:tab General settings for a folder.", "General" ) );
}

@ -87,6 +87,7 @@ private:
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionGeneralPageFactory, CollectionGeneralPage )
#endif /* COLLECTIONGENERALPAGE_H */

@ -40,6 +40,7 @@ using namespace Akonadi;
CollectionMaintenancePage::CollectionMaintenancePage(QWidget * parent) :
CollectionPropertiesPage( parent ), mIsNotAVirtualCollection( true )
{
setObjectName( QLatin1String( "KMail::CollectionMaintenancePage" ) );
setPageTitle( i18n("Maintenance") );
}

@ -52,7 +52,7 @@ private:
QLabel *mCollectionUnread;
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionMaintenancePageFactory, CollectionMaintenancePage )
#endif /* COLLECTIONMAINTENANCEPAGE_H */

@ -48,6 +48,7 @@
CollectionQuotaPage::CollectionQuotaPage( QWidget* parent )
: CollectionPropertiesPage( parent )
{
setObjectName( QLatin1String( "KMail::CollectionQuotaPage" ) );
setPageTitle( i18n("Quota") );
init();
}

@ -54,6 +54,7 @@ private:
QuotaWidget* mQuotaWidget;
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionQuotaPageFactory, CollectionQuotaPage )
#endif /* COLLECTIONQUOTAPAGE_H */

@ -36,6 +36,7 @@ using namespace MailCommon;
CollectionTemplatesPage::CollectionTemplatesPage(QWidget * parent) :
CollectionPropertiesPage( parent ), mFolderCollection( 0 )
{
setObjectName( QLatin1String( "KMail::CollectionTemplatesPage" ) );
setPageTitle( i18n( "Templates" ) );
init();
}

@ -55,5 +55,7 @@ private:
bool mIsLocalSystemFolder;
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionTemplatesPageFactory, CollectionTemplatesPage )
#endif /* COLLECTIONTEMPLATESPAGE_H */

@ -47,6 +47,7 @@ using namespace MailCommon;
CollectionViewPage::CollectionViewPage(QWidget * parent) :
CollectionPropertiesPage( parent ), mFolderCollection( 0 )
{
setObjectName( QLatin1String( "KMail::CollectionViewPage" ) );
setPageTitle( i18nc( "@title:tab View settings for a folder.", "View" ) );
}

@ -74,6 +74,7 @@ private:
int mShowSenderReceiverValue;
};
AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionViewPageFactory, CollectionViewPage )
#endif /* COLLECTIONVIEWPAGE_H */

@ -1,93 +0,0 @@
/*
This file is part of KMail, the KDE mail client.
Copyright (c) 2010 Montel Laurent <montel@kde.org>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KMail is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "kmcollectionpropertiesdialog.h"
#include "collectiontemplatespage.h"
#include "collectionmaintenancepage.h"
#include "collectiongeneralpage.h"
#include "collectionviewpage.h"
#include "collectionquotapage.h"
#include "collectionaclpage.h"
#include <akonadi/cachepolicypage.h>
#include <akonadi/collectionmodifyjob.h>
#include <ktabwidget.h>
#include <QtGui/QBoxLayout>
KMCollectionPropertiesDialog::KMCollectionPropertiesDialog( const Akonadi::Collection &collection, QWidget *parent ) :
KDialog( parent )
{
mCollection = collection;
QBoxLayout *layout = new QHBoxLayout( mainWidget() );
layout->setMargin( 0 );
mTabWidget = new KTabWidget( mainWidget() );
layout->addWidget( mTabWidget );
Akonadi::CollectionPropertiesPage *page = new CollectionGeneralPage( mTabWidget );
insertPage( page );
page = new CollectionViewPage( mTabWidget );
insertPage( page );
page = new Akonadi::CachePolicyPage( mTabWidget );
insertPage( page );
page = new CollectionTemplatesPage( mTabWidget );
insertPage( page );
page = new CollectionAclPage( mTabWidget );
insertPage( page );
page = new CollectionQuotaPage( mTabWidget );
insertPage( page );
page = new CollectionMaintenancePage( mTabWidget );
insertPage( page );
connect( this, SIGNAL( okClicked() ), SLOT( save() ) );
connect( this, SIGNAL( cancelClicked() ), SLOT( deleteLater() ) );
}
void KMCollectionPropertiesDialog::insertPage( Akonadi::CollectionPropertiesPage * page )
{
if ( page->canHandle( mCollection ) ) {
mTabWidget->addTab( page, page->pageTitle() );
page->load( mCollection );
} else {
delete page;
}
}
void KMCollectionPropertiesDialog::save()
{
for ( int i = 0; i < mTabWidget->count(); ++i ) {
Akonadi::CollectionPropertiesPage *page = static_cast<Akonadi::CollectionPropertiesPage*>( mTabWidget->widget( i ) );
page->save( mCollection );
}
Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( mCollection, this );
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( saveResult( KJob* ) ) );
}
void KMCollectionPropertiesDialog::saveResult( KJob *job )
{
if ( job->error() ) {
// TODO
kWarning() << job->errorString();
}
deleteLater();
}
#include "kmcollectionpropertiesdialog.moc"

@ -1,50 +0,0 @@
/*
This file is part of KMail, the KDE mail client.
Copyright (c) 2010 Montel Laurent <montel@kde.org>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KMail is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef KMCOLLECTIONPROPERTIESDIALOG_H
#define KMCOLLECTIONPROPERTIESDIALOG_H
#include <KDialog>
#include <KJob>
#include <Akonadi/Collection>
#include <Akonadi/CollectionPropertiesPage>
class KTabWidget;
class KMCollectionPropertiesDialog : public KDialog
{
Q_OBJECT
public:
explicit KMCollectionPropertiesDialog( const Akonadi::Collection &collection, QWidget *parent = 0 );
protected:
void insertPage( Akonadi::CollectionPropertiesPage * page );
protected slots:
void save();
void saveResult( KJob *job );
private:
Akonadi::Collection mCollection;
KTabWidget* mTabWidget;
};
#endif /* KMCOLLECTIONPROPERTIESDIALOG_H */

@ -47,12 +47,19 @@
#include "tagactionmanager.h"
#include "foldershortcutactionmanager.h"
#include "collectionpane.h"
#include "kmcollectionpropertiesdialog.h"
#if !defined(NDEBUG)
#include <ksieveui/sievedebugdialog.h>
using KSieveUi::SieveDebugDialog;
#endif
#include "collectionaclpage.h"
#include "collectiongeneralpage.h"
#include "collectionmaintenancepage.h"
#include "collectionquotapage.h"
#include "collectiontemplatespage.h"
#include "collectionviewpage.h"
#include "mailcommon/filtermanager.h"
#include "mailcommon/mailfilter.h"
@ -271,6 +278,21 @@ K_GLOBAL_STATIC( KMMainWidget::PtrList, theMainWidgetList )
Akonadi::AttributeFactory::registerAttribute<Akonadi::CollectionAnnotationsAttribute>();
{ // make sure the pages are registered only once, since there can be multiple instances of KMMainWidget
static bool pagesRegistered = false;
if ( !pagesRegistered ) {
Akonadi::CollectionPropertiesDialog::registerPage( new CollectionAclPageFactory );
Akonadi::CollectionPropertiesDialog::registerPage( new CollectionGeneralPageFactory );
Akonadi::CollectionPropertiesDialog::registerPage( new CollectionMaintenancePageFactory );
Akonadi::CollectionPropertiesDialog::registerPage( new CollectionQuotaPageFactory );
Akonadi::CollectionPropertiesDialog::registerPage( new CollectionTemplatesPageFactory );
Akonadi::CollectionPropertiesDialog::registerPage( new CollectionViewPageFactory );
pagesRegistered = true;
}
}
KMainWindow *mainWin = dynamic_cast<KMainWindow*>(topLevelWidget());
KStatusBar *sb = mainWin ? mainWin->statusBar() : 0;
mVacationScriptIndicator = new KMail::StatusBarLabel( sb );
@ -4175,20 +4197,27 @@ KAction *KMMainWidget::akonadiStandardAction( Akonadi::StandardMailActionManager
void KMMainWidget::slotCollectionProperties()
{
if (!mCurrentFolder) return;
if ( !mCurrentFolder )
return;
Akonadi::CollectionAttributesSynchronizationJob sync( mCurrentFolder->collection() );
// FIXME: this hangs kmail entirely when opening the folder properties dialog!
// sync.exec();
sync.start();
Akonadi::CollectionFetchJob fetch( mCurrentFolder->collection(), Akonadi::CollectionFetchJob::Base );
fetch.exec();
Akonadi::Collection c = fetch.collections().first();
const Akonadi::Collection collection = fetch.collections().first();
const QStringList pages = QStringList() << QLatin1String( "KMail::CollectionGeneralPage" )
<< QLatin1String( "KMail::CollectionViewPage" )
<< QLatin1String( "Akonadi::CachePolicyPage" )
<< QLatin1String( "KMail::CollectionTemplatesPage" )
<< QLatin1String( "KMail::CollectionAclPage" )
<< QLatin1String( "KMail::CollectionQuotaPage" )
<< QLatin1String( "KMail::CollectionMaintenancePage" );
KMCollectionPropertiesDialog* dlg = new KMCollectionPropertiesDialog( c, this );
dlg->setCaption( i18nc( "@title:window", "Properties of Folder %1", c.name() ) );
Akonadi::CollectionPropertiesDialog *dlg = new Akonadi::CollectionPropertiesDialog( collection, pages, this );
dlg->setCaption( i18nc( "@title:window", "Properties of Folder %1", collection.name() ) );
dlg->resize( 500, 400 );
dlg->show();
}

Loading…
Cancel
Save