kontact

journalplugin.cpp
1/*
2 This file is part of Kontact.
3
4 Copyright (c) 2004 Allen Winter <winter@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25#include <tqwidget.h>
26
27#include <tdeapplication.h>
28#include <tdeaction.h>
29#include <kdebug.h>
30#include <kgenericfactory.h>
31#include <kiconloader.h>
32#include <tdemessagebox.h>
33#include <dcopclient.h>
34#include <dcopref.h>
35
36#include "core.h"
37#include "journalplugin.h"
38#include "korg_uniqueapp.h"
39
40
41typedef KGenericFactory< JournalPlugin, Kontact::Core > JournalPluginFactory;
42K_EXPORT_COMPONENT_FACTORY( libkontact_journalplugin,
43 JournalPluginFactory( "kontact_journalplugin" ) )
44
45JournalPlugin::JournalPlugin( Kontact::Core *core, const char *, const TQStringList& )
46 : Kontact::Plugin( core, core, "korganizer" ),
47 mIface( 0 )
48{
49 setInstance( JournalPluginFactory::instance() );
50 instance()->iconLoader()->addAppDir("tdepim");
51
52 insertNewAction( new TDEAction( i18n( "New Journal..." ), "newjournal",
53 CTRL+SHIFT+Key_J, this, TQ_SLOT( slotNewJournal() ), actionCollection(),
54 "new_journal" ) );
55 insertSyncAction( new TDEAction( i18n( "Synchronize Journal" ), "reload",
56 0, this, TQ_SLOT( slotSyncJournal() ), actionCollection(),
57 "journal_sync" ) );
58
59
60 mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
62}
63
64JournalPlugin::~JournalPlugin()
65{
66}
67
68KParts::ReadOnlyPart *JournalPlugin::createPart()
69{
70 KParts::ReadOnlyPart *part = loadPart();
71
72 if ( !part )
73 return 0;
74
75 dcopClient(); // ensure that we register to DCOP as "korganizer"
76 mIface = new KCalendarIface_stub( dcopClient(), "kontact", "CalendarIface" );
77
78 return part;
79}
80
82{
83 interface()->showJournalView();
84}
85
87{
88 TQStringList invisible;
89 invisible += "new_event";
90 invisible += "new_todo";
91 invisible += "new_journal";
92
93 invisible += "view_day";
94 invisible += "view_list";
95 invisible += "view_workweek";
96 invisible += "view_week";
97 invisible += "view_nextx";
98 invisible += "view_month";
99 invisible += "view_todo";
100 return invisible;
101}
102
103KCalendarIface_stub *JournalPlugin::interface()
104{
105 if ( !mIface ) {
106 part();
107 }
108 Q_ASSERT( mIface );
109 return mIface;
110}
111
112void JournalPlugin::slotNewJournal()
113{
114 interface()->openJournalEditor( "" );
115}
116
117void JournalPlugin::slotSyncJournal()
118{
119 DCOPRef ref( "kmail", "KMailICalIface" );
120 ref.send( "triggerSync", TQString("Journal") );
121}
122
123bool JournalPlugin::createDCOPInterface( const TQString& serviceType )
124{
125 kdDebug(5602) << k_funcinfo << serviceType << endl;
126 if ( serviceType == "DCOP/Organizer" || serviceType == "DCOP/Calendar" ) {
127 if ( part() )
128 return true;
129 }
130
131 return false;
132}
133
135{
136 return mUniqueAppWatcher->isRunningStandalone();
137}
138
139#include "journalplugin.moc"
KParts::ReadOnlyPart * part()
You can use this method if you need to access the current part.
Definition plugin.cpp:145
DCOPClient * dcopClient() const
Retrieve the current DCOP Client for the plugin.
Definition plugin.cpp:163
virtual TQStringList invisibleToolbarActions() const
Returns a list of action name which shall be hidden in the main toolbar.
Definition plugin.h:233
virtual bool isRunningStandalone()
Reimplement this method and return whether a standalone application is still running This is only req...
Definition plugin.h:131
virtual void select()
This function is called when the plugin is selected by the user before the widget of the KPart belong...
Definition plugin.cpp:201
virtual KParts::ReadOnlyPart * createPart()=0
Reimplement and return the part here.
Used by UniqueAppWatcher below, to create the above UniqueAppHandler object when necessary.
If the standalone application is running by itself, we need to watch for when the user closes it,...