2 * recurrenceedit_p.h - private classes for recurrenceedit.cpp
4 * Copyright © 2003,2005,2007,2009,2010 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 RECURRENCEEDIT_P_H
22 #define RECURRENCEEDIT_P_H
24 #include "karecurrence.h"
25 #include "radiobutton.h"
30 #include <QAbstractButton>
43 class NoRule
: public QFrame
47 explicit NoRule(QWidget
* parent
) : QFrame(parent
) { }
48 virtual int frequency() const { return 0; }
51 class Rule
: public NoRule
55 Rule(const QString
& freqText
, const QString
& freqWhatsThis
, bool time
, bool readOnly
,
57 int frequency() const;
58 void setFrequency(int);
59 virtual void setFrequencyFocus() { mSpinBox
->setFocus(); }
60 QVBoxLayout
* layout() const { return mLayout
; }
61 virtual QWidget
* validate(QString
&) { return 0; }
62 virtual void saveState();
63 virtual bool stateChanged() const;
66 void frequencyChanged();
67 void changed(); // emitted whenever any control changes
72 TimeSpinBox
* mTimeSpinBox
;
74 // Saved state of all controls
75 int mSavedFrequency
; // frequency for the selected rule
78 // Subdaily rule choices
79 class SubDailyRule
: public Rule
83 SubDailyRule(bool readOnly
, QWidget
* parent
);
86 // Daily/weekly rule choices base class
87 class DayWeekRule
: public Rule
91 DayWeekRule(const QString
& freqText
, const QString
& freqWhatsThis
, const QString
& daysWhatsThis
,
92 bool readOnly
, QWidget
* parent
);
93 QBitArray
days() const;
95 void setDays(const QBitArray
& days
);
96 void setDay(int dayOfWeek
);
97 virtual QWidget
* validate(QString
& errorMessage
);
98 virtual void saveState();
99 virtual bool stateChanged() const;
102 CheckBox
* mDayBox
[7];
103 // Saved state of all controls
104 QBitArray mSavedDays
; // ticked days for weekly rule
107 // Daily rule choices
108 class DailyRule
: public DayWeekRule
112 DailyRule(bool readOnly
, QWidget
* parent
);
115 // Weekly rule choices
116 class WeeklyRule
: public DayWeekRule
120 WeeklyRule(bool readOnly
, QWidget
* parent
);
123 // Monthly/yearly rule choices base class
124 class MonthYearRule
: public Rule
128 enum DayPosType
{ DATE
, POS
};
130 MonthYearRule(const QString
& freqText
, const QString
& freqWhatsThis
, bool allowEveryWeek
,
131 bool readOnly
, QWidget
* parent
);
132 DayPosType
type() const;
133 int date() const; // if date in month is selected
134 int week() const; // if position is selected
135 int dayOfWeek() const; // if position is selected
136 void setType(DayPosType
);
137 void setDate(int dayOfMonth
);
138 void setPosition(int week
, int dayOfWeek
);
139 void setDefaultValues(int dayOfMonth
, int dayOfWeek
);
140 virtual void saveState();
141 virtual bool stateChanged() const;
144 void typeChanged(DayPosType
);
147 DayPosType
buttonType(QAbstractButton
* b
) const { return b
== mDayButton
? DATE
: POS
; }
148 virtual void daySelected(int /*day*/) { }
151 virtual void clicked(QAbstractButton
*);
154 virtual void slotDaySelected(int index
);
157 void enableSelection(DayPosType
);
159 ButtonGroup
* mButtonGroup
;
160 RadioButton
* mDayButton
;
161 RadioButton
* mPosButton
;
163 ComboBox
* mWeekCombo
;
164 ComboBox
* mDayOfWeekCombo
;
165 bool mEveryWeek
; // "Every" week is allowed
166 // Saved state of all controls
167 int mSavedType
; // whether day-of-month or month position radio button was selected
168 int mSavedDay
; // chosen day of month selected item
169 int mSavedWeek
; // chosen month position: selected week item
170 int mSavedWeekDay
; // chosen month position: selected day of week
173 // Monthly rule choices
174 class MonthlyRule
: public MonthYearRule
178 MonthlyRule(bool readOnly
, QWidget
* parent
);
181 // Yearly rule choices
182 class YearlyRule
: public MonthYearRule
186 YearlyRule(bool readOnly
, QWidget
* parent
);
187 QList
<int> months() const;
188 void setMonths(const QList
<int>& months
);
189 void setDefaultValues(int dayOfMonth
, int dayOfWeek
, int month
);
190 KARecurrence::Feb29Type
feb29Type() const;
191 void setFeb29Type(KARecurrence::Feb29Type
);
192 virtual QWidget
* validate(QString
& errorMessage
);
193 virtual void saveState();
194 virtual bool stateChanged() const;
197 virtual void daySelected(int day
);
200 virtual void clicked(QAbstractButton
*);
206 CheckBox
* mMonthBox
[12];
208 ComboBox
* mFeb29Combo
;
209 // Saved state of all controls
210 QList
<int> mSavedMonths
; // ticked months for yearly rule
211 int mSavedFeb29Type
; // February 29th recurrence type
214 #endif // RECURRENCEEDIT_P_H