00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "summaryview_plugin.h"
00021 #include "core.h"
00022 #include "summaryview_part.h"
00023
00024 #include <dcopref.h>
00025 #include <kgenericfactory.h>
00026 #include <kparts/componentfactory.h>
00027 #include <kaboutdata.h>
00028 #include <kaction.h>
00029
00030 #include <tqpopupmenu.h>
00031
00032 typedef KGenericFactory< SummaryView, Kontact::Core > SummaryViewFactory;
00033 K_EXPORT_COMPONENT_FACTORY( libkontact_summaryplugin,
00034 SummaryViewFactory( "kontact_summaryplugin" ) )
00035
00036 SummaryView::SummaryView( Kontact::Core *core, const char *name, const TQStringList& )
00037 : Kontact::Plugin( core, core, name),
00038 mAboutData( 0 ), mPart( 0 )
00039 {
00040 setInstance( SummaryViewFactory::instance() );
00041
00042 mSyncAction = new KSelectAction( i18n( "Synchronize All" ), "reload", 0, 0,
00043 0, actionCollection(),
00044 "kontact_summary_sync" );
00045 connect( mSyncAction, TQT_SIGNAL( activated( const TQString& ) ), this, TQT_SLOT( syncAccount( const TQString& ) ) );
00046 connect( mSyncAction->popupMenu(), TQT_SIGNAL( aboutToShow() ), this, TQT_SLOT( fillSyncActionSubEntries() ) );
00047
00048 insertSyncAction( mSyncAction );
00049 fillSyncActionSubEntries();
00050 }
00051
00052 void SummaryView::fillSyncActionSubEntries()
00053 {
00054 TQStringList menuItems;
00055 menuItems.append( i18n("All") );
00056
00057 DCOPRef ref( "kmail", "KMailIface" );
00058 DCOPReply reply = ref.call( "accounts" );
00059
00060 if ( reply.isValid() )
00061 {
00062 const TQStringList accounts = reply;
00063 menuItems += accounts;
00064 }
00065 mSyncAction->clear();
00066 mSyncAction->setItems( menuItems );
00067 }
00068
00069 void SummaryView::syncAccount( const TQString& account )
00070 {
00071 if ( account == i18n("All") ) {
00072 doSync();
00073 } else {
00074 DCOPRef ref( "kmail", "KMailIface" );
00075 ref.send( "checkAccount", account );
00076 }
00077 fillSyncActionSubEntries();
00078 }
00079
00080 SummaryView::~SummaryView()
00081 {
00082 }
00083
00084 void SummaryView::doSync()
00085 {
00086 if ( mPart )
00087 mPart->updateSummaries();
00088
00089 const TQValueList<Kontact::Plugin*> pluginList = core()->pluginList();
00090 for ( TQValueList<Kontact::Plugin*>::ConstIterator it = pluginList.begin(), end = pluginList.end();
00091 it != end; ++it ) {
00092
00093 TQPtrList<KAction> *actions = (*it)->syncActions();
00094 for ( TQPtrList<KAction>::Iterator jt = actions->begin(), end = actions->end(); jt != end; ++jt ) {
00095 if ( *jt != mSyncAction )
00096 (*jt)->activate();
00097 }
00098 }
00099 fillSyncActionSubEntries();
00100 }
00101
00102 KParts::ReadOnlyPart *SummaryView::createPart()
00103 {
00104 mPart = new SummaryViewPart( core(), "summarypartframe", aboutData(),
00105 this, "summarypart" );
00106 return mPart;
00107 }
00108
00109 const KAboutData *SummaryView::aboutData()
00110 {
00111 if ( !mAboutData ) {
00112 mAboutData = new KAboutData( "kontactsummary", I18N_NOOP("Kontact Summary"),
00113 "1.1",
00114 I18N_NOOP("Kontact Summary View"),
00115 KAboutData::License_LGPL,
00116 I18N_NOOP("(c) 2003 The Kontact developers" ) );
00117 mAboutData->addAuthor( "Sven Lueppken", "", "sven@kde.org" );
00118 mAboutData->addAuthor( "Cornelius Schumacher", "", "schumacher@kde.org" );
00119 mAboutData->addAuthor( "Tobias Koenig", "", "tokoe@kde.org" );
00120 mAboutData->setProductName( "kontact/summary" );
00121 }
00122
00123 return mAboutData;
00124 }
00125
00126 #include "summaryview_plugin.moc"