kalarm
recurrenceeditprivate.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef RECURRENCEEDITPRIVATE_H
00022 #define RECURRENCEEDITPRIVATE_H
00023
00024 #include <QList>
00025 #include <QFrame>
00026 #include <QBitArray>
00027
00028 class QLabel;
00029 class QWidget;
00030 class QVBoxLayout;
00031 class ButtonGroup;
00032 class RadioButton;
00033 class ComboBox;
00034 class CheckBox;
00035 class SpinBox;
00036 class TimeSpinBox;
00037 class QString;
00038
00039
00040 class NoRule : public QFrame
00041 {
00042 public:
00043 explicit NoRule(QWidget* parent) : QFrame(parent) { }
00044 virtual int frequency() const { return 0; }
00045 };
00046
00047 class Rule : public NoRule
00048 {
00049 Q_OBJECT
00050 public:
00051 Rule(const QString& freqText, const QString& freqWhatsThis, bool time, bool readOnly,
00052 QWidget* parent);
00053 int frequency() const;
00054 void setFrequency(int);
00055 virtual void setFrequencyFocus() { mSpinBox->setFocus(); }
00056 QVBoxLayout* layout() const { return mLayout; }
00057 virtual QWidget* validate(QString&) { return 0; }
00058 virtual void saveState();
00059 virtual bool stateChanged() const;
00060 signals:
00061 void frequencyChanged();
00062 private:
00063 QWidget* mSpinBox;
00064 SpinBox* mIntSpinBox;
00065 TimeSpinBox* mTimeSpinBox;
00066 QVBoxLayout* mLayout;
00067
00068 int mSavedFrequency;
00069 };
00070
00071
00072 class SubDailyRule : public Rule
00073 {
00074 Q_OBJECT
00075 public:
00076 SubDailyRule(bool readOnly, QWidget* parent);
00077 };
00078
00079
00080 class DayWeekRule : public Rule
00081 {
00082 Q_OBJECT
00083 public:
00084 DayWeekRule(const QString& freqText, const QString& freqWhatsThis, const QString& daysWhatsThis,
00085 bool readOnly, QWidget* parent);
00086 QBitArray days() const;
00087 void setDays(bool);
00088 void setDays(const QBitArray& days);
00089 void setDay(int dayOfWeek);
00090 virtual QWidget* validate(QString& errorMessage);
00091 virtual void saveState();
00092 virtual bool stateChanged() const;
00093 private:
00094 CheckBox* mDayBox[7];
00095
00096 QBitArray mSavedDays;
00097 };
00098
00099
00100 class DailyRule : public DayWeekRule
00101 {
00102 public:
00103 DailyRule(bool readOnly, QWidget* parent);
00104 };
00105
00106
00107 class WeeklyRule : public DayWeekRule
00108 {
00109 public:
00110 WeeklyRule(bool readOnly, QWidget* parent);
00111 };
00112
00113
00114 class MonthYearRule : public Rule
00115 {
00116 Q_OBJECT
00117 public:
00118 enum DayPosType { DATE, POS };
00119
00120 MonthYearRule(const QString& freqText, const QString& freqWhatsThis, bool allowEveryWeek,
00121 bool readOnly, QWidget* parent);
00122 DayPosType type() const;
00123 int date() const;
00124 int week() const;
00125 int dayOfWeek() const;
00126 void setType(DayPosType);
00127 void setDate(int dayOfMonth);
00128 void setPosition(int week, int dayOfWeek);
00129 void setDefaultValues(int dayOfMonth, int dayOfWeek);
00130 virtual void saveState();
00131 virtual bool stateChanged() const;
00132 signals:
00133 void typeChanged(DayPosType);
00134 protected:
00135 DayPosType buttonType(QAbstractButton* b) const { return b == mDayButton ? DATE : POS; }
00136 virtual void daySelected(int ) { }
00137 protected slots:
00138 virtual void clicked(QAbstractButton*);
00139 private slots:
00140 virtual void slotDaySelected(int index);
00141 private:
00142 void enableSelection(DayPosType);
00143
00144 ButtonGroup* mButtonGroup;
00145 RadioButton* mDayButton;
00146 RadioButton* mPosButton;
00147 ComboBox* mDayCombo;
00148 ComboBox* mWeekCombo;
00149 ComboBox* mDayOfWeekCombo;
00150 bool mEveryWeek;
00151
00152 int mSavedType;
00153 int mSavedDay;
00154 int mSavedWeek;
00155 int mSavedWeekDay;
00156 };
00157
00158
00159 class MonthlyRule : public MonthYearRule
00160 {
00161 public:
00162 MonthlyRule(bool readOnly, QWidget* parent);
00163 };
00164
00165
00166 class YearlyRule : public MonthYearRule
00167 {
00168 Q_OBJECT
00169 public:
00170 YearlyRule(bool readOnly, QWidget* parent);
00171 QList<int> months() const;
00172 void setMonths(const QList<int>& months);
00173 void setDefaultValues(int dayOfMonth, int dayOfWeek, int month);
00174 Preferences::Feb29Type feb29Type() const;
00175 void setFeb29Type(Preferences::Feb29Type);
00176 virtual QWidget* validate(QString& errorMessage);
00177 virtual void saveState();
00178 virtual bool stateChanged() const;
00179 protected:
00180 virtual void daySelected(int day);
00181 protected slots:
00182 virtual void clicked(QAbstractButton*);
00183 private slots:
00184 void enableFeb29();
00185 private:
00186 CheckBox* mMonthBox[12];
00187 QLabel* mFeb29Label;
00188 ComboBox* mFeb29Combo;
00189
00190 QList<int> mSavedMonths;
00191 int mSavedFeb29Type;
00192 };
00193
00194 #endif // RECURRENCEEDITPRIVATE_H