summaryrefslogtreecommitdiffstats
path: root/kalarm/mainwindow.h
blob: 47a02447d6f04fe036228dd29eb819b900377951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
 *  mainwindow.h  -  main application window
 *  Program:  kalarm
 *  Copyright © 2001-2007 by David Jarvie <djarvie@kde.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

/** @file mainwindow.h - main application window */

#include "alarmevent.h"
#include "alarmtext.h"
#include "mainwindowbase.h"
#include "undo.h"

class TQListViewItem;
class KAction;
class KToggleAction;
class KToolBarPopupAction;
class KPopupMenu;
class ActionAlarmsEnabled;
class AlarmListView;
class TemplateDlg;
class TemplateMenuAction;


class MainWindow : public MainWindowBase
{
		Q_OBJECT
  

	public:
		static MainWindow* create(bool restored = false);
		~MainWindow();
		bool               isTrayParent() const;
		bool               isHiddenTrayParent() const   { return mHiddenTrayParent; }
		bool               showingExpired() const       { return mShowExpired; }
		void               selectEvent(const TQString& eventID);

		static void        refresh();
		static void        updateExpired();
		static void        addEvent(const KAEvent&, MainWindow*);
		static void        executeNew(MainWindow* w = 0, KAEvent::Action a = KAEvent::MESSAGE, const AlarmText& t = AlarmText())
		                                      { executeNew(w, 0, a, t); }
		static void        executeNew(const KAEvent& e, MainWindow* w = 0)
		                                      { executeNew(w, &e); }
		static void        executeEdit(KAEvent&, MainWindow* = 0);
		static void        executeDragEnterEvent(TQDragEnterEvent*);
		static void        executeDropEvent(MainWindow*, TQDropEvent*);
		static void        closeAll();
		static MainWindow* toggleWindow(MainWindow*);
		static MainWindow* mainMainWindow();
		static MainWindow* firstWindow()      { return mWindowList.first(); }
		static int         count()            { return mWindowList.count(); }

		static TQString i18n_a_ShowAlarmTimes();     // text of 'Show Alarm Times' checkbox, with 'A' shortcut
		static TQString i18n_m_ShowAlarmTime();      // text of 'Show alarm time' checkbox, with 'M' shortcut
		static TQString i18n_o_ShowTimeToAlarms();   // text of 'Show Time to Alarms' checkbox, with 'O' shortcut
		static TQString i18n_l_ShowTimeToAlarm();    // text of 'Show time until alarm' checkbox, with 'L' shortcut
		static TQString i18n_ShowExpiredAlarms();    // plain text of 'Show Expired Alarms' action
		static TQString i18n_e_ShowExpiredAlarms();  // text of 'Show Expired Alarms' checkbox, with 'E' shortcut
		static TQString i18n_HideExpiredAlarms();    // plain text of 'Hide Expired Alarms' action
		static TQString i18n_e_HideExpiredAlarms();  // text of 'Hide Expired Alarms' action, with 'E' shortcut

	public slots:
		virtual void   show();

	protected:
		virtual void   resizeEvent(TQResizeEvent*);
		virtual void   showEvent(TQShowEvent*);
		virtual void   hideEvent(TQHideEvent*);
		virtual void   closeEvent(TQCloseEvent*);
		virtual void   dragEnterEvent(TQDragEnterEvent*);
		virtual void   dropEvent(TQDropEvent*);
		virtual void   saveProperties(TDEConfig*);
		virtual void   readProperties(TDEConfig*);

	private slots:
		void           slotNew();
		void           slotNewFromTemplate(const KAEvent&);
		void           slotNewTemplate();
		void           slotCopy();
		void           slotModify();
		void           slotDelete();
		void           slotReactivate();
		void           slotView();
		void           slotEnable();
		void           slotToggleTrayIcon();
		void           slotResetDaemon();
		void           slotImportAlarms();
		void           slotBirthdays();
		void           slotTemplates();
		void           slotTemplatesEnd();
		void           slotPreferences();
		void           slotConfigureKeys();
		void           slotConfigureToolbar();
		void           slotNewToolbarConfig();
		void           slotQuit();
		void           slotDeletion();
		void           slotSelection();
		void           slotContextMenuRequested(TQListViewItem*, const TQPoint&, int);
		void           slotMouseClicked(int button, TQListViewItem*, const TQPoint&, int);
		void           slotDoubleClicked(TQListViewItem*);
		void           slotShowTime();
		void           slotShowTimeTo();
		void           slotShowExpired();
		void           slotUpdateTimeTo();
		void           slotUndo();
		void           slotUndoItem(int id);
		void           slotRedo();
		void           slotRedoItem(int id);
		void           slotInitUndoMenu();
		void           slotInitRedoMenu();
		void           slotUndoStatus(const TQString&, const TQString&);
		void           slotFindActive(bool);
		void           slotPrefsChanged();
		void           updateTrayIconAction();
		void           updateActionsMenu();
		void           columnsReordered();

	private:
		typedef TQValueList<MainWindow*> WindowList;

		MainWindow(bool restored);
		void           createListView(bool recreate);
		void           initActions();
		void           setEnableText(bool enable);
		static KAEvent::Action  getDropAction(TQDropEvent*, TQString& text);
		static void    executeNew(MainWindow*, const KAEvent*, KAEvent::Action = KAEvent::MESSAGE, const AlarmText& = AlarmText());
		static void    initUndoMenu(KPopupMenu*, Undo::Type);
		static void    setUpdateTimer();
		static void    enableTemplateMenuItem(bool);

		static WindowList    mWindowList;   // active main windows
		static TemplateDlg*  mTemplateDlg;  // the one and only template dialogue

		AlarmListView*       mListView;
		KAction*             mActionTemplates;
		KAction*             mActionNew;
		TemplateMenuAction*  mActionNewFromTemplate;
		KAction*             mActionCreateTemplate;
		KAction*             mActionCopy;
		KAction*             mActionModify;
		KAction*             mActionView;
		KAction*             mActionDelete;
		KAction*             mActionReactivate;
		KAction*             mActionEnable;
		KAction*             mActionFindNext;
		KAction*             mActionFindPrev;
		KToolBarPopupAction* mActionUndo;
		KToolBarPopupAction* mActionRedo;
		KToggleAction*       mActionToggleTrayIcon;
		KToggleAction*       mActionShowTime;
		KToggleAction*       mActionShowTimeTo;
		KToggleAction*       mActionShowExpired;
		KPopupMenu*          mActionsMenu;
		KPopupMenu*          mContextMenu;
		bool                 mMinuteTimerActive;   // minute timer is active
		bool                 mHiddenTrayParent;    // on session restoration, hide this window
		bool                 mShowExpired;         // include expired alarms in the displayed list
		bool                 mShowTime;            // show alarm times
		bool                 mShowTimeTo;          // show time-to-alarms
		bool                 mActionEnableEnable;  // Enable/Disable action is set to "Enable"
		bool                 mMenuError;           // error occurred creating menus: need to show error message
};

#endif // MAINWINDOW_H