french -> French
[kdepim.git] / kalarm / editdlg.h
blob27f4003ee3b10600c3e8fb4752680b0d8b7f15d0
1 /*
2 * editdlg.h - dialog to create or modify an alarm or alarm template
3 * Program: kalarm
4 * Copyright © 2001-2013 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef EDITDLG_H
22 #define EDITDLG_H
24 #include <kalarmcal/alarmtext.h>
25 #include <kalarmcal/datetime.h>
26 #include <kalarmcal/kaevent.h>
28 #ifdef USE_AKONADI
29 #include <akonadi/collection.h>
30 #endif
32 #include <kdialog.h>
34 class QLabel;
35 class QShowEvent;
36 class QResizeEvent;
37 class QAbstractButton;
38 class QGroupBox;
39 class QFrame;
40 class QVBoxLayout;
41 class KLineEdit;
42 class KTabWidget;
43 #ifndef USE_AKONADI
44 class AlarmResource;
45 #endif
46 class ButtonGroup;
47 class TimeEdit;
48 class RadioButton;
49 class CheckBox;
50 class LateCancelSelector;
51 class AlarmTimeWidget;
52 class RecurrenceEdit;
53 class Reminder;
54 class ShellProcess;
55 class StackedScrollGroup;
56 class TimeSpinBox;
58 using namespace KAlarmCal;
61 class EditAlarmDlg : public KDialog
63 Q_OBJECT
64 public:
65 enum Type { NO_TYPE, DISPLAY, COMMAND, EMAIL, AUDIO };
66 enum GetResourceType {
67 RES_PROMPT, // prompt for resource
68 RES_USE_EVENT_ID, // use resource containing event, or prompt if not found
69 RES_IGNORE // don't get resource
72 static EditAlarmDlg* create(bool Template, Type, QWidget* parent = 0,
73 GetResourceType = RES_PROMPT);
74 static EditAlarmDlg* create(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
75 GetResourceType = RES_PROMPT, bool readOnly = false);
76 virtual ~EditAlarmDlg();
77 #ifdef USE_AKONADI
78 bool getEvent(KAEvent&, Akonadi::Collection&);
79 #else
80 bool getEvent(KAEvent&, AlarmResource*&);
81 #endif
83 // Methods to initialise values in the New Alarm dialogue.
84 // N.B. setTime() must be called first to set the date-only characteristic,
85 // followed by setRecurrence() if applicable.
86 void setTime(const DateTime&); // must be called first to set date-only value
87 void setRecurrence(const KARecurrence&, int subRepeatInterval, int subRepeatCount);
88 void setRepeatAtLogin();
89 virtual void setAction(KAEvent::SubAction, const AlarmText& = AlarmText()) = 0;
90 void setLateCancel(int minutes);
91 void setShowInKOrganizer(bool);
93 virtual QSize sizeHint() const { return minimumSizeHint(); }
95 static QString i18n_chk_ShowInKOrganizer(); // text of 'Show in KOrganizer' checkbox
97 protected:
98 EditAlarmDlg(bool Template, KAEvent::SubAction, QWidget* parent = 0,
99 GetResourceType = RES_PROMPT);
100 EditAlarmDlg(bool Template, const KAEvent*, bool newAlarm, QWidget* parent = 0,
101 GetResourceType = RES_PROMPT, bool readOnly = false);
102 void init(const KAEvent* event);
103 virtual void resizeEvent(QResizeEvent*);
104 virtual void showEvent(QShowEvent*);
105 virtual void closeEvent(QCloseEvent*);
106 virtual QString type_caption() const = 0;
107 virtual void type_init(QWidget* parent, QVBoxLayout* frameLayout) = 0;
108 virtual void type_initValues(const KAEvent*) = 0;
109 virtual void type_showOptions(bool more) = 0;
110 virtual void setReadOnly(bool readOnly) = 0;
111 virtual void saveState(const KAEvent*) = 0;
112 virtual bool type_stateChanged() const = 0;
113 virtual void type_setEvent(KAEvent&, const KDateTime&, const QString& text, int lateCancel, bool trial) = 0;
114 virtual KAEvent::Flags getAlarmFlags() const;
115 virtual bool type_validate(bool trial) = 0;
116 virtual void type_aboutToTry() {}
117 virtual void type_executedTry(const QString& text, void* obj) { Q_UNUSED(text); Q_UNUSED(obj); }
118 virtual Reminder* createReminder(QWidget* parent) { Q_UNUSED(parent); return 0; }
119 virtual CheckBox* type_createConfirmAckCheckbox(QWidget* parent) { Q_UNUSED(parent); return 0; }
120 virtual bool checkText(QString& result, bool showErrorMessage = true) const = 0;
122 void showMainPage();
123 bool isTemplate() const { return mTemplate; }
124 bool isNewAlarm() const { return mNewAlarm; }
125 bool dateOnly() const;
126 bool isTimedRecurrence() const;
127 bool showingMore() const { return mShowingMore; }
128 Reminder* reminder() const { return mReminder; }
129 LateCancelSelector* lateCancel() const { return mLateCancel; }
131 protected slots:
132 virtual void slotTry();
133 virtual void slotHelp(); // Load Template
134 virtual void slotDefault(); // More/Less Options
135 virtual void slotButtonClicked(int button);
136 void contentsChanged();
138 private slots:
139 void slotRecurTypeChange(int repeatType);
140 void slotRecurFrequencyChange();
141 void slotEditDeferral();
142 void slotShowMainPage();
143 void slotShowRecurrenceEdit();
144 void slotAnyTimeToggled(bool anyTime);
145 void slotTemplateTimeType(QAbstractButton*);
146 void slotSetSubRepetition();
147 void slotResize();
149 private:
150 void init(const KAEvent* event, GetResourceType getResource);
151 void initValues(const KAEvent*);
152 void setEvent(KAEvent&, const QString& text, bool trial);
153 bool validate();
154 void setRecurTabTitle(const KAEvent* = 0);
155 virtual bool stateChanged() const;
156 void showOptions(bool more);
158 protected:
159 KAEvent::SubAction mAlarmType; // actual alarm type
160 private:
161 KTabWidget* mTabs; // the tabs in the dialog
162 StackedScrollGroup* mTabScrollGroup;
163 int mMainPageIndex;
164 int mRecurPageIndex;
165 bool mMainPageShown; // true once the main tab has been displayed
166 bool mRecurPageShown; // true once the recurrence tab has been displayed
167 bool mRecurSetDefaultEndDate; // adjust default end date/time when recurrence tab is displayed
169 // Templates
170 KLineEdit* mTemplateName;
171 ButtonGroup* mTemplateTimeGroup;
172 RadioButton* mTemplateDefaultTime; // no alarm time is specified
173 RadioButton* mTemplateUseTimeAfter;// alarm time is specified as an offset from current
174 RadioButton* mTemplateAnyTime; // alarms have date only, no time
175 RadioButton* mTemplateUseTime; // an alarm time is specified
176 TimeSpinBox* mTemplateTimeAfter; // the specified offset from the current time
177 TimeEdit* mTemplateTime; // the alarm time which is specified
178 QGroupBox* mDeferGroup;
179 QLabel* mDeferTimeLabel;
180 QPushButton* mDeferChangeButton;
182 AlarmTimeWidget* mTimeWidget;
183 LateCancelSelector* mLateCancel;
184 Reminder* mReminder; // null except for display alarms
185 CheckBox* mShowInKorganizer;
187 QFrame* mMoreOptions; // contains options hidden by default
189 RecurrenceEdit* mRecurrenceEdit;
191 QString mAlarmMessage; // message text/file name/command/email message
192 DateTime mAlarmDateTime;
193 DateTime mDeferDateTime;
194 #ifdef USE_AKONADI
195 Akonadi::Item::Id mCollectionItemId; // if >=0, save alarm in collection containing this item ID
196 Akonadi::Collection mCollection; // collection to save event into, or null
197 #else
198 QString mResourceEventId; // if non-empty, save alarm in resource containing this event ID
199 AlarmResource* mResource; // resource to save event into, or null
200 #endif
201 int mDeferGroupHeight; // height added by deferred time widget
202 int mDesktop; // desktop to display the dialog in
203 QString mEventId; // UID of event being edited, or blank for new event
204 bool mTemplate; // editing an alarm template
205 bool mNewAlarm; // editing a new alarm
206 bool mExpiredRecurrence; // initially a recurrence which has expired
207 mutable bool mChanged; // controls other than deferral have changed since dialog was displayed
208 mutable bool mOnlyDeferred; // the only change made in the dialog was to the existing deferral
209 bool mDesiredReadOnly; // the specified read-only status of the dialog
210 bool mReadOnly; // the actual read-only status of the dialog
211 bool mShowingMore; // the More Options button has been clicked
213 // Initial state of all controls
214 KAEvent* mSavedEvent;
215 QString mSavedTemplateName; // mTemplateName value
216 QAbstractButton* mSavedTemplateTimeType; // selected button in mTemplateTimeGroup
217 QTime mSavedTemplateTime; // mTemplateTime value
218 int mSavedTemplateAfterTime;// mTemplateAfterTime value
219 QString mSavedTextFileCommandMessage; // mTextMessageEdit/mFileMessageEdit/mCmdCommandEdit/mEmailMessageEdit value
220 KDateTime mSavedDateTime; // mTimeWidget value
221 KDateTime mSavedDeferTime; // mDeferDateTime value
222 int mSavedRecurrenceType; // RecurrenceEdit::RepeatType value
223 int mSavedLateCancel; // mLateCancel value
224 bool mSavedShowInKorganizer; // mShowInKorganizer status
227 #endif // EDITDLG_H
229 // vim: et sw=4: