• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kontact

summaryview_plugin.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of the KDE project
00003 
00004   Copyright (C) 2003 Sven L�ppken <sven@kde.org>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015 
00016   You should have received a copy of the GNU Library General Public License
00017   along with this library; see the file COPYING.LIB.  If not, write to
00018   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019   Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #include "summaryview_plugin.h"
00023 #include "summaryview_part.h"
00024 #ifdef KMAIL_SUPPORTED
00025 # include "kmailinterface.h"
00026 #endif
00027 
00028 #include <kontactinterfaces/core.h>
00029 #include <kontactinterfaces/plugin.h>
00030 
00031 #include <KAboutData>
00032 #include <KAction>
00033 #include <KActionCollection>
00034 #include <KGenericFactory>
00035 #include <KSelectAction>
00036 #include <kparts/componentfactory.h>
00037 
00038 #include <QList>
00039 #include <QMenu>
00040 #include <QtDBus/QtDBus>
00041 
00042 EXPORT_KONTACT_PLUGIN( SummaryView, summary )
00043 
00044 SummaryView::SummaryView( Kontact::Core *core, const QVariantList & )
00045   : Kontact::Plugin( core, core, 0 ), mAboutData( 0 ), mPart( 0 )
00046 {
00047   setComponentData( KontactPluginFactory::componentData() );
00048 
00049   mSyncAction = new KSelectAction( KIcon( "view-refresh" ), i18n( "Synchronize All" ), this );
00050   actionCollection()->addAction( "kontact_summary_sync", mSyncAction );
00051   connect( mSyncAction, SIGNAL(triggered(QString)), SLOT(syncAccount(QString)) );
00052   connect( mSyncAction->menu(), SIGNAL(aboutToShow()), this, SLOT(fillSyncActionSubEntries()) );
00053 
00054   insertSyncAction( mSyncAction );
00055   fillSyncActionSubEntries();
00056 }
00057 
00058 void SummaryView::fillSyncActionSubEntries()
00059 {
00060   QStringList menuItems;
00061   menuItems.append( i18nc( "@action:inmenu sync everything", "All" ) );
00062 
00063 #ifdef KMAIL_SUPPORTED
00064   org::kde::kmail::kmail kmail( "org.kde.kmail", "/KMail", QDBusConnection::sessionBus() );
00065   const QDBusReply<QStringList> reply = kmail.accounts();
00066   if ( reply.isValid() ) {
00067     menuItems << reply.value();
00068   }
00069 #endif
00070 
00071   mSyncAction->clear();
00072   mSyncAction->setItems( menuItems );
00073 }
00074 
00075 void SummaryView::syncAccount( const QString &account )
00076 {
00077   if ( account == i18nc( "sync everything", "All" ) ) {
00078     doSync();
00079   } else {
00080 #ifdef KMAIL_SUPPORTED
00081     org::kde::kmail::kmail kmail( "org.kde.kmail", "/KMail",
00082                                   QDBusConnection::sessionBus() );
00083     kmail.checkAccount( account );
00084 #endif
00085   }
00086   fillSyncActionSubEntries();
00087 }
00088 
00089 SummaryView::~SummaryView()
00090 {
00091 }
00092 
00093 void SummaryView::doSync()
00094 {
00095   if ( mPart ) {
00096     mPart->updateSummaries();
00097   }
00098 
00099   const QList<Kontact::Plugin *> pluginList = core()->pluginList();
00100   Q_FOREACH( const Kontact::Plugin *i, pluginList ) {
00101     // execute all sync actions but our own
00102     const QList<KAction *>* actions = i->syncActions();
00103     Q_FOREACH( KAction *j, *actions ) {
00104       if ( j != mSyncAction ) {
00105         j->trigger();
00106       }
00107     }
00108   }
00109   fillSyncActionSubEntries();
00110 }
00111 
00112 KParts::ReadOnlyPart *SummaryView::createPart()
00113 {
00114   mPart = new SummaryViewPart( core(), "summarypartframe", aboutData(), this );
00115   mPart->setObjectName( "summaryPart" );
00116   return mPart;
00117 }
00118 
00119 const KAboutData *SummaryView::aboutData()
00120 {
00121   if ( !mAboutData ) {
00122     mAboutData = new KAboutData(
00123       "kontactsummary", 0, ki18n( "Kontact Summary" ),
00124       "1.1",
00125       ki18n( "Kontact Summary View" ),
00126       KAboutData::License_LGPL,
00127       ki18n( "(c) 2003 The Kontact developers" ) );
00128 
00129     mAboutData->addAuthor( ki18n( "Sven Lueppken" ),
00130                            KLocalizedString(), "sven@kde.org" );
00131     mAboutData->addAuthor( ki18n( "Cornelius Schumacher" ),
00132                            KLocalizedString(), "schumacher@kde.org" );
00133     mAboutData->addAuthor( ki18n( "Tobias Koenig" ),
00134                            KLocalizedString(), "tokoe@kde.org" );
00135     mAboutData->setProductName( "kontact/summary" );
00136   }
00137 
00138   return mAboutData;
00139 }
00140 
00141 #include "summaryview_plugin.moc"

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal