kalarm

recurrenceedit.h
1 /*
2  * recurrenceedit.h - widget to edit the event's recurrence definition
3  * Program: kalarm
4  * Copyright © 2002-2005,2008 by David Jarvie <djarvie@kde.org>
5  *
6  * Based originally on KOrganizer module koeditorrecurrence.h,
7  * Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef RECURRENCEEDIT_H
25 #define RECURRENCEEDIT_H
26 
27 #include <tqframe.h>
28 #include <tqdatetime.h>
29 #include <tqvaluelist.h>
30 
31 #include "datetime.h"
32 class TQWidgetStack;
33 class TQGroupBox;
34 class TQLabel;
35 class TQListBox;
36 class TQButton;
37 class TQPushButton;
38 class TQBoxLayout;
39 class SpinBox;
40 class CheckBox;
41 class RadioButton;
42 class DateEdit;
43 class TimeEdit;
44 class ButtonGroup;
45 class RepetitionButton;
46 class KAEvent;
47 class Rule;
48 class NoRule;
49 class SubDailyRule;
50 class DailyRule;
51 class WeeklyRule;
52 class MonthlyRule;
53 class YearlyRule;
54 
55 
56 class RecurrenceEdit : public TQFrame
57 {
58  Q_OBJECT
59 
60  public:
61  // Don't alter the order of these recurrence types
62  enum RepeatType { INVALID_RECUR = -1, NO_RECUR, AT_LOGIN, SUBDAILY, DAILY, WEEKLY, MONTHLY, ANNUAL };
63 
64  RecurrenceEdit(bool readOnly, TQWidget* parent, const char* name = 0);
65  virtual ~RecurrenceEdit() { }
66 
68  void setDefaults(const TQDateTime& from);
70  void set(const KAEvent&, bool keepDuration);
72  void updateEvent(KAEvent&, bool adjustStart);
73  TQWidget* checkData(const TQDateTime& startDateTime, TQString& errorMessage) const;
74  RepeatType repeatType() const { return mRuleButtonType; }
75  bool isTimedRepeatType() const { return mRuleButtonType >= SUBDAILY; }
76  int subRepeatCount(int* subRepeatInterval = 0) const;
77  void setSubRepetition(int reminderMinutes, bool dateOnly);
78  void setStartDate(const TQDate&, const TQDate& today);
79  void setDefaultEndDate(const TQDate&);
80  void setEndDateTime(const DateTime&);
81  DateTime endDateTime() const;
82  bool stateChanged() const;
83  void activateSubRepetition();
84 
85  static TQString i18n_Norecur(); // text of 'No recurrence' selection, lower case
86  static TQString i18n_NoRecur(); // text of 'No Recurrence' selection, initial capitals
87  static TQString i18n_AtLogin(); // text of 'At Login' selection
88  static TQString i18n_l_Atlogin(); // text of 'At &login' selection, with 'L' shortcut
89  static TQString i18n_HourlyMinutely(); // text of 'Hourly/Minutely'
90  static TQString i18n_u_HourlyMinutely(); // text of 'Ho&urly/Minutely' selection, with 'U' shortcut
91  static TQString i18n_Daily(); // text of 'Daily' selection
92  static TQString i18n_d_Daily(); // text of '&Daily' selection, with 'D' shortcut
93  static TQString i18n_Weekly(); // text of 'Weekly' selection
94  static TQString i18n_w_Weekly(); // text of '&Weekly' selection, with 'W' shortcut
95  static TQString i18n_Monthly(); // text of 'Monthly' selection
96  static TQString i18n_m_Monthly(); // text of '&Monthly' selection, with 'M' shortcut
97  static TQString i18n_Yearly(); // text of 'Yearly' selection
98  static TQString i18n_y_Yearly(); // text of '&Yearly' selection, with 'Y' shortcut
99 
100  public slots:
101  void setDateTime(const TQDateTime& start) { mCurrStartDateTime = start; }
102 
103  signals:
104  void shown();
105  void typeChanged(int recurType); // returns a RepeatType value
106  void frequencyChanged();
107  void repeatNeedsInitialisation();
108 
109  protected:
110  virtual void showEvent(TQShowEvent*);
111 
112  private slots:
113  void periodClicked(int);
114  void rangeTypeClicked();
115  void repeatCountChanged(int value);
116  void slotAnyTimeToggled(bool);
117  void addException();
118  void changeException();
119  void deleteException();
120  void enableExceptionButtons();
121 
122  private:
123  void setRuleDefaults(const TQDate& start);
124  void saveState();
125 
126  // Main rule box and choices
127  TQWidgetStack* mRuleStack;
128  Rule* mRule; // current rule widget, or 0 if NoRule
129  NoRule* mNoRule;
130  SubDailyRule* mSubDailyRule;
131  DailyRule* mDailyRule;
132  WeeklyRule* mWeeklyRule;
133  MonthlyRule* mMonthlyRule;
134  YearlyRule* mYearlyRule;
135 
136  ButtonGroup* mRuleButtonGroup;
137  RadioButton* mNoneButton;
138  RadioButton* mAtLoginButton;
139  RadioButton* mSubDailyButton;
140  RadioButton* mDailyButton;
141  RadioButton* mWeeklyButton;
142  RadioButton* mMonthlyButton;
143  RadioButton* mYearlyButton;
144  int mNoneButtonId;
145  int mAtLoginButtonId;
146  int mSubDailyButtonId;
147  int mDailyButtonId;
148  int mWeeklyButtonId;
149  int mMonthlyButtonId;
150  int mYearlyButtonId;
151  RepeatType mRuleButtonType;
152  bool mDailyShown; // daily rule has been displayed at some time or other
153  bool mWeeklyShown; // weekly rule has been displayed at some time or other
154  bool mMonthlyShown; // monthly rule has been displayed at some time or other
155  bool mYearlyShown; // yearly rule has been displayed at some time or other
156 
157  // Range
158  ButtonGroup* mRangeButtonGroup;
159  RadioButton* mNoEndDateButton;
160  RadioButton* mRepeatCountButton;
161  SpinBox* mRepeatCountEntry;
162  TQLabel* mRepeatCountLabel;
163  RadioButton* mEndDateButton;
164  DateEdit* mEndDateEdit;
165  TimeEdit* mEndTimeEdit;
166  CheckBox* mEndAnyTimeCheckBox;
167 
168  // Exceptions
169  TQGroupBox* mExceptionGroup;
170  TQListBox* mExceptionDateList;
171  DateEdit* mExceptionDateEdit;
172  TQPushButton* mChangeExceptionButton;
173  TQPushButton* mDeleteExceptionButton;
174  TQValueList<TQDate> mExceptionDates;
175 
176  // Current start date and time
177  TQDateTime mCurrStartDateTime;
178  RepetitionButton* mSubRepetition;
179  bool mNoEmitTypeChanged; // suppress typeChanged() signal
180  bool mReadOnly;
181 
182  // Initial state of non-rule controls
183  TQButton* mSavedRuleButton; // which rule button was selected
184  TQButton* mSavedRangeButton; // which range button was selected
185  int mSavedRecurCount; // recurrence repeat count
186  DateTime mSavedEndDateTime; // end date/time
187  TQValueList<TQDate> mSavedExceptionDates; // exception dates
188  int mSavedRepeatInterval; // sub-repetition interval (via mSubRepetition button)
189  int mSavedRepeatCount; // sub-repetition count (via mSubRepetition button)
190 };
191 
192 #endif // RECURRENCEEDIT_H
KAEvent corresponds to a KCal::Event instance.
Definition: alarmevent.h:232