Remove grantlee_strings_extractor.pyc
[kdepim.git] / korganizer / actionmanager.h
blob7271335b80bea523a63d13ab31af1ade0e591651
1 /*
2 This file is part of KOrganizer.
4 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
5 Copyright (c) 2002 Don Sanders <sanders@kde.org>
6 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
7 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
8 Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 As a special exception, permission is given to link this program
25 with any edition of Qt, and distribute the resulting executable,
26 without including the source code for Qt in the source distribution.
29 #ifndef KORG_ACTIONMANAGER_H
30 #define KORG_ACTIONMANAGER_H
32 #include "korganizerprivate_export.h"
33 #include "part.h"
35 #include <AkonadiCore/Item>
36 #include <Akonadi/Calendar/ETMCalendar>
38 #include <QUrl>
39 #include <KViewStateMaintainer>
41 #include <QObject>
43 class AkonadiCollectionView;
44 class CalendarView;
45 class KOWindowList;
46 namespace KOrg
48 class HTMLExportSettings;
51 namespace Akonadi
53 class ETMViewStateSaver;
56 class QAction;
57 class QMenuBar;
58 class KSelectAction;
59 class QTemporaryFile;
60 class KToggleAction;
62 /**
63 The ActionManager creates all the actions in KOrganizer. This class
64 is shared between the main application and the part so all common
65 actions are in one location.
66 It also provides D-Bus interfaces.
68 class KORGANIZERPRIVATE_EXPORT ActionManager : public QObject
70 Q_OBJECT
71 public:
72 ActionManager(KXMLGUIClient *client, CalendarView *widget,
73 QObject *parent, KOrg::MainWindow *mainWindow,
74 bool isPart, QMenuBar *menuBar = Q_NULLPTR);
75 virtual ~ActionManager();
77 /** Peform initialization that requires this* to be full constructed */
78 void init();
80 CalendarView *view() const
82 return mCalendarView;
85 /**
86 Create Calendar object based on the akonadi framework and set it on the view.
88 void createCalendarAkonadi();
90 public Q_SLOTS:
91 bool importURL(const QUrl &url, bool merge);
93 /** Save calendar file to URL of current calendar */
94 bool saveURL();
96 /** Save calendar file to URL */
97 bool saveAsURL(const QUrl &QUrl);
99 /**
100 Export the calendar to an HTML file. Reads up the user settings as needed.
101 Intended to be used as part of the auto HTML export feature.
103 void exportHTML();
106 Export the calendar to an HTML file, per the user settings.
107 @param settings is a pointer to an KOrg::HTMLExportSettings instance.
108 @param autoMode if true, indicates that this export is for an autosave;
109 if false, then the export is explicitly user invoked.
111 void exportHTML(KOrg::HTMLExportSettings *settings, bool autoMode = false);
112 void toggleMenubar(bool dontShowWarning = false);
114 public:
115 /** Get current URL */
116 QUrl url() const
118 return mURL;
121 /** Is there a instance with this URL? */
122 static KOrg::MainWindow *findInstance(const QUrl &url);
124 /** Open calendar file from URL */
125 bool openURL(const QString &url);
127 /** Open calendar file from URL */
128 bool mergeURL(const QString &url);
130 /** Save calendar file to URL */
131 bool saveAsURL(const QString &url);
133 /** Get current URL as QString */
134 QString getCurrentURLasString() const;
137 Delete the incidence with the given unique id from current calendar.
138 @param uid UID of the incidence to delete.
139 @param force If true, all recurrences and sub-todos (if applicable) will
140 be deleted without prompting for confirmation.
142 virtual bool deleteIncidence(Akonadi::Item::Id id, bool force = false);
144 bool editIncidence(Akonadi::Item::Id id);
147 Add an incidence to the active calendar.
148 @param ical A calendar in iCalendar format containing the incidence.
150 bool addIncidence(const QString &ical);
151 //bool addIncidence( const Akonadi::Item::Id &ical );
153 bool showIncidence(Akonadi::Item::Id id);
156 Show an incidence in context. This means showing the todo, agenda or
157 journal view (as appropriate) and scrolling it to show the incidence.
158 @param uid Unique ID of the incidence to show.
160 bool showIncidenceContext(Akonadi::Item::Id id);
163 * Called by KOrganizerUniqueAppHandler in the kontact plugin
164 * Returns true if the command line was successfully handled
165 * false otherwise.
167 bool handleCommandLine(const QStringList &args);
169 public Q_SLOTS:
170 void openEventEditor(const QString &);
171 void openEventEditor(const QString &summary,
172 const QString &description,
173 const QStringList &attachments);
174 void openEventEditor(const QString &summary,
175 const QString &description,
176 const QStringList &attachments,
177 const QStringList &attendees);
178 void openEventEditor(const QString &summary,
179 const QString &description,
180 const QString &uri,
181 const QString &file,
182 const QStringList &attendees,
183 const QString &attachmentMimetype);
184 void openEventEditor(const QString &summary,
185 const QString &description,
186 const QStringList &attachmentUris,
187 const QStringList &attendees,
188 const QStringList &attachmentMimetypes,
189 bool attachmentIsInline);
190 void openTodoEditor(const QString &);
191 void openTodoEditor(const QString &summary,
192 const QString &description,
193 const QStringList &attachments);
194 void openTodoEditor(const QString &summary,
195 const QString &description,
196 const QStringList &attachments,
197 const QStringList &attendees);
198 void openTodoEditor(const QString &summary,
199 const QString &description,
200 const QString &uri,
201 const QString &file,
202 const QStringList &attendees,
203 const QString &attachmentMimetype);
204 void openTodoEditor(const QString &summary,
205 const QString &description,
206 const QStringList &attachmentUris,
207 const QStringList &attendees,
208 const QStringList &attachmentMimetypes,
209 bool attachmentIsInline);
211 void openJournalEditor(const QDate &date);
212 void openJournalEditor(const QString &text, const QDate &date);
213 void openJournalEditor(const QString &text);
215 void showJournalView();
216 void showTodoView();
217 void showEventView();
219 void goDate(const QDate &);
220 void goDate(const QString &);
221 void showDate(const QDate &date);
223 public:
224 QString localFileName();
226 bool queryClose();
228 Q_SIGNALS:
230 Emitted when the "New" action is activated.
232 //void actionNewMainWindow( const QUrl &url = QUrl() );
233 void toggleMenuBar();
235 When change is made to options dialog, the topwidget will catch this
236 and Q_EMIT this signal which notifies all widgets which have registered
237 for notification to update their settings.
239 void configChanged();
241 public Q_SLOTS:
243 Options dialog made a changed to the configuration. we catch this
244 and notify all widgets which need to update their configuration.
246 void updateConfig();
248 void processIncidenceSelection(const Akonadi::Item &item, const QDate &date);
249 void keyBindings();
252 Using the KConfig associated with the kapp variable, read in the
253 settings from the config file.
255 void readSettings();
258 Write current state to config file.
260 void writeSettings();
262 /* Session management */
263 void saveProperties(KConfigGroup &);
264 void readProperties(const KConfigGroup &);
266 void loadParts();
268 void importCalendar(const QUrl &url);
270 protected Q_SLOTS:
271 void setItems(const QStringList &, int);
273 /** called by the autoExportTimer to automatically export the calendar */
274 void checkAutoExport();
276 /** open new window */
277 //void file_new();
279 /** open a file, load it into the calendar. */
280 void file_open();
282 /** open a file from the list of recent files. Also called from file_open()
283 after the URL is obtained from the user.
284 @param url the URL to open
286 void file_open(const QUrl &url);
288 /** import a non-ics calendar from another program like ical. */
289 void file_icalimport();
291 /** import a generic ics file */
292 void file_import();
294 /** delete or archive old entries in your calendar for speed/space. */
295 void file_archive();
297 /** Open kcontrol module for configuring date and time formats */
298 void configureDateTime();
300 void downloadNewStuff();
302 void toggleDateNavigator();
303 void toggleTodoView();
304 void toggleEventViewer();
305 void toggleResourceView();
307 /** connected to CalendarView's signal which comes from the ArchiveDialog */
308 void slotAutoArchivingSettingsModified();
310 /** called by the auto archive timer to automatically delete/archive events */
311 void slotAutoArchive();
313 void setTitle();
315 void updateUndoRedoActions();
317 protected:
318 /** Get URL for saving. Opens FileDialog. */
319 QUrl getSaveURL();
322 Return widget used as parent for dialogs and message boxes.
324 QWidget *dialogParent();
326 private Q_SLOTS:
327 void handleExportJobResult(KJob *);
328 void dumpText(const QString &); // only for debugging purposes
330 void slotDefaultResourceChanged(const Akonadi::Collection &);
331 void slotResourcesAddedRemoved();
333 void slotNewEvent();
334 void slotNewTodo();
335 void slotNewSubTodo();
336 void slotNewJournal();
338 void slotMergeFinished(bool success, int total);
339 void slotNewResourceFinished(bool);
341 private:
342 class ActionStringsVisitor;
343 void setHelpText(QAction *act, const QString &text);
344 void restoreCollectionViewSetting();
345 /** Create all the actions. */
346 void initActions();
347 void enableIncidenceActions(bool enable);
348 Akonadi::ETMCalendar::Ptr calendar() const;
350 Akonadi::Collection selectedCollection() const;
352 KOrg::Part::List mParts; // List of parts loaded
353 QUrl mURL; // URL of calendar file
354 QString mFile; // Local name of calendar file
355 QString mLastUrl; // URL of last loaded calendar.
357 QTemporaryFile *mTempFile;
358 QTimer *mAutoExportTimer; // used if calendar is to be autoexported
359 QTimer *mAutoArchiveTimer; // used for the auto-archiving feature
361 // list of all existing KOrganizer instances
362 static KOWindowList *mWindowList;
364 KToggleAction *mDateNavigatorShowAction;
365 KToggleAction *mTodoViewShowAction;
366 KToggleAction *mCollectionViewShowAction;
367 KToggleAction *mEventViewerShowAction;
369 KToggleAction *mHideMenuBarAction;
371 QAction *mImportAction;
373 QAction *mNewEventAction;
374 QAction *mNewTodoAction;
375 QAction *mNewSubtodoAction;
376 QAction *mNewJournalAction;
377 QAction *mConfigureViewAction;
379 QAction *mShowIncidenceAction;
380 QAction *mEditIncidenceAction;
381 QAction *mDeleteIncidenceAction;
383 QAction *mCutAction;
384 QAction *mCopyAction;
385 QAction *mDeleteAction;
386 QAction *mNextXDays;
387 QAction *mPublishEvent;
388 QAction *mForwardEvent;
390 QAction *mSendInvitation;
391 QAction *mSendCancel;
392 QAction *mSendStatusUpdate;
394 QAction *mRequestChange;
395 QAction *mRequestUpdate;
397 QAction *mUndoAction;
398 QAction *mRedoAction;
399 QMenuBar *mMenuBar;
401 KSelectAction *mFilterAction;
403 KXMLGUIClient *mGUIClient;
404 KActionCollection *mACollection;
405 CalendarView *mCalendarView;
406 KOrg::MainWindow *mMainWindow;
407 bool mIsPart;
408 bool mHtmlExportSync;
410 AkonadiCollectionView *mCollectionView;
411 KViewStateMaintainer<Akonadi::ETMViewStateSaver> *mCollectionViewStateSaver;
412 KViewStateMaintainer<Akonadi::ETMViewStateSaver> *mCollectionSelectionModelStateSaver;
413 QSet<KOrg::HTMLExportSettings *> mSettingsToFree;
416 #endif