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  TQ_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  bool validateDate(const DateTime &date) const;
85 
86  static TQString i18n_Norecur(); // text of 'No recurrence' selection, lower case
87  static TQString i18n_NoRecur(); // text of 'No Recurrence' selection, initial capitals
88  static TQString i18n_AtLogin(); // text of 'At Login' selection
89  static TQString i18n_l_Atlogin(); // text of 'At &login' selection, with 'L' shortcut
90  static TQString i18n_HourlyMinutely(); // text of 'Hourly/Minutely'
91  static TQString i18n_u_HourlyMinutely(); // text of 'Ho&urly/Minutely' selection, with 'U' shortcut
92  static TQString i18n_Daily(); // text of 'Daily' selection
93  static TQString i18n_d_Daily(); // text of '&Daily' selection, with 'D' shortcut
94  static TQString i18n_Weekly(); // text of 'Weekly' selection
95  static TQString i18n_w_Weekly(); // text of '&Weekly' selection, with 'W' shortcut
96  static TQString i18n_Monthly(); // text of 'Monthly' selection
97  static TQString i18n_m_Monthly(); // text of '&Monthly' selection, with 'M' shortcut
98  static TQString i18n_Yearly(); // text of 'Yearly' selection
99  static TQString i18n_y_Yearly(); // text of '&Yearly' selection, with 'Y' shortcut
100 
101  public slots:
102  void setDateTime(const TQDateTime& start) { mCurrStartDateTime = start; }
103 
104  signals:
105  void shown();
106  void typeChanged(int recurType); // returns a RepeatType value
107  void frequencyChanged();
108  void repeatNeedsInitialisation();
109 
110  protected:
111  virtual void showEvent(TQShowEvent*);
112 
113  private slots:
114  void periodClicked(int);
115  void rangeTypeClicked();
116  void repeatCountChanged(int value);
117  void slotAnyTimeToggled(bool);
118  void addException();
119  void changeException();
120  void deleteException();
121  void enableExceptionButtons();
122 
123  private:
124  void setRuleDefaults(const TQDate& start);
125  void saveState();
126 
127  // Main rule box and choices
128  TQWidgetStack* mRuleStack;
129  Rule* mRule; // current rule widget, or 0 if NoRule
130  NoRule* mNoRule;
131  SubDailyRule* mSubDailyRule;
132  DailyRule* mDailyRule;
133  WeeklyRule* mWeeklyRule;
134  MonthlyRule* mMonthlyRule;
135  YearlyRule* mYearlyRule;
136 
137  ButtonGroup* mRuleButtonGroup;
138  RadioButton* mNoneButton;
139  RadioButton* mAtLoginButton;
140  RadioButton* mSubDailyButton;
141  RadioButton* mDailyButton;
142  RadioButton* mWeeklyButton;
143  RadioButton* mMonthlyButton;
144  RadioButton* mYearlyButton;
145  int mNoneButtonId;
146  int mAtLoginButtonId;
147  int mSubDailyButtonId;
148  int mDailyButtonId;
149  int mWeeklyButtonId;
150  int mMonthlyButtonId;
151  int mYearlyButtonId;
152  RepeatType mRuleButtonType;
153  bool mDailyShown; // daily rule has been displayed at some time or other
154  bool mWeeklyShown; // weekly rule has been displayed at some time or other
155  bool mMonthlyShown; // monthly rule has been displayed at some time or other
156  bool mYearlyShown; // yearly rule has been displayed at some time or other
157 
158  // Range
159  ButtonGroup* mRangeButtonGroup;
160  RadioButton* mNoEndDateButton;
161  RadioButton* mRepeatCountButton;
162  SpinBox* mRepeatCountEntry;
163  TQLabel* mRepeatCountLabel;
164  RadioButton* mEndDateButton;
165  DateEdit* mEndDateEdit;
166  TimeEdit* mEndTimeEdit;
167  CheckBox* mEndAnyTimeCheckBox;
168 
169  // Exceptions
170  TQGroupBox* mExceptionGroup;
171  TQListBox* mExceptionDateList;
172  DateEdit* mExceptionDateEdit;
173  TQPushButton* mChangeExceptionButton;
174  TQPushButton* mDeleteExceptionButton;
175  TQValueList<TQDate> mExceptionDates;
176 
177  // Current start date and time
178  TQDateTime mCurrStartDateTime;
179  RepetitionButton* mSubRepetition;
180  bool mNoEmitTypeChanged; // suppress typeChanged() signal
181  bool mReadOnly;
182 
183  // Initial state of non-rule controls
184  TQButton* mSavedRuleButton; // which rule button was selected
185  TQButton* mSavedRangeButton; // which range button was selected
186  int mSavedRecurCount; // recurrence repeat count
187  DateTime mSavedEndDateTime; // end date/time
188  TQValueList<TQDate> mSavedExceptionDates; // exception dates
189  int mSavedRepeatInterval; // sub-repetition interval (via mSubRepetition button)
190  int mSavedRepeatCount; // sub-repetition count (via mSubRepetition button)
191 };
192 
193 #endif // RECURRENCEEDIT_H
KAEvent corresponds to a KCal::Event instance.
Definition: alarmevent.h:232