26#include <tqdragobject.h>
29#include <tdeapplication.h>
30#include <tdeabc/vcardconverter.h>
33#include <kgenericfactory.h>
34#include <kiconloader.h>
35#include <tdemessagebox.h>
36#include <dcopclient.h>
38#include <tdetempfile.h>
40#include <libkcal/calendarlocal.h>
41#include <libkcal/icaldrag.h>
43#include <libtdepim/maillistdrag.h>
44#include <libtdepim/kvcarddrag.h>
45#include <libtdepim/kpimprefs.h>
49#include "todoplugin.h"
50#include "todosummarywidget.h"
51#include "korg_uniqueapp.h"
53typedef KGenericFactory< TodoPlugin, Kontact::Core > TodoPluginFactory;
54K_EXPORT_COMPONENT_FACTORY( libkontact_todoplugin,
55 TodoPluginFactory(
"kontact_todoplugin" ) )
57TodoPlugin::TodoPlugin( Kontact::Core *core, const
char *, const TQStringList& )
58 : Kontact::Plugin( core, core,
"korganizer" ),
61 setInstance( TodoPluginFactory::instance() );
62 instance()->iconLoader()->addAppDir(
"tdepim");
64 insertNewAction(
new TDEAction( i18n(
"New To-do..." ),
"newtodo",
65 CTRL+SHIFT+Key_T,
this, TQ_SLOT( slotNewTodo() ), actionCollection(),
68 insertSyncAction(
new TDEAction( i18n(
"Synchronize To-do List" ),
"reload",
69 0,
this, TQ_SLOT( slotSyncTodos() ), actionCollection(),
76TodoPlugin::~TodoPlugin()
82 return new TodoSummaryWidget(
this, parent );
87 KParts::ReadOnlyPart *
part = loadPart();
93 mIface =
new KCalendarIface_stub(
dcopClient(),
"kontact",
"CalendarIface" );
100 interface()->showTodoView();
105 TQStringList invisible;
106 invisible +=
"new_event";
107 invisible +=
"new_todo";
108 invisible +=
"new_journal";
110 invisible +=
"view_day";
111 invisible +=
"view_list";
112 invisible +=
"view_workweek";
113 invisible +=
"view_week";
114 invisible +=
"view_nextx";
115 invisible +=
"view_month";
116 invisible +=
"view_journal";
120KCalendarIface_stub *TodoPlugin::interface()
129void TodoPlugin::slotNewTodo()
131 interface()->openTodoEditor(
"" );
134void TodoPlugin::slotSyncTodos()
136 DCOPRef ref(
"kmail",
"KMailICalIface" );
137 ref.send(
"triggerSync", TQString(
"Todo") );
140bool TodoPlugin::createDCOPInterface(
const TQString& serviceType )
142 kdDebug(5602) << k_funcinfo << serviceType << endl;
143 if ( serviceType ==
"DCOP/Organizer" || serviceType ==
"DCOP/Calendar" ) {
151bool TodoPlugin::canDecodeDrag( TQMimeSource *mimeSource )
153 return TQTextDrag::canDecode( mimeSource ) ||
154 KPIM::MailListDrag::canDecode( mimeSource );
159 return mUniqueAppWatcher->isRunningStandalone();
162void TodoPlugin::processDropEvent( TQDropEvent *event )
164 TDEABC::Addressee::List list;
165 if ( KVCardDrag::decode( event, list ) ) {
166 TQStringList attendees;
167 TDEABC::Addressee::List::Iterator it;
168 for ( it = list.begin(); it != list.end(); ++it ) {
169 TQString email = (*it).fullEmail();
170 if ( email.isEmpty() ) {
171 attendees.append( (*it).realName() +
"<>" );
173 attendees.append( email );
176 interface()->openTodoEditor( i18n(
"Meeting" ), TQString(), TQString(),
182 KCal::CalendarLocal cal( KPimPrefs::timezone() );
184 KCal::Incidence::List incidences = cal.incidences();
185 if ( !incidences.isEmpty() ) {
187 KCal::Incidence *i = incidences.first();
189 if (
dynamic_cast<KCal::Journal*
>( i ) )
190 summary = i18n(
"Note: %1" ).arg( i->
summary() );
193 interface()->openTodoEditor( summary, i->
description(), TQString() );
201 if ( TQTextDrag::decode( event, text ) ) {
202 interface()->openTodoEditor( text );
206 KPIM::MailList mails;
207 if ( KPIM::MailListDrag::decode( event, mails ) ) {
208 if ( mails.count() != 1 ) {
209 KMessageBox::sorry( core(),
210 i18n(
"Drops of multiple mails are not supported." ) );
212 KPIM::MailSummary mail = mails.first();
213 TQString txt = i18n(
"From: %1\nTo: %2\nSubject: %3").arg( mail.from() )
214 .arg( mail.to() ).arg( mail.subject() );
217 tf.setAutoDelete(
true );
218 TQString uri =
"kmail:" + TQString::number( mail.serialNumber() ) +
"/" +
220 tf.file()->writeBlock( event->encodedData(
"message/rfc822" ) );
222 interface()->openTodoEditor( i18n(
"Mail: %1").arg( mail.subject() ),
223 txt, uri, tf.name(), TQStringList(),
"message/rfc822",
false );
228 KMessageBox::sorry( core(), i18n(
"Cannot handle drop events of type '%1'.")
229 .arg( event->format() ) );
232#include "todoplugin.moc"
static bool canDecode(TQMimeSource *)
static bool decode(TQMimeSource *e, Calendar *cal)
TQString description() const
KParts::ReadOnlyPart * part()
You can use this method if you need to access the current part.
DCOPClient * dcopClient() const
Retrieve the current DCOP Client for the plugin.
virtual TQStringList invisibleToolbarActions() const
Returns a list of action name which shall be hidden in the main toolbar.
virtual bool isRunningStandalone()
Reimplement this method and return whether a standalone application is still running This is only req...
virtual void select()
This function is called when the plugin is selected by the user before the widget of the KPart belong...
virtual KParts::ReadOnlyPart * createPart()=0
Reimplement and return the part here.
Summary widget for display in the Summary View plugin.
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,...