kalarm

mainwindow.h

Go to the documentation of this file.
00001 /*
00002  *  mainwindow.h  -  main application window
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2006 by David Jarvie <software@astrojar.org.uk>
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 QListViewItem;
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 
00046     public:
00047         static MainWindow* create(bool restored = false);
00048         ~MainWindow();
00049         bool               isTrayParent() const;
00050         bool               isHiddenTrayParent() const   { return mHiddenTrayParent; }
00051         bool               showingExpired() const       { return mShowExpired; }
00052         void               selectEvent(const QString& eventID);
00053 
00054         static void        refresh();
00055         static void        updateExpired();
00056         static void        updateTimeColumns(bool oldTime, bool oldTimeTo);
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(QDragEnterEvent*);
00064         static void        executeDropEvent(MainWindow*, QDropEvent*);
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 QString i18n_a_ShowAlarmTimes();     // text of 'Show Alarm Times' checkbox, with 'A' shortcut
00072         static QString i18n_t_ShowAlarmTime();      // text of 'Show alarm time' checkbox, with 'T' shortcut
00073         static QString i18n_m_ShowAlarmTime();      // text of 'Show alarm time' checkbox, with 'M' shortcut
00074         static QString i18n_o_ShowTimeToAlarms();   // text of 'Show Time to Alarms' checkbox, with 'O' shortcut
00075         static QString i18n_n_ShowTimeToAlarm();    // text of 'Show time until alarm' checkbox, with 'N' shortcut
00076         static QString i18n_l_ShowTimeToAlarm();    // text of 'Show time until alarm' checkbox, with 'L' shortcut
00077         static QString i18n_ShowExpiredAlarms();    // plain text of 'Show Expired Alarms' action
00078         static QString i18n_e_ShowExpiredAlarms();  // text of 'Show Expired Alarms' checkbox, with 'E' shortcut
00079         static QString i18n_HideExpiredAlarms();    // plain text of 'Hide Expired Alarms' action
00080         static QString i18n_e_HideExpiredAlarms();  // text of 'Hide Expired Alarms' action, with 'E' shortcut
00081 
00082     public slots:
00083         virtual void   show();
00084 
00085     protected:
00086         virtual void   resizeEvent(QResizeEvent*);
00087         virtual void   showEvent(QShowEvent*);
00088         virtual void   hideEvent(QHideEvent*);
00089         virtual void   closeEvent(QCloseEvent*);
00090         virtual void   dragEnterEvent(QDragEnterEvent*);
00091         virtual void   dropEvent(QDropEvent*);
00092         virtual void   saveProperties(KConfig*);
00093         virtual void   readProperties(KConfig*);
00094 
00095     private slots:
00096         void           slotNew();
00097         void           slotNewFromTemplate(const KAEvent&);
00098         void           slotNewTemplate();
00099         void           slotCopy();
00100         void           slotModify();
00101         void           slotDelete();
00102         void           slotReactivate();
00103         void           slotView();
00104         void           slotEnable();
00105         void           slotToggleTrayIcon();
00106         void           slotResetDaemon();
00107         void           slotImportAlarms();
00108         void           slotBirthdays();
00109         void           slotTemplates();
00110         void           slotTemplatesEnd();
00111         void           slotPreferences();
00112         void           slotConfigureKeys();
00113         void           slotConfigureToolbar();
00114         void           slotNewToolbarConfig();
00115         void           slotQuit();
00116         void           slotDeletion();
00117         void           slotSelection();
00118         void           slotMouseClicked(int button, QListViewItem* item, const QPoint&, int);
00119         void           slotDoubleClicked(QListViewItem*);
00120         void           slotShowTime();
00121         void           slotShowTimeTo();
00122         void           slotShowExpired();
00123         void           slotUpdateTimeTo();
00124         void           slotUndo();
00125         void           slotUndoItem(int id);
00126         void           slotRedo();
00127         void           slotRedoItem(int id);
00128         void           slotInitUndoMenu();
00129         void           slotInitRedoMenu();
00130         void           slotUndoStatus(const QString&, const QString&);
00131         void           slotFindActive(bool);
00132         void           updateTrayIconAction();
00133         void           updateActionsMenu();
00134         void           columnsReordered();
00135 
00136     private:
00137         typedef QValueList<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(QDropEvent*, QString& 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 
KDE Home | KDE Accessibility Home | Description of Access Keys