26 #include <tqdragobject.h>
29 #include <tdeapplication.h>
30 #include <tdeabc/vcardconverter.h>
31 #include <tdeaction.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"
53 typedef KGenericFactory< TodoPlugin, Kontact::Core > TodoPluginFactory;
54 K_EXPORT_COMPONENT_FACTORY( libkontact_todoplugin,
55 TodoPluginFactory(
"kontact_todoplugin" ) )
57 TodoPlugin::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(),
76 TodoPlugin::~TodoPlugin()
82 return new TodoSummaryWidget(
this, parent );
85 KParts::ReadOnlyPart *TodoPlugin::createPart()
87 KParts::ReadOnlyPart *part = loadPart();
93 mIface =
new KCalendarIface_stub( dcopClient(),
"kontact",
"CalendarIface" );
98 void TodoPlugin::select()
100 interface()->showTodoView();
103 TQStringList TodoPlugin::invisibleToolbarActions()
const
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";
120 KCalendarIface_stub *TodoPlugin::interface()
129 void TodoPlugin::slotNewTodo()
131 interface()->openTodoEditor(
"" );
134 void TodoPlugin::slotSyncTodos()
136 DCOPRef ref(
"kmail",
"KMailICalIface" );
137 ref.send(
"triggerSync", TQString(
"Todo") );
140 bool TodoPlugin::createDCOPInterface(
const TQString& serviceType )
142 kdDebug(5602) << k_funcinfo << serviceType << endl;
143 if ( serviceType ==
"DCOP/Organizer" || serviceType ==
"DCOP/Calendar" ) {
151 bool TodoPlugin::canDecodeDrag( TQMimeSource *mimeSource )
153 return TQTextDrag::canDecode( mimeSource ) ||
154 KPIM::MailListDrag::canDecode( mimeSource );
157 bool TodoPlugin::isRunningStandalone()
159 return mUniqueAppWatcher->isRunningStandalone();
162 void 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(),
184 KCal::Incidence::List incidences = cal.incidences();
185 if ( !incidences.isEmpty() ) {
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"