The concept of local folders doesn't apply any more.
[kdepim.git] / kalarm / mainwindow.h
blobf87094344d83919df270c9aa94c564b6e2163430
1 /*
2 * mainwindow.h - main application window
3 * Program: kalarm
4 * Copyright © 2001-2011 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
24 /** @file mainwindow.h - main application window */
26 #ifndef USE_AKONADI
27 #include "alarmresources.h"
28 #endif
29 #include "editdlg.h"
30 #include "mainwindowbase.h"
31 #include "undo.h"
33 #include <kalarmcal/kaevent.h>
35 #ifdef USE_AKONADI
36 #include <akonadi/item.h>
37 #include <kcalcore/calendar.h>
38 #else
39 #include <kcal/calendar.h>
40 #endif
42 #include <QList>
43 #include <QMap>
45 class QDragEnterEvent;
46 class QHideEvent;
47 class QShowEvent;
48 class QResizeEvent;
49 class QDropEvent;
50 class QCloseEvent;
51 class QSplitter;
52 class QMenu;
53 class KAction;
54 class KToggleAction;
55 class KToolBarPopupAction;
56 #ifdef USE_AKONADI
57 class AlarmListModel;
58 #else
59 class AlarmListFilterModel;
60 #endif
61 class AlarmListView;
62 class NewAlarmAction;
63 class TemplateDlg;
64 class TemplateMenuAction;
65 class ResourceSelector;
68 #ifdef USE_AKONADI
69 class MainWindow : public MainWindowBase, public KCalCore::Calendar::CalendarObserver
70 #else
71 class MainWindow : public MainWindowBase, public KCal::Calendar::CalendarObserver
72 #endif
74 Q_OBJECT
76 public:
77 static MainWindow* create(bool restored = false);
78 ~MainWindow();
79 bool isTrayParent() const;
80 bool isHiddenTrayParent() const { return mHiddenTrayParent; }
81 bool showingArchived() const { return mShowArchived; }
82 #ifdef USE_AKONADI
83 void selectEvent(Akonadi::Item::Id);
84 KAEvent selectedEvent() const;
85 void editAlarm(EditAlarmDlg*, const KAEvent&);
86 #else
87 void selectEvent(const QString& eventID);
88 KAEvent* selectedEvent() const;
89 void editAlarm(EditAlarmDlg*, const KAEvent&, AlarmResource*);
90 #endif
91 void clearSelection();
92 virtual bool eventFilter(QObject*, QEvent*);
94 static void refresh();
95 static void executeDragEnterEvent(QDragEnterEvent*);
96 static void executeDropEvent(MainWindow*, QDropEvent*);
97 static void closeAll();
98 static MainWindow* toggleWindow(MainWindow*);
99 static MainWindow* mainMainWindow();
100 static MainWindow* firstWindow() { return mWindowList.isEmpty() ? 0 : mWindowList[0]; }
101 static int count() { return mWindowList.count(); }
103 static QString i18n_a_ShowAlarmTimes(); // text of 'Show Alarm Times' action, with 'A' shortcut
104 static QString i18n_chk_ShowAlarmTime(); // text of 'Show alarm time' checkbox
105 static QString i18n_o_ShowTimeToAlarms(); // text of 'Show Time to Alarms' action, with 'O' shortcut
106 static QString i18n_chk_ShowTimeToAlarm(); // text of 'Show time until alarm' checkbox
108 public slots:
109 virtual void show();
111 signals:
112 void selectionChanged();
114 protected:
115 virtual void resizeEvent(QResizeEvent*);
116 virtual void showEvent(QShowEvent*);
117 virtual void hideEvent(QHideEvent*);
118 virtual void closeEvent(QCloseEvent*);
119 virtual void dragEnterEvent(QDragEnterEvent* e) { executeDragEnterEvent(e); }
120 virtual void dropEvent(QDropEvent*);
121 virtual void saveProperties(KConfigGroup&);
122 virtual void readProperties(const KConfigGroup&);
124 private slots:
125 void slotNew(EditAlarmDlg::Type);
126 void slotNewDisplay() { slotNew(EditAlarmDlg::DISPLAY); }
127 void slotNewCommand() { slotNew(EditAlarmDlg::COMMAND); }
128 void slotNewEmail() { slotNew(EditAlarmDlg::EMAIL); }
129 void slotNewAudio() { slotNew(EditAlarmDlg::AUDIO); }
130 void slotNewFromTemplate(const KAEvent*);
131 void slotNewTemplate();
132 void slotCopy();
133 void slotModify();
134 void slotDeleteIf() { slotDelete(false); }
135 void slotDeleteForce() { slotDelete(true); }
136 void slotReactivate();
137 void slotEnable();
138 void slotToggleTrayIcon();
139 void slotRefreshAlarms();
140 void slotImportAlarms();
141 void slotExportAlarms();
142 void slotBirthdays();
143 void slotTemplates();
144 void slotTemplatesEnd();
145 void slotPreferences();
146 void slotConfigureKeys();
147 void slotConfigureToolbar();
148 void slotNewToolbarConfig();
149 void slotQuit();
150 void slotSelection();
151 void slotContextMenuRequested(const QPoint& globalPos);
152 void slotShowTime();
153 void slotShowTimeTo();
154 void slotShowArchived();
155 void slotSpreadWindowsShortcut();
156 void slotWakeFromSuspend();
157 void updateKeepArchived(int days);
158 void slotUndo();
159 void slotUndoItem(QAction* id);
160 void slotRedo();
161 void slotRedoItem(QAction* id);
162 void slotInitUndoMenu();
163 void slotInitRedoMenu();
164 void slotUndoStatus(const QString&, const QString&);
165 void slotFindActive(bool);
166 void updateTrayIconAction();
167 void slotToggleResourceSelector();
168 void slotCalendarStatusChanged();
169 void resourcesResized();
170 void showErrorMessage(const QString&);
171 void editAlarmOk();
172 void editAlarmDeleted(QObject*);
174 private:
175 typedef QList<MainWindow*> WindowList;
177 explicit MainWindow(bool restored);
178 void createListView(bool recreate);
179 void initActions();
180 void initCalendarResources();
181 void selectionCleared();
182 void setEnableText(bool enable);
183 void initUndoMenu(QMenu*, Undo::Type);
184 void slotDelete(bool force);
185 static KAEvent::SubAction getDropAction(QDropEvent*, QString& text);
186 static void setUpdateTimer();
187 static void enableTemplateMenuItem(bool);
189 static WindowList mWindowList; // active main windows
190 static TemplateDlg* mTemplateDlg; // the one and only template dialog
192 #ifdef USE_AKONADI
193 AlarmListModel* mListFilterModel;
194 #else
195 AlarmListFilterModel* mListFilterModel;
196 #endif
197 AlarmListView* mListView;
198 ResourceSelector* mResourceSelector; // resource selector widget
199 QSplitter* mSplitter; // splits window into list and resource selector
200 #ifndef USE_AKONADI
201 AlarmResources* mAlarmResources; // calendar resources to use for this window
202 #endif
203 QMap<EditAlarmDlg*, KAEvent> mEditAlarmMap; // edit alarm dialogs to be handled by this window
204 KToggleAction* mActionToggleResourceSel;
205 KAction* mActionImportAlarms;
206 KAction* mActionExportAlarms;
207 KAction* mActionExport;
208 KAction* mActionImportBirthdays;
209 KAction* mActionTemplates;
210 NewAlarmAction* mActionNew;
211 KAction* mActionCreateTemplate;
212 KAction* mActionCopy;
213 KAction* mActionModify;
214 KAction* mActionDelete;
215 KAction* mActionDeleteForce;
216 KAction* mActionReactivate;
217 KAction* mActionEnable;
218 KAction* mActionFindNext;
219 KAction* mActionFindPrev;
220 KToolBarPopupAction* mActionUndo;
221 KToolBarPopupAction* mActionRedo;
222 KToggleAction* mActionToggleTrayIcon;
223 KToggleAction* mActionShowTime;
224 KToggleAction* mActionShowTimeTo;
225 KToggleAction* mActionShowArchived;
226 KToggleAction* mActionSpreadWindows;
227 KMenu* mActionsMenu;
228 KMenu* mContextMenu;
229 QMap<QAction*, int> mUndoMenuIds; // items in the undo/redo menu, in order of appearance
230 int mResourcesWidth; // width of resource selector widget
231 bool mHiddenTrayParent; // on session restoration, hide this window
232 bool mShowResources; // show resource selector
233 bool mShowArchived; // include archived alarms in the displayed list
234 bool mShowTime; // show alarm times
235 bool mShowTimeTo; // show time-to-alarms
236 bool mShown; // true once the window has been displayed
237 bool mActionEnableEnable; // Enable/Disable action is set to "Enable"
238 bool mMenuError; // error occurred creating menus: need to show error message
239 bool mResizing; // window resize is in progress
242 #endif // MAINWINDOW_H
244 // vim: et sw=4: