kalarm

mainwindow.h

Go to the documentation of this file.
00001 /*
00002  *  mainwindow.h  -  main application window
00003  *  Program:  kalarm
00004  *  Copyright (C) 2001 - 2005 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        executeDragEnterEvent(QDragEnterEvent*);
00063         static void        executeDropEvent(MainWindow*, QDropEvent*);
00064         static void        closeAll();
00065         static MainWindow* toggleWindow(MainWindow*);
00066         static MainWindow* mainMainWindow();
00067         static MainWindow* firstWindow()      { return mWindowList.first(); }
00068         static int         count()            { return mWindowList.count(); }
00069 
00070         static QString i18n_a_ShowAlarmTimes();     // text of 'Show Alarm Times' checkbox, with 'A' shortcut
00071         static QString i18n_t_ShowAlarmTime();      // text of 'Show alarm time' checkbox, with 'T' shortcut
00072         static QString i18n_m_ShowAlarmTime();      // text of 'Show alarm time' checkbox, with 'M' shortcut
00073         static QString i18n_o_ShowTimeToAlarms();   // text of 'Show Time to Alarms' checkbox, with 'O' shortcut
00074         static QString i18n_n_ShowTimeToAlarm();    // text of 'Show time until alarm' checkbox, with 'N' shortcut
00075         static QString i18n_l_ShowTimeToAlarm();    // text of 'Show time until alarm' checkbox, with 'L' shortcut
00076         static QString i18n_ShowExpiredAlarms();    // plain text of 'Show Expired Alarms' action
00077         static QString i18n_e_ShowExpiredAlarms();  // text of 'Show Expired Alarms' checkbox, with 'E' shortcut
00078         static QString i18n_HideExpiredAlarms();    // plain text of 'Hide Expired Alarms' action
00079         static QString i18n_e_HideExpiredAlarms();  // text of 'Hide Expired Alarms' action, with 'E' shortcut
00080 
00081     public slots:
00082         virtual void   show();
00083 
00084     protected:
00085         virtual void   resizeEvent(QResizeEvent*);
00086         virtual void   showEvent(QShowEvent*);
00087         virtual void   hideEvent(QHideEvent*);
00088         virtual void   closeEvent(QCloseEvent*);
00089         virtual void   dragEnterEvent(QDragEnterEvent*);
00090         virtual void   dropEvent(QDropEvent*);
00091         virtual void   saveProperties(KConfig*);
00092         virtual void   readProperties(KConfig*);
00093 
00094     private slots:
00095         void           slotNew();
00096         void           slotNewFromTemplate(const KAEvent&);
00097         void           slotNewTemplate();
00098         void           slotCopy();
00099         void           slotModify();
00100         void           slotDelete();
00101         void           slotReactivate();
00102         void           slotView();
00103         void           slotEnable();
00104         void           slotToggleTrayIcon();
00105         void           slotResetDaemon();
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           slotMouseClicked(int button, QListViewItem* item, const QPoint&, int);
00117         void           slotDoubleClicked(QListViewItem*);
00118         void           slotShowTime();
00119         void           slotShowTimeTo();
00120         void           slotShowExpired();
00121         void           slotUpdateTimeTo();
00122         void           slotUndo();
00123         void           slotUndoItem(int id);
00124         void           slotRedo();
00125         void           slotRedoItem(int id);
00126         void           slotInitUndoMenu();
00127         void           slotInitRedoMenu();
00128         void           slotUndoStatus(const QString&, const QString&);
00129         void           slotFindActive(bool);
00130         void           updateTrayIconAction();
00131         void           updateActionsMenu();
00132 
00133     private:
00134         typedef QValueList<MainWindow*> WindowList;
00135 
00136         MainWindow(bool restored);
00137         void           createListView(bool recreate);
00138         void           initActions();
00139         void           setEnableText(bool enable);
00140         static KAEvent::Action  getDropAction(QDropEvent*, QString& text);
00141         static void    executeNew(MainWindow*, const KAEvent*, KAEvent::Action = KAEvent::MESSAGE, const AlarmText& = AlarmText());
00142         static void    initUndoMenu(KPopupMenu*, Undo::Type);
00143         static void    setUpdateTimer();
00144         static void    enableTemplateMenuItem(bool);
00145 
00146         static WindowList    mWindowList;   // active main windows
00147         static TemplateDlg*  mTemplateDlg;  // the one and only template dialogue
00148 
00149         AlarmListView*       mListView;
00150         KAction*             mActionTemplates;
00151         KAction*             mActionNew;
00152         TemplateMenuAction*  mActionNewFromTemplate;
00153         KAction*             mActionCreateTemplate;
00154         KAction*             mActionCopy;
00155         KAction*             mActionModify;
00156         KAction*             mActionView;
00157         KAction*             mActionDelete;
00158         KAction*             mActionReactivate;
00159         KAction*             mActionEnable;
00160         KAction*             mActionFindNext;
00161         KAction*             mActionFindPrev;
00162         KToolBarPopupAction* mActionUndo;
00163         KToolBarPopupAction* mActionRedo;
00164         KToggleAction*       mActionToggleTrayIcon;
00165         KToggleAction*       mActionShowTime;
00166         KToggleAction*       mActionShowTimeTo;
00167         KToggleAction*       mActionShowExpired;
00168         KPopupMenu*          mActionsMenu;
00169         KPopupMenu*          mContextMenu;
00170         bool                 mMinuteTimerActive;   // minute timer is active
00171         bool                 mHiddenTrayParent;    // on session restoration, hide this window
00172         bool                 mShowExpired;         // include expired alarms in the displayed list
00173         bool                 mShowTime;            // show alarm times
00174         bool                 mShowTimeTo;          // show time-to-alarms
00175         bool                 mActionEnableEnable;  // Enable/Disable action is set to "Enable"
00176         bool                 mMenuError;           // error occurred creating menus: need to show error message
00177 };
00178 
00179 #endif // MAINWINDOW_H
00180 
KDE Home | KDE Accessibility Home | Description of Access Keys