• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

korganizer

  • sources
  • kde-4.12
  • kdepim
  • korganizer
actionmanager.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
5  Copyright (c) 2002 Don Sanders <sanders@kde.org>
6  Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
7  Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
8  Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
9  Copyright (c) 2010 Laurent Montel <montel@kde.org>
10  Copyright (c) 2012 Allen Winter <winter@kde.org>
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License along
23  with this program; if not, write to the Free Software Foundation, Inc.,
24  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 
26  As a special exception, permission is given to link this program
27  with any edition of Qt, and distribute the resulting executable,
28  without including the source code for Qt in the source distribution.
29 */
30 
31 #include "actionmanager.h"
32 #include "akonadicollectionview.h"
33 #include "calendaradaptor.h"
34 #include "calendarview.h"
35 #include "htmlexportjob.h"
36 #include "htmlexportsettings.h"
37 #include "kocore.h"
38 #include "kodialogmanager.h"
39 #include "korganizeradaptor.h"
40 #include "koglobals.h"
41 #include "koprefs.h"
42 #include "koviewmanager.h"
43 #include "kowindowlist.h"
44 #include "reminderclient.h"
45 #include "kocheckableproxymodel.h"
46 
47 #include <calendarsupport/collectionselection.h>
48 #include <calendarsupport/eventarchiver.h>
49 #include <calendarsupport/kcalprefs.h>
50 #include <calendarsupport/utils.h>
51 
52 #include <incidenceeditor-ng/globalsettings.h>
53 
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>
60 
61 #include <KCalCore/FileStorage>
62 #include <KCalCore/ICalFormat>
63 #include <KCalCore/Person>
64 
65 #include <KHolidays/Holidays>
66 
67 #include <KMime/KMimeMessage>
68 
69 #include <KAction>
70 #include <KActionCollection>
71 #include <KCmdLineArgs>
72 #include <KFileDialog>
73 #include <KGlobalSettings>
74 #include <KMenu>
75 #include <KMenuBar>
76 #include <KMessageBox>
77 #include <KMimeTypeTrader>
78 #include <KProcess>
79 #include <KSelectAction>
80 #include <KSelectionProxyModel>
81 #include <KShortcutsDialog>
82 #include <KStandardAction>
83 #include <KStandardDirs>
84 #include <KSystemTimeZones>
85 #include <KTemporaryFile>
86 #include <KTipDialog>
87 #include <KToggleAction>
88 #include <KWindowSystem>
89 #include <KIO/NetAccess>
90 #include <KNS3/DownloadDialog>
91 
92 #include <QApplication>
93 #include <QTimer>
94 
95 KOWindowList *ActionManager::mWindowList = 0;
96 
97 ActionManager::ActionManager( KXMLGUIClient *client, CalendarView *widget,
98  QObject *parent, KOrg::MainWindow *mainWindow,
99  bool isPart, KMenuBar *menuBar )
100  : QObject( parent ),
101  mCollectionViewShowAction( 0 ),
102  mCollectionView( 0 ), mCollectionViewStateSaver( 0 ),
103  mCollectionSelectionModelStateSaver( 0 )
104 {
105  new KOrgCalendarAdaptor( this );
106  QDBusConnection::sessionBus().registerObject( QLatin1String("/Calendar"), this );
107 
108  mGUIClient = client;
109  mACollection = mGUIClient->actionCollection();
110  mCalendarView = widget;
111  mIsPart = isPart;
112  mTempFile = 0;
113  mHtmlExportSync = false;
114  mMainWindow = mainWindow;
115  mMenuBar = menuBar;
116 }
117 
118 ActionManager::~ActionManager()
119 {
120  // Remove Part plugins
121  KOCore::self()->unloadParts( mMainWindow, mParts );
122 
123  delete mTempFile;
124 
125  // Take this window out of the window list.
126  mWindowList->removeWindow( mMainWindow );
127 
128  delete mCollectionSelectionModelStateSaver;
129  delete mCollectionViewStateSaver;
130 
131  delete mCalendarView;
132 }
133 
134 void ActionManager::toggleMenubar( bool dontShowWarning )
135 {
136  if ( mMenuBar ) {
137  if ( mHideMenuBarAction->isChecked() ) {
138  mMenuBar->show();
139  } else {
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") );
146  }
147  mMenuBar->hide();
148  }
149  KOPrefs::instance()->setShowMenuBar( mHideMenuBarAction->isChecked() );
150  }
151 }
152 // see the Note: below for why this method is necessary
153 void ActionManager::init()
154 {
155  // add this instance of the window to the static list.
156  if ( !mWindowList ) {
157  mWindowList = new KOWindowList;
158  // Show tip of the day, when the first calendar is shown.
159  if ( !mIsPart ) {
160  QTimer::singleShot( 0, this, SLOT(showTipOnStart()) );
161  }
162  }
163 
164  // Note: We need this ActionManager to be fully constructed, and
165  // parent() to have a valid reference to it before the following
166  // addWindow is called.
167  mWindowList->addWindow( mMainWindow );
168 
169  // initialize the KAction instances
170  initActions();
171 
172  // set up autoExporting stuff
173  mAutoExportTimer = new QTimer( this );
174  connect( mAutoExportTimer, SIGNAL(timeout()), SLOT(checkAutoExport()) );
175  if ( KOPrefs::instance()->mAutoExport &&
176  KOPrefs::instance()->mAutoExportInterval > 0 ) {
177  mAutoExportTimer->start( 1000 * 60 * KOPrefs::instance()->mAutoExportInterval );
178  }
179 
180  // set up autoSaving stuff
181  mAutoArchiveTimer = new QTimer( this );
182  mAutoArchiveTimer->setSingleShot( true );
183  connect( mAutoArchiveTimer, SIGNAL(timeout()), SLOT(slotAutoArchive()) );
184 
185  // First auto-archive should be in 5 minutes (like in kmail).
186  if ( CalendarSupport::KCalPrefs::instance()->mAutoArchive ) {
187  mAutoArchiveTimer->start( 5 * 60 * 1000 ); // singleshot
188  }
189 
190  setTitle();
191 
192  connect( mCalendarView, SIGNAL(modifiedChanged(bool)), SLOT(setTitle()) );
193  connect( mCalendarView, SIGNAL(configChanged()), SLOT(updateConfig()) );
194 
195  connect( mCalendarView, SIGNAL(incidenceSelected(Akonadi::Item,QDate)),
196  this, SLOT(processIncidenceSelection(Akonadi::Item,QDate)) );
197  connect( mCalendarView, SIGNAL(exportHTML(KOrg::HTMLExportSettings*)),
198  this, SLOT(exportHTML(KOrg::HTMLExportSettings*)) );
199 
200  processIncidenceSelection( Akonadi::Item(), QDate() );
201 
202  // Update state of paste action
203  mCalendarView->checkClipboard();
204 }
205 
206 Akonadi::ETMCalendar::Ptr ActionManager::calendar() const
207 {
208  return mCalendarView->calendar();
209 }
210 
211 void ActionManager::createCalendarAkonadi()
212 {
213  Q_ASSERT( calendar() );
214 
215  KConfig *config = KOGlobals::self()->config();
216  mCollectionSelectionModelStateSaver =
217  new KViewStateMaintainer<Akonadi::ETMViewStateSaver>(
218  config->group( "GlobalCollectionSelection" ) );
219  mCollectionSelectionModelStateSaver->setSelectionModel( calendar()->checkableProxyModel()->selectionModel() );
220 
221  AkonadiCollectionViewFactory factory( mCalendarView );
222  mCalendarView->addExtension( &factory );
223  mCollectionView = factory.collectionView();
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()),
229  mCalendarView, SLOT(updateConfig()) );
230 
231  mCollectionViewStateSaver = new KViewStateMaintainer<Akonadi::ETMViewStateSaver>( config->group( "GlobalCollectionView" ) );
232  mCollectionViewStateSaver->setView( mCollectionView->view() );
233 
234  KCheckableProxyModel *checkableProxy = calendar()->checkableProxyModel();
235  QItemSelectionModel *selectionModel = checkableProxy->selectionModel();
236 
237  mCollectionView->setCollectionSelectionProxyModel( checkableProxy );
238 
239  CalendarSupport::CollectionSelection *collectionSelection = new CalendarSupport::CollectionSelection( selectionModel );
240  EventViews::EventView::setGlobalCollectionSelection( collectionSelection );
241 
242  mCalendarView->readSettings();
243 
244  connect( calendar().data(), SIGNAL(calendarChanged()),
245  mCalendarView, SLOT(resourcesChanged()) );
246  connect( mCalendarView, SIGNAL(configChanged()), SLOT(updateConfig()) );
247 
248  calendar()->setOwner( KCalCore::Person::Ptr( new KCalCore::Person( CalendarSupport::KCalPrefs::instance()->fullName(),
249  CalendarSupport::KCalPrefs::instance()->email() ) ) );
250 
251 }
252 
253 void ActionManager::initActions()
254 {
255  KAction *action;
256 
257  /*************************** FILE MENU **********************************/
258 
259  //~~~~~~~~~~~~~~~~~~~~~~~ LOADING / SAVING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260  if ( mIsPart ) {
261  if ( mMainWindow->hasDocument() ) {
262  KAction *a = mACollection->addAction( KStandardAction::Open, this, SLOT(file_open()) );
263  mACollection->addAction( QLatin1String("korganizer_open"), a );
264  }
265 
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 );
270  a->setEnabled(
271  !KMimeTypeTrader::self()->query( QLatin1String("application/pdf"), QLatin1String("KParts/ReadOnlyPart") ).isEmpty() );
272  } else {
273  KStandardAction::open( this, SLOT(file_open()), mACollection );
274  KStandardAction::print( mCalendarView, SLOT(print()), mACollection );
275  QAction *preview =
276  KStandardAction::printPreview( mCalendarView, SLOT(printPreview()), mACollection );
277  preview->setEnabled(
278  !KMimeTypeTrader::self()->query( QLatin1String("application/pdf"), QLatin1String("KParts/ReadOnlyPart")).isEmpty() );
279  }
280 
281  //~~~~~~~~~~~~~~~~~~~~~~~~ IMPORT / EXPORT ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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()) );
290 
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()) );
299 
300  action = new KAction( i18n( "Get &Hot New Stuff..." ), this );
301  mACollection->addAction( QLatin1String("downloadnewstuff"), action );
302  connect( action, SIGNAL(triggered(bool)), SLOT(downloadNewStuff()) );
303 
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()) );
307 
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()) );
311 
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()) );
315 
316  //Laurent: 2009-03-24 comment it until upload will implement
317  //action = new KAction( i18n( "Upload &Hot New Stuff..." ), this );
318  //mACollection->addAction( "uploadnewstuff", action );
319  //connect( action, SIGNAL(triggered(bool)), SLOT(uploadNewStuff()) );
320 
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()) );
324 
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()) );
328 
329  /************************** EDIT MENU *********************************/
330 
331  QAction *pasteAction;
332  Akonadi::History *history = mCalendarView->history();
333  if ( mIsPart ) {
334  // edit menu
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()) );
345  } else {
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 );
351  }
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()) );
355  if ( mIsPart ) {
356  QAction *a =
357  KStandardAction::find( mCalendarView->dialogManager(),
358  SLOT(showSearchDialog()), mACollection );
359  mACollection->addAction( QLatin1String("korganizer_find"), a );
360  } else {
361  KStandardAction::find( mCalendarView->dialogManager(),
362  SLOT(showSearchDialog()), mACollection );
363  }
364  pasteAction->setEnabled( false );
365  mUndoAction->setEnabled( false );
366  mRedoAction->setEnabled( false );
367  connect( mCalendarView, SIGNAL(pasteEnabled(bool)), pasteAction, SLOT(setEnabled(bool)) );
368  connect( history, SIGNAL(changed()), SLOT(updateUndoRedoActions()) );
369 
370  /************************** VIEW MENU *********************************/
371 
372  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VIEWS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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()) );
377 
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()) );
382 
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()) );
387 
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()) );
392 
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(),
396  SLOT(showTodoView()) );
397 
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(),
401  SLOT(showJournalView()) );
402 
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()) );
407 
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()) );
412 
413  //~~~~~~~~~~~~~~~~~~~~~~~~~~~ REFRESH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
414  action = new KAction( i18n( "&Refresh" ), this );
415  mACollection->addAction( QLatin1String("update"), action );
416  connect( action, SIGNAL(triggered(bool)), mCalendarView, SLOT(updateView()) );
417 
418  //~~~~~~~~~~~~~~~~~~~~~~~~~~~ FILTER ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
419 
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()),
429  this, SLOT(setTitle()) );
430 
431  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ZOOM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
432  // TODO: try to find / create better icons for the following 4 actions
433  action = new KAction( KIcon( QLatin1String("zoom-in") ), i18n( "In Horizontally" ), this );
434  action->setEnabled( mCalendarView->currentView()->supportsZoom() );
435  mACollection->addAction( QLatin1String("zoom_in_horizontally"), action );
436  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
437  SLOT(zoomInHorizontally()) );
438 
439  action = new KAction( KIcon( QLatin1String("zoom-out") ), i18n( "Out Horizontally" ), this );
440  action->setEnabled( mCalendarView->currentView()->supportsZoom() );
441  mACollection->addAction( QLatin1String("zoom_out_horizontally"), action );
442  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
443  SLOT(zoomOutHorizontally()) );
444 
445  action = new KAction( KIcon( QLatin1String("zoom-in") ), i18n( "In Vertically" ), this );
446  action->setEnabled( mCalendarView->currentView()->supportsZoom() );
447  mACollection->addAction( QLatin1String("zoom_in_vertically"), action );
448  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
449  SLOT(zoomInVertically()) );
450 
451  action = new KAction( KIcon( QLatin1String("zoom-out") ), i18n( "Out Vertically" ), this );
452  action->setEnabled( mCalendarView->currentView()->supportsZoom() );
453  mACollection->addAction( QLatin1String("zoom_out_vertically"), action );
454  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
455  SLOT(zoomOutVertically()) );
456 
457  /************************** Actions MENU *********************************/
458  bool isRTL = QApplication::isRightToLeft();
459 
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()) );
466 
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()) );
473 
474  // Changing the action text by setText makes the toolbar button disappear.
475  // This has to be fixed first, before the connects below can be reenabled.
476  /*
477  connect( mCalendarView, SIGNAL(changeNavStringPrev(QString)),
478  action, SLOT(setText(QString)) );
479  connect( mCalendarView, SIGNAL(changeNavStringPrev(QString)),
480  this, SLOT(dumpText(QString)) );*/
481 
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()) );
488  /*
489  connect( mCalendarView,SIGNAL(changeNavStringNext(QString)),
490  action,SLOT(setText(QString)) );
491  */
492 
493  action = new KAction( KIcon( QLatin1String("view-calendar-day") ), i18n( "&Day" ), this );
494  mACollection->addAction( QLatin1String("select_day"), action );
495  action->setEnabled( mCalendarView->currentView()->supportsDateRangeSelection() );
496  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
497  SLOT(selectDay()) );
498 
499  mNextXDays = new KAction( KIcon( QLatin1String("view-calendar-upcoming-days") ), QString(), this );
500  mNextXDays->setEnabled( mCalendarView->currentView()->supportsDateRangeSelection() );
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 ) );
505 
506  action = new KAction( KIcon( QLatin1String("view-calendar-workweek") ), i18n( "W&ork Week" ), this );
507  action->setEnabled( mCalendarView->currentView()->supportsDateRangeSelection() );
508  mACollection->addAction( QLatin1String("select_workweek"), action );
509  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
510  SLOT(selectWorkWeek()) );
511 
512  action = new KAction( KIcon( QLatin1String("view-calendar-week") ), i18n( "&Week" ), this );
513  action->setEnabled( mCalendarView->currentView()->supportsDateRangeSelection() );
514  mACollection->addAction( QLatin1String("select_week"), action );
515  connect( action, SIGNAL(triggered(bool)), mCalendarView->viewManager(),
516  SLOT(selectWeek()) );
517 
518  /************************** Actions MENU *********************************/
519  mNewEventAction = new KAction( KIcon( QLatin1String("appointment-new") ), i18n( "New E&vent..." ), this );
520  //mNewEventAction->setIconText( i18nc( "@action:intoolbar create a new event", "Event" ) );
521  mNewEventAction->setHelpText( i18n( "Create a new Event" ) );
522 
523  mACollection->addAction( QLatin1String("new_event"), mNewEventAction );
524  connect( mNewEventAction, SIGNAL(triggered(bool)), this,
525  SLOT(slotNewEvent()) );
526 
527  mNewTodoAction = new KAction( KIcon( QLatin1String("task-new") ), i18n( "New &To-do..." ), this );
528  //mNewTodoAction->setIconText( i18n( "To-do" ) );
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()) );
533 
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)) );
541 
542  mNewJournalAction = new KAction( KIcon( QLatin1String("journal-new") ), i18n( "New &Journal..." ), this );
543  //mNewJournalAction->setIconText( i18n( "Journal" ) );
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()) );
548 
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() &&
553  mCalendarView->currentView()->hasConfigurationDialog() );
554  mACollection->addAction( QLatin1String("configure_view"), mConfigureViewAction );
555  connect( mConfigureViewAction, SIGNAL(triggered(bool)), mCalendarView,
556  SLOT(configureCurrentView()) );
557 
558  mShowIncidenceAction = new KAction( i18n( "&Show" ), this );
559  mACollection->addAction( QLatin1String("show_incidence"), mShowIncidenceAction );
560  connect( mShowIncidenceAction, SIGNAL(triggered(bool)), mCalendarView,
561  SLOT(showIncidence()) );
562 
563  mEditIncidenceAction = new KAction( i18n( "&Edit..." ), this );
564  mACollection->addAction( QLatin1String("edit_incidence"), mEditIncidenceAction );
565  connect( mEditIncidenceAction, SIGNAL(triggered(bool)), mCalendarView,
566  SLOT(editIncidence()) );
567 
568  mDeleteIncidenceAction = new KAction( i18n( "&Delete" ), this );
569  mACollection->addAction( QLatin1String("delete_incidence"), mDeleteIncidenceAction );
570  connect( mDeleteIncidenceAction, SIGNAL(triggered(bool)), mCalendarView,
571  SLOT(deleteIncidence()) );
572  mDeleteIncidenceAction->setShortcut( QKeySequence( Qt::Key_Delete ) );
573 
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)) );
581 
582 // TODO: Add item to quickly toggle the reminder of a given incidence
583 // mToggleAlarmAction = new KToggleAction( i18n( "&Activate Reminder" ), 0,
584 // mCalendarView, SLOT(toggleAlarm()),
585 // mACollection, "activate_alarm" );
586 
587  /************************** SCHEDULE MENU ********************************/
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 );
592 
593  mSendInvitation =
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)) );
600 
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)) );
607 
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)) );
614 
615  mSendStatusUpdate =
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)) );
622 
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)) );
629 
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 );
634 
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 );
639 
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 );
644 
645  if ( !mIsPart ) {
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()) );
649  }
650 
651  /************************** SETTINGS MENU ********************************/
652 
653  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SIDEBAR ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
654  mDateNavigatorShowAction = new KToggleAction( i18n( "Show Date Navigator" ), this );
655  mACollection->addAction( QLatin1String("show_datenavigator"), mDateNavigatorShowAction );
656  connect( mDateNavigatorShowAction, SIGNAL(triggered(bool)), SLOT(toggleDateNavigator()) );
657 
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()) );
661 
662  mEventViewerShowAction = new KToggleAction( i18n( "Show Item Viewer" ), this );
663  mACollection->addAction( QLatin1String("show_eventviewer"), mEventViewerShowAction );
664  connect( mEventViewerShowAction, SIGNAL(triggered(bool)), SLOT(toggleEventViewer()) );
665  KConfigGroup config( KOGlobals::self()->config(), "Settings" );
666  mDateNavigatorShowAction->setChecked( config.readEntry( "DateNavigatorVisible", true ) );
667  // if we are a kpart, then let's not show the todo in the left pane by
668  // default since there's also a Todo part and we'll assume they'll be
669  // using that as well, so let's not duplicate it (by default) here
670  mTodoViewShowAction->setChecked(
671  config.readEntry( "TodoViewVisible", false ) ); //mIsPart ? false : true ) );
672  mEventViewerShowAction->setChecked( config.readEntry( "EventViewerVisible", true ) );
673  toggleDateNavigator();
674  toggleTodoView();
675  toggleEventViewer();
676 
677  if ( !mMainWindow->hasDocument() ) {
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 ) );
682 
683  toggleResourceView();
684  }
685 
686  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SIDEBAR ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
687  mHideMenuBarAction = KStandardAction::showMenubar( this, SLOT(toggleMenubar()), mACollection );
688  mHideMenuBarAction->setChecked( KOPrefs::instance()->showMenuBar() );
689  toggleMenubar( true );
690 
691  action = new KAction( i18n( "Configure &Date && Time..." ), this );
692  mACollection->addAction( QLatin1String("conf_datetime"), action );
693  connect( action, SIGNAL(triggered(bool)),
694  SLOT(configureDateTime()) );
695 // TODO: Add an item to show the resource management dlg
696 // new KAction( i18n( "Manage &Calendars..." ), 0,
697 // this, SLOT(manageResources()),
698 // mACollection, "conf_resources" );
699 
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()) );
704 
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()) );
709 
710  if ( mIsPart ) {
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"),
716  this, SLOT(keyBindings()) );
717  } else {
718  KStandardAction::preferences( mCalendarView, SLOT(edit_options()), mACollection );
719  KStandardAction::keyBindings( this, SLOT(keyBindings()), mACollection );
720  }
721 
722  /**************************** HELP MENU **********************************/
723  QAction *a = mACollection->addAction( KStandardAction::TipofDay, this,
724  SLOT(showTip()) );
725  mACollection->addAction( QLatin1String("help_tipofday"), a );
726 }
727 
728 void ActionManager::setItems( const QStringList &lst, int idx )
729 {
730  mFilterAction->setItems( lst );
731  mFilterAction->setCurrentItem( idx );
732 }
733 
734 void ActionManager::slotResourcesAddedRemoved()
735 {
736  restoreCollectionViewSetting();
737 }
738 
739 void ActionManager::slotDefaultResourceChanged( const Akonadi::Collection &collection )
740 {
741  mCalendarView->incidenceChanger()->setDefaultCollection( collection );
742 }
743 
744 void ActionManager::slotNewEvent()
745 {
746  mCalendarView->newEvent();
747 }
748 
749 void ActionManager::slotNewTodo()
750 {
751  mCalendarView->newTodo( selectedCollection() );
752 }
753 
754 void ActionManager::slotNewSubTodo()
755 {
756  mCalendarView->newSubTodo( selectedCollection() );
757 }
758 
759 void ActionManager::slotNewJournal()
760 {
761  mCalendarView->newJournal( selectedCollection() );
762 }
763 
764 void ActionManager::slotMergeFinished(bool success, int total)
765 {
766  Q_ASSERT(sender());
767  sender()->deleteLater();
768  mImportAction->setEnabled(true);
769  Akonadi::ICalImporter *importer = qobject_cast<Akonadi::ICalImporter*>(sender());
770 
771  if (success) {
772  mCalendarView->showMessage(i18np("1 incidence was imported successfully.", "%1 incidences were imported successfully.", total), KMessageWidget::Information);
773  } else {
774  mCalendarView->showMessage(i18n("There was an error while merging the calendar: %1", importer->errorMessage()), KMessageWidget::Error);
775  }
776 }
777 
778 void ActionManager::slotNewResourceFinished(bool success)
779 {
780  Q_ASSERT(sender());
781  sender()->deleteLater();
782  Akonadi::ICalImporter *importer = qobject_cast<Akonadi::ICalImporter*>(sender());
783  mImportAction->setEnabled(true);
784  if (success) {
785  mCalendarView->showMessage(i18n("New calendar added successfully"), KMessageWidget::Information);
786  } else {
787  mCalendarView->showMessage(i18n("Could not add a calendar. Error: %1", importer->errorMessage()), KMessageWidget::Error);
788  }
789 }
790 
791 void ActionManager::readSettings()
792 {
793  // read settings from the KConfig, supplying reasonable
794  // defaults where none are to be found
795 
796  mCalendarView->readSettings();
797  restoreCollectionViewSetting();
798 }
799 
800 void ActionManager::restoreCollectionViewSetting()
801 {
802  mCollectionSelectionModelStateSaver->restoreState();
803  mCollectionViewStateSaver->restoreState();
804 }
805 
806 void ActionManager::writeSettings()
807 {
808  KConfigGroup config = KOGlobals::self()->config()->group( "Settings" );
809  mCalendarView->writeSettings();
810 
811  if ( mDateNavigatorShowAction ) {
812  config.writeEntry( "DateNavigatorVisible", mDateNavigatorShowAction->isChecked() );
813  }
814 
815  if ( mTodoViewShowAction ) {
816  config.writeEntry( "TodoViewVisible", mTodoViewShowAction->isChecked() );
817  }
818 
819  if ( mCollectionViewShowAction ) {
820  config.writeEntry( "ResourceViewVisible", mCollectionViewShowAction->isChecked() );
821  }
822 
823  if ( mEventViewerShowAction ) {
824  config.writeEntry( "EventViewerVisible", mEventViewerShowAction->isChecked() );
825  }
826 
827  mCollectionViewStateSaver->saveState();
828  mCollectionSelectionModelStateSaver->saveState();
829 
830  KConfigGroup selectionViewGroup = KOGlobals::self()->config()->group( "GlobalCollectionView" );
831  KConfigGroup selectionGroup = KOGlobals::self()->config()->group( "GlobalCollectionSelection" );
832  selectionGroup.sync();
833  selectionViewGroup.sync();
834  config.sync();
835 }
836 
837 /*
838 void ActionManager::file_new()
839 {
840  emit actionNewMainWindow();
841 }
842 */
843 
844 void ActionManager::file_open()
845 {
846  const QString defaultPath = KStandardDirs::locateLocal( "data",QLatin1String("korganizer/") );
847  const KUrl url = KFileDialog::getOpenUrl( defaultPath, QLatin1String("text/calendar"), dialogParent() );
848 
849  file_open( url );
850 }
851 
852 void ActionManager::file_open( const KUrl &url )
853 {
854  if ( url.isEmpty() ) {
855  return;
856  }
857 
858  // is that URL already opened somewhere else? Activate that window
859  KOrg::MainWindow *korg = ActionManager::findInstance( url );
860  if ( ( 0 != korg )&&( korg != mMainWindow ) ) {
861 #ifdef Q_WS_X11
862  KWindowSystem::activateWindow( korg->topLevelWidget()->winId() );
863 #endif
864  return;
865  }
866 
867  kDebug() << url.prettyUrl();
868 
869  importCalendar( url );
870 }
871 
872 void ActionManager::file_icalimport()
873 {
874  // FIXME: eventually, we will need a dialog box to select import type, etc.
875  // for now, hard-coded to ical file, $HOME/.calendar.
876  int retVal = -1;
877  QString progPath;
878  KTemporaryFile tmpfn;
879  tmpfn.open();
880 
881  QString homeDir = QDir::homePath() + QLatin1String( "/.calendar" );
882 
883  if ( !QFile::exists( homeDir ) ) {
884  KMessageBox::error( dialogParent(),
885  i18n( "You have no ical file in your home directory.\n"
886  "Import cannot proceed.\n" ) );
887  return;
888  }
889 
890  KProcess proc;
891  proc << QLatin1String("ical2vcal") << tmpfn.fileName();
892  retVal = proc.execute();
893 
894  if ( retVal < 0 ) {
895  kDebug() << "Error executing ical2vcal.";
896  return;
897  }
898 
899  kDebug() << "ical2vcal return value:" << retVal;
900 
901  if ( retVal >= 0 && retVal <= 2 ) {
902  // now we need to MERGE what is in the iCal to the current calendar.
903  const bool success = importURL(KUrl(tmpfn.fileName()), /*merge=*/ true);
904  if ( !success ) {
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);
909 
910  } else {
911  // else nothing, the operation is async and the use will se a message widget when the operation finishes, not now.
912  }
913  } else if ( retVal == -1 ) { // XXX this is bogus
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 ) { // XXX this is bogus
917  mCalendarView->showMessage( i18n( "KOrganizer does not think that your .calendar "
918  "file is a valid ical calendar; import has failed." ), KMessageWidget::Error );
919  }
920 }
921 
922 void ActionManager::file_import()
923 {
924  const KUrl url = KFileDialog::getOpenUrl( KStandardDirs::locateLocal( "data",QLatin1String("korganizer/") ),
925  QLatin1String("text/calendar"),
926  dialogParent() );
927  if ( !url.isEmpty() ) { // isEmpty if user canceled the dialog
928  importCalendar( url );
929  }
930 }
931 
932 void ActionManager::file_archive()
933 {
934  mCalendarView->archiveCalendar();
935 }
936 
937 bool ActionManager::importURL(const KUrl &url, bool merge)
938 {
939  Akonadi::ICalImporter *importer = new Akonadi::ICalImporter();
940  bool jobStarted;
941  if (merge) {
942  connect(importer, SIGNAL(importIntoExistingFinished(bool,int)), SLOT(slotMergeFinished(bool,int))),
943  jobStarted = importer->importIntoExistingResource(url, Akonadi::Collection());
944  } else {
945  connect(importer, SIGNAL(importIntoNewFinished(bool)), SLOT(slotNewResourceFinished(bool)));
946  jobStarted = importer->importIntoNewResource(url.path());
947  }
948 
949  if (jobStarted) {
950  mImportAction->setEnabled(false);
951  } else {
952  // empty error message means user canceled.
953  if (!importer->errorMessage().isEmpty())
954  mCalendarView->showMessage(i18n("An error occurred: %1", importer->errorMessage()), KMessageWidget::Error);
955  }
956 
957  return jobStarted;
958 }
959 
960 bool ActionManager::saveURL()
961 {
962  QString ext;
963 
964  if ( mURL.isLocalFile() ) {
965  ext = mFile.right( 4 );
966  } else {
967  ext = mURL.fileName().right( 4 );
968  }
969 
970  if ( ext == QLatin1String( ".vcs" ) ) {
971  int result = KMessageBox::warningContinueCancel(
972  dialogParent(),
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 ) {
979  return false;
980  }
981 
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();
987  }
988  setTitle();
989  }
990 
991  if ( !mCalendarView->saveCalendar( mFile ) ) {
992  kDebug() << "calendar view save failed.";
993  return false;
994  }
995 
996  if ( !mURL.isLocalFile() ) {
997  if ( !KIO::NetAccess::upload( mFile, mURL, view() ) ) {
998  QString msg = i18n( "Cannot upload calendar to '%1'",
999  mURL.prettyUrl() );
1000  KMessageBox::error( dialogParent(), msg );
1001  return false;
1002  }
1003  }
1004 
1005  mMainWindow->showStatusMessage( i18n( "Saved calendar '%1'.", mURL.prettyUrl() ) );
1006 
1007  return true;
1008 }
1009 
1010 void ActionManager::exportHTML()
1011 {
1012  HTMLExportSettings *settings = new HTMLExportSettings( QLatin1String("KOrganizer") );
1013  mSettingsToFree.insert( settings );
1014  // Manually read in the config, because parametrized kconfigxt objects don't
1015  // seem to load the config theirselves
1016  settings->readConfig();
1017 
1018  const QDate qd1 = QDate::currentDate();
1019  QDate qd2 = qd1;
1020 
1021  if ( settings->monthView() ) {
1022  qd2 = qd2.addMonths( 1 );
1023  } else {
1024  qd2 = qd2.addDays( 7 );
1025  }
1026  settings->setDateStart( QDateTime( qd1 ) );
1027  settings->setDateEnd( QDateTime( qd2 ) );
1028 
1029  exportHTML( settings, true/*autoMode*/ );
1030 }
1031 
1032 void ActionManager::exportHTML( KOrg::HTMLExportSettings *settings, bool autoMode )
1033 {
1034  if ( !settings ) {
1035  kWarning() << "Settings is null" << settings;
1036  return;
1037  }
1038 
1039  if ( settings->outputFile().isEmpty() ) {
1040  int result = KMessageBox::questionYesNo(
1041  dialogParent(),
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" ),
1045  QString() );
1046  if ( result == KMessageBox::No ) {
1047  mMainWindow->showStatusMessage(
1048  i18nc( "@info:status",
1049  "Calendar HTML operation canceled due to unspecified output file name" ) );
1050  return;
1051  }
1052 
1053  const QString fileName =
1054  KFileDialog::getSaveFileName(
1055  KGlobalSettings::documentPath(),
1056  i18n( "*.html|HTML Files" ),
1057  dialogParent(),
1058  i18n( "Select path for HTML calendar export" ) );
1059  settings->setOutputFile( fileName );
1060  settings->writeConfig();
1061  }
1062 
1063  if ( !autoMode && QFileInfo( settings->outputFile() ).exists() ) {
1064  if ( KMessageBox::warningContinueCancel(
1065  dialogParent(),
1066  i18n( "Do you want to overwrite file \"%1\"?",
1067  settings->outputFile() ),
1068  QString(),
1069  KStandardGuiItem::overwrite() ) == KMessageBox::Cancel ) {
1070  mMainWindow->showStatusMessage(
1071  i18nc( "@info:status",
1072  "Calendar HTML operation canceled due to output file overwrite" ) );
1073  return;
1074  }
1075  }
1076 
1077  settings->setEMail( CalendarSupport::KCalPrefs::instance()->email() );
1078  settings->setName( CalendarSupport::KCalPrefs::instance()->fullName() );
1079 
1080  settings->setCreditName( QLatin1String("KOrganizer") );
1081  settings->setCreditURL( QLatin1String("http://korganizer.kde.org") );
1082 
1083  KOrg::HtmlExportJob *exportJob = new KOrg::HtmlExportJob( calendar(), settings, autoMode, mMainWindow, view() );
1084 
1085  if ( KOGlobals::self()->holidays() ) {
1086  KHolidays::Holiday::List holidays = KOGlobals::self()->holidays()->holidays(
1087  settings->dateStart().date(), settings->dateEnd().date() );
1088  foreach ( const KHolidays::Holiday &holiday, holidays ) {
1089  exportJob->addHoliday( holiday.date(), holiday.text() );
1090  }
1091  }
1092 
1093  connect( exportJob, SIGNAL(result(KJob*)), SLOT(handleExportJobResult(KJob*)) );
1094  exportJob->start();
1095 }
1096 
1097 bool ActionManager::saveAsURL( const KUrl &url )
1098 {
1099  kDebug() << url.prettyUrl();
1100 
1101  if ( url.isEmpty() ) {
1102  kDebug() << "Empty URL.";
1103  return false;
1104  }
1105  if ( !url.isValid() ) {
1106  kDebug() << "Malformed URL.";
1107  return false;
1108  }
1109 
1110  QString fileOrig = mFile;
1111  KUrl URLOrig = mURL;
1112 
1113  KTemporaryFile *tempFile = 0;
1114  if ( url.isLocalFile() ) {
1115  mFile = url.toLocalFile();
1116  } else {
1117  tempFile = new KTemporaryFile;
1118  tempFile->setAutoRemove(false);
1119  tempFile->open();
1120  mFile = tempFile->fileName();
1121  }
1122  mURL = url;
1123 
1124  bool success = saveURL(); // Save local file and upload local file
1125  if ( success ) {
1126  delete mTempFile;
1127  mTempFile = tempFile;
1128  KIO::NetAccess::removeTempFile( fileOrig );
1129  setTitle();
1130  } else {
1131  KMessageBox::sorry( dialogParent(),
1132  i18n( "Unable to save calendar to the file %1.", mFile ),
1133  i18n( "Error" ) );
1134  kDebug() << "failed";
1135  mURL = URLOrig;
1136  mFile = fileOrig;
1137  delete tempFile;
1138  }
1139 
1140  return success;
1141 }
1142 
1143 #ifdef AKONADI_PORT_DISABLED // can go away, kept for reference
1144 bool ActionManager::saveModifiedURL()
1145 {
1146  kDebug();
1147 
1148  // If calendar isn't modified do nothing.
1149  if ( !mCalendarView->isModified() ) {
1150  return true;
1151  }
1152 
1153  mHtmlExportSync = true;
1154  if ( KOPrefs::instance()->mAutoSave && !mURL.isEmpty() ) {
1155  // Save automatically, when auto save is enabled.
1156  return saveURL();
1157  } else {
1158  int result = KMessageBox::warningYesNoCancel(
1159  dialogParent(),
1160  i18n( "The calendar has been modified.\nDo you want to save it?" ),
1161  QString(),
1162  KStandardGuiItem::save(), KStandardGuiItem::discard() );
1163  switch( result ) {
1164  case KMessageBox::Yes:
1165  if ( mURL.isEmpty() ) {
1166  KUrl url = getSaveURL();
1167  return saveAsURL( url );
1168  } else {
1169  return saveURL();
1170  }
1171  case KMessageBox::No:
1172  return true;
1173  case KMessageBox::Cancel:
1174  default:
1175  {
1176  mHtmlExportSync = false;
1177  return false;
1178  }
1179  }
1180  }
1181 }
1182 #endif
1183 
1184 KUrl ActionManager::getSaveURL()
1185 {
1186  KUrl url =
1187  KFileDialog::getSaveUrl( KStandardDirs::locateLocal( "data",QLatin1String("korganizer/") ),
1188  i18n( "*.ics *.vcs|Calendar Files" ),
1189  dialogParent() );
1190 
1191  if ( url == KUrl() ) {
1192  return url;
1193  }
1194 
1195  QString filename = url.fileName();
1196 
1197  QString e = filename.right( 4 );
1198  if ( e != QLatin1String( ".vcs" ) && e != QLatin1String( ".ics" ) ) {
1199  // Default save format is iCalendar
1200  filename += QLatin1String(".ics");
1201  }
1202 
1203  url.setFileName( filename );
1204 
1205  kDebug() << "url:" << url.url();
1206 
1207  return url;
1208 }
1209 
1210 void ActionManager::saveProperties( KConfigGroup &config )
1211 {
1212  kDebug();
1213 
1214  config.writeEntry( "UseResourceCalendar", !mMainWindow->hasDocument() );
1215  if ( mMainWindow->hasDocument() ) {
1216  config.writePathEntry( "Calendar", mURL.url() );
1217  }
1218 }
1219 
1220 void ActionManager::readProperties( const KConfigGroup & )
1221 {
1222  mMainWindow->init( false );
1223 }
1224 
1225 // Configuration changed as a result of the options dialog.
1226 void ActionManager::updateConfig()
1227 {
1228  kDebug();
1229  mNextXDays->setText( i18np( "&Next Day", "&Next %1 Days",
1230  KOPrefs::instance()->mNextXDays ) );
1231 
1232  KOCore::self()->reloadPlugins();
1233 
1234  /* Hide/Show the Reminder Daemon */
1235  if ( !KOPrefs::instance()->mShowReminderDaemon ) {
1236  KPIM::ReminderClient::hideDaemon();
1237  } else {
1238  KPIM::ReminderClient::showDaemon();
1239  }
1240 
1241 // Commented out because it crashes KOrganizer.
1242 // mParts = KOCore::self()->reloadParts( mMainWindow, mParts );
1243 #ifdef AKONADI_PORT_DISABLED // shouldn't be required anymore
1244  if ( mCollectionView ) {
1245  mCollectionView->updateView();
1246  }
1247 #endif
1248 }
1249 
1250 void ActionManager::configureDateTime()
1251 {
1252  KProcess proc;
1253  proc << QLatin1String("kcmshell4") << QLatin1String("language");
1254 
1255  if ( !proc.startDetached() ) {
1256  KMessageBox::sorry( dialogParent(),
1257  i18n( "Could not start control module for date and time format." ) );
1258  }
1259 }
1260 
1261 void ActionManager::showTip()
1262 {
1263  KTipDialog::showTip( dialogParent(), QString(), true );
1264 }
1265 
1266 void ActionManager::showTipOnStart()
1267 {
1268  KConfigGroup config( KGlobal::config(), "TipOfDay" );
1269  KTipDialog::setShowOnStart( config.readEntry( "RunOnStart", false ) );
1270  KTipDialog::showTip( dialogParent() );
1271 }
1272 
1273 KOrg::MainWindow *ActionManager::findInstance( const KUrl &url )
1274 {
1275  if ( mWindowList ) {
1276  if ( url.isEmpty() ) {
1277  return mWindowList->defaultInstance();
1278  } else {
1279  return mWindowList->findInstance( url );
1280  }
1281  } else {
1282  return 0;
1283  }
1284 }
1285 
1286 bool ActionManager::openURL(const QString &url)
1287 {
1288  importCalendar(KUrl(url));
1289  return true;
1290 }
1291 
1292 void ActionManager::dumpText( const QString &str )
1293 {
1294  kDebug() << str;
1295 }
1296 
1297 void ActionManager::toggleDateNavigator()
1298 {
1299  bool visible = mDateNavigatorShowAction->isChecked();
1300  if ( mCalendarView ) {
1301  mCalendarView->showDateNavigator( visible );
1302  }
1303 }
1304 
1305 void ActionManager::toggleTodoView()
1306 {
1307  bool visible = mTodoViewShowAction->isChecked();
1308  if ( mCalendarView ) {
1309  mCalendarView->showTodoView( visible );
1310  }
1311 }
1312 
1313 void ActionManager::toggleEventViewer()
1314 {
1315  bool visible = mEventViewerShowAction->isChecked();
1316  if ( mCalendarView ) {
1317  mCalendarView->showEventViewer( visible );
1318  }
1319 }
1320 
1321 void ActionManager::toggleResourceView()
1322 {
1323  const bool visible = mCollectionViewShowAction->isChecked();
1324  if ( mCollectionView ) {
1325  if ( visible ) {
1326  mCollectionView->show();
1327  } else {
1328  mCollectionView->hide();
1329  }
1330  }
1331 }
1332 
1333 bool ActionManager::mergeURL( const QString &url )
1334 {
1335  return importURL( KUrl( url ), true );
1336 }
1337 
1338 bool ActionManager::saveAsURL( const QString &url )
1339 {
1340  return saveAsURL( KUrl( url ) );
1341 }
1342 
1343 QString ActionManager::getCurrentURLasString() const
1344 {
1345  return mURL.url();
1346 }
1347 
1348 bool ActionManager::editIncidence( Akonadi::Item::Id id )
1349 {
1350  return mCalendarView->editIncidence( id );
1351 }
1352 
1353 bool ActionManager::showIncidence( Akonadi::Item::Id id )
1354 {
1355  return mCalendarView->showIncidence( id );
1356 }
1357 
1358 bool ActionManager::showIncidenceContext( Akonadi::Item::Id id )
1359 {
1360  return mCalendarView->showIncidenceContext( id );
1361 }
1362 
1363 bool ActionManager::handleCommandLine()
1364 {
1365  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
1366  KOrg::MainWindow *mainWindow = ActionManager::findInstance( KUrl() );
1367 
1368  bool ret = true;
1369 
1370  if ( !mainWindow ) {
1371  kError() << "Unable to find default calendar resources view.";
1372  ret = false;
1373  } else if ( args->count() <= 0 ) {
1374  // No filenames given => all other args are meaningless, show main Window
1375  mainWindow->topLevelWidget()->show();
1376  } else {
1377  // Import, merge, or ask => we need the resource calendar window anyway.
1378  mainWindow->topLevelWidget()->show();
1379 
1380  // Check for import, merge or ask
1381  if ( args->isSet( "import" ) ) {
1382  for ( int i = 0; i < args->count(); ++i ) {
1383  importURL( args->url( i ), /*merge=*/false );
1384  }
1385  } else if ( args->isSet( "merge" ) ) {
1386  for ( int i = 0; i < args->count(); ++i ) {
1387  importURL( args->url( i ), /*merge=*/true );
1388  }
1389  } else {
1390  for ( int i = 0; i < args->count(); ++i ) {
1391  mainWindow->actionManager()->importCalendar( args->url( i ) );
1392  }
1393  }
1394  }
1395  return ret;
1396 }
1397 
1398 bool ActionManager::deleteIncidence( Akonadi::Item::Id id, bool force )
1399 {
1400  return mCalendarView->deleteIncidence( id, force );
1401 }
1402 
1403 bool ActionManager::addIncidence( const QString &ical )
1404 {
1405  return mCalendarView->addIncidence( ical );
1406 }
1407 
1408 void ActionManager::downloadNewStuff()
1409 {
1410  kDebug();
1411  KNS3::DownloadDialog dialog(mCalendarView);
1412  dialog.exec();
1413  foreach ( const KNS3::Entry &e, dialog.installedEntries() ) {
1414  kDebug() << " downloadNewStuff :";
1415  const QStringList lstFile = e.installedFiles();
1416  if ( lstFile.count() != 1 ) {
1417  continue;
1418  }
1419  const QString file = lstFile.at( 0 );
1420  const KUrl filename( file );
1421  kDebug() << "filename :" << filename;
1422  if( ! filename.isValid() ) {
1423  continue;
1424  }
1425 
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 ) );
1431  } else {
1432  QStringList eventSummaries;
1433  KCalCore::Event::List events = calendar()->events();
1434  foreach ( KCalCore::Event::Ptr event, events ) {
1435  eventSummaries.append( event->summary() );
1436  }
1437 
1438  const int result = KMessageBox::warningContinueCancelList( mCalendarView,
1439  i18n( "The downloaded events will be merged into your current calendar." ),
1440  eventSummaries );
1441 
1442  if ( result != KMessageBox::Continue ) {
1443  // FIXME (KNS2): hm, no way out here :-)
1444  }
1445 
1446  if ( importURL( KUrl(file), true ) ) {
1447  // FIXME (KNS2): here neither
1448  }
1449  }
1450  }
1451 }
1452 
1453 QString ActionManager::localFileName()
1454 {
1455  return mFile;
1456 }
1457 
1458 class ActionManager::ActionStringsVisitor : public KCalCore::Visitor
1459 {
1460  public:
1461  ActionStringsVisitor() : mShow( 0 ), mEdit( 0 ), mDelete( 0 ) {}
1462 
1463  bool act( KCalCore::IncidenceBase::Ptr incidence, QAction *show, QAction *edit, QAction *del )
1464  {
1465  mShow = show;
1466  mEdit = edit;
1467  mDelete = del;
1468  return incidence->accept( *this, incidence );
1469  }
1470 
1471  protected:
1472  bool visit( KCalCore::Event::Ptr )
1473  {
1474  if ( mShow ) {
1475  mShow->setText( i18n( "&Show Event" ) );
1476  }
1477  if ( mEdit ) {
1478  mEdit->setText( i18n( "&Edit Event..." ) );
1479  }
1480  if ( mDelete ) {
1481  mDelete->setText( i18n( "&Delete Event" ) );
1482  }
1483  return true;
1484  }
1485 
1486  bool visit( KCalCore::Todo::Ptr )
1487  {
1488  if ( mShow ) {
1489  mShow->setText( i18n( "&Show To-do" ) );
1490  }
1491  if ( mEdit ) {
1492  mEdit->setText( i18n( "&Edit To-do..." ) );
1493  }
1494  if ( mDelete ) {
1495  mDelete->setText( i18n( "&Delete To-do" ) );
1496  }
1497  return true;
1498  }
1499 
1500  bool visit( KCalCore::Journal::Ptr )
1501  {
1502  return assignDefaultStrings();
1503  }
1504 
1505  bool visit( KCalCore::FreeBusy::Ptr ) // to inhibit hidden virtual compile warning
1506  {
1507  return false;
1508  }
1509 
1510  protected:
1511  bool assignDefaultStrings()
1512  {
1513  if ( mShow ) {
1514  mShow->setText( i18n( "&Show" ) );
1515  }
1516  if ( mEdit ) {
1517  mEdit->setText( i18n( "&Edit..." ) );
1518  }
1519  if ( mDelete ) {
1520  mDelete->setText( i18n( "&Delete" ) );
1521  }
1522  return true;
1523  }
1524  QAction *mShow;
1525  QAction *mEdit;
1526  QAction *mDelete;
1527 };
1528 
1529 void ActionManager::processIncidenceSelection( const Akonadi::Item &item, const QDate &date )
1530 {
1531  //kDebug(5850) << "ActionManager::processIncidenceSelection()";
1532  Q_UNUSED( date );
1533 
1534  const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
1535  if ( !incidence ) {
1536  enableIncidenceActions( false );
1537  return;
1538  }
1539 
1540  enableIncidenceActions( true );
1541 
1542  if ( !mCalendarView->calendar()->hasRight( item, Akonadi::Collection::CanDeleteItem ) ) {
1543  mCutAction->setEnabled( false );
1544  mDeleteAction->setEnabled( false );
1545  }
1546 
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" ) );
1552  }
1553 }
1554 
1555 void ActionManager::enableIncidenceActions( bool enabled )
1556 {
1557  mShowIncidenceAction->setEnabled( enabled );
1558  mEditIncidenceAction->setEnabled( enabled );
1559  mDeleteIncidenceAction->setEnabled( enabled );
1560 
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 );
1571 }
1572 
1573 Akonadi::Collection ActionManager::selectedCollection() const
1574 {
1575  const QModelIndex index = mCollectionView->view()->currentIndex();
1576  if ( !index.isValid() ) {
1577  return Akonadi::Collection();
1578  }
1579 
1580  return index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
1581 }
1582 
1583 void ActionManager::keyBindings()
1584 {
1585  KShortcutsDialog dlg( KShortcutsEditor::AllActions,
1586  KShortcutsEditor::LetterShortcutsDisallowed, view() );
1587  if ( mMainWindow ) {
1588  dlg.addCollection( mMainWindow->getActionCollection() );
1589  }
1590 
1591  foreach ( KOrg::Part *part, mParts ) {
1592  if ( part ) {
1593  dlg.addCollection( part->actionCollection(), part->shortInfo() );
1594  }
1595  }
1596  dlg.configure();
1597 }
1598 
1599 void ActionManager::loadParts()
1600 {
1601  mParts = KOCore::self()->loadParts( mMainWindow );
1602 }
1603 
1604 void ActionManager::setTitle()
1605 {
1606  mMainWindow->setTitle();
1607 }
1608 
1609 void ActionManager::openEventEditor( const QString &text )
1610 {
1611  mCalendarView->newEvent( text );
1612 }
1613 
1614 void ActionManager::openEventEditor( const QString &summary,
1615  const QString &description,
1616  const QStringList &attachments )
1617 {
1618  mCalendarView->newEvent( summary, description, attachments );
1619 }
1620 
1621 void ActionManager::openEventEditor( const QString &summary,
1622  const QString &description,
1623  const QStringList &attachments,
1624  const QStringList &attendees )
1625 {
1626  mCalendarView->newEvent( summary, description, attachments, attendees );
1627 }
1628 
1629 void ActionManager::openEventEditor( const QString &summary,
1630  const QString &description,
1631  const QString &uri,
1632  const QString &file,
1633  const QStringList &attendees,
1634  const QString &attachmentMimetype )
1635 {
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" ) );
1647 
1648  QAction *ret = menu->exec( QCursor::pos() );
1649  delete menu;
1650 
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;
1657  } else {
1658  return;
1659  }
1660  }
1661 
1662  QString attData;
1663  KTemporaryFile tf;
1664  tf.setAutoRemove( true );
1665  switch ( action ) {
1666  case IncidenceEditorNG::GlobalSettings::Link:
1667  attData = uri;
1668  break;
1669  case IncidenceEditorNG::GlobalSettings::InlineFull:
1670  attData = file;
1671  break;
1672  case IncidenceEditorNG::GlobalSettings::InlineBody:
1673  {
1674  QFile f( file );
1675  if ( !f.open( QFile::ReadOnly ) ) {
1676  return;
1677  }
1678  KMime::Message *msg = new KMime::Message();
1679  msg->setContent( f.readAll() );
1680  msg->parse();
1681  if ( msg == msg->textContent() || msg->textContent() == 0 ) { // no attachments
1682  attData = file;
1683  } else {
1684  if ( KMessageBox::warningContinueCancel(
1685  0,
1686  i18n( "Removing attachments from an email might invalidate its signature." ),
1687  i18n( "Remove Attachments" ), KStandardGuiItem::cont(), KStandardGuiItem::cancel(),
1688  QLatin1String("BodyOnlyInlineAttachment") ) != KMessageBox::Continue ) {
1689  delete msg;
1690  return;
1691  }
1692  KMime::Message *newMsg = new KMime::Message();
1693  newMsg->setHead( msg->head() );
1694  newMsg->setBody( msg->textContent()->body() );
1695  newMsg->parse();
1696  newMsg->contentTransferEncoding()->from7BitString(
1697  msg->textContent()->contentTransferEncoding()->as7BitString() );
1698  newMsg->contentType()->from7BitString( msg->textContent()->contentType()->as7BitString() );
1699  newMsg->assemble();
1700  tf.write( newMsg->encodedContent() );
1701  attData = tf.fileName();
1702  }
1703  tf.close();
1704  delete msg;
1705  break;
1706  }
1707  default:
1708  return;
1709  }
1710 
1711  mCalendarView->newEvent( summary, description, QStringList(attData),
1712  attendees, QStringList(attachmentMimetype),
1713  action != IncidenceEditorNG::GlobalSettings::Link );
1714 }
1715 
1716 void ActionManager::openTodoEditor( const QString &text )
1717 {
1718  mCalendarView->newTodo( text );
1719 }
1720 
1721 void ActionManager::openTodoEditor( const QString &summary,
1722  const QString &description,
1723  const QStringList &attachments )
1724 {
1725  mCalendarView->newTodo( summary, description, attachments );
1726 }
1727 void ActionManager::openTodoEditor( const QString &summary,
1728  const QString &description,
1729  const QStringList &attachments,
1730  const QStringList &attendees )
1731 {
1732  mCalendarView->newTodo( summary, description, attachments, attendees );
1733 }
1734 
1735 void ActionManager::openTodoEditor( const QString &summary,
1736  const QString &description,
1737  const QString &uri,
1738  const QString &file,
1739  const QStringList &attendees,
1740  const QString &attachmentMimetype )
1741 {
1742  int action = KOPrefs::instance()->defaultTodoAttachMethod();
1743  if ( attachmentMimetype != QLatin1String("message/rfc822") ) {
1744  action = KOPrefs::TodoAttachLink;
1745  } else if ( KOPrefs::instance()->defaultTodoAttachMethod() == KOPrefs::TodoAttachAsk ) {
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" ) );
1751 
1752  QAction *ret = menu->exec( QCursor::pos() );
1753  delete menu;
1754 
1755  if ( ret == attachLink ) {
1756  action = KOPrefs::TodoAttachLink;
1757  } else if ( ret == attachInline ) {
1758  action = KOPrefs::TodoAttachInlineFull;
1759  } else {
1760  return;
1761  }
1762  }
1763 
1764  QString attData;
1765  switch ( action ) {
1766  case KOPrefs::TodoAttachLink:
1767  attData = uri;
1768  break;
1769  case KOPrefs::TodoAttachInlineFull:
1770  attData = file;
1771  break;
1772  default:
1773  return;
1774  }
1775 
1776  mCalendarView->newTodo( summary, description, QStringList( attData ),
1777  attendees, QStringList( attachmentMimetype ),
1778  action != KOPrefs::TodoAttachLink );
1779 }
1780 
1781 void ActionManager::openJournalEditor( const QDate &date )
1782 {
1783  mCalendarView->newJournal( date );
1784 }
1785 
1786 void ActionManager::openJournalEditor( const QString &text, const QDate &date )
1787 {
1788  mCalendarView->newJournal( text, date );
1789 }
1790 
1791 void ActionManager::openJournalEditor( const QString &text )
1792 {
1793  mCalendarView->newJournal( text );
1794 }
1795 
1796 void ActionManager::showJournalView()
1797 {
1798  mCalendarView->viewManager()->showJournalView();
1799 }
1800 
1801 void ActionManager::showTodoView()
1802 {
1803  mCalendarView->viewManager()->showTodoView();
1804 }
1805 
1806 void ActionManager::showEventView()
1807 {
1808  mCalendarView->viewManager()->showEventView();
1809 }
1810 
1811 void ActionManager::goDate( const QDate &date )
1812 {
1813  mCalendarView->goDate( date );
1814 }
1815 
1816 void ActionManager::goDate( const QString &date )
1817 {
1818  goDate( KGlobal::locale()->readDate( date ) );
1819 }
1820 
1821 void ActionManager::showDate( const QDate &date )
1822 {
1823  mCalendarView->showDate( date );
1824 }
1825 
1826 void ActionManager::updateUndoRedoActions()
1827 {
1828  Akonadi::History *history = mCalendarView->incidenceChanger()->history();
1829 
1830  if ( history->undoAvailable() ) {
1831  mUndoAction->setEnabled( true );
1832  mUndoAction->setText( i18n( "Undo: %1", history->nextUndoDescription() ) );
1833  } else {
1834  mUndoAction->setEnabled( false );
1835  mUndoAction->setText( i18n( "Undo" ) );
1836  }
1837 
1838  if ( history->redoAvailable() ) {
1839  mRedoAction->setEnabled( true );
1840  mRedoAction->setText( i18n( "Redo: %1", history->nextRedoDescription() ) );
1841  } else {
1842  mRedoAction->setEnabled( false );
1843  mRedoAction->setText( i18n( "Redo" ) );
1844  }
1845 
1846  mUndoAction->setIconText( i18n( "Undo" ) );
1847 }
1848 
1849 bool ActionManager::queryClose()
1850 {
1851  return true;
1852 }
1853 
1854 void ActionManager::importCalendar( const KUrl &url )
1855 {
1856  if ( !url.isValid() ) {
1857  KMessageBox::error( dialogParent(),
1858  i18n( "URL '%1' is invalid.", url.prettyUrl() ) );
1859  return;
1860  }
1861 
1862  const QString questionText =
1863  i18nc( "@info",
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>" );
1869 
1870  const int answer =
1871  KMessageBox::questionYesNoCancel(
1872  dialogParent(),
1873  questionText,
1874  i18nc( "@title:window", "Import Calendar" ),
1875  KGuiItem( i18n( "Merge into existing calendar" ) ),
1876  KGuiItem( i18n( "Add as new calendar" ) ) );
1877 
1878  switch( answer ) {
1879  case KMessageBox::Yes: //merge
1880  importURL( url, true );
1881  break;
1882  case KMessageBox::No: //import
1883  importURL( url, false );
1884  break;
1885  default:
1886  return;
1887  }
1888 }
1889 
1890 void ActionManager::slotAutoArchivingSettingsModified()
1891 {
1892  if ( CalendarSupport::KCalPrefs::instance()->mAutoArchive ) {
1893  mAutoArchiveTimer->start( 4 * 60 * 60 * 1000 ); // check again in 4 hours
1894  } else {
1895  mAutoArchiveTimer->stop();
1896  }
1897 }
1898 
1899 void ActionManager::slotAutoArchive()
1900 {
1901  if ( !mCalendarView->calendar() ) { // can this happen?
1902  return;
1903  }
1904 
1905  mAutoArchiveTimer->stop();
1906  CalendarSupport::EventArchiver archiver;
1907 
1908  archiver.runAuto( calendar(), mCalendarView->incidenceChanger(), mCalendarView, false /*no gui*/);
1909 
1910  // restart timer with the correct delay ( especially useful for the first time )
1911  slotAutoArchivingSettingsModified();
1912 }
1913 
1914 QWidget *ActionManager::dialogParent()
1915 {
1916  return mCalendarView->topLevelWidget();
1917 }
1918 
1919 void ActionManager::checkAutoExport()
1920 {
1921  // Don't save if auto save interval is zero
1922  if ( KOPrefs::instance()->mAutoExportInterval == 0 ) {
1923  return;
1924  }
1925 
1926  // has this calendar been saved before? If yes automatically save it.
1927  if ( KOPrefs::instance()->mAutoExport ) {
1928  exportHTML();
1929  }
1930 }
1931 
1932 void ActionManager::openTodoEditor( const QString &summary,
1933  const QString &description,
1934  const QStringList &attachmentUris,
1935  const QStringList &attendees,
1936  const QStringList &attachmentMimetypes,
1937  bool attachmentIsInline )
1938 {
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";
1946 }
1947 
1948 void ActionManager::openEventEditor( const QString &summary,
1949  const QString &description,
1950  const QStringList &attachmentUris,
1951  const QStringList &attendees,
1952  const QStringList &attachmentMimetypes,
1953  bool attachmentIsInline )
1954 {
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";
1962 }
1963 
1964 void ActionManager::handleExportJobResult( KJob *job )
1965 {
1966  HtmlExportJob *htmlExportJob = qobject_cast<HtmlExportJob*>( job );
1967  Q_ASSERT( htmlExportJob );
1968 
1969  if ( mSettingsToFree.contains( htmlExportJob->settings() ) ) {
1970  mSettingsToFree.remove( htmlExportJob->settings() );
1971  delete htmlExportJob->settings();
1972  }
1973 }
1974 
1975 #include "actionmanager.moc"
ActionManager::editIncidence
bool editIncidence(Akonadi::Item::Id id)
Definition: actionmanager.cpp:1348
ActionManager::toggleResourceView
void toggleResourceView()
Definition: actionmanager.cpp:1321
KOViewManager::showJournalView
void showJournalView()
Definition: koviewmanager.cpp:590
ActionManager::toggleDateNavigator
void toggleDateNavigator()
Definition: actionmanager.cpp:1297
CalendarView::deleteIncidence
bool deleteIncidence(const Akonadi::Item &item, bool force=false)
Delete the supplied incidence.
Definition: calendarview.cpp:2357
KOrg::BaseView::supportsDateRangeSelection
virtual bool supportsDateRangeSelection()
returns whether this view supports date range selection Base implementation returns true...
Definition: baseview.cpp:212
ActionManager::configChanged
void configChanged()
When change is made to options dialog, the topwidget will catch this and emit this signal which notif...
CalendarView::newEvent
void newEvent(const QDate &)
Definition: calendarview.cpp:966
ActionManager::importCalendar
void importCalendar(const KUrl &url)
Definition: actionmanager.cpp:1854
ActionManager::importURL
bool importURL(const KUrl &url, bool merge)
Definition: actionmanager.cpp:937
KOPrefsBase::defaultTodoAttachMethod
int defaultTodoAttachMethod() const
Get Default todo attachment method.
Definition: koprefs_base.h:1377
KOCore::reloadPlugins
void reloadPlugins()
Definition: kocore.cpp:361
KOrg::MainWindow::setTitle
virtual void setTitle()=0
Set window title.
ActionManager::showJournalView
void showJournalView()
Definition: actionmanager.cpp:1796
ActionManager::openTodoEditor
void openTodoEditor(const QString &)
Definition: actionmanager.cpp:1716
koglobals.h
KCheckableProxyModel
ActionManager::mergeURL
bool mergeURL(const QString &url)
Open calendar file from URL.
Definition: actionmanager.cpp:1333
KOrg::HTMLExportSettings::setOutputFile
void setOutputFile(const QString &v)
Set Output filename.
Definition: htmlexportsettings.h:197
ActionManager::readProperties
void readProperties(const KConfigGroup &)
Definition: actionmanager.cpp:1220
CalendarView::showDateNavigator
void showDateNavigator(bool)
Definition: calendarview.cpp:2065
CalendarView::incidenceChanger
virtual Akonadi::IncidenceChanger * incidenceChanger() const
Definition: calendarview.h:145
kowindowlist.h
KOViewManager::showTodoView
void showTodoView()
Definition: koviewmanager.cpp:573
KOrg::HTMLExportSettings
Definition: htmlexportsettings.h:12
CalendarView::readSettings
void readSettings()
Using the KConfig associated with the kapp variable, read in the settings from the config file...
Definition: calendarview.cpp:392
CalendarView::newSubTodo
void newSubTodo()
create new todo with a parent todo
Definition: calendarview.cpp:1170
ActionManager::ActionManager
ActionManager(KXMLGUIClient *client, CalendarView *widget, QObject *parent, KOrg::MainWindow *mainWindow, bool isPart, KMenuBar *menuBar=0)
Definition: actionmanager.cpp:97
CalendarView::addIncidence
bool addIncidence(const QString &ical)
Add an incidence to the active calendar.
Definition: calendarview.cpp:1226
ActionManager::getSaveURL
KUrl getSaveURL()
Get URL for saving.
Definition: actionmanager.cpp:1184
KOCore::loadParts
KOrg::Part::List loadParts(KOrg::MainWindow *parent)
Definition: kocore.cpp:288
KOWindowList::removeWindow
void removeWindow(KOrg::MainWindow *)
Unregister a main window.
Definition: kowindowlist.cpp:48
KOrg::MainWindow::init
virtual void init(bool hasDocument)
Definition: mainwindow.cpp:34
QWidget
AkonadiCollectionView::view
Akonadi::EntityTreeView * view() const
Definition: akonadicollectionview.cpp:428
ActionManager::downloadNewStuff
void downloadNewStuff()
Definition: actionmanager.cpp:1408
CalendarView::editIncidence
bool editIncidence(const Akonadi::Item &item, bool isCounter=false)
Create an editor for the supplied incidence.
Definition: calendarview.cpp:2266
ActionManager::localFileName
QString localFileName()
Definition: actionmanager.cpp:1453
KOrg::HtmlExportJob::start
virtual void start()
Definition: htmlexportjob.cpp:89
ActionManager::setTitle
void setTitle()
Definition: actionmanager.cpp:1604
ActionManager::dialogParent
QWidget * dialogParent()
Return widget used as parent for dialogs and message boxes.
Definition: actionmanager.cpp:1914
CalendarView::goDate
void goDate(const QDate &date)
Move the current view date to the specified date.
Definition: calendarview.cpp:515
CalendarView::writeSettings
void writeSettings()
write current state to config file.
Definition: calendarview.cpp:429
KOWindowList
This class manages a list of KOrganizer instances, each associated with a window displaying a calenda...
Definition: kowindowlist.h:44
KOCore::unloadParts
void unloadParts(KOrg::MainWindow *parent, KOrg::Part::List &parts)
Unload the parts in &p parts for this main window.
Definition: kocore.cpp:339
KOrg::HTMLExportSettings::outputFile
QString outputFile() const
Get Output filename.
Definition: htmlexportsettings.h:206
KOrg::BaseView::hasConfigurationDialog
virtual bool hasConfigurationDialog() const
Definition: baseview.cpp:113
ActionManager::showTodoView
void showTodoView()
Definition: actionmanager.cpp:1801
KOrg::HTMLExportSettings::setDateEnd
void setDateEnd(const QDateTime &v)
Set Date end.
Definition: htmlexportsettings.h:172
ActionManager::exportHTML
void exportHTML()
Export the calendar to an HTML file.
Definition: actionmanager.cpp:1010
ActionManager::saveProperties
void saveProperties(KConfigGroup &)
Definition: actionmanager.cpp:1210
kocheckableproxymodel.h
ActionManager::file_icalimport
void file_icalimport()
import a non-ics calendar from another program like ical.
Definition: actionmanager.cpp:872
actionmanager.h
ActionManager::openURL
bool openURL(const QString &url)
Open calendar file from URL.
Definition: actionmanager.cpp:1286
QObject
KOPrefsBase::TodoAttachInlineFull
Definition: koprefs_base.h:18
KOGlobals::holidays
KHolidays::HolidayRegion * holidays() const
return the HolidayRegion object or 0 if none has been defined
Definition: koglobals.cpp:136
CalendarView::saveCalendar
bool saveCalendar(const QString &filename)
Save calendar data to file.
Definition: calendarview.cpp:375
KOrg::MainWindow::actionManager
virtual ActionManager * actionManager()=0
Return ActionManager of this main window.
AkonadiCollectionViewFactory::collectionView
AkonadiCollectionView * collectionView() const
Definition: akonadicollectionview.cpp:196
htmlexportjob.h
KOrg::HTMLExportSettings::monthView
bool monthView() const
Get Export in month view.
Definition: htmlexportsettings.h:331
CalendarView::archiveCalendar
void archiveCalendar()
Archive old events of calendar.
Definition: calendarview.cpp:387
KOrg::Part
Definition: part.h:34
akonadicollectionview.h
ActionManager::updateConfig
void updateConfig()
Options dialog made a changed to the configuration.
Definition: actionmanager.cpp:1226
CalendarView::dialogManager
KODialogManager * dialogManager() const
Definition: calendarview.h:137
CalendarView
This is the main calendar widget.
Definition: calendarview.h:99
CalendarView::calendar
Akonadi::ETMCalendar::Ptr calendar() const
Definition: calendarview.cpp:313
ActionManager::loadParts
void loadParts()
Definition: actionmanager.cpp:1599
koprefs.h
KOViewManager::showEventView
void showEventView()
Definition: koviewmanager.cpp:614
ActionManager::updateUndoRedoActions
void updateUndoRedoActions()
Definition: actionmanager.cpp:1826
KOWindowList::addWindow
void addWindow(KOrg::MainWindow *)
Register a main window.
Definition: kowindowlist.cpp:39
ActionManager::findInstance
static KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
Definition: actionmanager.cpp:1273
KOrg::HtmlExportJob::addHoliday
void addHoliday(const QDate &date, const QString &name)
Definition: htmlexportjob.cpp:879
ActionManager::showTipOnStart
void showTipOnStart()
Show tip of the day.
Definition: actionmanager.cpp:1266
KOrg::HTMLExportSettings::dateStart
QDateTime dateStart() const
Get Date start.
Definition: htmlexportsettings.h:156
KOrg::HTMLExportSettings::setEMail
void setEMail(const QString &v)
Set Email of the calendar owner.
Definition: htmlexportsettings.h:47
ActionManager::view
CalendarView * view() const
Definition: actionmanager.h:78
CalendarView::showIncidence
void showIncidence(const Akonadi::Item &item)
Create a read-only viewer dialog for the supplied incidence.
Definition: calendarview.cpp:2228
ActionManager::~ActionManager
virtual ~ActionManager()
Definition: actionmanager.cpp:118
ActionManager::showIncidence
bool showIncidence(Akonadi::Item::Id id)
Definition: actionmanager.cpp:1353
KOrg::HTMLExportSettings::setDateStart
void setDateStart(const QDateTime &v)
Set Date start.
Definition: htmlexportsettings.h:147
KOrg::HTMLExportSettings::setName
void setName(const QString &v)
Set Full name of the calendar owner.
Definition: htmlexportsettings.h:22
KOrg::MainWindow::getActionCollection
virtual KActionCollection * getActionCollection() const =0
Return actionCollection of this main window.
CalendarView::addExtension
void addExtension(CalendarViewExtension::Factory *)
Adds a calendar view extension widget.
Definition: calendarview.cpp:2104
ActionManager::openEventEditor
void openEventEditor(const QString &)
Definition: actionmanager.cpp:1609
KOrg::MainWindow
interface for korganizer main window
Definition: mainwindow.h:44
CalendarView::newTodo
void newTodo()
create new todo
Definition: calendarview.cpp:1056
KOrg::MainWindow::hasDocument
bool hasDocument() const
Definition: mainwindow.cpp:44
ActionManager::openJournalEditor
void openJournalEditor(const QDate &date)
Definition: actionmanager.cpp:1781
ActionManager::showEventView
void showEventView()
Definition: actionmanager.cpp:1806
CalendarView::currentView
KOrg::BaseView * currentView() const
Definition: calendarview.cpp:1157
KOrg::HTMLExportSettings::setCreditURL
void setCreditURL(const QString &v)
Set Creator URL.
Definition: htmlexportsettings.h:97
KOrg::HtmlExportJob::settings
HTMLExportSettings * settings() const
Definition: htmlexportjob.cpp:899
KOWindowList::defaultInstance
KOrg::MainWindow * defaultInstance()
Return default instance.
Definition: kowindowlist.cpp:80
ActionManager::saveAsURL
bool saveAsURL(const KUrl &kurl)
Save calendar file to URL.
Definition: actionmanager.cpp:1097
ActionManager::processIncidenceSelection
void processIncidenceSelection(const Akonadi::Item &item, const QDate &date)
Definition: actionmanager.cpp:1529
CalendarView::showEventViewer
void showEventViewer(bool)
Definition: calendarview.cpp:2085
ActionManager::configureDateTime
void configureDateTime()
Open kcontrol module for configuring date and time formats.
Definition: actionmanager.cpp:1250
ActionManager::toggleTodoView
void toggleTodoView()
Definition: actionmanager.cpp:1305
KOGlobals::self
static KOGlobals * self()
Definition: koglobals.cpp:43
CalendarView::showDate
void showDate(const QDate &date)
Show the given date without changing date selection length.
Definition: calendarview.cpp:520
ActionManager::goDate
void goDate(const QDate &)
Definition: actionmanager.cpp:1811
KOrg::MainWindow::topLevelWidget
virtual QWidget * topLevelWidget()=0
Return widget whcih represents this main window.
ActionManager::deleteIncidence
virtual bool deleteIncidence(Akonadi::Item::Id id, bool force=false)
Delete the incidence with the given unique id from current calendar.
Definition: actionmanager.cpp:1398
CalendarView::showIncidenceContext
void showIncidenceContext(const Akonadi::Item &incidence)
Show an incidence in context.
Definition: calendarview.cpp:2240
CalendarView::showMessage
void showMessage(const QString &message, KMessageWidget::MessageType)
Definition: calendarview.cpp:2793
ActionManager::readSettings
void readSettings()
Using the KConfig associated with the kapp variable, read in the settings from the config file...
Definition: actionmanager.cpp:791
ActionManager::showIncidenceContext
bool showIncidenceContext(Akonadi::Item::Id id)
Show an incidence in context.
Definition: actionmanager.cpp:1358
CalendarView::newJournal
void newJournal()
Definition: calendarview.cpp:1105
KOPrefsBase::TodoAttachAsk
Definition: koprefs_base.h:18
ActionManager::keyBindings
void keyBindings()
Definition: actionmanager.cpp:1583
ActionManager::file_import
void file_import()
import a generic ics file
Definition: actionmanager.cpp:922
ActionManager::toggleEventViewer
void toggleEventViewer()
Definition: actionmanager.cpp:1313
ActionManager::handleCommandLine
bool handleCommandLine()
Called by KOrganizerUniqueAppHandler in the kontact plugin Returns true if the command line was succe...
Definition: actionmanager.cpp:1363
KOWindowList::findInstance
KOrg::MainWindow * findInstance(const KUrl &url)
Is there a instance with this URL?
Definition: kowindowlist.cpp:70
CalendarView::history
Akonadi::History * history() const
Definition: calendarview.cpp:2723
kodialogmanager.h
KOPrefsBase::TodoAttachLink
Definition: koprefs_base.h:18
KOrg::HTMLExportSettings::dateEnd
QDateTime dateEnd() const
Get Date end.
Definition: htmlexportsettings.h:181
ActionManager::toggleMenubar
void toggleMenubar(bool dontShowWarning=false)
Definition: actionmanager.cpp:134
KOrg::MainWindow::showStatusMessage
virtual void showStatusMessage(const QString &message)=0
Show status message in status bar.
KOPrefs::instance
static KOPrefs * instance()
Get instance of KOPrefs.
Definition: koprefs.cpp:68
ActionManager::showDate
void showDate(const QDate &date)
Definition: actionmanager.cpp:1821
ActionManager::saveURL
bool saveURL()
Save calendar file to URL of current calendar.
Definition: actionmanager.cpp:960
ActionManager::queryClose
bool queryClose()
Definition: actionmanager.cpp:1849
calendarview.h
koviewmanager.h
ActionManager::writeSettings
void writeSettings()
Write current state to config file.
Definition: actionmanager.cpp:806
ActionManager::setItems
void setItems(const QStringList &, int)
Definition: actionmanager.cpp:728
htmlexportsettings.h
AkonadiCollectionView::setCollectionSelectionProxyModel
void setCollectionSelectionProxyModel(KCheckableProxyModel *)
Definition: akonadicollectionview.cpp:409
ActionManager::slotAutoArchive
void slotAutoArchive()
called by the auto archive timer to automatically delete/archive events
Definition: actionmanager.cpp:1899
CalendarView::showTodoView
void showTodoView(bool)
Definition: calendarview.cpp:2075
ActionManager::url
KUrl url() const
Get current URL.
Definition: actionmanager.h:111
KOrg::BaseView::supportsZoom
virtual bool supportsZoom()
returns whether this view supports zoom.
Definition: baseview.cpp:207
KOrg::HTMLExportSettings::setCreditName
void setCreditName(const QString &v)
Set Creator application.
Definition: htmlexportsettings.h:72
ActionManager::getCurrentURLasString
QString getCurrentURLasString() const
Get current URL as QString.
Definition: actionmanager.cpp:1343
ActionManager::showTip
void showTip()
Show tip of the day.
Definition: actionmanager.cpp:1261
KOPrefsBase::setShowMenuBar
void setShowMenuBar(bool v)
Set ShowMenuBar.
Definition: koprefs_base.h:1418
CalendarView::checkClipboard
void checkClipboard()
Check if clipboard contains vCalendar event.
Definition: calendarview.cpp:1966
ActionManager::addIncidence
bool addIncidence(const QString &ical)
Add an incidence to the active calendar.
Definition: actionmanager.cpp:1403
KOGlobals::config
KConfig * config() const
Definition: koglobals.cpp:54
ActionManager::createCalendarAkonadi
void createCalendarAkonadi()
Create Calendar object based on the akonadi framework and set it on the view.
Definition: actionmanager.cpp:211
ActionManager::checkAutoExport
void checkAutoExport()
called by the autoExportTimer to automatically export the calendar
Definition: actionmanager.cpp:1919
KJob
KOrg::HtmlExportJob
This class provides the functions to export a calendar as a HTML page.
Definition: htmlexportjob.h:42
ActionManager::file_archive
void file_archive()
delete or archive old entries in your calendar for speed/space.
Definition: actionmanager.cpp:932
ActionManager::init
void init()
Peform initialization that requires this* to be full constructed.
Definition: actionmanager.cpp:153
kocore.h
CalendarView::viewManager
KOViewManager * viewManager() const
Definition: calendarview.h:136
ActionManager::file_open
void file_open()
open new window
Definition: actionmanager.cpp:844
KOCore::self
static KOCore * self()
Definition: kocore.cpp:37
KOrg::Part::shortInfo
virtual QString shortInfo()=0
short name of the part, used as category in the keybindings dialog
ActionManager::slotAutoArchivingSettingsModified
void slotAutoArchivingSettingsModified()
connected to CalendarView's signal which comes from the ArchiveDialog
Definition: actionmanager.cpp:1890
AkonadiCollectionViewFactory
The factory for AkonadiCollectionView instances.
Definition: akonadicollectionview.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal