SVN_SILENT made messages (.desktop file)
[kdepim.git] / kalarm / recurrenceedit_p.h
blobbc516b1ce7840aafcd7c422069a288d4e637c268
1 /*
2 * recurrenceedit_p.h - private classes for recurrenceedit.cpp
3 * Program: kalarm
4 * Copyright © 2003,2005,2007,2009-2011 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 "radiobutton.h"
26 #include <kalarmcal/karecurrence.h>
28 #include <QList>
29 #include <QVector>
30 #include <QFrame>
31 #include <QBitArray>
32 #include <QAbstractButton>
34 class QLabel;
35 class QWidget;
36 class QVBoxLayout;
37 class ButtonGroup;
38 class ComboBox;
39 class CheckBox;
40 class SpinBox;
41 class TimeSpinBox;
42 class QString;
44 using namespace KAlarmCal;
47 class NoRule : public QFrame
49 Q_OBJECT
50 public:
51 explicit NoRule(QWidget* parent) : QFrame(parent) { }
52 virtual int frequency() const { return 0; }
55 class Rule : public NoRule
57 Q_OBJECT
58 public:
59 Rule(const QString& freqText, const QString& freqWhatsThis, bool time, bool readOnly,
60 QWidget* parent);
61 int frequency() const;
62 void setFrequency(int);
63 virtual void setFrequencyFocus() { mSpinBox->setFocus(); }
64 QVBoxLayout* layout() const { return mLayout; }
65 virtual QWidget* validate(QString&) { return 0; }
66 virtual void saveState();
67 virtual bool stateChanged() const;
69 signals:
70 void frequencyChanged();
71 void changed(); // emitted whenever any control changes
73 private:
74 QWidget* mSpinBox;
75 SpinBox* mIntSpinBox;
76 TimeSpinBox* mTimeSpinBox;
77 QVBoxLayout* mLayout;
78 // Saved state of all controls
79 int mSavedFrequency; // frequency for the selected rule
82 // Subdaily rule choices
83 class SubDailyRule : public Rule
85 Q_OBJECT
86 public:
87 SubDailyRule(bool readOnly, QWidget* parent);
90 // Daily/weekly rule choices base class
91 class DayWeekRule : public Rule
93 Q_OBJECT
94 public:
95 DayWeekRule(const QString& freqText, const QString& freqWhatsThis, const QString& daysWhatsThis,
96 bool readOnly, QWidget* parent);
97 QBitArray days() const;
98 void setDays(bool);
99 void setDays(const QBitArray& days);
100 void setDay(int dayOfWeek);
101 virtual QWidget* validate(QString& errorMessage);
102 virtual void saveState();
103 virtual bool stateChanged() const;
105 private:
106 CheckBox* mDayBox[7];
107 // Saved state of all controls
108 QBitArray mSavedDays; // ticked days for weekly rule
111 // Daily rule choices
112 class DailyRule : public DayWeekRule
114 Q_OBJECT
115 public:
116 DailyRule(bool readOnly, QWidget* parent);
119 // Weekly rule choices
120 class WeeklyRule : public DayWeekRule
122 Q_OBJECT
123 public:
124 WeeklyRule(bool readOnly, QWidget* parent);
127 // Monthly/yearly rule choices base class
128 class MonthYearRule : public Rule
130 Q_OBJECT
131 public:
132 enum DayPosType { DATE, POS };
134 MonthYearRule(const QString& freqText, const QString& freqWhatsThis, bool allowEveryWeek,
135 bool readOnly, QWidget* parent);
136 DayPosType type() const;
137 int date() const; // if date in month is selected
138 int week() const; // if position is selected
139 int dayOfWeek() const; // if position is selected
140 void setType(DayPosType);
141 void setDate(int dayOfMonth);
142 void setPosition(int week, int dayOfWeek);
143 void setDefaultValues(int dayOfMonth, int dayOfWeek);
144 virtual void saveState();
145 virtual bool stateChanged() const;
147 signals:
148 void typeChanged(DayPosType);
150 protected:
151 DayPosType buttonType(QAbstractButton* b) const { return b == mDayButton ? DATE : POS; }
152 virtual void daySelected(int /*day*/) { }
154 protected slots:
155 virtual void clicked(QAbstractButton*);
157 private slots:
158 virtual void slotDaySelected(int index);
160 private:
161 void enableSelection(DayPosType);
163 ButtonGroup* mButtonGroup;
164 RadioButton* mDayButton;
165 RadioButton* mPosButton;
166 ComboBox* mDayCombo;
167 ComboBox* mWeekCombo;
168 ComboBox* mDayOfWeekCombo;
169 bool mEveryWeek; // "Every" week is allowed
170 // Saved state of all controls
171 int mSavedType; // whether day-of-month or month position radio button was selected
172 int mSavedDay; // chosen day of month selected item
173 int mSavedWeek; // chosen month position: selected week item
174 int mSavedWeekDay; // chosen month position: selected day of week
177 // Monthly rule choices
178 class MonthlyRule : public MonthYearRule
180 Q_OBJECT
181 public:
182 MonthlyRule(bool readOnly, QWidget* parent);
185 // Yearly rule choices
186 class YearlyRule : public MonthYearRule
188 Q_OBJECT
189 public:
190 YearlyRule(bool readOnly, QWidget* parent);
191 QVector<int> months() const;
192 void setMonths(const QList<int>& months);
193 void setDefaultValues(int dayOfMonth, int dayOfWeek, int month);
194 KARecurrence::Feb29Type feb29Type() const;
195 void setFeb29Type(KARecurrence::Feb29Type);
196 virtual QWidget* validate(QString& errorMessage);
197 virtual void saveState();
198 virtual bool stateChanged() const;
200 protected:
201 virtual void daySelected(int day);
203 protected slots:
204 virtual void clicked(QAbstractButton*);
206 private slots:
207 void enableFeb29();
209 private:
210 CheckBox* mMonthBox[12];
211 QLabel* mFeb29Label;
212 ComboBox* mFeb29Combo;
213 // Saved state of all controls
214 QVector<int> mSavedMonths; // ticked months for yearly rule
215 int mSavedFeb29Type; // February 29th recurrence type
218 #endif // RECURRENCEEDIT_P_H
220 // vim: et sw=4: