kalarm

recurrenceeditprivate.h

00001 /*
00002  *  recurrenceeditprivate.h  -  private classes for recurrenceedit.cpp
00003  *  Program:  kalarm
00004  *  Copyright (c) 2003, 2005 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef RECURRENCEEDITPRIVATE_H
00022 #define RECURRENCEEDITPRIVATE_H
00023 
00024 #include <qframe.h>
00025 #include <qvaluelist.h>
00026 #include <qbitarray.h>
00027 
00028 class QWidget;
00029 class QVBoxLayout;
00030 class ButtonGroup;
00031 class RadioButton;
00032 class ComboBox;
00033 class CheckBox;
00034 class SpinBox;
00035 class TimeSpinBox;
00036 class QString;
00037 
00038 
00039 class NoRule : public QFrame
00040 {
00041     public:
00042         NoRule(QWidget* parent, const char* name = 0) : QFrame(parent, name)
00043                                                          { setFrameStyle(QFrame::NoFrame); }
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, const char* name = 0);
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         // Saved state of all controls
00068         int              mSavedFrequency;    // frequency for the selected rule
00069 };
00070 
00071 // Subdaily rule choices
00072 class SubDailyRule : public Rule
00073 {
00074         Q_OBJECT
00075     public:
00076         SubDailyRule(bool readOnly, QWidget* parent, const char* name = 0);
00077 };
00078 
00079 // Daily/weekly rule choices base class
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, const char* name = 0);
00086         QBitArray        days() const;
00087         void             setDays(bool);
00088         void             setDays(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         // Saved state of all controls
00096         QBitArray        mSavedDays;         // ticked days for weekly rule
00097 };
00098 
00099 // Daily rule choices
00100 class DailyRule : public DayWeekRule
00101 {
00102     public:
00103         DailyRule(bool readOnly, QWidget* parent, const char* name = 0);
00104 };
00105 
00106 // Weekly rule choices
00107 class WeeklyRule : public DayWeekRule
00108 {
00109     public:
00110         WeeklyRule(bool readOnly, QWidget* parent, const char* name = 0);
00111 };
00112 
00113 // Monthly/yearly rule choices base class
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, const char* name = 0);
00122         DayPosType       type() const;
00123         int              date() const;       // if date in month is selected
00124         int              week() const;       // if position is selected
00125         int              dayOfWeek() const;  // if position is selected
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(int id) const  { return id == mDayButtonId ? DATE : POS; }
00136         virtual void     daySelected(int /*day*/)  { }
00137     protected slots:
00138         virtual void     clicked(int id);
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         int              mDayButtonId;
00151         int              mPosButtonId;
00152         bool             mEveryWeek;         // "Every" week is allowed
00153         // Saved state of all controls
00154         int              mSavedType;         // whether day-of-month or month position radio button was selected
00155         int              mSavedDay;          // chosen day of month selected item
00156         int              mSavedWeek;         // chosen month position: selected week item
00157         int              mSavedWeekDay;      // chosen month position: selected day of week
00158 };
00159 
00160 // Monthly rule choices
00161 class MonthlyRule : public MonthYearRule
00162 {
00163     public:
00164         MonthlyRule(bool readOnly, QWidget* parent, const char* name = 0);
00165 };
00166 
00167 // Yearly rule choices
00168 class YearlyRule : public MonthYearRule
00169 {
00170         Q_OBJECT
00171     public:
00172         YearlyRule(bool readOnly, QWidget* parent, const char* name = 0);
00173         QValueList<int>  months() const;
00174         void             setMonths(const QValueList<int>& months);
00175         void             setDefaultValues(int dayOfMonth, int dayOfWeek, int month);
00176         KARecurrence::Feb29Type feb29Type() const;
00177         void             setFeb29Type(KARecurrence::Feb29Type);
00178         virtual QWidget* validate(QString& errorMessage);
00179         virtual void     saveState();
00180         virtual bool     stateChanged() const;
00181     protected:
00182         virtual void     daySelected(int day);
00183     protected slots:
00184         virtual void     clicked(int id);
00185     private slots:
00186         void             enableFeb29();
00187     private:
00188         CheckBox*        mMonthBox[12];
00189         QLabel*          mFeb29Label;
00190         ComboBox*        mFeb29Combo;
00191         // Saved state of all controls
00192         QValueList<int>  mSavedMonths;       // ticked months for yearly rule
00193         int              mSavedFeb29Type;    // February 29th recurrence type
00194 };
00195 
00196 #endif // RECURRENCEEDITPRIVATE_H
KDE Home | KDE Accessibility Home | Description of Access Keys