kalarm
mainwindow.h
Go to the documentation of this file.00001 /* 00002 * mainwindow.h - main application window 00003 * Program: kalarm 00004 * Copyright © 2001-2008 by David Jarvie <djarvie@kde.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef MAINWINDOW_H 00022 #define MAINWINDOW_H 00023 00026 #include <QList> 00027 #include <QMap> 00028 00029 #include <kcal/calendar.h> 00030 00031 #include "alarmevent.h" 00032 #include "alarmresources.h" 00033 #include "editdlg.h" 00034 #include "mainwindowbase.h" 00035 #include "undo.h" 00036 00037 class QDragEnterEvent; 00038 class QHideEvent; 00039 class QShowEvent; 00040 class QResizeEvent; 00041 class QDropEvent; 00042 class QCloseEvent; 00043 class QModelIndex; 00044 class QSplitter; 00045 class QMenu; 00046 class KAction; 00047 class KToggleAction; 00048 class KToolBarPopupAction; 00049 class AlarmListFilterModel; 00050 class AlarmListDelegate; 00051 class AlarmListView; 00052 class NewAlarmAction; 00053 class TemplateDlg; 00054 class TemplateMenuAction; 00055 class ResourceSelector; 00056 00057 00058 class MainWindow : public MainWindowBase, public KCal::Calendar::CalendarObserver 00059 { 00060 Q_OBJECT 00061 00062 public: 00063 static MainWindow* create(bool restored = false); 00064 ~MainWindow(); 00065 bool isTrayParent() const; 00066 bool isHiddenTrayParent() const { return mHiddenTrayParent; } 00067 bool showingArchived() const { return mShowArchived; } 00068 void selectEvent(const QString& eventID); 00069 virtual bool eventFilter(QObject*, QEvent*); 00070 00071 static void refresh(); 00072 static void executeDragEnterEvent(QDragEnterEvent*, QWidget* recipient); 00073 static void executeDropEvent(MainWindow*, QDropEvent*); 00074 static void closeAll(); 00075 static MainWindow* toggleWindow(MainWindow*); 00076 static MainWindow* mainMainWindow(); 00077 static MainWindow* firstWindow() { return mWindowList.isEmpty() ? 0 : mWindowList[0]; } 00078 static int count() { return mWindowList.count(); } 00079 00080 static QString i18n_a_ShowAlarmTimes(); // text of 'Show Alarm Times' action, with 'A' shortcut 00081 static QString i18n_chk_ShowAlarmTime(); // text of 'Show alarm time' checkbox 00082 static QString i18n_o_ShowTimeToAlarms(); // text of 'Show Time to Alarms' action, with 'O' shortcut 00083 static QString i18n_chk_ShowTimeToAlarm(); // text of 'Show time until alarm' checkbox 00084 static QString i18n_a_ShowArchivedAlarms(); // text of 'Show Archived Alarms' action, with 'A' shortcut 00085 static QString i18n_tip_ShowArchivedAlarms(); // text of 'Show Archived Alarms' tooltip 00086 static QString i18n_tip_HideArchivedAlarms(); // text of 'Hide Archived Alarms' tooltip 00087 00088 public slots: 00089 virtual void show(); 00090 00091 protected: 00092 virtual void resizeEvent(QResizeEvent*); 00093 virtual void showEvent(QShowEvent*); 00094 virtual void hideEvent(QHideEvent*); 00095 virtual void closeEvent(QCloseEvent*); 00096 virtual void dragEnterEvent(QDragEnterEvent*); 00097 virtual void dropEvent(QDropEvent*); 00098 virtual void saveProperties(KConfigGroup&); 00099 virtual void readProperties(const KConfigGroup&); 00100 00101 private slots: 00102 void slotNew(EditAlarmDlg::Type); 00103 void slotNewFromTemplate(const KAEvent*); 00104 void slotNewTemplate(); 00105 void slotCopy(); 00106 void slotModify(); 00107 void slotDelete(); 00108 void slotReactivate(); 00109 void slotEnable(); 00110 void slotToggleTrayIcon(); 00111 void slotRefreshAlarms(); 00112 void slotImportAlarms(); 00113 void slotBirthdays(); 00114 void slotTemplates(); 00115 void slotTemplatesEnd(); 00116 void slotPreferences(); 00117 void slotConfigureKeys(); 00118 void slotConfigureToolbar(); 00119 void slotNewToolbarConfig(); 00120 void slotQuit(); 00121 void slotSelection(); 00122 void slotContextMenuRequested(const QPoint& globalPos); 00123 void slotShowTime(); 00124 void slotShowTimeTo(); 00125 void slotShowArchived(); 00126 void updateKeepArchived(int days); 00127 void slotUndo(); 00128 void slotUndoItem(QAction* id); 00129 void slotRedo(); 00130 void slotRedoItem(QAction* id); 00131 void slotInitUndoMenu(); 00132 void slotInitRedoMenu(); 00133 void slotUndoStatus(const QString&, const QString&); 00134 void slotFindActive(bool); 00135 void updateTrayIconAction(); 00136 void slotToggleResourceSelector(); 00137 void slotResourceStatusChanged(); 00138 void resourcesResized(); 00139 void showErrorMessage(const QString&); 00140 00141 private: 00142 typedef QList<MainWindow*> WindowList; 00143 00144 explicit MainWindow(bool restored); 00145 void createListView(bool recreate); 00146 void initActions(); 00147 void initCalendarResources(); 00148 void selectionCleared(); 00149 void setEnableText(bool enable); 00150 void initUndoMenu(QMenu*, Undo::Type); 00151 static KAEvent::Action getDropAction(QDropEvent*, QString& text); 00152 static void setUpdateTimer(); 00153 static void enableTemplateMenuItem(bool); 00154 00155 static WindowList mWindowList; // active main windows 00156 static TemplateDlg* mTemplateDlg; // the one and only template dialog 00157 00158 AlarmListFilterModel* mListFilterModel; 00159 AlarmListView* mListView; 00160 ResourceSelector* mResourceSelector; // resource selector widget 00161 QSplitter* mSplitter; // splits window into list and resource selector 00162 AlarmResources* mAlarmResources; // calendar resources to use for this window 00163 KToggleAction* mActionToggleResourceSel; 00164 KAction* mActionImportAlarms; 00165 KAction* mActionImportBirthdays; 00166 KAction* mActionTemplates; 00167 NewAlarmAction* mActionNew; 00168 TemplateMenuAction* mActionNewFromTemplate; 00169 KAction* mActionCreateTemplate; 00170 KAction* mActionCopy; 00171 KAction* mActionModify; 00172 KAction* mActionDelete; 00173 KAction* mActionReactivate; 00174 KAction* mActionEnable; 00175 KAction* mActionFindNext; 00176 KAction* mActionFindPrev; 00177 KToolBarPopupAction* mActionUndo; 00178 KToolBarPopupAction* mActionRedo; 00179 KToggleAction* mActionToggleTrayIcon; 00180 KToggleAction* mActionShowTime; 00181 KToggleAction* mActionShowTimeTo; 00182 KToggleAction* mActionShowArchived; 00183 KMenu* mActionsMenu; 00184 KMenu* mContextMenu; 00185 QMap<QAction*, int> mUndoMenuIds; // items in the undo/redo menu, in order of appearance 00186 int mResourcesWidth; // width of resource selector widget 00187 bool mMinuteTimerActive; // minute timer is active 00188 bool mHiddenTrayParent; // on session restoration, hide this window 00189 bool mShowResources; // show resource selector 00190 bool mShowArchived; // include archived alarms in the displayed list 00191 bool mShowTime; // show alarm times 00192 bool mShowTimeTo; // show time-to-alarms 00193 bool mShown; // true once the window has been displayed 00194 bool mActionEnableEnable; // Enable/Disable action is set to "Enable" 00195 bool mMenuError; // error occurred creating menus: need to show error message 00196 bool mResizing; // window resize is in progress 00197 }; 00198 00199 #endif // MAINWINDOW_H 00200
KDE 4.2 API Reference