Use qtpaths directly
[kdepim.git] / kalarm / mainwindow.h
blob1aeaf72626eba0576aa8c7db69dc9f0e0d10561f
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 #include "editdlg.h"
27 #include "mainwindowbase.h"
28 #include "undo.h"
30 #include <kalarmcal/kaevent.h>
32 #include <AkonadiCore/item.h>
33 #include <KCalCore/Calendar>
35 #include <QList>
36 #include <QMap>
38 class QDragEnterEvent;
39 class QHideEvent;
40 class QShowEvent;
41 class QResizeEvent;
42 class QDropEvent;
43 class QCloseEvent;
44 class QSplitter;
45 class QMenu;
46 class QAction;
47 class KToggleAction;
48 class KToolBarPopupAction;
49 class AlarmListModel;
50 class AlarmListView;
51 class NewAlarmAction;
52 class TemplateDlg;
53 class ResourceSelector;
56 class MainWindow : public MainWindowBase, public KCalCore::Calendar::CalendarObserver
58 Q_OBJECT
60 public:
61 static MainWindow* create(bool restored = false);
62 ~MainWindow();
63 bool isTrayParent() const;
64 bool isHiddenTrayParent() const { return mHiddenTrayParent; }
65 bool showingArchived() const { return mShowArchived; }
66 void selectEvent(Akonadi::Item::Id);
67 KAEvent selectedEvent() const;
68 void editAlarm(EditAlarmDlg*, const KAEvent&);
69 void clearSelection();
70 bool eventFilter(QObject*, QEvent*) Q_DECL_OVERRIDE;
72 static void refresh();
73 static void executeDragEnterEvent(QDragEnterEvent*);
74 static void executeDropEvent(MainWindow*, QDropEvent*);
75 static void closeAll();
76 static MainWindow* toggleWindow(MainWindow*);
77 static MainWindow* mainMainWindow();
78 static MainWindow* firstWindow() { return mWindowList.isEmpty() ? Q_NULLPTR : mWindowList[0]; }
79 static int count() { return mWindowList.count(); }
81 static QString i18n_a_ShowAlarmTimes(); // text of 'Show Alarm Times' action, with 'A' shortcut
82 static QString i18n_chk_ShowAlarmTime(); // text of 'Show alarm time' checkbox
83 static QString i18n_o_ShowTimeToAlarms(); // text of 'Show Time to Alarms' action, with 'O' shortcut
84 static QString i18n_chk_ShowTimeToAlarm(); // text of 'Show time until alarm' checkbox
86 public Q_SLOTS:
87 virtual void show();
89 Q_SIGNALS:
90 void selectionChanged();
92 protected:
93 void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
94 void showEvent(QShowEvent*) Q_DECL_OVERRIDE;
95 void hideEvent(QHideEvent*) Q_DECL_OVERRIDE;
96 void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE;
97 void dragEnterEvent(QDragEnterEvent* e) Q_DECL_OVERRIDE { executeDragEnterEvent(e); }
98 void dropEvent(QDropEvent*) Q_DECL_OVERRIDE;
99 void saveProperties(KConfigGroup&) Q_DECL_OVERRIDE;
100 void readProperties(const KConfigGroup&) Q_DECL_OVERRIDE;
102 private Q_SLOTS:
103 void slotNew(EditAlarmDlg::Type);
104 void slotNewDisplay() { slotNew(EditAlarmDlg::DISPLAY); }
105 void slotNewCommand() { slotNew(EditAlarmDlg::COMMAND); }
106 void slotNewEmail() { slotNew(EditAlarmDlg::EMAIL); }
107 void slotNewAudio() { slotNew(EditAlarmDlg::AUDIO); }
108 void slotNewFromTemplate(const KAEvent*);
109 void slotNewTemplate();
110 void slotCopy();
111 void slotModify();
112 void slotDeleteIf() { slotDelete(false); }
113 void slotDeleteForce() { slotDelete(true); }
114 void slotReactivate();
115 void slotEnable();
116 void slotToggleTrayIcon();
117 void slotRefreshAlarms();
118 void slotImportAlarms();
119 void slotExportAlarms();
120 void slotBirthdays();
121 void slotTemplates();
122 void slotTemplatesEnd();
123 void slotPreferences();
124 void slotConfigureKeys();
125 void slotConfigureToolbar();
126 void slotNewToolbarConfig();
127 void slotQuit();
128 void slotSelection();
129 void slotContextMenuRequested(const QPoint& globalPos);
130 void slotShowTime();
131 void slotShowTimeTo();
132 void slotShowArchived();
133 void slotSpreadWindowsShortcut();
134 void slotWakeFromSuspend();
135 void updateKeepArchived(int days);
136 void slotUndo();
137 void slotUndoItem(QAction* id);
138 void slotRedo();
139 void slotRedoItem(QAction* id);
140 void slotInitUndoMenu();
141 void slotInitRedoMenu();
142 void slotUndoStatus(const QString&, const QString&);
143 void slotFindActive(bool);
144 void updateTrayIconAction();
145 void slotToggleResourceSelector();
146 void slotCalendarStatusChanged();
147 void resourcesResized();
148 void showErrorMessage(const QString&);
149 void editAlarmOk();
150 void editAlarmDeleted(QObject*);
152 private:
153 typedef QList<MainWindow*> WindowList;
155 explicit MainWindow(bool restored);
156 void createListView(bool recreate);
157 void initActions();
158 void initCalendarResources();
159 void selectionCleared();
160 void setEnableText(bool enable);
161 void initUndoMenu(QMenu*, Undo::Type);
162 void slotDelete(bool force);
163 static KAEvent::SubAction getDropAction(QDropEvent*, QString& text);
164 static void setUpdateTimer();
165 static void enableTemplateMenuItem(bool);
167 static WindowList mWindowList; // active main windows
168 static TemplateDlg* mTemplateDlg; // the one and only template dialog
170 AlarmListModel* mListFilterModel;
171 AlarmListView* mListView;
172 ResourceSelector* mResourceSelector; // resource selector widget
173 QSplitter* mSplitter; // splits window into list and resource selector
174 QMap<EditAlarmDlg*, KAEvent> mEditAlarmMap; // edit alarm dialogs to be handled by this window
175 KToggleAction* mActionToggleResourceSel;
176 QAction* mActionImportAlarms;
177 QAction* mActionExportAlarms;
178 QAction* mActionExport;
179 QAction* mActionImportBirthdays;
180 QAction* mActionTemplates;
181 NewAlarmAction* mActionNew;
182 QAction* mActionCreateTemplate;
183 QAction* mActionCopy;
184 QAction* mActionModify;
185 QAction* mActionDelete;
186 QAction* mActionDeleteForce;
187 QAction* mActionReactivate;
188 QAction* mActionEnable;
189 QAction* mActionFindNext;
190 QAction* mActionFindPrev;
191 KToolBarPopupAction* mActionUndo;
192 KToolBarPopupAction* mActionRedo;
193 KToggleAction* mActionToggleTrayIcon;
194 KToggleAction* mActionShowTime;
195 KToggleAction* mActionShowTimeTo;
196 KToggleAction* mActionShowArchived;
197 KToggleAction* mActionSpreadWindows;
198 QMenu* mActionsMenu;
199 QMenu* mContextMenu;
200 QMap<QAction*, int> mUndoMenuIds; // items in the undo/redo menu, in order of appearance
201 int mResourcesWidth; // width of resource selector widget
202 bool mHiddenTrayParent; // on session restoration, hide this window
203 bool mShowResources; // show resource selector
204 bool mShowArchived; // include archived alarms in the displayed list
205 bool mShowTime; // show alarm times
206 bool mShowTimeTo; // show time-to-alarms
207 bool mShown; // true once the window has been displayed
208 bool mActionEnableEnable; // Enable/Disable action is set to "Enable"
209 bool mMenuError; // error occurred creating menus: need to show error message
210 bool mResizing; // window resize is in progress
213 #endif // MAINWINDOW_H
215 // vim: et sw=4: