kalarm

recurrenceeditprivate.h
1/*
2 * recurrenceeditprivate.h - private classes for recurrenceedit.cpp
3 * Program: kalarm
4 * Copyright © 2003,2005,2007 by David Jarvie <software@astrojar.org.uk>
5 *
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.
10 *
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.
15 *
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.
19 */
20
21#ifndef RECURRENCEEDITPRIVATE_H
22#define RECURRENCEEDITPRIVATE_H
23
24#include <tqframe.h>
25#include <tqvaluelist.h>
26#include <tqbitarray.h>
27
28class TQWidget;
29class TQVBoxLayout;
30class ButtonGroup;
31class RadioButton;
32class ComboBox;
33class CheckBox;
34class SpinBox;
35class TimeSpinBox;
36class TQString;
37
38
39class NoRule : public TQFrame
40{
41 public:
42 NoRule(TQWidget* parent, const char* name = 0) : TQFrame(parent, name)
43 { setFrameStyle(TQFrame::NoFrame); }
44 virtual int frequency() const { return 0; }
45};
46
47class Rule : public NoRule
48{
49 TQ_OBJECT
50
51 public:
52 Rule(const TQString& freqText, const TQString& freqWhatsThis, bool time, bool readOnly,
53 TQWidget* parent, const char* name = 0);
54 int frequency() const;
55 void setFrequency(int);
56 virtual void setFrequencyFocus() { mSpinBox->setFocus(); }
57 TQVBoxLayout* layout() const { return mLayout; }
58 virtual TQWidget* validate(TQString&) { return 0; }
59 virtual void saveState();
60 virtual bool stateChanged() const;
61 signals:
62 void frequencyChanged();
63 private:
64 TQWidget* mSpinBox;
65 SpinBox* mIntSpinBox;
66 TimeSpinBox* mTimeSpinBox;
67 TQVBoxLayout* mLayout;
68 // Saved state of all controls
69 int mSavedFrequency; // frequency for the selected rule
70};
71
72// Subdaily rule choices
73class SubDailyRule : public Rule
74{
75 TQ_OBJECT
76
77 public:
78 SubDailyRule(bool readOnly, TQWidget* parent, const char* name = 0);
79};
80
81// Daily/weekly rule choices base class
82class DayWeekRule : public Rule
83{
84 TQ_OBJECT
85
86 public:
87 DayWeekRule(const TQString& freqText, const TQString& freqWhatsThis, const TQString& daysWhatsThis,
88 bool readOnly, TQWidget* parent, const char* name = 0);
89 TQBitArray days() const;
90 void setDays(bool);
91 void setDays(const TQBitArray& days);
92 void setDay(int dayOfWeek);
93 virtual TQWidget* validate(TQString& errorMessage);
94 virtual void saveState();
95 virtual bool stateChanged() const;
96 private:
97 CheckBox* mDayBox[7];
98 // Saved state of all controls
99 TQBitArray mSavedDays; // ticked days for weekly rule
100};
101
102// Daily rule choices
103class DailyRule : public DayWeekRule
104{
105 public:
106 DailyRule(bool readOnly, TQWidget* parent, const char* name = 0);
107};
108
109// Weekly rule choices
110class WeeklyRule : public DayWeekRule
111{
112 public:
113 WeeklyRule(bool readOnly, TQWidget* parent, const char* name = 0);
114};
115
116// Monthly/yearly rule choices base class
117class MonthYearRule : public Rule
118{
119 TQ_OBJECT
120
121 public:
122 enum DayPosType { DATE, POS };
123
124 MonthYearRule(const TQString& freqText, const TQString& freqWhatsThis, bool allowEveryWeek,
125 bool readOnly, TQWidget* parent, const char* name = 0);
126 DayPosType type() const;
127 int date() const; // if date in month is selected
128 int week() const; // if position is selected
129 int dayOfWeek() const; // if position is selected
130 void setType(DayPosType);
131 void setDate(int dayOfMonth);
132 void setPosition(int week, int dayOfWeek);
133 void setDefaultValues(int dayOfMonth, int dayOfWeek);
134 virtual void saveState();
135 virtual bool stateChanged() const;
136 signals:
137 void typeChanged(DayPosType);
138 protected:
139 DayPosType buttonType(int id) const { return id == mDayButtonId ? DATE : POS; }
140 virtual void daySelected(int /*day*/) { }
141 protected slots:
142 virtual void clicked(int id);
143 private slots:
144 virtual void slotDaySelected(int index);
145 private:
146 void enableSelection(DayPosType);
147
148 ButtonGroup* mButtonGroup;
149 RadioButton* mDayButton;
150 RadioButton* mPosButton;
151 ComboBox* mDayCombo;
152 ComboBox* mWeekCombo;
153 ComboBox* mDayOfWeekCombo;
154 int mDayButtonId;
155 int mPosButtonId;
156 bool mEveryWeek; // "Every" week is allowed
157 // Saved state of all controls
158 int mSavedType; // whether day-of-month or month position radio button was selected
159 int mSavedDay; // chosen day of month selected item
160 int mSavedWeek; // chosen month position: selected week item
161 int mSavedWeekDay; // chosen month position: selected day of week
162};
163
164// Monthly rule choices
165class MonthlyRule : public MonthYearRule
166{
167 public:
168 MonthlyRule(bool readOnly, TQWidget* parent, const char* name = 0);
169};
170
171// Yearly rule choices
172class YearlyRule : public MonthYearRule
173{
174 TQ_OBJECT
175
176 public:
177 YearlyRule(bool readOnly, TQWidget* parent, const char* name = 0);
178 TQValueList<int> months() const;
179 void setMonths(const TQValueList<int>& months);
180 void setDefaultValues(int dayOfMonth, int dayOfWeek, int month);
181 KARecurrence::Feb29Type feb29Type() const;
182 void setFeb29Type(KARecurrence::Feb29Type);
183 virtual TQWidget* validate(TQString& errorMessage);
184 virtual void saveState();
185 virtual bool stateChanged() const;
186 protected:
187 virtual void daySelected(int day);
188 protected slots:
189 virtual void clicked(int id);
190 private slots:
191 void enableFeb29();
192 private:
193 CheckBox* mMonthBox[12];
194 TQLabel* mFeb29Label;
195 ComboBox* mFeb29Combo;
196 // Saved state of all controls
197 TQValueList<int> mSavedMonths; // ticked months for yearly rule
198 int mSavedFeb29Type; // February 29th recurrence type
199};
200
201#endif // RECURRENCEEDITPRIVATE_H