kontact

journalplugin.cpp

00001 /*
00002     This file is part of Kontact.
00003 
00004     Copyright (c) 2004 Allen Winter <winter@kde.org>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program 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
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #include <qwidget.h>
00026 
00027 #include <kapplication.h>
00028 #include <kaction.h>
00029 #include <kdebug.h>
00030 #include <kgenericfactory.h>
00031 #include <kiconloader.h>
00032 #include <kmessagebox.h>
00033 #include <dcopclient.h>
00034 
00035 #include "core.h"
00036 
00037 #include "journalplugin.h"
00038 #include "korg_uniqueapp.h"
00039 
00040 typedef KGenericFactory< JournalPlugin, Kontact::Core > JournalPluginFactory;
00041 K_EXPORT_COMPONENT_FACTORY( libkontact_journalplugin,
00042                             JournalPluginFactory( "kontact_journalplugin" ) )
00043 
00044 JournalPlugin::JournalPlugin( Kontact::Core *core, const char *, const QStringList& )
00045   : Kontact::Plugin( core, core, "korganizer" ),
00046     mIface( 0 )
00047 {
00048   setInstance( JournalPluginFactory::instance() );
00049   instance()->iconLoader()->addAppDir("kdepim");
00050 
00051   insertNewAction( new KAction( i18n( "New Journal..." ), "newjournal",
00052                    CTRL+SHIFT+Key_J, this, SLOT( slotNewJournal() ), actionCollection(),
00053                    "new_journal" ) );
00054 
00055 
00056   mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
00057       new Kontact::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(), this );
00058 }
00059 
00060 JournalPlugin::~JournalPlugin()
00061 {
00062 }
00063 
00064 KParts::ReadOnlyPart *JournalPlugin::createPart()
00065 {
00066   KParts::ReadOnlyPart *part = loadPart();
00067 
00068   if ( !part )
00069     return 0;
00070 
00071   dcopClient(); // ensure that we register to DCOP as "korganizer"
00072   mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" );
00073 
00074   return part;
00075 }
00076 
00077 void JournalPlugin::select()
00078 {
00079   interface()->showJournalView();
00080 }
00081 
00082 QStringList JournalPlugin::invisibleToolbarActions() const
00083 {
00084   QStringList invisible;
00085   invisible += "new_event";
00086   invisible += "new_todo";
00087   invisible += "new_journal";
00088 
00089   invisible += "view_day";
00090   invisible += "view_list";
00091   invisible += "view_workweek";
00092   invisible += "view_week";
00093   invisible += "view_nextx";
00094   invisible += "view_month";
00095   invisible += "view_todo";
00096   return invisible;
00097 }
00098 
00099 KCalendarIface_stub *JournalPlugin::interface()
00100 {
00101   if ( !mIface ) {
00102     part();
00103   }
00104   Q_ASSERT( mIface );
00105   return mIface;
00106 }
00107 
00108 void JournalPlugin::slotNewJournal()
00109 {
00110   interface()->openJournalEditor( "" );
00111 }
00112 
00113 bool JournalPlugin::createDCOPInterface( const QString& serviceType )
00114 {
00115   kdDebug(5602) << k_funcinfo << serviceType << endl;
00116   if ( serviceType == "DCOP/Organizer" || serviceType == "DCOP/Calendar" ) {
00117     if ( part() )
00118       return true;
00119   }
00120 
00121   return false;
00122 }
00123 
00124 bool JournalPlugin::isRunningStandalone()
00125 {
00126   return mUniqueAppWatcher->isRunningStandalone();
00127 }
00128 
00129 #include "journalplugin.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys