27 #include "calendarinterface.h"
32 #include <KABC/VCardDrag>
34 #include <KCalCore/Incidence>
35 #include <KCalCore/MemoryCalendar>
37 #include <KCalUtils/ICalDrag>
39 #include <KontactInterface/Core>
42 #include <KActionCollection>
45 #include <KIconLoader>
47 #include <KMessageBox>
48 #include <KStandardDirs>
49 #include <KSystemTimeZone>
50 #include <KTemporaryFile>
57 : KontactInterface::Plugin( core, core, "korganizer", "calendar" ), mIface( 0 )
59 setComponentData( KontactPluginFactory::componentData() );
60 KIconLoader::global()->addAppDir( QLatin1String(
"korganizer") );
61 KIconLoader::global()->addAppDir( QLatin1String(
"kdepim") );
64 new KAction( KIcon( QLatin1String(
"appointment-new") ),
65 i18nc(
"@action:inmenu",
"New Event..." ),
this );
66 actionCollection()->addAction( QLatin1String(
"new_event"), action );
67 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT+Qt::Key_E ) );
69 i18nc(
"@info:status",
"Create a new event" ) );
71 i18nc(
"@info:whatsthis",
72 "You will be presented with a dialog where you can create a new event item." ) );
73 connect( action, SIGNAL(triggered(
bool)), SLOT(slotNewEvent()) );
74 insertNewAction( action );
77 new KAction( KIcon( QLatin1String(
"view-refresh") ),
78 i18nc(
"@action:inmenu",
"Sync Calendar" ),
this );
79 actionCollection()->addAction( QLatin1String(
"korganizer_sync"), syncAction );
80 syncAction->setHelpText(
81 i18nc(
"@info:status",
"Synchronize groupware calendar" ) );
82 syncAction->setWhatsThis(
83 i18nc(
"@info:whatsthis",
84 "Choose this option to synchronize your groupware events." ) );
85 connect( syncAction, SIGNAL(triggered(
bool)), SLOT(slotSyncEvents()) );
86 insertSyncAction( syncAction );
88 mUniqueAppWatcher =
new KontactInterface::UniqueAppWatcher(
89 new KontactInterface::UniqueAppHandlerFactory<KOrganizerUniqueAppHandler>(),
this );
103 KParts::ReadOnlyPart *part = loadPart();
109 mIface =
new OrgKdeKorganizerCalendarInterface(
110 QLatin1String(
"org.kde.korganizer"), QLatin1String(
"/Calendar"), QDBusConnection::sessionBus(),
this );
117 QString file = KStandardDirs::locate(
"data", QLatin1String(
"korganizer/tips") );
123 QStringList invisible;
124 invisible += QLatin1String(
"new_event");
125 invisible += QLatin1String(
"new_todo");
126 invisible += QLatin1String(
"new_journal");
128 invisible += QLatin1String(
"view_todo");
129 invisible += QLatin1String(
"view_journal");
147 void KOrganizerPlugin::slotNewEvent()
149 interface()->openEventEditor( QString() );
152 void KOrganizerPlugin::slotSyncEvents()
155 QDBusMessage message =
156 QDBusMessage::createMethodCall(
"org.kde.kmail",
"/Groupware",
157 "org.kde.kmail.groupware",
159 message << QString(
"Calendar" );
160 QDBusConnection::sessionBus().send( message );
162 kWarning() <<
" KOrganizerPlugin::slotSyncEvents : need to port to Akonadi";
168 if ( serviceType == QLatin1String(
"DBUS/Organizer") || serviceType == QLatin1String(
"DBUS/Calendar") ) {
178 return mUniqueAppWatcher->isRunningStandalone();
183 return mimeData->hasText() ||
192 KABC::Addressee::List contacts;
196 KABC::Addressee::List::ConstIterator it;
198 KABC::Addressee::List::ConstIterator end(contacts.constEnd());
199 QStringList attendees;
200 for ( it = contacts.constBegin(); it != end; ++it ) {
201 QString email = (*it).fullEmail();
202 if ( email.isEmpty() ) {
203 attendees.append( (*it).realName() + QLatin1String(
"<>") );
205 attendees.append( email );
209 interface()->openEventEditor( i18nc(
"@item",
"Meeting" ),
210 QString(), QStringList(), attendees );
215 KCalCore::MemoryCalendar::Ptr cal(
216 new KCalCore::MemoryCalendar( KSystemTimeZones::local() ) );
218 KCalCore::Incidence::List incidences = cal->incidences();
219 Q_ASSERT( incidences.count() );
220 if ( !incidences.isEmpty() ) {
222 KCalCore::Incidence::Ptr i = incidences.first();
224 if ( i->type() == KCalCore::Incidence::TypeJournal ) {
225 summary = i18nc(
"@item",
"Note: %1", i->summary() );
227 summary = i->summary();
229 interface()->openEventEditor( summary, i->description(), QStringList() );
236 if ( md->hasText() ) {
237 const QString
text = md->text();
238 kDebug() <<
"DROP:" <<
text;
246 if ( mails.count() != 1 ) {
249 i18nc(
"@info",
"Dropping multiple mails is not supported." ) );
252 QString txt = i18nc(
"@item",
"From: %1\nTo: %2\nSubject: %3",
256 tf.setAutoRemove(
true );
258 QString uri = QLatin1String(
"kmail:" ) + QString::number( mail.
serialNumber() );
259 tf.write( event->encodedData(
"message/rfc822" ) );
261 i18nc(
"@item",
"Mail: %1", mail.
subject() ), txt,
262 uri, tf.fileName(), QStringList(), QLatin1String(
"message/rfc822") );
268 kWarning() << QString::fromLatin1(
"Cannot handle drop events of type '%1'." ).arg( QLatin1String(event->format()) );
271 #include "korganizerplugin.moc"
virtual KontactInterface::Summary * createSummaryWidget(QWidget *parent)
bool isRunningStandalone() const
virtual QByteArray text(quint32 serialNumber) const =0
static MailList fromMimeData(const QMimeData *md)
static bool canDecode(const QMimeData *md)
QStringList invisibleToolbarActions() const
KParts::ReadOnlyPart * createPart()
bool createDBUSInterface(const QString &serviceType)
OrgKdeKorganizerCalendarInterface * interface()
quint32 serialNumber() const
bool canDecodeMimeData(const QMimeData *) const
void processDropEvent(QDropEvent *)