mainwindow.h
Go to the documentation of this file.
00001 /* 00002 * mainwindow.h - main application window 00003 * Program: kalarm 00004 * Copyright © 2001-2007 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 "alarmevent.h" 00027 #include "alarmtext.h" 00028 #include "mainwindowbase.h" 00029 #include "undo.h" 00030 00031 class TQListViewItem; 00032 class KAction; 00033 class KToggleAction; 00034 class KToolBarPopupAction; 00035 class KPopupMenu; 00036 class ActionAlarmsEnabled; 00037 class AlarmListView; 00038 class TemplateDlg; 00039 class TemplateMenuAction; 00040 00041 00042 class MainWindow : public MainWindowBase 00043 { 00044 Q_OBJECT 00045 TQ_OBJECT 00046 00047 public: 00048 static MainWindow* create(bool restored = false); 00049 ~MainWindow(); 00050 bool isTrayParent() const; 00051 bool isHiddenTrayParent() const { return mHiddenTrayParent; } 00052 bool showingExpired() const { return mShowExpired; } 00053 void selectEvent(const TQString& eventID); 00054 00055 static void refresh(); 00056 static void updateExpired(); 00057 static void addEvent(const KAEvent&, MainWindow*); 00058 static void executeNew(MainWindow* w = 0, KAEvent::Action a = KAEvent::MESSAGE, const AlarmText& t = AlarmText()) 00059 { executeNew(w, 0, a, t); } 00060 static void executeNew(const KAEvent& e, MainWindow* w = 0) 00061 { executeNew(w, &e); } 00062 static void executeEdit(KAEvent&, MainWindow* = 0); 00063 static void executeDragEnterEvent(TQDragEnterEvent*); 00064 static void executeDropEvent(MainWindow*, TQDropEvent*); 00065 static void closeAll(); 00066 static MainWindow* toggleWindow(MainWindow*); 00067 static MainWindow* mainMainWindow(); 00068 static MainWindow* firstWindow() { return mWindowList.first(); } 00069 static int count() { return mWindowList.count(); } 00070 00071 static TQString i18n_a_ShowAlarmTimes(); // text of 'Show Alarm Times' checkbox, with 'A' shortcut 00072 static TQString i18n_m_ShowAlarmTime(); // text of 'Show alarm time' checkbox, with 'M' shortcut 00073 static TQString i18n_o_ShowTimeToAlarms(); // text of 'Show Time to Alarms' checkbox, with 'O' shortcut 00074 static TQString i18n_l_ShowTimeToAlarm(); // text of 'Show time until alarm' checkbox, with 'L' shortcut 00075 static TQString i18n_ShowExpiredAlarms(); // plain text of 'Show Expired Alarms' action 00076 static TQString i18n_e_ShowExpiredAlarms(); // text of 'Show Expired Alarms' checkbox, with 'E' shortcut 00077 static TQString i18n_HideExpiredAlarms(); // plain text of 'Hide Expired Alarms' action 00078 static TQString i18n_e_HideExpiredAlarms(); // text of 'Hide Expired Alarms' action, with 'E' shortcut 00079 00080 public slots: 00081 virtual void show(); 00082 00083 protected: 00084 virtual void resizeEvent(TQResizeEvent*); 00085 virtual void showEvent(TQShowEvent*); 00086 virtual void hideEvent(TQHideEvent*); 00087 virtual void closeEvent(TQCloseEvent*); 00088 virtual void dragEnterEvent(TQDragEnterEvent*); 00089 virtual void dropEvent(TQDropEvent*); 00090 virtual void saveProperties(KConfig*); 00091 virtual void readProperties(KConfig*); 00092 00093 private slots: 00094 void slotNew(); 00095 void slotNewFromTemplate(const KAEvent&); 00096 void slotNewTemplate(); 00097 void slotCopy(); 00098 void slotModify(); 00099 void slotDelete(); 00100 void slotReactivate(); 00101 void slotView(); 00102 void slotEnable(); 00103 void slotToggleTrayIcon(); 00104 void slotResetDaemon(); 00105 void slotImportAlarms(); 00106 void slotBirthdays(); 00107 void slotTemplates(); 00108 void slotTemplatesEnd(); 00109 void slotPreferences(); 00110 void slotConfigureKeys(); 00111 void slotConfigureToolbar(); 00112 void slotNewToolbarConfig(); 00113 void slotQuit(); 00114 void slotDeletion(); 00115 void slotSelection(); 00116 void slotContextMenuRequested(TQListViewItem*, const TQPoint&, int); 00117 void slotMouseClicked(int button, TQListViewItem*, const TQPoint&, int); 00118 void slotDoubleClicked(TQListViewItem*); 00119 void slotShowTime(); 00120 void slotShowTimeTo(); 00121 void slotShowExpired(); 00122 void slotUpdateTimeTo(); 00123 void slotUndo(); 00124 void slotUndoItem(int id); 00125 void slotRedo(); 00126 void slotRedoItem(int id); 00127 void slotInitUndoMenu(); 00128 void slotInitRedoMenu(); 00129 void slotUndoStatus(const TQString&, const TQString&); 00130 void slotFindActive(bool); 00131 void slotPrefsChanged(); 00132 void updateTrayIconAction(); 00133 void updateActionsMenu(); 00134 void columnsReordered(); 00135 00136 private: 00137 typedef TQValueList<MainWindow*> WindowList; 00138 00139 MainWindow(bool restored); 00140 void createListView(bool recreate); 00141 void initActions(); 00142 void setEnableText(bool enable); 00143 static KAEvent::Action getDropAction(TQDropEvent*, TQString& text); 00144 static void executeNew(MainWindow*, const KAEvent*, KAEvent::Action = KAEvent::MESSAGE, const AlarmText& = AlarmText()); 00145 static void initUndoMenu(KPopupMenu*, Undo::Type); 00146 static void setUpdateTimer(); 00147 static void enableTemplateMenuItem(bool); 00148 00149 static WindowList mWindowList; // active main windows 00150 static TemplateDlg* mTemplateDlg; // the one and only template dialogue 00151 00152 AlarmListView* mListView; 00153 KAction* mActionTemplates; 00154 KAction* mActionNew; 00155 TemplateMenuAction* mActionNewFromTemplate; 00156 KAction* mActionCreateTemplate; 00157 KAction* mActionCopy; 00158 KAction* mActionModify; 00159 KAction* mActionView; 00160 KAction* mActionDelete; 00161 KAction* mActionReactivate; 00162 KAction* mActionEnable; 00163 KAction* mActionFindNext; 00164 KAction* mActionFindPrev; 00165 KToolBarPopupAction* mActionUndo; 00166 KToolBarPopupAction* mActionRedo; 00167 KToggleAction* mActionToggleTrayIcon; 00168 KToggleAction* mActionShowTime; 00169 KToggleAction* mActionShowTimeTo; 00170 KToggleAction* mActionShowExpired; 00171 KPopupMenu* mActionsMenu; 00172 KPopupMenu* mContextMenu; 00173 bool mMinuteTimerActive; // minute timer is active 00174 bool mHiddenTrayParent; // on session restoration, hide this window 00175 bool mShowExpired; // include expired alarms in the displayed list 00176 bool mShowTime; // show alarm times 00177 bool mShowTimeTo; // show time-to-alarms 00178 bool mActionEnableEnable; // Enable/Disable action is set to "Enable" 00179 bool mMenuError; // error occurred creating menus: need to show error message 00180 }; 00181 00182 #endif // MAINWINDOW_H 00183