33 #include "calendaradaptor.h"
39 #include "korganizeradaptor.h"
44 #include "reminderclient.h"
47 #include <calendarsupport/collectionselection.h>
48 #include <calendarsupport/eventarchiver.h>
49 #include <calendarsupport/kcalprefs.h>
50 #include <calendarsupport/utils.h>
52 #include <incidenceeditor-ng/globalsettings.h>
54 #include <Akonadi/EntityDisplayAttribute>
55 #include <Akonadi/EntityTreeView>
56 #include <Akonadi/EntityTreeModel>
57 #include <Akonadi/ETMViewStateSaver>
58 #include <Akonadi/Calendar/History>
59 #include <Akonadi/Calendar/ICalImporter>
61 #include <KCalCore/FileStorage>
62 #include <KCalCore/ICalFormat>
63 #include <KCalCore/Person>
65 #include <KHolidays/Holidays>
67 #include <KMime/KMimeMessage>
70 #include <KActionCollection>
71 #include <KCmdLineArgs>
72 #include <KFileDialog>
73 #include <KGlobalSettings>
76 #include <KMessageBox>
77 #include <KMimeTypeTrader>
79 #include <KSelectAction>
80 #include <KSelectionProxyModel>
81 #include <KShortcutsDialog>
82 #include <KStandardAction>
83 #include <KStandardDirs>
84 #include <KSystemTimeZones>
85 #include <KTemporaryFile>
87 #include <KToggleAction>
88 #include <KWindowSystem>
89 #include <KIO/NetAccess>
90 #include <KNS3/DownloadDialog>
92 #include <QApplication>
99 bool isPart, KMenuBar *menuBar )
101 mCollectionViewShowAction( 0 ),
102 mCollectionView( 0 ), mCollectionViewStateSaver( 0 ),
103 mCollectionSelectionModelStateSaver( 0 )
105 new KOrgCalendarAdaptor(
this );
106 QDBusConnection::sessionBus().registerObject( QLatin1String(
"/Calendar"),
this );
109 mACollection = mGUIClient->actionCollection();
110 mCalendarView = widget;
113 mHtmlExportSync =
false;
114 mMainWindow = mainWindow;
128 delete mCollectionSelectionModelStateSaver;
129 delete mCollectionViewStateSaver;
131 delete mCalendarView;
137 if ( mHideMenuBarAction->isChecked() ) {
140 if ( !dontShowWarning ) {
141 QString accel = mHideMenuBarAction->shortcut().toString();
142 KMessageBox::information( mCalendarView,
143 i18n(
"<qt>This will hide the menu bar completely."
144 " You can show it again by typing %1.</qt>", accel ),
145 i18n(
"Hide menu bar"), QLatin1String(
"HideMenuBarWarning") );
156 if ( !mWindowList ) {
173 mAutoExportTimer =
new QTimer(
this );
174 connect( mAutoExportTimer, SIGNAL(timeout()), SLOT(
checkAutoExport()) );
181 mAutoArchiveTimer =
new QTimer(
this );
182 mAutoArchiveTimer->setSingleShot(
true );
183 connect( mAutoArchiveTimer, SIGNAL(timeout()), SLOT(
slotAutoArchive()) );
186 if ( CalendarSupport::KCalPrefs::instance()->mAutoArchive ) {
187 mAutoArchiveTimer->start( 5 * 60 * 1000 );
192 connect( mCalendarView, SIGNAL(modifiedChanged(
bool)), SLOT(
setTitle()) );
195 connect( mCalendarView, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
206 Akonadi::ETMCalendar::Ptr ActionManager::calendar()
const
213 Q_ASSERT( calendar() );
216 mCollectionSelectionModelStateSaver =
217 new KViewStateMaintainer<Akonadi::ETMViewStateSaver>(
218 config->group(
"GlobalCollectionSelection" ) );
219 mCollectionSelectionModelStateSaver->setSelectionModel( calendar()->checkableProxyModel()->selectionModel() );
224 mCollectionView->setObjectName( QLatin1String(
"Resource View") );
225 connect( mCollectionView, SIGNAL(resourcesAddedRemoved()), SLOT(slotResourcesAddedRemoved()));
226 connect( mCollectionView, SIGNAL(defaultResourceChanged(Akonadi::Collection)),
227 SLOT(slotDefaultResourceChanged(Akonadi::Collection)) );
228 connect( mCollectionView, SIGNAL(colorsChanged()),
231 mCollectionViewStateSaver =
new KViewStateMaintainer<Akonadi::ETMViewStateSaver>( config->group(
"GlobalCollectionView" ) );
232 mCollectionViewStateSaver->setView( mCollectionView->
view() );
235 QItemSelectionModel *selectionModel = checkableProxy->selectionModel();
239 CalendarSupport::CollectionSelection *collectionSelection =
new CalendarSupport::CollectionSelection( selectionModel );
240 EventViews::EventView::setGlobalCollectionSelection( collectionSelection );
244 connect( calendar().data(), SIGNAL(calendarChanged()),
245 mCalendarView, SLOT(resourcesChanged()) );
248 calendar()->setOwner( KCalCore::Person::Ptr(
new KCalCore::Person( CalendarSupport::KCalPrefs::instance()->fullName(),
249 CalendarSupport::KCalPrefs::instance()->email() ) ) );
253 void ActionManager::initActions()
262 KAction *a = mACollection->addAction( KStandardAction::Open,
this, SLOT(
file_open()) );
263 mACollection->addAction( QLatin1String(
"korganizer_open"), a );
266 QAction *a = mACollection->addAction( KStandardAction::Print, mCalendarView, SLOT(print()) );
267 mACollection->addAction( QLatin1String(
"korganizer_print"), a );
268 a = mACollection->addAction( KStandardAction::PrintPreview, mCalendarView, SLOT(print()) );
269 mACollection->addAction( QLatin1String(
"korganizer_print_preview"), a );
271 !KMimeTypeTrader::self()->query( QLatin1String(
"application/pdf"), QLatin1String(
"KParts/ReadOnlyPart") ).isEmpty() );
273 KStandardAction::open(
this, SLOT(
file_open()), mACollection );
274 KStandardAction::print( mCalendarView, SLOT(print()), mACollection );
276 KStandardAction::printPreview( mCalendarView, SLOT(printPreview()), mACollection );
278 !KMimeTypeTrader::self()->query( QLatin1String(
"application/pdf"), QLatin1String(
"KParts/ReadOnlyPart")).isEmpty() );
282 mImportAction =
new KAction( i18n(
"Import &Calendar..." ),
this );
283 mImportAction->setHelpText(
284 i18n(
"Merge the contents of another iCalendar" ) );
285 mImportAction->setWhatsThis(
286 i18n(
"Select this menu entry if you would like to merge the contents "
287 "of another iCalendar into your current calendar." ) );
288 mACollection->addAction( QLatin1String(
"import_icalendar"), mImportAction );
289 connect( mImportAction, SIGNAL(triggered(
bool)), SLOT(
file_import()) );
291 KAction *importAction =
new KAction( i18n(
"&Import From UNIX Ical Tool" ),
this );
292 importAction->setHelpText(
293 i18n(
"Import a calendar in another format" ) );
294 importAction->setWhatsThis(
295 i18n(
"Select this menu entry if you would like to import the contents "
296 "of a non-iCalendar formatted file into your current calendar." ) );
297 mACollection->addAction( QLatin1String(
"import_ical"), importAction );
298 connect( importAction, SIGNAL(triggered(
bool)), SLOT(
file_icalimport()) );
300 action =
new KAction( i18n(
"Get &Hot New Stuff..." ),
this );
301 mACollection->addAction( QLatin1String(
"downloadnewstuff"), action );
304 action =
new KAction( i18n(
"Export &Web Page..." ),
this );
305 mACollection->addAction( QLatin1String(
"export_web"), action );
306 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(exportWeb()) );
308 action =
new KAction( i18n(
"Export as &iCalendar..." ),
this );
309 mACollection->addAction( QLatin1String(
"export_icalendar"), action );
310 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(exportICalendar()) );
312 action =
new KAction( i18n(
"Export as &vCalendar..." ),
this );
313 mACollection->addAction( QLatin1String(
"export_vcalendar"), action );
314 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(exportVCalendar()) );
321 action =
new KAction( i18n(
"Archive O&ld Entries..." ),
this );
322 mACollection->addAction( QLatin1String(
"file_archive"), action );
323 connect( action, SIGNAL(triggered(
bool)), SLOT(
file_archive()) );
325 action =
new KAction( i18n(
"Pur&ge Completed To-dos" ), mACollection );
326 mACollection->addAction( QLatin1String(
"purge_completed"), action );
327 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(purgeCompleted()) );
331 QAction *pasteAction;
332 Akonadi::History *history = mCalendarView->
history();
335 mCutAction = mACollection->addAction( KStandardAction::Cut, QLatin1String(
"korganizer_cut"),
336 mCalendarView, SLOT(edit_cut()) );
337 mCopyAction = mACollection->addAction( KStandardAction::Copy, QLatin1String(
"korganizer_copy"),
338 mCalendarView, SLOT(edit_copy()) );
339 pasteAction = mACollection->addAction( KStandardAction::Paste, QLatin1String(
"korganizer_paste"),
340 mCalendarView, SLOT(edit_paste()) );
341 mUndoAction = mACollection->addAction( KStandardAction::Undo, QLatin1String(
"korganizer_undo"),
342 history, SLOT(undo()) );
343 mRedoAction = mACollection->addAction( KStandardAction::Redo, QLatin1String(
"korganizer_redo"),
344 history, SLOT(redo()) );
346 mCutAction = KStandardAction::cut( mCalendarView, SLOT(edit_cut()), mACollection );
347 mCopyAction = KStandardAction::copy( mCalendarView, SLOT(edit_copy()), mACollection );
348 pasteAction = KStandardAction::paste( mCalendarView, SLOT(edit_paste()), mACollection );
349 mUndoAction = KStandardAction::undo( history, SLOT(undo()), mACollection );
350 mRedoAction = KStandardAction::redo( history, SLOT(redo()), mACollection );
352 mDeleteAction =
new KAction( KIcon( QLatin1String(
"edit-delete") ), i18n(
"&Delete" ),
this );
353 mACollection->addAction( QLatin1String(
"edit_delete"), mDeleteAction );
354 connect( mDeleteAction, SIGNAL(triggered(
bool)), mCalendarView, SLOT(appointment_delete()) );
358 SLOT(showSearchDialog()), mACollection );
359 mACollection->addAction( QLatin1String(
"korganizer_find"), a );
362 SLOT(showSearchDialog()), mACollection );
364 pasteAction->setEnabled(
false );
365 mUndoAction->setEnabled(
false );
366 mRedoAction->setEnabled(
false );
367 connect( mCalendarView, SIGNAL(pasteEnabled(
bool)), pasteAction, SLOT(setEnabled(
bool)) );
373 action =
new KAction( KIcon( QLatin1String(
"view-calendar-upcoming-events") ), i18n(
"What's &Next" ),
this );
374 mACollection->addAction( QLatin1String(
"view_whatsnext"), action );
375 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
376 SLOT(showWhatsNextView()) );
378 action =
new KAction( KIcon( QLatin1String(
"view-calendar-month") ), i18n(
"&Month" ),
this );
379 mACollection->addAction( QLatin1String(
"view_month"), action );
380 connect( action, SIGNAL(triggered(
bool)),
381 mCalendarView->
viewManager(), SLOT(showMonthView()) );
383 action =
new KAction( KIcon( QLatin1String(
"view-calendar-agenda") ), i18n(
"&Agenda" ),
this );
384 mACollection->addAction( QLatin1String(
"view_agenda"), action );
385 connect( action, SIGNAL(triggered(
bool)),
386 mCalendarView->
viewManager(), SLOT(showAgendaView()) );
388 action =
new KAction( KIcon( QLatin1String(
"view-calendar-list") ), i18n(
"&Event List" ),
this );
389 mACollection->addAction( QLatin1String(
"view_list"), action );
390 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
391 SLOT(showListView()) );
393 action =
new KAction( KIcon( QLatin1String(
"view-calendar-tasks") ), i18n(
"&To-do List" ),
this );
394 mACollection->addAction( QLatin1String(
"view_todo"), action );
395 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
398 action =
new KAction( KIcon( QLatin1String(
"view-calendar-journal" )), i18n(
"&Journal" ),
this );
399 mACollection->addAction( QLatin1String(
"view_journal"), action );
400 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
403 action =
new KAction( KIcon( QLatin1String(
"view-calendar-timeline") ), i18n(
"Time&line" ),
this );
404 mACollection->addAction( QLatin1String(
"view_timeline"), action );
405 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
406 SLOT(showTimeLineView()) );
408 action =
new KAction( KIcon( QLatin1String(
"view-calendar-time-spent") ), i18n(
"Time&spent" ),
this );
409 mACollection->addAction( QLatin1String(
"view_timespent"), action );
410 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
411 SLOT(showTimeSpentView()) );
414 action =
new KAction( i18n(
"&Refresh" ),
this );
415 mACollection->addAction( QLatin1String(
"update"), action );
416 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(updateView()) );
420 mFilterAction =
new KSelectAction( i18n(
"F&ilter" ),
this );
421 mFilterAction->setToolBarMode( KSelectAction::MenuMode );
422 mACollection->addAction( QLatin1String(
"filter_select"), mFilterAction );
423 mFilterAction->setEditable(
false );
424 connect( mFilterAction, SIGNAL(triggered(
int)),
425 mCalendarView, SLOT(filterActivated(
int)) );
426 connect( mCalendarView, SIGNAL(filtersUpdated(QStringList,
int)),
427 this, SLOT(
setItems(QStringList,
int)) );
428 connect( mCalendarView, SIGNAL(filterChanged()),
433 action =
new KAction( KIcon( QLatin1String(
"zoom-in") ), i18n(
"In Horizontally" ),
this );
435 mACollection->addAction( QLatin1String(
"zoom_in_horizontally"), action );
436 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
437 SLOT(zoomInHorizontally()) );
439 action =
new KAction( KIcon( QLatin1String(
"zoom-out") ), i18n(
"Out Horizontally" ),
this );
441 mACollection->addAction( QLatin1String(
"zoom_out_horizontally"), action );
442 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
443 SLOT(zoomOutHorizontally()) );
445 action =
new KAction( KIcon( QLatin1String(
"zoom-in") ), i18n(
"In Vertically" ),
this );
447 mACollection->addAction( QLatin1String(
"zoom_in_vertically"), action );
448 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
449 SLOT(zoomInVertically()) );
451 action =
new KAction( KIcon( QLatin1String(
"zoom-out") ), i18n(
"Out Vertically" ),
this );
453 mACollection->addAction( QLatin1String(
"zoom_out_vertically"), action );
454 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
455 SLOT(zoomOutVertically()) );
458 bool isRTL = QApplication::isRightToLeft();
460 action =
new KAction( KIcon( QLatin1String(
"go-jump-today") ),
461 i18nc(
"@action Jump to today",
"To &Today" ),
this );
462 action->setIconText( i18n(
"Today" ) );
463 action->setHelpText( i18n(
"Scroll to Today" ) );
464 mACollection->addAction( QLatin1String(
"go_today"), action );
465 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(goToday()) );
467 action =
new KAction( KIcon( isRTL ? QLatin1String(
"go-next") : QLatin1String(
"go-previous") ),
468 i18nc(
"scroll backward",
"&Backward" ),
this );
469 action->setIconText( i18nc(
"scroll backward",
"Back" ) );
470 action->setHelpText( i18n(
"Scroll Backward" ) );
471 mACollection->addAction( QLatin1String(
"go_previous"), action );
472 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(goPrevious()) );
482 action =
new KAction( KIcon( isRTL ? QLatin1String(
"go-previous") : QLatin1String(
"go-next") ),
483 i18nc(
"scroll forward",
"&Forward" ),
this );
484 action->setIconText( i18nc(
"scoll forward",
"Forward" ) );
485 action->setHelpText( i18n(
"Scroll Forward" ) );
486 mACollection->addAction( QLatin1String(
"go_next"), action );
487 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(goNext()) );
493 action =
new KAction( KIcon( QLatin1String(
"view-calendar-day") ), i18n(
"&Day" ),
this );
494 mACollection->addAction( QLatin1String(
"select_day"), action );
496 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
499 mNextXDays =
new KAction( KIcon( QLatin1String(
"view-calendar-upcoming-days") ), QString(),
this );
501 mACollection->addAction( QLatin1String(
"select_nextx"), mNextXDays );
502 connect( mNextXDays, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
503 SLOT(selectNextX()) );
504 mNextXDays->setText( i18np(
"&Next Day",
"&Next %1 Days",
KOPrefs::instance()->mNextXDays ) );
506 action =
new KAction( KIcon( QLatin1String(
"view-calendar-workweek") ), i18n(
"W&ork Week" ),
this );
508 mACollection->addAction( QLatin1String(
"select_workweek"), action );
509 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
510 SLOT(selectWorkWeek()) );
512 action =
new KAction( KIcon( QLatin1String(
"view-calendar-week") ), i18n(
"&Week" ),
this );
514 mACollection->addAction( QLatin1String(
"select_week"), action );
515 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
viewManager(),
516 SLOT(selectWeek()) );
519 mNewEventAction =
new KAction( KIcon( QLatin1String(
"appointment-new") ), i18n(
"New E&vent..." ),
this );
521 mNewEventAction->setHelpText( i18n(
"Create a new Event" ) );
523 mACollection->addAction( QLatin1String(
"new_event"), mNewEventAction );
524 connect( mNewEventAction, SIGNAL(triggered(
bool)),
this,
525 SLOT(slotNewEvent()) );
527 mNewTodoAction =
new KAction( KIcon( QLatin1String(
"task-new") ), i18n(
"New &To-do..." ),
this );
529 mNewTodoAction->setHelpText( i18n(
"Create a new To-do" ) );
530 mACollection->addAction( QLatin1String(
"new_todo"), mNewTodoAction );
531 connect( mNewTodoAction, SIGNAL(triggered(
bool)),
this,
532 SLOT(slotNewTodo()) );
534 mNewSubtodoAction =
new KAction( i18n(
"New Su&b-to-do..." ),
this );
535 mACollection->addAction( QLatin1String(
"new_subtodo"), mNewSubtodoAction );
536 connect( mNewSubtodoAction, SIGNAL(triggered(
bool)),
this,
537 SLOT(slotNewSubTodo()));
538 mNewSubtodoAction->setEnabled(
false );
539 connect( mCalendarView,SIGNAL(todoSelected(
bool)), mNewSubtodoAction,
540 SLOT(setEnabled(
bool)) );
542 mNewJournalAction =
new KAction( KIcon( QLatin1String(
"journal-new") ), i18n(
"New &Journal..." ),
this );
544 mNewJournalAction->setHelpText( i18n(
"Create a new Journal" ) );
545 mACollection->addAction( QLatin1String(
"new_journal"), mNewJournalAction );
546 connect( mNewJournalAction, SIGNAL(triggered(
bool)),
this,
547 SLOT(slotNewJournal()) );
549 mConfigureViewAction =
new KAction( KIcon( QLatin1String(
"configure") ), i18n(
"Configure View..." ),
this );
550 mConfigureViewAction->setIconText( i18n(
"Configure" ) );
551 mConfigureViewAction->setHelpText( i18n(
"Configure the view" ) );
552 mConfigureViewAction->setEnabled( mCalendarView->
currentView() &&
554 mACollection->addAction( QLatin1String(
"configure_view"), mConfigureViewAction );
555 connect( mConfigureViewAction, SIGNAL(triggered(
bool)), mCalendarView,
556 SLOT(configureCurrentView()) );
558 mShowIncidenceAction =
new KAction( i18n(
"&Show" ),
this );
559 mACollection->addAction( QLatin1String(
"show_incidence"), mShowIncidenceAction );
560 connect( mShowIncidenceAction, SIGNAL(triggered(
bool)), mCalendarView,
563 mEditIncidenceAction =
new KAction( i18n(
"&Edit..." ),
this );
564 mACollection->addAction( QLatin1String(
"edit_incidence"), mEditIncidenceAction );
565 connect( mEditIncidenceAction, SIGNAL(triggered(
bool)), mCalendarView,
568 mDeleteIncidenceAction =
new KAction( i18n(
"&Delete" ),
this );
569 mACollection->addAction( QLatin1String(
"delete_incidence"), mDeleteIncidenceAction );
570 connect( mDeleteIncidenceAction, SIGNAL(triggered(
bool)), mCalendarView,
572 mDeleteIncidenceAction->setShortcut( QKeySequence( Qt::Key_Delete ) );
574 action =
new KAction( i18n(
"&Make Sub-to-do Independent" ),
this );
575 mACollection->addAction( QLatin1String(
"unsub_todo"), action );
576 connect( action, SIGNAL(triggered(
bool)), mCalendarView,
577 SLOT(todo_unsub()) );
578 action->setEnabled(
false );
579 connect( mCalendarView, SIGNAL(subtodoSelected(
bool)), action,
580 SLOT(setEnabled(
bool)) );
588 mPublishEvent =
new KAction( KIcon( QLatin1String(
"mail-send") ), i18n(
"&Publish Item Information..." ),
this );
589 mACollection->addAction( QLatin1String(
"schedule_publish"), mPublishEvent );
590 connect( mPublishEvent, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_publish()) );
591 mPublishEvent->setEnabled(
false );
594 new KAction( KIcon( QLatin1String(
"mail-send") ), i18n(
"Send &Invitation to Attendees" ),
this );
595 mACollection->addAction( QLatin1String(
"schedule_request"), mSendInvitation );
596 connect( mSendInvitation, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_request()) );
597 mSendInvitation->setEnabled(
false );
598 connect( mCalendarView, SIGNAL(organizerEventsSelected(
bool)),
599 mSendInvitation, SLOT(setEnabled(
bool)) );
601 mRequestUpdate =
new KAction( i18n(
"Re&quest Update" ),
this );
602 mACollection->addAction( QLatin1String(
"schedule_refresh"), mRequestUpdate );
603 connect( mRequestUpdate, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_refresh()) );
604 mRequestUpdate->setEnabled(
false );
605 connect( mCalendarView, SIGNAL(groupEventsSelected(
bool)),
606 mRequestUpdate, SLOT(setEnabled(
bool)) );
608 mSendCancel =
new KAction( i18n(
"Send &Cancellation to Attendees" ),
this );
609 mACollection->addAction( QLatin1String(
"schedule_cancel"), mSendCancel );
610 connect( mSendCancel, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_cancel()) );
611 mSendCancel->setEnabled(
false );
612 connect( mCalendarView, SIGNAL(organizerEventsSelected(
bool)),
613 mSendCancel, SLOT(setEnabled(
bool)) );
616 new KAction( KIcon(QLatin1String(
"mail-reply-sender") ), i18n(
"Send Status &Update" ),
this );
617 mACollection->addAction( QLatin1String(
"schedule_reply"), mSendStatusUpdate );
618 connect( mSendStatusUpdate, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_reply()) );
619 mSendStatusUpdate->setEnabled(
false );
620 connect( mCalendarView, SIGNAL(groupEventsSelected(
bool)),
621 mSendStatusUpdate, SLOT(setEnabled(
bool)) );
623 mRequestChange =
new KAction( i18nc(
"counter proposal",
"Request Chan&ge" ),
this );
624 mACollection->addAction( QLatin1String(
"schedule_counter"), mRequestChange );
625 connect( mRequestChange, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_counter()) );
626 mRequestChange->setEnabled(
false );
627 connect( mCalendarView, SIGNAL(groupEventsSelected(
bool)),
628 mRequestChange, SLOT(setEnabled(
bool)) );
630 action =
new KAction( i18n(
"&Mail Free Busy Information..." ),
this );
631 mACollection->addAction( QLatin1String(
"mail_freebusy"), action );
632 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(mailFreeBusy()) );
633 action->setEnabled(
true );
635 mForwardEvent =
new KAction( KIcon( QLatin1String(
"mail-forward") ), i18n(
"&Send as iCalendar..." ),
this );
636 mACollection->addAction( QLatin1String(
"schedule_forward"), mForwardEvent );
637 connect( mForwardEvent, SIGNAL(triggered(
bool)), mCalendarView, SLOT(schedule_forward()) );
638 mForwardEvent->setEnabled(
false );
640 action =
new KAction( i18n(
"&Upload Free Busy Information" ),
this );
641 mACollection->addAction( QLatin1String(
"upload_freebusy"), action );
642 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(uploadFreeBusy()) );
643 action->setEnabled(
true );
646 action =
new KAction( KIcon( QLatin1String(
"help-contents") ), i18n(
"&Address Book" ),
this );
647 mACollection->addAction( QLatin1String(
"addressbook"), action );
648 connect( action, SIGNAL(triggered(
bool)), mCalendarView, SLOT(openAddressbook()) );
654 mDateNavigatorShowAction =
new KToggleAction( i18n(
"Show Date Navigator" ),
this );
655 mACollection->addAction( QLatin1String(
"show_datenavigator"), mDateNavigatorShowAction );
658 mTodoViewShowAction =
new KToggleAction( i18n(
"Show To-do View" ),
this );
659 mACollection->addAction( QLatin1String(
"show_todoview"), mTodoViewShowAction );
660 connect( mTodoViewShowAction, SIGNAL(triggered(
bool)), SLOT(
toggleTodoView()) );
662 mEventViewerShowAction =
new KToggleAction( i18n(
"Show Item Viewer" ),
this );
663 mACollection->addAction( QLatin1String(
"show_eventviewer"), mEventViewerShowAction );
664 connect( mEventViewerShowAction, SIGNAL(triggered(
bool)), SLOT(
toggleEventViewer()) );
666 mDateNavigatorShowAction->setChecked( config.readEntry(
"DateNavigatorVisible",
true ) );
670 mTodoViewShowAction->setChecked(
671 config.readEntry(
"TodoViewVisible",
false ) );
672 mEventViewerShowAction->setChecked( config.readEntry(
"EventViewerVisible",
true ) );
678 mCollectionViewShowAction =
new KToggleAction( i18n(
"Show Calendar Manager" ),
this );
679 mACollection->addAction( QLatin1String(
"show_resourceview"), mCollectionViewShowAction );
680 connect( mCollectionViewShowAction, SIGNAL(triggered(
bool)), SLOT(
toggleResourceView()) );
681 mCollectionViewShowAction->setChecked( config.readEntry(
"ResourceViewVisible",
true ) );
687 mHideMenuBarAction = KStandardAction::showMenubar(
this, SLOT(
toggleMenubar()), mACollection );
691 action =
new KAction( i18n(
"Configure &Date && Time..." ),
this );
692 mACollection->addAction( QLatin1String(
"conf_datetime"), action );
693 connect( action, SIGNAL(triggered(
bool)),
700 action =
new KAction( KIcon( QLatin1String(
"view-filter") ), i18n(
"Manage View &Filters..." ),
this );
701 mACollection->addAction( QLatin1String(
"edit_filters"), action );
702 connect( action, SIGNAL(triggered(
bool)), mCalendarView,
703 SLOT(editFilters()) );
705 action =
new KAction( i18n(
"Manage C&ategories..." ),
this );
706 mACollection->addAction( QLatin1String(
"edit_categories"), action );
707 connect( action, SIGNAL(triggered(
bool)), mCalendarView->
dialogManager(),
708 SLOT(showCategoryEditDialog()) );
711 action =
new KAction( KIcon( QLatin1String(
"configure") ), i18n(
"&Configure KOrganizer..." ),
this );
712 mACollection->addAction( QLatin1String(
"korganizer_configure"), action );
713 connect( action, SIGNAL(triggered(
bool)), mCalendarView,
714 SLOT(edit_options()) );
715 mACollection->addAction( KStandardAction::KeyBindings, QLatin1String(
"korganizer_configure_shortcuts"),
718 KStandardAction::preferences( mCalendarView, SLOT(edit_options()), mACollection );
719 KStandardAction::keyBindings(
this, SLOT(
keyBindings()), mACollection );
723 QAction *a = mACollection->addAction( KStandardAction::TipofDay,
this,
725 mACollection->addAction( QLatin1String(
"help_tipofday"), a );
730 mFilterAction->setItems( lst );
731 mFilterAction->setCurrentItem( idx );
734 void ActionManager::slotResourcesAddedRemoved()
736 restoreCollectionViewSetting();
739 void ActionManager::slotDefaultResourceChanged(
const Akonadi::Collection &collection )
744 void ActionManager::slotNewEvent()
749 void ActionManager::slotNewTodo()
751 mCalendarView->
newTodo( selectedCollection() );
754 void ActionManager::slotNewSubTodo()
756 mCalendarView->
newSubTodo( selectedCollection() );
759 void ActionManager::slotNewJournal()
761 mCalendarView->
newJournal( selectedCollection() );
764 void ActionManager::slotMergeFinished(
bool success,
int total)
767 sender()->deleteLater();
768 mImportAction->setEnabled(
true);
769 Akonadi::ICalImporter *importer = qobject_cast<Akonadi::ICalImporter*>(sender());
772 mCalendarView->
showMessage(i18np(
"1 incidence was imported successfully.",
"%1 incidences were imported successfully.", total), KMessageWidget::Information);
774 mCalendarView->
showMessage(i18n(
"There was an error while merging the calendar: %1", importer->errorMessage()), KMessageWidget::Error);
778 void ActionManager::slotNewResourceFinished(
bool success)
781 sender()->deleteLater();
782 Akonadi::ICalImporter *importer = qobject_cast<Akonadi::ICalImporter*>(sender());
783 mImportAction->setEnabled(
true);
785 mCalendarView->
showMessage(i18n(
"New calendar added successfully"), KMessageWidget::Information);
787 mCalendarView->
showMessage(i18n(
"Could not add a calendar. Error: %1", importer->errorMessage()), KMessageWidget::Error);
797 restoreCollectionViewSetting();
800 void ActionManager::restoreCollectionViewSetting()
802 mCollectionSelectionModelStateSaver->restoreState();
803 mCollectionViewStateSaver->restoreState();
811 if ( mDateNavigatorShowAction ) {
812 config.writeEntry(
"DateNavigatorVisible", mDateNavigatorShowAction->isChecked() );
815 if ( mTodoViewShowAction ) {
816 config.writeEntry(
"TodoViewVisible", mTodoViewShowAction->isChecked() );
819 if ( mCollectionViewShowAction ) {
820 config.writeEntry(
"ResourceViewVisible", mCollectionViewShowAction->isChecked() );
823 if ( mEventViewerShowAction ) {
824 config.writeEntry(
"EventViewerVisible", mEventViewerShowAction->isChecked() );
827 mCollectionViewStateSaver->saveState();
828 mCollectionSelectionModelStateSaver->saveState();
832 selectionGroup.sync();
833 selectionViewGroup.sync();
846 const QString defaultPath = KStandardDirs::locateLocal(
"data",QLatin1String(
"korganizer/") );
847 const KUrl
url = KFileDialog::getOpenUrl( defaultPath, QLatin1String(
"text/calendar"),
dialogParent() );
854 if ( url.isEmpty() ) {
860 if ( ( 0 != korg )&&( korg != mMainWindow ) ) {
867 kDebug() << url.prettyUrl();
878 KTemporaryFile tmpfn;
881 QString homeDir = QDir::homePath() + QLatin1String(
"/.calendar" );
883 if ( !QFile::exists( homeDir ) ) {
885 i18n(
"You have no ical file in your home directory.\n"
886 "Import cannot proceed.\n" ) );
891 proc << QLatin1String(
"ical2vcal") << tmpfn.fileName();
892 retVal = proc.execute();
895 kDebug() <<
"Error executing ical2vcal.";
899 kDebug() <<
"ical2vcal return value:" << retVal;
901 if ( retVal >= 0 && retVal <= 2 ) {
903 const bool success =
importURL(KUrl(tmpfn.fileName()),
true);
905 mCalendarView->
showMessage( i18n(
"KOrganizer encountered some unknown fields while "
906 "parsing your .calendar ical file, and had to "
907 "discard them; please check to see that all "
908 "your relevant data was correctly imported." ), KMessageWidget::Warning);
913 }
else if ( retVal == -1 ) {
914 mCalendarView->
showMessage( i18n(
"KOrganizer encountered an error parsing your "
915 ".calendar file from ical; import has failed." ), KMessageWidget::Error );
916 }
else if ( retVal == -2 ) {
917 mCalendarView->
showMessage( i18n(
"KOrganizer does not think that your .calendar "
918 "file is a valid ical calendar; import has failed." ), KMessageWidget::Error );
924 const KUrl
url = KFileDialog::getOpenUrl( KStandardDirs::locateLocal(
"data",QLatin1String(
"korganizer/") ),
925 QLatin1String(
"text/calendar"),
927 if ( !url.isEmpty() ) {
939 Akonadi::ICalImporter *importer =
new Akonadi::ICalImporter();
942 connect(importer, SIGNAL(importIntoExistingFinished(
bool,
int)), SLOT(slotMergeFinished(
bool,
int))),
943 jobStarted = importer->importIntoExistingResource(url, Akonadi::Collection());
945 connect(importer, SIGNAL(importIntoNewFinished(
bool)), SLOT(slotNewResourceFinished(
bool)));
946 jobStarted = importer->importIntoNewResource(url.path());
950 mImportAction->setEnabled(
false);
953 if (!importer->errorMessage().isEmpty())
954 mCalendarView->
showMessage(i18n(
"An error occurred: %1", importer->errorMessage()), KMessageWidget::Error);
964 if ( mURL.isLocalFile() ) {
965 ext = mFile.right( 4 );
967 ext = mURL.fileName().right( 4 );
970 if ( ext == QLatin1String(
".vcs" ) ) {
971 int result = KMessageBox::warningContinueCancel(
973 i18n(
"Your calendar will be saved in iCalendar format. Use "
974 "'Export vCalendar' to save in vCalendar format." ),
975 i18n(
"Format Conversion" ), KGuiItem( i18n(
"Proceed" ) ),
976 KStandardGuiItem::cancel(),
977 QLatin1String(
"dontaskFormatConversion" ), KMessageBox::Notify );
978 if ( result != KMessageBox::Continue ) {
982 QString filename = mURL.fileName();
983 filename.replace( filename.length() - 4, 4, QLatin1String(
".ics") );
984 mURL.setFileName( filename );
985 if ( mURL.isLocalFile() ) {
986 mFile = mURL.toLocalFile();
992 kDebug() <<
"calendar view save failed.";
996 if ( !mURL.isLocalFile() ) {
997 if ( !KIO::NetAccess::upload( mFile, mURL,
view() ) ) {
998 QString msg = i18n(
"Cannot upload calendar to '%1'",
1005 mMainWindow->
showStatusMessage( i18n(
"Saved calendar '%1'.", mURL.prettyUrl() ) );
1013 mSettingsToFree.insert( settings );
1016 settings->readConfig();
1018 const QDate qd1 = QDate::currentDate();
1022 qd2 = qd2.addMonths( 1 );
1024 qd2 = qd2.addDays( 7 );
1035 kWarning() <<
"Settings is null" << settings;
1040 int result = KMessageBox::questionYesNo(
1042 i18n(
"The HTML calendar export file has not been specified yet.\n"
1043 "Do you want to set it now?\n\n"
1044 "If you answer \"no\" then this export operation will be canceled" ),
1046 if ( result == KMessageBox::No ) {
1048 i18nc(
"@info:status",
1049 "Calendar HTML operation canceled due to unspecified output file name" ) );
1053 const QString fileName =
1054 KFileDialog::getSaveFileName(
1055 KGlobalSettings::documentPath(),
1056 i18n(
"*.html|HTML Files" ),
1058 i18n(
"Select path for HTML calendar export" ) );
1060 settings->writeConfig();
1063 if ( !autoMode && QFileInfo( settings->
outputFile() ).exists() ) {
1064 if ( KMessageBox::warningContinueCancel(
1066 i18n(
"Do you want to overwrite file \"%1\"?",
1069 KStandardGuiItem::overwrite() ) == KMessageBox::Cancel ) {
1071 i18nc(
"@info:status",
1072 "Calendar HTML operation canceled due to output file overwrite" ) );
1077 settings->
setEMail( CalendarSupport::KCalPrefs::instance()->email() );
1078 settings->
setName( CalendarSupport::KCalPrefs::instance()->fullName() );
1081 settings->
setCreditURL( QLatin1String(
"http://korganizer.kde.org") );
1088 foreach (
const KHolidays::Holiday &holiday, holidays ) {
1089 exportJob->
addHoliday( holiday.date(), holiday.text() );
1093 connect( exportJob, SIGNAL(result(
KJob*)), SLOT(handleExportJobResult(
KJob*)) );
1099 kDebug() << url.prettyUrl();
1101 if ( url.isEmpty() ) {
1102 kDebug() <<
"Empty URL.";
1105 if ( !url.isValid() ) {
1106 kDebug() <<
"Malformed URL.";
1110 QString fileOrig = mFile;
1111 KUrl URLOrig = mURL;
1113 KTemporaryFile *tempFile = 0;
1114 if ( url.isLocalFile() ) {
1115 mFile = url.toLocalFile();
1117 tempFile =
new KTemporaryFile;
1118 tempFile->setAutoRemove(
false);
1120 mFile = tempFile->fileName();
1127 mTempFile = tempFile;
1128 KIO::NetAccess::removeTempFile( fileOrig );
1132 i18n(
"Unable to save calendar to the file %1.", mFile ),
1134 kDebug() <<
"failed";
1143 #ifdef AKONADI_PORT_DISABLED // can go away, kept for reference
1144 bool ActionManager::saveModifiedURL()
1149 if ( !mCalendarView->isModified() ) {
1153 mHtmlExportSync =
true;
1158 int result = KMessageBox::warningYesNoCancel(
1160 i18n(
"The calendar has been modified.\nDo you want to save it?" ),
1162 KStandardGuiItem::save(), KStandardGuiItem::discard() );
1164 case KMessageBox::Yes:
1165 if ( mURL.isEmpty() ) {
1171 case KMessageBox::No:
1173 case KMessageBox::Cancel:
1176 mHtmlExportSync =
false;
1187 KFileDialog::getSaveUrl( KStandardDirs::locateLocal(
"data",QLatin1String(
"korganizer/") ),
1188 i18n(
"*.ics *.vcs|Calendar Files" ),
1191 if ( url == KUrl() ) {
1195 QString filename = url.fileName();
1197 QString e = filename.right( 4 );
1198 if ( e != QLatin1String(
".vcs" ) && e != QLatin1String(
".ics" ) ) {
1200 filename += QLatin1String(
".ics");
1203 url.setFileName( filename );
1205 kDebug() <<
"url:" << url.url();
1214 config.writeEntry(
"UseResourceCalendar", !mMainWindow->
hasDocument() );
1216 config.writePathEntry(
"Calendar", mURL.url() );
1222 mMainWindow->
init(
false );
1229 mNextXDays->setText( i18np(
"&Next Day",
"&Next %1 Days",
1236 KPIM::ReminderClient::hideDaemon();
1238 KPIM::ReminderClient::showDaemon();
1243 #ifdef AKONADI_PORT_DISABLED // shouldn't be required anymore
1244 if ( mCollectionView ) {
1245 mCollectionView->updateView();
1253 proc << QLatin1String(
"kcmshell4") << QLatin1String(
"language");
1255 if ( !proc.startDetached() ) {
1257 i18n(
"Could not start control module for date and time format." ) );
1263 KTipDialog::showTip(
dialogParent(), QString(),
true );
1268 KConfigGroup config( KGlobal::config(),
"TipOfDay" );
1269 KTipDialog::setShowOnStart( config.readEntry(
"RunOnStart",
false ) );
1275 if ( mWindowList ) {
1276 if ( url.isEmpty() ) {
1292 void ActionManager::dumpText(
const QString &str )
1299 bool visible = mDateNavigatorShowAction->isChecked();
1300 if ( mCalendarView ) {
1307 bool visible = mTodoViewShowAction->isChecked();
1308 if ( mCalendarView ) {
1315 bool visible = mEventViewerShowAction->isChecked();
1316 if ( mCalendarView ) {
1323 const bool visible = mCollectionViewShowAction->isChecked();
1324 if ( mCollectionView ) {
1326 mCollectionView->show();
1328 mCollectionView->hide();
1365 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
1370 if ( !mainWindow ) {
1371 kError() <<
"Unable to find default calendar resources view.";
1373 }
else if ( args->count() <= 0 ) {
1381 if ( args->isSet(
"import" ) ) {
1382 for (
int i = 0; i < args->count(); ++i ) {
1385 }
else if ( args->isSet(
"merge" ) ) {
1386 for (
int i = 0; i < args->count(); ++i ) {
1390 for (
int i = 0; i < args->count(); ++i ) {
1411 KNS3::DownloadDialog dialog(mCalendarView);
1413 foreach (
const KNS3::Entry &e, dialog.installedEntries() ) {
1414 kDebug() <<
" downloadNewStuff :";
1415 const QStringList lstFile = e.installedFiles();
1416 if ( lstFile.count() != 1 ) {
1419 const QString file = lstFile.at( 0 );
1420 const KUrl filename( file );
1421 kDebug() <<
"filename :" << filename;
1422 if( ! filename.isValid() ) {
1426 KCalCore::FileStorage storage( calendar() );
1427 storage.setFileName( file );
1428 storage.setSaveFormat(
new KCalCore::ICalFormat );
1429 if ( !storage.load() ) {
1430 KMessageBox::error( mCalendarView, i18n(
"Could not load calendar %1.", file ) );
1432 QStringList eventSummaries;
1433 KCalCore::Event::List events = calendar()->events();
1434 foreach ( KCalCore::Event::Ptr event, events ) {
1435 eventSummaries.append( event->summary() );
1438 const int result = KMessageBox::warningContinueCancelList( mCalendarView,
1439 i18n(
"The downloaded events will be merged into your current calendar." ),
1442 if ( result != KMessageBox::Continue ) {
1458 class ActionManager::ActionStringsVisitor :
public KCalCore::Visitor
1461 ActionStringsVisitor() : mShow( 0 ), mEdit( 0 ), mDelete( 0 ) {}
1463 bool act( KCalCore::IncidenceBase::Ptr incidence, QAction *show, QAction *edit, QAction *del )
1468 return incidence->accept( *
this, incidence );
1472 bool visit( KCalCore::Event::Ptr )
1475 mShow->setText( i18n(
"&Show Event" ) );
1478 mEdit->setText( i18n(
"&Edit Event..." ) );
1481 mDelete->setText( i18n(
"&Delete Event" ) );
1486 bool visit( KCalCore::Todo::Ptr )
1489 mShow->setText( i18n(
"&Show To-do" ) );
1492 mEdit->setText( i18n(
"&Edit To-do..." ) );
1495 mDelete->setText( i18n(
"&Delete To-do" ) );
1500 bool visit( KCalCore::Journal::Ptr )
1502 return assignDefaultStrings();
1505 bool visit( KCalCore::FreeBusy::Ptr )
1511 bool assignDefaultStrings()
1514 mShow->setText( i18n(
"&Show" ) );
1517 mEdit->setText( i18n(
"&Edit..." ) );
1520 mDelete->setText( i18n(
"&Delete" ) );
1534 const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
1536 enableIncidenceActions(
false );
1540 enableIncidenceActions(
true );
1542 if ( !mCalendarView->
calendar()->hasRight( item, Akonadi::Collection::CanDeleteItem ) ) {
1543 mCutAction->setEnabled(
false );
1544 mDeleteAction->setEnabled(
false );
1547 ActionStringsVisitor v;
1548 if ( !v.act( incidence, mShowIncidenceAction, mEditIncidenceAction, mDeleteIncidenceAction ) ) {
1549 mShowIncidenceAction->setText( i18n(
"&Show" ) );
1550 mEditIncidenceAction->setText( i18n(
"&Edit..." ) );
1551 mDeleteIncidenceAction->setText( i18n(
"&Delete" ) );
1555 void ActionManager::enableIncidenceActions(
bool enabled )
1557 mShowIncidenceAction->setEnabled( enabled );
1558 mEditIncidenceAction->setEnabled( enabled );
1559 mDeleteIncidenceAction->setEnabled( enabled );
1561 mCutAction->setEnabled( enabled );
1562 mCopyAction->setEnabled( enabled );
1563 mDeleteAction->setEnabled( enabled );
1564 mPublishEvent->setEnabled( enabled );
1565 mForwardEvent->setEnabled( enabled );
1566 mSendInvitation->setEnabled( enabled );
1567 mSendCancel->setEnabled( enabled );
1568 mSendStatusUpdate->setEnabled( enabled );
1569 mRequestChange->setEnabled( enabled );
1570 mRequestUpdate->setEnabled( enabled );
1573 Akonadi::Collection ActionManager::selectedCollection()
const
1575 const QModelIndex index = mCollectionView->
view()->currentIndex();
1576 if ( !index.isValid() ) {
1577 return Akonadi::Collection();
1580 return index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
1585 KShortcutsDialog dlg( KShortcutsEditor::AllActions,
1586 KShortcutsEditor::LetterShortcutsDisallowed,
view() );
1587 if ( mMainWindow ) {
1593 dlg.addCollection( part->actionCollection(), part->
shortInfo() );
1615 const QString &description,
1616 const QStringList &attachments )
1618 mCalendarView->
newEvent( summary, description, attachments );
1622 const QString &description,
1623 const QStringList &attachments,
1624 const QStringList &attendees )
1626 mCalendarView->
newEvent( summary, description, attachments, attendees );
1630 const QString &description,
1632 const QString &file,
1633 const QStringList &attendees,
1634 const QString &attachmentMimetype )
1636 int action = IncidenceEditorNG::GlobalSettings::self()->defaultEmailAttachMethod();
1637 if ( attachmentMimetype != QLatin1String(
"message/rfc822") ) {
1638 action = IncidenceEditorNG::GlobalSettings::Link;
1639 }
else if ( IncidenceEditorNG::GlobalSettings::self()->defaultEmailAttachMethod() ==
1640 IncidenceEditorNG::GlobalSettings::Ask ) {
1641 KMenu *menu =
new KMenu( 0 );
1642 QAction *attachLink = menu->addAction( i18n(
"Attach as &link" ) );
1643 QAction *attachInline = menu->addAction( i18n(
"Attach &inline" ) );
1644 QAction *attachBody = menu->addAction( i18n(
"Attach inline &without attachments" ) );
1645 menu->addSeparator();
1646 menu->addAction( KIcon( QLatin1String(
"dialog-cancel") ), i18n(
"C&ancel" ) );
1648 QAction *ret = menu->exec( QCursor::pos() );
1651 if ( ret == attachLink ) {
1652 action = IncidenceEditorNG::GlobalSettings::Link;
1653 }
else if ( ret == attachInline ) {
1654 action = IncidenceEditorNG::GlobalSettings::InlineFull;
1655 }
else if ( ret == attachBody ) {
1656 action = IncidenceEditorNG::GlobalSettings::InlineBody;
1664 tf.setAutoRemove(
true );
1666 case IncidenceEditorNG::GlobalSettings::Link:
1669 case IncidenceEditorNG::GlobalSettings::InlineFull:
1672 case IncidenceEditorNG::GlobalSettings::InlineBody:
1675 if ( !f.open( QFile::ReadOnly ) ) {
1678 KMime::Message *msg =
new KMime::Message();
1679 msg->setContent( f.readAll() );
1681 if ( msg == msg->textContent() || msg->textContent() == 0 ) {
1684 if ( KMessageBox::warningContinueCancel(
1686 i18n(
"Removing attachments from an email might invalidate its signature." ),
1687 i18n(
"Remove Attachments" ), KStandardGuiItem::cont(), KStandardGuiItem::cancel(),
1688 QLatin1String(
"BodyOnlyInlineAttachment") ) != KMessageBox::Continue ) {
1692 KMime::Message *newMsg =
new KMime::Message();
1693 newMsg->setHead( msg->head() );
1694 newMsg->setBody( msg->textContent()->body() );
1696 newMsg->contentTransferEncoding()->from7BitString(
1697 msg->textContent()->contentTransferEncoding()->as7BitString() );
1698 newMsg->contentType()->from7BitString( msg->textContent()->contentType()->as7BitString() );
1700 tf.write( newMsg->encodedContent() );
1701 attData = tf.fileName();
1711 mCalendarView->
newEvent( summary, description, QStringList(attData),
1712 attendees, QStringList(attachmentMimetype),
1713 action != IncidenceEditorNG::GlobalSettings::Link );
1718 mCalendarView->
newTodo( text );
1722 const QString &description,
1723 const QStringList &attachments )
1725 mCalendarView->
newTodo( summary, description, attachments );
1728 const QString &description,
1729 const QStringList &attachments,
1730 const QStringList &attendees )
1732 mCalendarView->
newTodo( summary, description, attachments, attendees );
1736 const QString &description,
1738 const QString &file,
1739 const QStringList &attendees,
1740 const QString &attachmentMimetype )
1743 if ( attachmentMimetype != QLatin1String(
"message/rfc822") ) {
1746 KMenu *menu =
new KMenu( 0 );
1747 QAction *attachLink = menu->addAction( i18n(
"Attach as &link" ) );
1748 QAction *attachInline = menu->addAction( i18n(
"Attach &inline" ) );
1749 menu->addSeparator();
1750 menu->addAction( KIcon( QLatin1String(
"dialog-cancel") ), i18n(
"C&ancel" ) );
1752 QAction *ret = menu->exec( QCursor::pos() );
1755 if ( ret == attachLink ) {
1757 }
else if ( ret == attachInline ) {
1776 mCalendarView->
newTodo( summary, description, QStringList( attData ),
1777 attendees, QStringList( attachmentMimetype ),
1813 mCalendarView->
goDate( date );
1818 goDate( KGlobal::locale()->readDate( date ) );
1830 if ( history->undoAvailable() ) {
1831 mUndoAction->setEnabled(
true );
1832 mUndoAction->setText( i18n(
"Undo: %1", history->nextUndoDescription() ) );
1834 mUndoAction->setEnabled(
false );
1835 mUndoAction->setText( i18n(
"Undo" ) );
1838 if ( history->redoAvailable() ) {
1839 mRedoAction->setEnabled(
true );
1840 mRedoAction->setText( i18n(
"Redo: %1", history->nextRedoDescription() ) );
1842 mRedoAction->setEnabled(
false );
1843 mRedoAction->setText( i18n(
"Redo" ) );
1846 mUndoAction->setIconText( i18n(
"Undo" ) );
1856 if ( !url.isValid() ) {
1858 i18n(
"URL '%1' is invalid.", url.prettyUrl() ) );
1862 const QString questionText =
1864 "<p>Would you like to merge this calendar item into an existing calendar "
1865 "or use it to create a brand new calendar?</p>"
1866 "<p>If you select merge, then you will be given the opportunity to select "
1867 "the destination calendar.</p>"
1868 "<p>If you select add, then a new calendar will be created for you automatically.</p>" );
1871 KMessageBox::questionYesNoCancel(
1874 i18nc(
"@title:window",
"Import Calendar" ),
1875 KGuiItem( i18n(
"Merge into existing calendar" ) ),
1876 KGuiItem( i18n(
"Add as new calendar" ) ) );
1879 case KMessageBox::Yes:
1882 case KMessageBox::No:
1892 if ( CalendarSupport::KCalPrefs::instance()->mAutoArchive ) {
1893 mAutoArchiveTimer->start( 4 * 60 * 60 * 1000 );
1895 mAutoArchiveTimer->stop();
1901 if ( !mCalendarView->
calendar() ) {
1905 mAutoArchiveTimer->stop();
1906 CalendarSupport::EventArchiver archiver;
1908 archiver.runAuto( calendar(), mCalendarView->
incidenceChanger(), mCalendarView,
false );
1916 return mCalendarView->topLevelWidget();
1933 const QString &description,
1934 const QStringList &attachmentUris,
1935 const QStringList &attendees,
1936 const QStringList &attachmentMimetypes,
1937 bool attachmentIsInline )
1939 Q_UNUSED( summary );
1940 Q_UNUSED( description );
1941 Q_UNUSED( attachmentUris );
1942 Q_UNUSED( attendees );
1943 Q_UNUSED( attachmentMimetypes );
1944 Q_UNUSED( attachmentIsInline );
1945 kWarning() <<
"Not implemented in korg-desktop";
1949 const QString &description,
1950 const QStringList &attachmentUris,
1951 const QStringList &attendees,
1952 const QStringList &attachmentMimetypes,
1953 bool attachmentIsInline )
1955 Q_UNUSED( summary );
1956 Q_UNUSED( description );
1957 Q_UNUSED( attachmentUris );
1958 Q_UNUSED( attendees );
1959 Q_UNUSED( attachmentMimetypes );
1960 Q_UNUSED( attachmentIsInline );
1961 kWarning() <<
"Not implemented in korg-desktop";
1964 void ActionManager::handleExportJobResult(
KJob *job )
1967 Q_ASSERT( htmlExportJob );
1969 if ( mSettingsToFree.contains( htmlExportJob->
settings() ) ) {
1970 mSettingsToFree.remove( htmlExportJob->
settings() );
1975 #include "actionmanager.moc"
bool editIncidence(Akonadi::Item::Id id)
void toggleResourceView()
void toggleDateNavigator()
bool deleteIncidence(const Akonadi::Item &item, bool force=false)
Delete the supplied incidence.
virtual bool supportsDateRangeSelection()
returns whether this view supports date range selection Base implementation returns true...
void configChanged()
When change is made to options dialog, the topwidget will catch this and emit this signal which notif...
void newEvent(const QDate &)
void importCalendar(const KUrl &url)
bool importURL(const KUrl &url, bool merge)
int defaultTodoAttachMethod() const
Get Default todo attachment method.
virtual void setTitle()=0
Set window title.
void openTodoEditor(const QString &)
bool mergeURL(const QString &url)
Open calendar file from URL.
void setOutputFile(const QString &v)
Set Output filename.
void readProperties(const KConfigGroup &)
void showDateNavigator(bool)
virtual Akonadi::IncidenceChanger * incidenceChanger() const
void readSettings()
Using the KConfig associated with the kapp variable, read in the settings from the config file...
void newSubTodo()
create new todo with a parent todo
ActionManager(KXMLGUIClient *client, CalendarView *widget, QObject *parent, KOrg::MainWindow *mainWindow, bool isPart, KMenuBar *menuBar=0)
bool addIncidence(const QString &ical)
Add an incidence to the active calendar.
KUrl getSaveURL()
Get URL for saving.
KOrg::Part::List loadParts(KOrg::MainWindow *parent)
void removeWindow(KOrg::MainWindow *)
Unregister a main window.
virtual void init(bool hasDocument)
Akonadi::EntityTreeView * view() const
bool editIncidence(const Akonadi::Item &item, bool isCounter=false)
Create an editor for the supplied incidence.
QWidget * dialogParent()
Return widget used as parent for dialogs and message boxes.
void goDate(const QDate &date)
Move the current view date to the specified date.
void writeSettings()
write current state to config file.
This class manages a list of KOrganizer instances, each associated with a window displaying a calenda...
void unloadParts(KOrg::MainWindow *parent, KOrg::Part::List &parts)
Unload the parts in &p parts for this main window.
QString outputFile() const
Get Output filename.
virtual bool hasConfigurationDialog() const
void setDateEnd(const QDateTime &v)
Set Date end.
void exportHTML()
Export the calendar to an HTML file.
void saveProperties(KConfigGroup &)
void file_icalimport()
import a non-ics calendar from another program like ical.
bool openURL(const QString &url)
Open calendar file from URL.
KHolidays::HolidayRegion * holidays() const
return the HolidayRegion object or 0 if none has been defined
bool saveCalendar(const QString &filename)
Save calendar data to file.
virtual ActionManager * actionManager()=0
Return ActionManager of this main window.
AkonadiCollectionView * collectionView() const
bool monthView() const
Get Export in month view.
void archiveCalendar()
Archive old events of calendar.
void updateConfig()
Options dialog made a changed to the configuration.
KODialogManager * dialogManager() const
This is the main calendar widget.
Akonadi::ETMCalendar::Ptr calendar() const
void updateUndoRedoActions()
void addWindow(KOrg::MainWindow *)
Register a main window.
static KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
void addHoliday(const QDate &date, const QString &name)
void showTipOnStart()
Show tip of the day.
QDateTime dateStart() const
Get Date start.
void setEMail(const QString &v)
Set Email of the calendar owner.
CalendarView * view() const
void showIncidence(const Akonadi::Item &item)
Create a read-only viewer dialog for the supplied incidence.
bool showIncidence(Akonadi::Item::Id id)
void setDateStart(const QDateTime &v)
Set Date start.
void setName(const QString &v)
Set Full name of the calendar owner.
virtual KActionCollection * getActionCollection() const =0
Return actionCollection of this main window.
void addExtension(CalendarViewExtension::Factory *)
Adds a calendar view extension widget.
void openEventEditor(const QString &)
interface for korganizer main window
void newTodo()
create new todo
void openJournalEditor(const QDate &date)
KOrg::BaseView * currentView() const
void setCreditURL(const QString &v)
Set Creator URL.
HTMLExportSettings * settings() const
KOrg::MainWindow * defaultInstance()
Return default instance.
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
void processIncidenceSelection(const Akonadi::Item &item, const QDate &date)
void showEventViewer(bool)
void configureDateTime()
Open kcontrol module for configuring date and time formats.
static KOGlobals * self()
void showDate(const QDate &date)
Show the given date without changing date selection length.
void goDate(const QDate &)
virtual QWidget * topLevelWidget()=0
Return widget whcih represents this main window.
virtual bool deleteIncidence(Akonadi::Item::Id id, bool force=false)
Delete the incidence with the given unique id from current calendar.
void showIncidenceContext(const Akonadi::Item &incidence)
Show an incidence in context.
void showMessage(const QString &message, KMessageWidget::MessageType)
void readSettings()
Using the KConfig associated with the kapp variable, read in the settings from the config file...
bool showIncidenceContext(Akonadi::Item::Id id)
Show an incidence in context.
void file_import()
import a generic ics file
bool handleCommandLine()
Called by KOrganizerUniqueAppHandler in the kontact plugin Returns true if the command line was succe...
KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
Akonadi::History * history() const
QDateTime dateEnd() const
Get Date end.
void toggleMenubar(bool dontShowWarning=false)
virtual void showStatusMessage(const QString &message)=0
Show status message in status bar.
static KOPrefs * instance()
Get instance of KOPrefs.
void showDate(const QDate &date)
bool saveURL()
Save calendar file to URL of current calendar.
void writeSettings()
Write current state to config file.
void setItems(const QStringList &, int)
void setCollectionSelectionProxyModel(KCheckableProxyModel *)
void slotAutoArchive()
called by the auto archive timer to automatically delete/archive events
KUrl url() const
Get current URL.
virtual bool supportsZoom()
returns whether this view supports zoom.
void setCreditName(const QString &v)
Set Creator application.
QString getCurrentURLasString() const
Get current URL as QString.
void showTip()
Show tip of the day.
void setShowMenuBar(bool v)
Set ShowMenuBar.
void checkClipboard()
Check if clipboard contains vCalendar event.
bool addIncidence(const QString &ical)
Add an incidence to the active calendar.
void createCalendarAkonadi()
Create Calendar object based on the akonadi framework and set it on the view.
void checkAutoExport()
called by the autoExportTimer to automatically export the calendar
This class provides the functions to export a calendar as a HTML page.
void file_archive()
delete or archive old entries in your calendar for speed/space.
void init()
Peform initialization that requires this* to be full constructed.
KOViewManager * viewManager() const
void file_open()
open new window
virtual QString shortInfo()=0
short name of the part, used as category in the keybindings dialog
void slotAutoArchivingSettingsModified()
connected to CalendarView's signal which comes from the ArchiveDialog
The factory for AkonadiCollectionView instances.