Remove KActionCollection::setComponentData: this does not work on a KActionCollection...
[kdepim.git] / kalarm / recurrenceedit_p.h
blob38ff7f867d05994d0e9dabf5b703176813840964
1 /*
2 * recurrenceedit_p.h - private classes for recurrenceedit.cpp
3 * Program: kalarm
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"
27 #include <QList>
28 #include <QFrame>
29 #include <QBitArray>
30 #include <QAbstractButton>
32 class QLabel;
33 class QWidget;
34 class QVBoxLayout;
35 class ButtonGroup;
36 class ComboBox;
37 class CheckBox;
38 class SpinBox;
39 class TimeSpinBox;
40 class QString;
43 class NoRule : public QFrame
45 Q_OBJECT
46 public:
47 explicit NoRule(QWidget* parent) : QFrame(parent) { }
48 virtual int frequency() const { return 0; }
51 class Rule : public NoRule
53 Q_OBJECT
54 public:
55 Rule(const QString& freqText, const QString& freqWhatsThis, bool time, bool readOnly,
56 QWidget* parent);
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;
65 signals:
66 void frequencyChanged();
67 void changed(); // emitted whenever any control changes
69 private:
70 QWidget* mSpinBox;
71 SpinBox* mIntSpinBox;
72 TimeSpinBox* mTimeSpinBox;
73 QVBoxLayout* mLayout;
74 // Saved state of all controls
75 int mSavedFrequency; // frequency for the selected rule
78 // Subdaily rule choices
79 class SubDailyRule : public Rule
81 Q_OBJECT
82 public:
83 SubDailyRule(bool readOnly, QWidget* parent);
86 // Daily/weekly rule choices base class
87 class DayWeekRule : public Rule
89 Q_OBJECT
90 public:
91 DayWeekRule(const QString& freqText, const QString& freqWhatsThis, const QString& daysWhatsThis,
92 bool readOnly, QWidget* parent);
93 QBitArray days() const;
94 void setDays(bool);
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;
101 private:
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
110 Q_OBJECT
111 public:
112 DailyRule(bool readOnly, QWidget* parent);
115 // Weekly rule choices
116 class WeeklyRule : public DayWeekRule
118 Q_OBJECT
119 public:
120 WeeklyRule(bool readOnly, QWidget* parent);
123 // Monthly/yearly rule choices base class
124 class MonthYearRule : public Rule
126 Q_OBJECT
127 public:
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;
143 signals:
144 void typeChanged(DayPosType);
146 protected:
147 DayPosType buttonType(QAbstractButton* b) const { return b == mDayButton ? DATE : POS; }
148 virtual void daySelected(int /*day*/) { }
150 protected slots:
151 virtual void clicked(QAbstractButton*);
153 private slots:
154 virtual void slotDaySelected(int index);
156 private:
157 void enableSelection(DayPosType);
159 ButtonGroup* mButtonGroup;
160 RadioButton* mDayButton;
161 RadioButton* mPosButton;
162 ComboBox* mDayCombo;
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
176 Q_OBJECT
177 public:
178 MonthlyRule(bool readOnly, QWidget* parent);
181 // Yearly rule choices
182 class YearlyRule : public MonthYearRule
184 Q_OBJECT
185 public:
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;
196 protected:
197 virtual void daySelected(int day);
199 protected slots:
200 virtual void clicked(QAbstractButton*);
202 private slots:
203 void enableFeb29();
205 private:
206 CheckBox* mMonthBox[12];
207 QLabel* mFeb29Label;
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
216 // vim: et sw=4: