Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 94 |
1 files changed, 51 insertions, 43 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index e0380c4..e0ae3a0 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -1,1067 +1,1075 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <q3filedialog.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <q3vbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <q3buttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <q3vgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <q3widgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qlistbox.h> | 32 | #include <q3listbox.h> |
33 | #include <qspinbox.h> | 33 | #include <qspinbox.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <QDesktopWidget> | ||
37 | //Added by qt3to4: | ||
38 | #include <Q3HBoxLayout> | ||
39 | #include <QLabel> | ||
40 | #include <Q3GridLayout> | ||
41 | #include <Q3PtrList> | ||
42 | #include <Q3Frame> | ||
43 | #include <Q3VBoxLayout> | ||
36 | 44 | ||
37 | #include <kdialog.h> | 45 | #include <kdialog.h> |
38 | #include <kglobal.h> | 46 | #include <kglobal.h> |
39 | #include <klocale.h> | 47 | #include <klocale.h> |
40 | #include <kiconloader.h> | 48 | #include <kiconloader.h> |
41 | #include <kdebug.h> | 49 | #include <kdebug.h> |
42 | #include <knumvalidator.h> | 50 | #include <knumvalidator.h> |
43 | 51 | ||
44 | #include <libkcal/event.h> | 52 | #include <libkcal/event.h> |
45 | #include <libkcal/todo.h> | 53 | #include <libkcal/todo.h> |
46 | 54 | ||
47 | #include <libkdepim/kdateedit.h> | 55 | #include <libkdepim/kdateedit.h> |
48 | 56 | ||
49 | #include "koprefs.h" | 57 | #include "koprefs.h" |
50 | 58 | ||
51 | #include "koeditorrecurrence.h" | 59 | #include "koeditorrecurrence.h" |
52 | 60 | ||
53 | /////////////////////////// RecurBase /////////////////////////////// | 61 | /////////////////////////// RecurBase /////////////////////////////// |
54 | 62 | ||
55 | RecurBase::RecurBase( QWidget *parent, const char *name ) : | 63 | RecurBase::RecurBase( QWidget *parent, const char *name ) : |
56 | QWidget( parent, name ) | 64 | QWidget( parent, name ) |
57 | { | 65 | { |
58 | mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); | 66 | mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); |
59 | mFrequencyEdit->setValue( 1 ); | 67 | mFrequencyEdit->setValue( 1 ); |
60 | } | 68 | } |
61 | 69 | ||
62 | QWidget *RecurBase::frequencyEdit() | 70 | QWidget *RecurBase::frequencyEdit() |
63 | { | 71 | { |
64 | return mFrequencyEdit; | 72 | return mFrequencyEdit; |
65 | } | 73 | } |
66 | 74 | ||
67 | void RecurBase::setFrequency( int f ) | 75 | void RecurBase::setFrequency( int f ) |
68 | { | 76 | { |
69 | if ( f < 1 ) f = 1; | 77 | if ( f < 1 ) f = 1; |
70 | 78 | ||
71 | mFrequencyEdit->setValue( f ); | 79 | mFrequencyEdit->setValue( f ); |
72 | } | 80 | } |
73 | 81 | ||
74 | int RecurBase::frequency() | 82 | int RecurBase::frequency() |
75 | { | 83 | { |
76 | return mFrequencyEdit->value(); | 84 | return mFrequencyEdit->value(); |
77 | } | 85 | } |
78 | 86 | ||
79 | /////////////////////////// RecurDaily /////////////////////////////// | 87 | /////////////////////////// RecurDaily /////////////////////////////// |
80 | 88 | ||
81 | RecurDaily::RecurDaily( QWidget *parent, const char *name ) : | 89 | RecurDaily::RecurDaily( QWidget *parent, const char *name ) : |
82 | RecurBase( parent, name ) | 90 | RecurBase( parent, name ) |
83 | { | 91 | { |
84 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 92 | Q3BoxLayout *topLayout = new Q3HBoxLayout( this ); |
85 | topLayout->setSpacing( KDialog::spacingHint() ); | 93 | topLayout->setSpacing( KDialog::spacingHint() ); |
86 | topLayout->setMargin( KDialog::marginHintSmall() ); | 94 | topLayout->setMargin( KDialog::marginHintSmall() ); |
87 | 95 | ||
88 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); | 96 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); |
89 | topLayout->addWidget( preLabel ); | 97 | topLayout->addWidget( preLabel ); |
90 | 98 | ||
91 | topLayout->addWidget( frequencyEdit() ); | 99 | topLayout->addWidget( frequencyEdit() ); |
92 | 100 | ||
93 | QLabel *postLabel = new QLabel( i18n("day(s)"), this ); | 101 | QLabel *postLabel = new QLabel( i18n("day(s)"), this ); |
94 | topLayout->addWidget( postLabel ); | 102 | topLayout->addWidget( postLabel ); |
95 | } | 103 | } |
96 | 104 | ||
97 | 105 | ||
98 | /////////////////////////// RecurWeekly /////////////////////////////// | 106 | /////////////////////////// RecurWeekly /////////////////////////////// |
99 | 107 | ||
100 | RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : | 108 | RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : |
101 | RecurBase( parent, name ) | 109 | RecurBase( parent, name ) |
102 | { | 110 | { |
103 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 111 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
104 | topLayout->setSpacing( KDialog::spacingHint() ); | 112 | topLayout->setSpacing( KDialog::spacingHint() ); |
105 | topLayout->setMargin( KDialog::marginHintSmall() ); | 113 | topLayout->setMargin( KDialog::marginHintSmall() ); |
106 | 114 | ||
107 | //topLayout->addStretch( 1 ); | 115 | //topLayout->addStretch( 1 ); |
108 | 116 | ||
109 | QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); | 117 | Q3BoxLayout *weeksLayout = new Q3HBoxLayout( topLayout ); |
110 | 118 | ||
111 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); | 119 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); |
112 | weeksLayout->addWidget( preLabel ); | 120 | weeksLayout->addWidget( preLabel ); |
113 | 121 | ||
114 | weeksLayout->addWidget( frequencyEdit() ); | 122 | weeksLayout->addWidget( frequencyEdit() ); |
115 | 123 | ||
116 | QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); | 124 | QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); |
117 | weeksLayout->addWidget( postLabel ); | 125 | weeksLayout->addWidget( postLabel ); |
118 | 126 | ||
119 | QHBox *dayBox = new QHBox( this ); | 127 | Q3HBox *dayBox = new Q3HBox( this ); |
120 | topLayout->addWidget( dayBox, 1, AlignVCenter ); | 128 | topLayout->addWidget( dayBox, 1, Qt::AlignVCenter ); |
121 | // TODO: Respect start of week setting | 129 | // TODO: Respect start of week setting |
122 | for ( int i = 0; i < 7; ++i ) { | 130 | for ( int i = 0; i < 7; ++i ) { |
123 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); | 131 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); |
124 | int left = 1; | 132 | int left = 1; |
125 | if ( QApplication::desktop()->width() > 480 ) { | 133 | if ( QApplication::desktop()->width() > 480 ) { |
126 | ++left; | 134 | ++left; |
127 | if ( QApplication::desktop()->width() > 640 ) | 135 | if ( QApplication::desktop()->width() > 640 ) |
128 | ++left; | 136 | ++left; |
129 | } | 137 | } |
130 | mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); | 138 | mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); |
131 | } | 139 | } |
132 | 140 | ||
133 | topLayout->addStretch( ); | 141 | topLayout->addStretch( ); |
134 | } | 142 | } |
135 | 143 | ||
136 | void RecurWeekly::setDays( const QBitArray &days ) | 144 | void RecurWeekly::setDays( const QBitArray &days ) |
137 | { | 145 | { |
138 | for ( int i = 0; i < 7; ++i ) { | 146 | for ( int i = 0; i < 7; ++i ) { |
139 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); | 147 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); |
140 | } | 148 | } |
141 | } | 149 | } |
142 | 150 | ||
143 | QBitArray RecurWeekly::days() | 151 | QBitArray RecurWeekly::days() |
144 | { | 152 | { |
145 | QBitArray days( 7 ); | 153 | QBitArray days( 7 ); |
146 | 154 | ||
147 | for ( int i = 0; i < 7; ++i ) { | 155 | for ( int i = 0; i < 7; ++i ) { |
148 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); | 156 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); |
149 | } | 157 | } |
150 | 158 | ||
151 | return days; | 159 | return days; |
152 | } | 160 | } |
153 | 161 | ||
154 | /////////////////////////// RecurMonthly /////////////////////////////// | 162 | /////////////////////////// RecurMonthly /////////////////////////////// |
155 | 163 | ||
156 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : | 164 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : |
157 | RecurBase( parent, name ) | 165 | RecurBase( parent, name ) |
158 | { | 166 | { |
159 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 167 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
160 | topLayout->setSpacing( KDialog::spacingHint() ); | 168 | topLayout->setSpacing( KDialog::spacingHint() ); |
161 | topLayout->setMargin( KDialog::marginHintSmall() ); | 169 | topLayout->setMargin( KDialog::marginHintSmall() ); |
162 | 170 | ||
163 | 171 | ||
164 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 172 | Q3BoxLayout *freqLayout = new Q3HBoxLayout( topLayout ); |
165 | 173 | ||
166 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 174 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
167 | freqLayout->addWidget( preLabel ); | 175 | freqLayout->addWidget( preLabel ); |
168 | 176 | ||
169 | freqLayout->addWidget( frequencyEdit() ); | 177 | freqLayout->addWidget( frequencyEdit() ); |
170 | 178 | ||
171 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); | 179 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); |
172 | freqLayout->addWidget( postLabel ); | 180 | freqLayout->addWidget( postLabel ); |
173 | 181 | ||
174 | 182 | ||
175 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 183 | Q3ButtonGroup *buttonGroup = new Q3ButtonGroup( this ); |
176 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 184 | buttonGroup->setFrameStyle( Q3Frame::NoFrame ); |
177 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 185 | topLayout->addWidget( buttonGroup, 1, Qt::AlignVCenter ); |
178 | 186 | ||
179 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 187 | Q3GridLayout *buttonLayout = new Q3GridLayout( buttonGroup, 3, 2 ); |
180 | buttonLayout->setSpacing( KDialog::spacingHint() ); | 188 | buttonLayout->setSpacing( KDialog::spacingHint() ); |
181 | buttonLayout->setMargin( KDialog::marginHintSmall() ); | 189 | buttonLayout->setMargin( KDialog::marginHintSmall() ); |
182 | 190 | ||
183 | 191 | ||
184 | QString recurOnText; | 192 | QString recurOnText; |
185 | if ( QApplication::desktop()->width() > 320 ) { | 193 | if ( QApplication::desktop()->width() > 320 ) { |
186 | recurOnText = i18n("Recur on the"); | 194 | recurOnText = i18n("Recur on the"); |
187 | } | 195 | } |
188 | 196 | ||
189 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); | 197 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); |
190 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); | 198 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); |
191 | 199 | ||
192 | mByDayCombo = new QComboBox( buttonGroup ); | 200 | mByDayCombo = new Q3ComboBox( buttonGroup ); |
193 | mByDayCombo->setSizeLimit( 7 ); | 201 | mByDayCombo->setSizeLimit( 7 ); |
194 | mByDayCombo->insertItem( i18n("1st") ); | 202 | mByDayCombo->insertItem( i18n("1st") ); |
195 | mByDayCombo->insertItem( i18n("2nd") ); | 203 | mByDayCombo->insertItem( i18n("2nd") ); |
196 | mByDayCombo->insertItem( i18n("3rd") ); | 204 | mByDayCombo->insertItem( i18n("3rd") ); |
197 | mByDayCombo->insertItem( i18n("4th") ); | 205 | mByDayCombo->insertItem( i18n("4th") ); |
198 | mByDayCombo->insertItem( i18n("5th") ); | 206 | mByDayCombo->insertItem( i18n("5th") ); |
199 | mByDayCombo->insertItem( i18n("6th") ); | 207 | mByDayCombo->insertItem( i18n("6th") ); |
200 | mByDayCombo->insertItem( i18n("7th") ); | 208 | mByDayCombo->insertItem( i18n("7th") ); |
201 | mByDayCombo->insertItem( i18n("8th") ); | 209 | mByDayCombo->insertItem( i18n("8th") ); |
202 | mByDayCombo->insertItem( i18n("9th") ); | 210 | mByDayCombo->insertItem( i18n("9th") ); |
203 | mByDayCombo->insertItem( i18n("10th") ); | 211 | mByDayCombo->insertItem( i18n("10th") ); |
204 | mByDayCombo->insertItem( i18n("11th") ); | 212 | mByDayCombo->insertItem( i18n("11th") ); |
205 | mByDayCombo->insertItem( i18n("12th") ); | 213 | mByDayCombo->insertItem( i18n("12th") ); |
206 | mByDayCombo->insertItem( i18n("13th") ); | 214 | mByDayCombo->insertItem( i18n("13th") ); |
207 | mByDayCombo->insertItem( i18n("14th") ); | 215 | mByDayCombo->insertItem( i18n("14th") ); |
208 | mByDayCombo->insertItem( i18n("15th") ); | 216 | mByDayCombo->insertItem( i18n("15th") ); |
209 | mByDayCombo->insertItem( i18n("16th") ); | 217 | mByDayCombo->insertItem( i18n("16th") ); |
210 | mByDayCombo->insertItem( i18n("17th") ); | 218 | mByDayCombo->insertItem( i18n("17th") ); |
211 | mByDayCombo->insertItem( i18n("18th") ); | 219 | mByDayCombo->insertItem( i18n("18th") ); |
212 | mByDayCombo->insertItem( i18n("19th") ); | 220 | mByDayCombo->insertItem( i18n("19th") ); |
213 | mByDayCombo->insertItem( i18n("20th") ); | 221 | mByDayCombo->insertItem( i18n("20th") ); |
214 | mByDayCombo->insertItem( i18n("21st") ); | 222 | mByDayCombo->insertItem( i18n("21st") ); |
215 | mByDayCombo->insertItem( i18n("22nd") ); | 223 | mByDayCombo->insertItem( i18n("22nd") ); |
216 | mByDayCombo->insertItem( i18n("23rd") ); | 224 | mByDayCombo->insertItem( i18n("23rd") ); |
217 | mByDayCombo->insertItem( i18n("24th") ); | 225 | mByDayCombo->insertItem( i18n("24th") ); |
218 | mByDayCombo->insertItem( i18n("25th") ); | 226 | mByDayCombo->insertItem( i18n("25th") ); |
219 | mByDayCombo->insertItem( i18n("26th") ); | 227 | mByDayCombo->insertItem( i18n("26th") ); |
220 | mByDayCombo->insertItem( i18n("27th") ); | 228 | mByDayCombo->insertItem( i18n("27th") ); |
221 | mByDayCombo->insertItem( i18n("28th") ); | 229 | mByDayCombo->insertItem( i18n("28th") ); |
222 | mByDayCombo->insertItem( i18n("29th") ); | 230 | mByDayCombo->insertItem( i18n("29th") ); |
223 | mByDayCombo->insertItem( i18n("30th") ); | 231 | mByDayCombo->insertItem( i18n("30th") ); |
224 | mByDayCombo->insertItem( i18n("31st") ); | 232 | mByDayCombo->insertItem( i18n("31st") ); |
225 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); | 233 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); |
226 | 234 | ||
227 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); | 235 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); |
228 | buttonLayout->addWidget( byDayLabel, 0, 2 ); | 236 | buttonLayout->addWidget( byDayLabel, 0, 2 ); |
229 | 237 | ||
230 | 238 | ||
231 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); | 239 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); |
232 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); | 240 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); |
233 | 241 | ||
234 | mByPosCountCombo = new QComboBox( buttonGroup ); | 242 | mByPosCountCombo = new QComboBox( buttonGroup ); |
235 | mByPosCountCombo->insertItem( i18n("1st") ); | 243 | mByPosCountCombo->insertItem( i18n("1st") ); |
236 | mByPosCountCombo->insertItem( i18n("2nd") ); | 244 | mByPosCountCombo->insertItem( i18n("2nd") ); |
237 | mByPosCountCombo->insertItem( i18n("3rd") ); | 245 | mByPosCountCombo->insertItem( i18n("3rd") ); |
238 | mByPosCountCombo->insertItem( i18n("4th") ); | 246 | mByPosCountCombo->insertItem( i18n("4th") ); |
239 | mByPosCountCombo->insertItem( i18n("5th") ); | 247 | mByPosCountCombo->insertItem( i18n("5th") ); |
240 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); | 248 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); |
241 | 249 | ||
242 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); | 250 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); |
243 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); | 251 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); |
244 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); | 252 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); |
245 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); | 253 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); |
246 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); | 254 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); |
247 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); | 255 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); |
248 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); | 256 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); |
249 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); | 257 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); |
250 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); | 258 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); |
251 | } | 259 | } |
252 | 260 | ||
253 | void RecurMonthly::setByDay( int day ) | 261 | void RecurMonthly::setByDay( int day ) |
254 | { | 262 | { |
255 | mByDayRadio->setChecked( true ); | 263 | mByDayRadio->setChecked( true ); |
256 | mByDayCombo->setCurrentItem( day ); | 264 | mByDayCombo->setCurrentItem( day ); |
257 | } | 265 | } |
258 | 266 | ||
259 | void RecurMonthly::setByPos( int count, int weekday ) | 267 | void RecurMonthly::setByPos( int count, int weekday ) |
260 | { | 268 | { |
261 | mByPosRadio->setChecked( true ); | 269 | mByPosRadio->setChecked( true ); |
262 | mByPosCountCombo->setCurrentItem( count ); | 270 | mByPosCountCombo->setCurrentItem( count ); |
263 | mByPosWeekdayCombo->setCurrentItem( weekday ); | 271 | mByPosWeekdayCombo->setCurrentItem( weekday ); |
264 | } | 272 | } |
265 | 273 | ||
266 | bool RecurMonthly::byDay() | 274 | bool RecurMonthly::byDay() |
267 | { | 275 | { |
268 | return mByDayRadio->isChecked(); | 276 | return mByDayRadio->isChecked(); |
269 | } | 277 | } |
270 | 278 | ||
271 | bool RecurMonthly::byPos() | 279 | bool RecurMonthly::byPos() |
272 | { | 280 | { |
273 | return mByPosRadio->isChecked(); | 281 | return mByPosRadio->isChecked(); |
274 | } | 282 | } |
275 | 283 | ||
276 | int RecurMonthly::day() | 284 | int RecurMonthly::day() |
277 | { | 285 | { |
278 | return mByDayCombo->currentItem() + 1; | 286 | return mByDayCombo->currentItem() + 1; |
279 | } | 287 | } |
280 | 288 | ||
281 | int RecurMonthly::count() | 289 | int RecurMonthly::count() |
282 | { | 290 | { |
283 | return mByPosCountCombo->currentItem() + 1; | 291 | return mByPosCountCombo->currentItem() + 1; |
284 | } | 292 | } |
285 | 293 | ||
286 | int RecurMonthly::weekday() | 294 | int RecurMonthly::weekday() |
287 | { | 295 | { |
288 | return mByPosWeekdayCombo->currentItem(); | 296 | return mByPosWeekdayCombo->currentItem(); |
289 | } | 297 | } |
290 | 298 | ||
291 | /////////////////////////// RecurYearly /////////////////////////////// | 299 | /////////////////////////// RecurYearly /////////////////////////////// |
292 | 300 | ||
293 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | 301 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : |
294 | RecurBase( parent, name ) | 302 | RecurBase( parent, name ) |
295 | { | 303 | { |
296 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 304 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
297 | topLayout->setSpacing( KDialog::spacingHint() ); | 305 | topLayout->setSpacing( KDialog::spacingHint() ); |
298 | topLayout->setMargin( KDialog::marginHintSmall() ); | 306 | topLayout->setMargin( KDialog::marginHintSmall() ); |
299 | 307 | ||
300 | 308 | ||
301 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 309 | Q3BoxLayout *freqLayout = new Q3HBoxLayout( topLayout ); |
302 | 310 | ||
303 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 311 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
304 | freqLayout->addWidget( preLabel ); | 312 | freqLayout->addWidget( preLabel ); |
305 | 313 | ||
306 | freqLayout->addWidget( frequencyEdit() ); | 314 | freqLayout->addWidget( frequencyEdit() ); |
307 | 315 | ||
308 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); | 316 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); |
309 | freqLayout->addWidget( postLabel ); | 317 | freqLayout->addWidget( postLabel ); |
310 | 318 | ||
311 | 319 | ||
312 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 320 | Q3ButtonGroup *buttonGroup = new Q3ButtonGroup( this ); |
313 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 321 | buttonGroup->setFrameStyle( Q3Frame::NoFrame ); |
314 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 322 | topLayout->addWidget( buttonGroup, 1, Qt::AlignVCenter ); |
315 | 323 | ||
316 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); | 324 | Q3GridLayout *buttonLayout = new Q3GridLayout( buttonGroup, 2, 3 ); |
317 | 325 | ||
318 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); | 326 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); |
319 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); | 327 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); |
320 | mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); | 328 | mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); |
321 | 329 | ||
322 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); | 330 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); |
323 | mByMonthCombo = new QComboBox( buttonGroup ); | 331 | mByMonthCombo = new Q3ComboBox( buttonGroup ); |
324 | mByMonthCombo->insertItem( i18n("January") ); | 332 | mByMonthCombo->insertItem( i18n("January") ); |
325 | mByMonthCombo->insertItem( i18n("February") ); | 333 | mByMonthCombo->insertItem( i18n("February") ); |
326 | mByMonthCombo->insertItem( i18n("March") ); | 334 | mByMonthCombo->insertItem( i18n("March") ); |
327 | mByMonthCombo->insertItem( i18n("April") ); | 335 | mByMonthCombo->insertItem( i18n("April") ); |
328 | mByMonthCombo->insertItem( i18n("May") ); | 336 | mByMonthCombo->insertItem( i18n("May") ); |
329 | mByMonthCombo->insertItem( i18n("June") ); | 337 | mByMonthCombo->insertItem( i18n("June") ); |
330 | mByMonthCombo->insertItem( i18n("July") ); | 338 | mByMonthCombo->insertItem( i18n("July") ); |
331 | mByMonthCombo->insertItem( i18n("August") ); | 339 | mByMonthCombo->insertItem( i18n("August") ); |
332 | mByMonthCombo->insertItem( i18n("September") ); | 340 | mByMonthCombo->insertItem( i18n("September") ); |
333 | mByMonthCombo->insertItem( i18n("October") ); | 341 | mByMonthCombo->insertItem( i18n("October") ); |
334 | mByMonthCombo->insertItem( i18n("November") ); | 342 | mByMonthCombo->insertItem( i18n("November") ); |
335 | mByMonthCombo->insertItem( i18n("December") ); | 343 | mByMonthCombo->insertItem( i18n("December") ); |
336 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); | 344 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); |
337 | if ( QApplication::desktop()->width() <= 640 ) { | 345 | if ( QApplication::desktop()->width() <= 640 ) { |
338 | mByMonthCombo->setSizeLimit( 6 ); | 346 | mByMonthCombo->setSizeLimit( 6 ); |
339 | } | 347 | } |
340 | 348 | ||
341 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); | 349 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); |
342 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); | 350 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); |
343 | mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup ); | 351 | mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup ); |
344 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); | 352 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); |
345 | 353 | ||
346 | } | 354 | } |
347 | 355 | ||
348 | void RecurYearly::setByDay( int doy ) | 356 | void RecurYearly::setByDay( int doy ) |
349 | { | 357 | { |
350 | mByDayRadio->setChecked( true ); | 358 | mByDayRadio->setChecked( true ); |
351 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); | 359 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); |
352 | } | 360 | } |
353 | 361 | ||
354 | void RecurYearly::setByMonth( int month, int day ) | 362 | void RecurYearly::setByMonth( int month, int day ) |
355 | { | 363 | { |
356 | mByMonthRadio->setChecked( true ); | 364 | mByMonthRadio->setChecked( true ); |
357 | mByMonthCombo->setCurrentItem( month - 1 ); | 365 | mByMonthCombo->setCurrentItem( month - 1 ); |
358 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); | 366 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); |
359 | mDay = day; | 367 | mDay = day; |
360 | } | 368 | } |
361 | 369 | ||
362 | bool RecurYearly::byMonth() | 370 | bool RecurYearly::byMonth() |
363 | { | 371 | { |
364 | return mByMonthRadio->isChecked(); | 372 | return mByMonthRadio->isChecked(); |
365 | } | 373 | } |
366 | 374 | ||
367 | bool RecurYearly::byDay() | 375 | bool RecurYearly::byDay() |
368 | { | 376 | { |
369 | return mByDayRadio->isChecked(); | 377 | return mByDayRadio->isChecked(); |
370 | } | 378 | } |
371 | 379 | ||
372 | int RecurYearly::month() | 380 | int RecurYearly::month() |
373 | { | 381 | { |
374 | return mByMonthCombo->currentItem() + 1; | 382 | return mByMonthCombo->currentItem() + 1; |
375 | } | 383 | } |
376 | int RecurYearly::day() | 384 | int RecurYearly::day() |
377 | { | 385 | { |
378 | return mDay;//mByDayCombo->currentItem() + 1; | 386 | return mDay;//mByDayCombo->currentItem() + 1; |
379 | } | 387 | } |
380 | 388 | ||
381 | //////////////////////////// ExceptionsWidget ////////////////////////// | 389 | //////////////////////////// ExceptionsWidget ////////////////////////// |
382 | 390 | ||
383 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : | 391 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : |
384 | QWidget( parent, name ) | 392 | QWidget( parent, name ) |
385 | { | 393 | { |
386 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 394 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
387 | 395 | ||
388 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), | 396 | Q3GroupBox *groupBox = new Q3GroupBox( 1, Qt::Horizontal, i18n("Exceptions"), |
389 | this ); | 397 | this ); |
390 | topLayout->addWidget( groupBox ); | 398 | topLayout->addWidget( groupBox ); |
391 | 399 | ||
392 | QWidget *box = new QWidget( groupBox ); | 400 | QWidget *box = new QWidget( groupBox ); |
393 | 401 | ||
394 | QGridLayout *boxLayout = new QGridLayout( box ); | 402 | Q3GridLayout *boxLayout = new Q3GridLayout( box ); |
395 | 403 | ||
396 | mExceptionDateEdit = new KDateEdit( box ); | 404 | mExceptionDateEdit = new KDateEdit( box ); |
397 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); | 405 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); |
398 | 406 | ||
399 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); | 407 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); |
400 | boxLayout->addWidget( addExceptionButton, 1, 0 ); | 408 | boxLayout->addWidget( addExceptionButton, 1, 0 ); |
401 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); | 409 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); |
402 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); | 410 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); |
403 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); | 411 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); |
404 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); | 412 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); |
405 | 413 | ||
406 | mExceptionList = new QListBox( box ); | 414 | mExceptionList = new Q3ListBox( box ); |
407 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); | 415 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); |
408 | 416 | ||
409 | boxLayout->setRowStretch( 4, 1 ); | 417 | boxLayout->setRowStretch( 4, 1 ); |
410 | boxLayout->setColStretch( 1, 3 ); | 418 | boxLayout->setColStretch( 1, 3 ); |
411 | 419 | ||
412 | connect( addExceptionButton, SIGNAL( clicked() ), | 420 | connect( addExceptionButton, SIGNAL( clicked() ), |
413 | SLOT( addException() ) ); | 421 | SLOT( addException() ) ); |
414 | connect( changeExceptionButton, SIGNAL( clicked() ), | 422 | connect( changeExceptionButton, SIGNAL( clicked() ), |
415 | SLOT( changeException() ) ); | 423 | SLOT( changeException() ) ); |
416 | connect( deleteExceptionButton, SIGNAL( clicked() ), | 424 | connect( deleteExceptionButton, SIGNAL( clicked() ), |
417 | SLOT( deleteException() ) ); | 425 | SLOT( deleteException() ) ); |
418 | if ( QApplication::desktop()->width() < 480 ) { | 426 | if ( QApplication::desktop()->width() < 480 ) { |
419 | setMinimumWidth( 220 ); | 427 | setMinimumWidth( 220 ); |
420 | } else { | 428 | } else { |
421 | setMinimumWidth( 440 ); | 429 | setMinimumWidth( 440 ); |
422 | mExceptionDateEdit->setMinimumWidth( 200 ); | 430 | mExceptionDateEdit->setMinimumWidth( 200 ); |
423 | } | 431 | } |
424 | } | 432 | } |
425 | 433 | ||
426 | void ExceptionsWidget::setDefaults( const QDateTime &from ) | 434 | void ExceptionsWidget::setDefaults( const QDateTime &from ) |
427 | { | 435 | { |
428 | mExceptionList->clear(); | 436 | mExceptionList->clear(); |
429 | mExceptionDates.clear(); | 437 | mExceptionDates.clear(); |
430 | mExceptionDateEdit->setDate( from.date() ); | 438 | mExceptionDateEdit->setDate( from.date() ); |
431 | } | 439 | } |
432 | 440 | ||
433 | void ExceptionsWidget::addException() | 441 | void ExceptionsWidget::addException() |
434 | { | 442 | { |
435 | QDate date = mExceptionDateEdit->date(); | 443 | QDate date = mExceptionDateEdit->date(); |
436 | QString dateStr = KGlobal::locale()->formatDate( date ); | 444 | QString dateStr = KGlobal::locale()->formatDate( date ); |
437 | if( !mExceptionList->findItem( dateStr ) ) { | 445 | if( !mExceptionList->findItem( dateStr ) ) { |
438 | mExceptionDates.append( date ); | 446 | mExceptionDates.append( date ); |
439 | mExceptionList->insertItem( dateStr ); | 447 | mExceptionList->insertItem( dateStr ); |
440 | } | 448 | } |
441 | } | 449 | } |
442 | 450 | ||
443 | void ExceptionsWidget::changeException() | 451 | void ExceptionsWidget::changeException() |
444 | { | 452 | { |
445 | int pos = mExceptionList->currentItem(); | 453 | int pos = mExceptionList->currentItem(); |
446 | if ( pos < 0 ) return; | 454 | if ( pos < 0 ) return; |
447 | 455 | ||
448 | QDate date = mExceptionDateEdit->date(); | 456 | QDate date = mExceptionDateEdit->date(); |
449 | mExceptionDates[ pos ] = date; | 457 | mExceptionDates[ pos ] = date; |
450 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); | 458 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); |
451 | } | 459 | } |
452 | 460 | ||
453 | void ExceptionsWidget::deleteException() | 461 | void ExceptionsWidget::deleteException() |
454 | { | 462 | { |
455 | int pos = mExceptionList->currentItem(); | 463 | int pos = mExceptionList->currentItem(); |
456 | if ( pos < 0 ) return; | 464 | if ( pos < 0 ) return; |
457 | 465 | ||
458 | mExceptionDates.remove( mExceptionDates.at( pos ) ); | 466 | mExceptionDates.remove( mExceptionDates.at( pos ) ); |
459 | mExceptionList->removeItem( pos ); | 467 | mExceptionList->removeItem( pos ); |
460 | } | 468 | } |
461 | 469 | ||
462 | void ExceptionsWidget::setDates( const DateList &dates ) | 470 | void ExceptionsWidget::setDates( const DateList &dates ) |
463 | { | 471 | { |
464 | mExceptionList->clear(); | 472 | mExceptionList->clear(); |
465 | mExceptionDates.clear(); | 473 | mExceptionDates.clear(); |
466 | DateList::ConstIterator dit; | 474 | DateList::ConstIterator dit; |
467 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { | 475 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { |
468 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); | 476 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); |
469 | mExceptionDates.append( *dit ); | 477 | mExceptionDates.append( *dit ); |
470 | } | 478 | } |
471 | } | 479 | } |
472 | 480 | ||
473 | DateList ExceptionsWidget::dates() | 481 | DateList ExceptionsWidget::dates() |
474 | { | 482 | { |
475 | return mExceptionDates; | 483 | return mExceptionDates; |
476 | } | 484 | } |
477 | 485 | ||
478 | ///////////////////////// ExceptionsDialog /////////////////////////// | 486 | ///////////////////////// ExceptionsDialog /////////////////////////// |
479 | 487 | ||
480 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : | 488 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : |
481 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) | 489 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) |
482 | { | 490 | { |
483 | mExceptions = new ExceptionsWidget( this ); | 491 | mExceptions = new ExceptionsWidget( this ); |
484 | setMainWidget( mExceptions ); | 492 | setMainWidget( mExceptions ); |
485 | resize(220,10); | 493 | resize(220,10); |
486 | } | 494 | } |
487 | 495 | ||
488 | void ExceptionsDialog::setDefaults( const QDateTime &from ) | 496 | void ExceptionsDialog::setDefaults( const QDateTime &from ) |
489 | { | 497 | { |
490 | mExceptions->setDefaults( from ); | 498 | mExceptions->setDefaults( from ); |
491 | } | 499 | } |
492 | 500 | ||
493 | void ExceptionsDialog::setDates( const DateList &dates ) | 501 | void ExceptionsDialog::setDates( const DateList &dates ) |
494 | { | 502 | { |
495 | mExceptions->setDates( dates ); | 503 | mExceptions->setDates( dates ); |
496 | } | 504 | } |
497 | 505 | ||
498 | DateList ExceptionsDialog::dates() | 506 | DateList ExceptionsDialog::dates() |
499 | { | 507 | { |
500 | return mExceptions->dates(); | 508 | return mExceptions->dates(); |
501 | } | 509 | } |
502 | 510 | ||
503 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// | 511 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// |
504 | 512 | ||
505 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | 513 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, |
506 | const char *name ) | 514 | const char *name ) |
507 | : QWidget( parent, name ) | 515 | : QWidget( parent, name ) |
508 | { | 516 | { |
509 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 517 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
510 | 518 | ||
511 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), | 519 | mRangeGroupBox = new Q3GroupBox( 1, Qt::Horizontal, i18n("Recurrence Range"), |
512 | this ); | 520 | this ); |
513 | topLayout->addWidget( mRangeGroupBox ); | 521 | topLayout->addWidget( mRangeGroupBox ); |
514 | 522 | ||
515 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); | 523 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); |
516 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); | 524 | Q3VBoxLayout *rangeLayout = new Q3VBoxLayout( rangeBox ); |
517 | rangeLayout->setSpacing( KDialog::spacingHint() ); | 525 | rangeLayout->setSpacing( KDialog::spacingHint() ); |
518 | rangeLayout->setMargin( KDialog::marginHintSmall() ); | 526 | rangeLayout->setMargin( KDialog::marginHintSmall() ); |
519 | 527 | ||
520 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); | 528 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); |
521 | rangeLayout->addWidget( mStartDateLabel ); | 529 | rangeLayout->addWidget( mStartDateLabel ); |
522 | 530 | ||
523 | mRangeButtonGroup = new QButtonGroup; | 531 | mRangeButtonGroup = new Q3ButtonGroup; |
524 | 532 | ||
525 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); | 533 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); |
526 | mRangeButtonGroup->insert( mNoEndDateButton ); | 534 | mRangeButtonGroup->insert( mNoEndDateButton ); |
527 | rangeLayout->addWidget( mNoEndDateButton ); | 535 | rangeLayout->addWidget( mNoEndDateButton ); |
528 | 536 | ||
529 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); | 537 | Q3BoxLayout *durationLayout = new Q3HBoxLayout( rangeLayout ); |
530 | durationLayout->setSpacing( KDialog::spacingHint() ); | 538 | durationLayout->setSpacing( KDialog::spacingHint() ); |
531 | 539 | ||
532 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); | 540 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); |
533 | mRangeButtonGroup->insert( mEndDurationButton ); | 541 | mRangeButtonGroup->insert( mEndDurationButton ); |
534 | durationLayout->addWidget( mEndDurationButton ); | 542 | durationLayout->addWidget( mEndDurationButton ); |
535 | 543 | ||
536 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); | 544 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); |
537 | durationLayout->addWidget( mEndDurationEdit ); | 545 | durationLayout->addWidget( mEndDurationEdit ); |
538 | 546 | ||
539 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); | 547 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); |
540 | durationLayout ->addWidget( endDurationLabel ); | 548 | durationLayout ->addWidget( endDurationLabel ); |
541 | 549 | ||
542 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); | 550 | Q3BoxLayout *endDateLayout = new Q3HBoxLayout( rangeLayout ); |
543 | endDateLayout->setSpacing( KDialog::spacingHint() ); | 551 | endDateLayout->setSpacing( KDialog::spacingHint() ); |
544 | 552 | ||
545 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); | 553 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); |
546 | mRangeButtonGroup->insert( mEndDateButton ); | 554 | mRangeButtonGroup->insert( mEndDateButton ); |
547 | endDateLayout->addWidget( mEndDateButton ); | 555 | endDateLayout->addWidget( mEndDateButton ); |
548 | 556 | ||
549 | mEndDateEdit = new KDateEdit( rangeBox ); | 557 | mEndDateEdit = new KDateEdit( rangeBox ); |
550 | endDateLayout->addWidget( mEndDateEdit ); | 558 | endDateLayout->addWidget( mEndDateEdit ); |
551 | 559 | ||
552 | //endDateLayout->addStretch( 1 ); | 560 | //endDateLayout->addStretch( 1 ); |
553 | 561 | ||
554 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), | 562 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), |
555 | SLOT( showCurrentRange() ) ); | 563 | SLOT( showCurrentRange() ) ); |
556 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), | 564 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), |
557 | SLOT( showCurrentRange() ) ); | 565 | SLOT( showCurrentRange() ) ); |
558 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), | 566 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), |
559 | SLOT( showCurrentRange() ) ); | 567 | SLOT( showCurrentRange() ) ); |
560 | } | 568 | } |
561 | 569 | ||
562 | RecurrenceRangeWidget::~RecurrenceRangeWidget() | 570 | RecurrenceRangeWidget::~RecurrenceRangeWidget() |
563 | { | 571 | { |
564 | delete mRangeButtonGroup; | 572 | delete mRangeButtonGroup; |
565 | } | 573 | } |
566 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 574 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
567 | { | 575 | { |
568 | mNoEndDateButton->setChecked( true ); | 576 | mNoEndDateButton->setChecked( true ); |
569 | 577 | ||
570 | setDateTimes( from ); | 578 | setDateTimes( from ); |
571 | mEndDateEdit->setDate( from.date() ); | 579 | mEndDateEdit->setDate( from.date() ); |
572 | } | 580 | } |
573 | 581 | ||
574 | void RecurrenceRangeWidget::setDuration( int duration ) | 582 | void RecurrenceRangeWidget::setDuration( int duration ) |
575 | { | 583 | { |
576 | if ( duration == -1 ) { | 584 | if ( duration == -1 ) { |
577 | mNoEndDateButton->setChecked( true ); | 585 | mNoEndDateButton->setChecked( true ); |
578 | } else if ( duration == 0 ) { | 586 | } else if ( duration == 0 ) { |
579 | mEndDateButton->setChecked( true ); | 587 | mEndDateButton->setChecked( true ); |
580 | } else { | 588 | } else { |
581 | mEndDurationButton->setChecked( true ); | 589 | mEndDurationButton->setChecked( true ); |
582 | mEndDurationEdit->setValue( duration ); | 590 | mEndDurationEdit->setValue( duration ); |
583 | } | 591 | } |
584 | } | 592 | } |
585 | 593 | ||
586 | int RecurrenceRangeWidget::duration() | 594 | int RecurrenceRangeWidget::duration() |
587 | { | 595 | { |
588 | if ( mNoEndDateButton->isChecked() ) { | 596 | if ( mNoEndDateButton->isChecked() ) { |
589 | return -1; | 597 | return -1; |
590 | } else if ( mEndDurationButton->isChecked() ) { | 598 | } else if ( mEndDurationButton->isChecked() ) { |
591 | return mEndDurationEdit->value(); | 599 | return mEndDurationEdit->value(); |
592 | } else { | 600 | } else { |
593 | return 0; | 601 | return 0; |
594 | } | 602 | } |
595 | } | 603 | } |
596 | 604 | ||
597 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) | 605 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) |
598 | { | 606 | { |
599 | mEndDateEdit->setDate( date ); | 607 | mEndDateEdit->setDate( date ); |
600 | } | 608 | } |
601 | 609 | ||
602 | QDate RecurrenceRangeWidget::endDate() | 610 | QDate RecurrenceRangeWidget::endDate() |
603 | { | 611 | { |
604 | return mEndDateEdit->date(); | 612 | return mEndDateEdit->date(); |
605 | } | 613 | } |
606 | 614 | ||
607 | void RecurrenceRangeWidget::showCurrentRange() | 615 | void RecurrenceRangeWidget::showCurrentRange() |
608 | { | 616 | { |
609 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); | 617 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); |
610 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); | 618 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); |
611 | } | 619 | } |
612 | 620 | ||
613 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, | 621 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, |
614 | const QDateTime & ) | 622 | const QDateTime & ) |
615 | { | 623 | { |
616 | mStartDateLabel->setText( i18n("Start date: %1") | 624 | mStartDateLabel->setText( i18n("Start date: %1") |
617 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); | 625 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); |
618 | 626 | ||
619 | if(!mEndDateButton->isChecked()) | 627 | if(!mEndDateButton->isChecked()) |
620 | mEndDateEdit->setDate( start.date() ); | 628 | mEndDateEdit->setDate( start.date() ); |
621 | } | 629 | } |
622 | 630 | ||
623 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// | 631 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// |
624 | 632 | ||
625 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, | 633 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, |
626 | const char *name ) : | 634 | const char *name ) : |
627 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) | 635 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) |
628 | { | 636 | { |
629 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 637 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
630 | setMainWidget( mRecurrenceRangeWidget ); | 638 | setMainWidget( mRecurrenceRangeWidget ); |
631 | } | 639 | } |
632 | 640 | ||
633 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) | 641 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) |
634 | { | 642 | { |
635 | mRecurrenceRangeWidget->setDefaults( from ); | 643 | mRecurrenceRangeWidget->setDefaults( from ); |
636 | } | 644 | } |
637 | 645 | ||
638 | void RecurrenceRangeDialog::setDuration( int duration ) | 646 | void RecurrenceRangeDialog::setDuration( int duration ) |
639 | { | 647 | { |
640 | mRecurrenceRangeWidget->setDuration( duration ); | 648 | mRecurrenceRangeWidget->setDuration( duration ); |
641 | } | 649 | } |
642 | 650 | ||
643 | int RecurrenceRangeDialog::duration() | 651 | int RecurrenceRangeDialog::duration() |
644 | { | 652 | { |
645 | return mRecurrenceRangeWidget->duration(); | 653 | return mRecurrenceRangeWidget->duration(); |
646 | } | 654 | } |
647 | 655 | ||
648 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) | 656 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) |
649 | { | 657 | { |
650 | mRecurrenceRangeWidget->setEndDate( date ); | 658 | mRecurrenceRangeWidget->setEndDate( date ); |
651 | } | 659 | } |
652 | 660 | ||
653 | QDate RecurrenceRangeDialog::endDate() | 661 | QDate RecurrenceRangeDialog::endDate() |
654 | { | 662 | { |
655 | return mRecurrenceRangeWidget->endDate(); | 663 | return mRecurrenceRangeWidget->endDate(); |
656 | } | 664 | } |
657 | 665 | ||
658 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, | 666 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, |
659 | const QDateTime &end ) | 667 | const QDateTime &end ) |
660 | { | 668 | { |
661 | mRecurrenceRangeWidget->setDateTimes( start, end ); | 669 | mRecurrenceRangeWidget->setDateTimes( start, end ); |
662 | } | 670 | } |
663 | 671 | ||
664 | //////////////////////////// RecurrenceChooser //////////////////////// | 672 | //////////////////////////// RecurrenceChooser //////////////////////// |
665 | 673 | ||
666 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | 674 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : |
667 | QWidget( parent, name ) | 675 | QWidget( parent, name ) |
668 | { | 676 | { |
669 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 677 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
670 | 678 | ||
671 | mTypeCombo = new QComboBox( this ); | 679 | mTypeCombo = new QComboBox( this ); |
672 | mTypeCombo->insertItem( i18n("Daily") ); | 680 | mTypeCombo->insertItem( i18n("Daily") ); |
673 | mTypeCombo->insertItem( i18n("Weekly") ); | 681 | mTypeCombo->insertItem( i18n("Weekly") ); |
674 | mTypeCombo->insertItem( i18n("Monthly") ); | 682 | mTypeCombo->insertItem( i18n("Monthly") ); |
675 | mTypeCombo->insertItem( i18n("Yearly") ); | 683 | mTypeCombo->insertItem( i18n("Yearly") ); |
676 | 684 | ||
677 | topLayout->addWidget( mTypeCombo ); | 685 | topLayout->addWidget( mTypeCombo ); |
678 | 686 | ||
679 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 687 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
680 | 688 | ||
681 | } | 689 | } |
682 | 690 | ||
683 | int RecurrenceChooser::type() | 691 | int RecurrenceChooser::type() |
684 | { | 692 | { |
685 | if ( mTypeCombo ) { | 693 | if ( mTypeCombo ) { |
686 | return mTypeCombo->currentItem(); | 694 | return mTypeCombo->currentItem(); |
687 | } else { | 695 | } else { |
688 | if ( mDailyButton->isChecked() ) return Daily; | 696 | if ( mDailyButton->isChecked() ) return Daily; |
689 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 697 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
690 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 698 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
691 | else return Yearly; | 699 | else return Yearly; |
692 | } | 700 | } |
693 | } | 701 | } |
694 | 702 | ||
695 | void RecurrenceChooser::setType( int type ) | 703 | void RecurrenceChooser::setType( int type ) |
696 | { | 704 | { |
697 | if ( mTypeCombo ) { | 705 | if ( mTypeCombo ) { |
698 | mTypeCombo->setCurrentItem( type ); | 706 | mTypeCombo->setCurrentItem( type ); |
699 | } else { | 707 | } else { |
700 | switch ( type ) { | 708 | switch ( type ) { |
701 | case Daily: | 709 | case Daily: |
702 | mDailyButton->setChecked( true ); | 710 | mDailyButton->setChecked( true ); |
703 | break; | 711 | break; |
704 | case Weekly: | 712 | case Weekly: |
705 | mWeeklyButton->setChecked( true ); | 713 | mWeeklyButton->setChecked( true ); |
706 | break; | 714 | break; |
707 | case Monthly: | 715 | case Monthly: |
708 | mMonthlyButton->setChecked( true ); | 716 | mMonthlyButton->setChecked( true ); |
709 | break; | 717 | break; |
710 | case Yearly: | 718 | case Yearly: |
711 | default: | 719 | default: |
712 | mYearlyButton->setChecked( true ); | 720 | mYearlyButton->setChecked( true ); |
713 | break; | 721 | break; |
714 | } | 722 | } |
715 | } | 723 | } |
716 | } | 724 | } |
717 | 725 | ||
718 | void RecurrenceChooser::emitChoice() | 726 | void RecurrenceChooser::emitChoice() |
719 | { | 727 | { |
720 | emit chosen ( type() ); | 728 | emit chosen ( type() ); |
721 | } | 729 | } |
722 | 730 | ||
723 | /////////////////////////////// Main Widget ///////////////////////////// | 731 | /////////////////////////////// Main Widget ///////////////////////////// |
724 | 732 | ||
725 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 733 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
726 | QWidget( parent, name ) | 734 | QWidget( parent, name ) |
727 | { | 735 | { |
728 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 736 | Q3GridLayout *topLayout = new Q3GridLayout( this, 2,2 ); |
729 | topLayout->setSpacing( KDialog::spacingHint() ); | 737 | topLayout->setSpacing( KDialog::spacingHint() ); |
730 | topLayout->setMargin( KDialog::marginHintSmall() ); | 738 | topLayout->setMargin( KDialog::marginHintSmall() ); |
731 | 739 | ||
732 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 740 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
733 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 741 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
734 | SLOT( setEnabled( bool ) ) ); | 742 | SLOT( setEnabled( bool ) ) ); |
735 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 743 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
736 | 744 | ||
737 | 745 | ||
738 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), | 746 | mTimeGroupBox = new Q3GroupBox( 1, Qt::Horizontal, i18n("Time"), |
739 | this ); | 747 | this ); |
740 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 748 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
741 | 749 | ||
742 | if ( QApplication::desktop()->width() <= 640 ) { | 750 | if ( QApplication::desktop()->width() <= 640 ) { |
743 | mTimeGroupBox->hide(); | 751 | mTimeGroupBox->hide(); |
744 | } | 752 | } |
745 | 753 | ||
746 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 754 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
747 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 755 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
748 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 756 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
749 | 757 | ||
750 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 758 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
751 | // mDateTimeLabel = new QLabel( timeFrame ); | 759 | // mDateTimeLabel = new QLabel( timeFrame ); |
752 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 760 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
753 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); | 761 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); |
754 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); | 762 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); |
755 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); | 763 | mRuleBox = new Q3GroupBox( 1, Qt::Horizontal, i18n("Recurrence Rule"), this ); |
756 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 764 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
757 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 765 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
758 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 766 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
759 | SLOT( showCurrentRule( int ) ) ); | 767 | SLOT( showCurrentRule( int ) ) ); |
760 | 768 | ||
761 | 769 | ||
762 | mRuleStack = new QWidgetStack( mRuleBox ); | 770 | mRuleStack = new Q3WidgetStack( mRuleBox ); |
763 | 771 | ||
764 | mDaily = new RecurDaily( mRuleStack ); | 772 | mDaily = new RecurDaily( mRuleStack ); |
765 | mRuleStack->addWidget( mDaily, 0 ); | 773 | mRuleStack->addWidget( mDaily, 0 ); |
766 | 774 | ||
767 | mWeekly = new RecurWeekly( mRuleStack ); | 775 | mWeekly = new RecurWeekly( mRuleStack ); |
768 | mRuleStack->addWidget( mWeekly, 0 ); | 776 | mRuleStack->addWidget( mWeekly, 0 ); |
769 | 777 | ||
770 | mMonthly = new RecurMonthly( mRuleStack ); | 778 | mMonthly = new RecurMonthly( mRuleStack ); |
771 | mRuleStack->addWidget( mMonthly, 0 ); | 779 | mRuleStack->addWidget( mMonthly, 0 ); |
772 | 780 | ||
773 | mYearly = new RecurYearly( mRuleStack ); | 781 | mYearly = new RecurYearly( mRuleStack ); |
774 | mRuleStack->addWidget( mYearly, 0 ); | 782 | mRuleStack->addWidget( mYearly, 0 ); |
775 | 783 | ||
776 | showCurrentRule( mRecurrenceChooser->type() ); | 784 | showCurrentRule( mRecurrenceChooser->type() ); |
777 | mRecurrenceRangeWidget = 0; | 785 | mRecurrenceRangeWidget = 0; |
778 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 786 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
779 | mRecurrenceRange = mRecurrenceRangeDialog; | 787 | mRecurrenceRange = mRecurrenceRangeDialog; |
780 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 788 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
781 | this ); | 789 | this ); |
782 | 790 | ||
783 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 791 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
784 | SLOT( showRecurrenceRangeDialog() ) ); | 792 | SLOT( showRecurrenceRangeDialog() ) ); |
785 | 793 | ||
786 | mExceptionsWidget = 0; | 794 | mExceptionsWidget = 0; |
787 | mExceptionsDialog = new ExceptionsDialog( this ); | 795 | mExceptionsDialog = new ExceptionsDialog( this ); |
788 | mExceptions = mExceptionsDialog; | 796 | mExceptions = mExceptionsDialog; |
789 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 797 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
790 | if ( QApplication::desktop()->width() < 320 ) { | 798 | if ( QApplication::desktop()->width() < 320 ) { |
791 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 799 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
792 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 800 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
793 | } else { | 801 | } else { |
794 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 802 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
795 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 803 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
796 | } | 804 | } |
797 | connect( mExceptionsButton, SIGNAL( clicked() ), | 805 | connect( mExceptionsButton, SIGNAL( clicked() ), |
798 | SLOT( showExceptionsDialog() ) ); | 806 | SLOT( showExceptionsDialog() ) ); |
799 | } | 807 | } |
800 | 808 | ||
801 | KOEditorRecurrence::~KOEditorRecurrence() | 809 | KOEditorRecurrence::~KOEditorRecurrence() |
802 | { | 810 | { |
803 | } | 811 | } |
804 | 812 | ||
805 | void KOEditorRecurrence::setEnabled( bool enabled ) | 813 | void KOEditorRecurrence::setEnabled( bool enabled ) |
806 | { | 814 | { |
807 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 815 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
808 | 816 | ||
809 | mTimeGroupBox->setEnabled( enabled ); | 817 | mTimeGroupBox->setEnabled( enabled ); |
810 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 818 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
811 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 819 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
812 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 820 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
813 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 821 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
814 | mRuleBox->setEnabled( enabled ); | 822 | mRuleBox->setEnabled( enabled ); |
815 | } | 823 | } |
816 | 824 | ||
817 | void KOEditorRecurrence::showCurrentRule( int current ) | 825 | void KOEditorRecurrence::showCurrentRule( int current ) |
818 | { | 826 | { |
819 | switch ( current ) { | 827 | switch ( current ) { |
820 | case Daily: | 828 | case Daily: |
821 | mRuleStack->raiseWidget( mDaily ); | 829 | mRuleStack->raiseWidget( mDaily ); |
822 | break; | 830 | break; |
823 | case Weekly: | 831 | case Weekly: |
824 | mRuleStack->raiseWidget( mWeekly ); | 832 | mRuleStack->raiseWidget( mWeekly ); |
825 | break; | 833 | break; |
826 | case Monthly: | 834 | case Monthly: |
827 | mRuleStack->raiseWidget( mMonthly ); | 835 | mRuleStack->raiseWidget( mMonthly ); |
828 | break; | 836 | break; |
829 | default: | 837 | default: |
830 | case Yearly: | 838 | case Yearly: |
831 | mRuleStack->raiseWidget( mYearly ); | 839 | mRuleStack->raiseWidget( mYearly ); |
832 | break; | 840 | break; |
833 | } | 841 | } |
834 | } | 842 | } |
835 | 843 | ||
836 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 844 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
837 | { | 845 | { |
838 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 846 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
839 | 847 | ||
840 | mRecurrenceRange->setDateTimes( start, end ); | 848 | mRecurrenceRange->setDateTimes( start, end ); |
841 | mExceptions->setDefaults( end ); | 849 | mExceptions->setDefaults( end ); |
842 | 850 | ||
843 | } | 851 | } |
844 | void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) | 852 | void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) |
845 | { | 853 | { |
846 | setDateTimes( from, to ); | 854 | setDateTimes( from, to ); |
847 | QBitArray days( 7 ); | 855 | QBitArray days( 7 ); |
848 | days.fill( 0 ); | 856 | days.fill( 0 ); |
849 | days.setBit( from.date().dayOfWeek()- 1); | 857 | days.setBit( from.date().dayOfWeek()- 1); |
850 | mWeekly->setDays( days ); | 858 | mWeekly->setDays( days ); |
851 | bool byPos = mMonthly->byPos(); | 859 | bool byPos = mMonthly->byPos(); |
852 | if ( byPos ) | 860 | if ( byPos ) |
853 | mMonthly->setByDay( from.date().day()-1 ); | 861 | mMonthly->setByDay( from.date().day()-1 ); |
854 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 862 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
855 | if ( ! byPos) | 863 | if ( ! byPos) |
856 | mMonthly->setByDay( from.date().day()-1 ); | 864 | mMonthly->setByDay( from.date().day()-1 ); |
857 | 865 | ||
858 | bool byDay = mYearly->byDay(); | 866 | bool byDay = mYearly->byDay(); |
859 | if ( ! byDay ) | 867 | if ( ! byDay ) |
860 | mYearly->setByDay( from.date().dayOfYear() ); | 868 | mYearly->setByDay( from.date().dayOfYear() ); |
861 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 869 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
862 | if ( byDay ) | 870 | if ( byDay ) |
863 | mYearly->setByDay( from.date().dayOfYear() ); | 871 | mYearly->setByDay( from.date().dayOfYear() ); |
864 | } | 872 | } |
865 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) | 873 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) |
866 | { | 874 | { |
867 | 875 | ||
868 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 876 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
869 | //setDateTimes( from, to ); | 877 | //setDateTimes( from, to ); |
870 | 878 | ||
871 | bool enabled = false; | 879 | bool enabled = false; |
872 | mEnabledCheck->setChecked( enabled ); | 880 | mEnabledCheck->setChecked( enabled ); |
873 | setEnabled( enabled ); | 881 | setEnabled( enabled ); |
874 | 882 | ||
875 | mExceptions->setDefaults( to ); | 883 | mExceptions->setDefaults( to ); |
876 | mRecurrenceRange->setDefaults( to ); | 884 | mRecurrenceRange->setDefaults( to ); |
877 | 885 | ||
878 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 886 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
879 | showCurrentRule( mRecurrenceChooser->type() ); | 887 | showCurrentRule( mRecurrenceChooser->type() ); |
880 | 888 | ||
881 | mDaily->setFrequency( 1 ); | 889 | mDaily->setFrequency( 1 ); |
882 | mWeekly->setFrequency( 1 ); | 890 | mWeekly->setFrequency( 1 ); |
883 | mMonthly->setFrequency( 1 ); | 891 | mMonthly->setFrequency( 1 ); |
884 | mYearly->setFrequency( 1 ); | 892 | mYearly->setFrequency( 1 ); |
885 | setDefaultsDates( from, to ); | 893 | setDefaultsDates( from, to ); |
886 | } | 894 | } |
887 | 895 | ||
888 | void KOEditorRecurrence::readEvent(Incidence *event) | 896 | void KOEditorRecurrence::readEvent(Incidence *event) |
889 | { | 897 | { |
890 | 898 | ||
891 | QDateTime dtEnd; | 899 | QDateTime dtEnd; |
892 | if ( event->typeID() == eventID ) | 900 | if ( event->typeID() == eventID ) |
893 | dtEnd = ((Event*)event)->dtEnd(); | 901 | dtEnd = ((Event*)event)->dtEnd(); |
894 | else | 902 | else |
895 | dtEnd = ((Todo*)event)->dtDue(); | 903 | dtEnd = ((Todo*)event)->dtDue(); |
896 | 904 | ||
897 | setDefaults( event->dtStart(), dtEnd ); | 905 | setDefaults( event->dtStart(), dtEnd ); |
898 | QBitArray rDays( 7 ); | 906 | QBitArray rDays( 7 ); |
899 | QPtrList<Recurrence::rMonthPos> rmp; | 907 | Q3PtrList<Recurrence::rMonthPos> rmp; |
900 | QPtrList<int> rmd; | 908 | Q3PtrList<int> rmd; |
901 | int day = 0; | 909 | int day = 0; |
902 | int count = 0; | 910 | int count = 0; |
903 | int month = 0; | 911 | int month = 0; |
904 | setDateTimes( event->dtStart(), dtEnd ); | 912 | setDateTimes( event->dtStart(), dtEnd ); |
905 | 913 | ||
906 | 914 | ||
907 | 915 | ||
908 | int recurs = event->doesRecur(); | 916 | int recurs = event->doesRecur(); |
909 | 917 | ||
910 | mEnabledCheck->setChecked( recurs ); | 918 | mEnabledCheck->setChecked( recurs ); |
911 | setEnabled( recurs ); | 919 | setEnabled( recurs ); |
912 | 920 | ||
913 | int recurrenceType = RecurrenceChooser::Weekly; | 921 | int recurrenceType = RecurrenceChooser::Weekly; |
914 | if ( recurs ) { | 922 | if ( recurs ) { |
915 | Recurrence *r = event->recurrence(); | 923 | Recurrence *r = event->recurrence(); |
916 | int f = r->frequency(); | 924 | int f = r->frequency(); |
917 | switch ( recurs ) { | 925 | switch ( recurs ) { |
918 | case Recurrence::rNone: | 926 | case Recurrence::rNone: |
919 | setDefaults( event->dtStart(), dtEnd ); | 927 | setDefaults( event->dtStart(), dtEnd ); |
920 | break; | 928 | break; |
921 | case Recurrence::rDaily: | 929 | case Recurrence::rDaily: |
922 | recurrenceType = RecurrenceChooser::Daily; | 930 | recurrenceType = RecurrenceChooser::Daily; |
923 | mDaily->setFrequency( f ); | 931 | mDaily->setFrequency( f ); |
924 | break; | 932 | break; |
925 | case Recurrence::rWeekly: | 933 | case Recurrence::rWeekly: |
926 | recurrenceType = RecurrenceChooser::Weekly; | 934 | recurrenceType = RecurrenceChooser::Weekly; |
927 | mWeekly->setFrequency( f ); | 935 | mWeekly->setFrequency( f ); |
928 | mWeekly->setDays( r->days() ); | 936 | mWeekly->setDays( r->days() ); |
929 | break; | 937 | break; |
930 | case Recurrence::rMonthlyPos: | 938 | case Recurrence::rMonthlyPos: |
931 | // we only handle one possibility in the list right now, | 939 | // we only handle one possibility in the list right now, |
932 | // so I have hardcoded calls with first(). If we make the GUI | 940 | // so I have hardcoded calls with first(). If we make the GUI |
933 | // more extended, this can be changed. | 941 | // more extended, this can be changed. |
934 | recurrenceType = RecurrenceChooser::Monthly; | 942 | recurrenceType = RecurrenceChooser::Monthly; |
935 | 943 | ||
936 | rmp = r->monthPositions(); | 944 | rmp = r->monthPositions(); |
937 | if ( rmp.first()->negative ) | 945 | if ( rmp.first()->negative ) |
938 | count = 5 - rmp.first()->rPos - 1; | 946 | count = 5 - rmp.first()->rPos - 1; |
939 | else | 947 | else |
940 | count = rmp.first()->rPos - 1; | 948 | count = rmp.first()->rPos - 1; |
941 | day = 0; | 949 | day = 0; |
942 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 950 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
943 | mMonthly->setByPos( count, day ); | 951 | mMonthly->setByPos( count, day ); |
944 | 952 | ||
945 | mMonthly->setFrequency( f ); | 953 | mMonthly->setFrequency( f ); |
946 | 954 | ||
947 | break; | 955 | break; |
948 | case Recurrence::rMonthlyDay: | 956 | case Recurrence::rMonthlyDay: |
949 | recurrenceType = RecurrenceChooser::Monthly; | 957 | recurrenceType = RecurrenceChooser::Monthly; |
950 | 958 | ||
951 | rmd = r->monthDays(); | 959 | rmd = r->monthDays(); |
952 | day = *rmd.first() - 1; | 960 | day = *rmd.first() - 1; |
953 | mMonthly->setByDay( day ); | 961 | mMonthly->setByDay( day ); |
954 | 962 | ||
955 | mMonthly->setFrequency( f ); | 963 | mMonthly->setFrequency( f ); |
956 | 964 | ||
957 | break; | 965 | break; |
958 | case Recurrence::rYearlyMonth: | 966 | case Recurrence::rYearlyMonth: |
959 | { | 967 | { |
960 | recurrenceType = RecurrenceChooser::Yearly; | 968 | recurrenceType = RecurrenceChooser::Yearly; |
961 | //qDebug("Recurrence::rYearlyMonth: "); | 969 | //qDebug("Recurrence::rYearlyMonth: "); |
962 | day = event->dtStart().date().day(); | 970 | day = event->dtStart().date().day(); |
963 | rmd = r->yearNums(); | 971 | rmd = r->yearNums(); |
964 | if ( rmd.count() > 0 ) | 972 | if ( rmd.count() > 0 ) |
965 | month = *rmd.first(); | 973 | month = *rmd.first(); |
966 | else | 974 | else |
967 | month = event->dtStart().date().month() ; | 975 | month = event->dtStart().date().month() ; |
968 | mYearly->setByMonth( month, day ); | 976 | mYearly->setByMonth( month, day ); |
969 | #if 0 | 977 | #if 0 |
970 | //qDebug("2day = %d ",day ); | 978 | //qDebug("2day = %d ",day ); |
971 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 979 | Q3PtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
972 | int month; | 980 | int month; |
973 | if ( !monthlist.isEmpty() ) { | 981 | if ( !monthlist.isEmpty() ) { |
974 | month = monthlist.first()->rPos ; | 982 | month = monthlist.first()->rPos ; |
975 | } else { | 983 | } else { |
976 | month = event->dtStart().date().month() ; | 984 | month = event->dtStart().date().month() ; |
977 | } | 985 | } |
978 | mYearly->setByMonth( day, month ); | 986 | mYearly->setByMonth( day, month ); |
979 | #endif | 987 | #endif |
980 | mYearly->setFrequency( f ); | 988 | mYearly->setFrequency( f ); |
981 | } | 989 | } |
982 | 990 | ||
983 | break; | 991 | break; |
984 | case Recurrence::rYearlyDay: | 992 | case Recurrence::rYearlyDay: |
985 | //qDebug("Recurrence::rYearlyDay: "); | 993 | //qDebug("Recurrence::rYearlyDay: "); |
986 | recurrenceType = RecurrenceChooser::Yearly; | 994 | recurrenceType = RecurrenceChooser::Yearly; |
987 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 995 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
988 | mYearly->setFrequency( f ); | 996 | mYearly->setFrequency( f ); |
989 | break; | 997 | break; |
990 | default: | 998 | default: |
991 | setDefaults( event->dtStart(), dtEnd ); | 999 | setDefaults( event->dtStart(), dtEnd ); |
992 | break; | 1000 | break; |
993 | } | 1001 | } |
994 | } | 1002 | } |
995 | mRecurrenceChooser->setType( recurrenceType ); | 1003 | mRecurrenceChooser->setType( recurrenceType ); |
996 | showCurrentRule( recurrenceType ); | 1004 | showCurrentRule( recurrenceType ); |
997 | 1005 | ||
998 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 1006 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
999 | 1007 | ||
1000 | if ( event->doesRecur() ) { | 1008 | if ( event->doesRecur() ) { |
1001 | Recurrence *r = event->recurrence(); | 1009 | Recurrence *r = event->recurrence(); |
1002 | mRecurrenceRange->setDuration( r->duration() ); | 1010 | mRecurrenceRange->setDuration( r->duration() ); |
1003 | if ( r->duration() == 0 ) | 1011 | if ( r->duration() == 0 ) |
1004 | { | 1012 | { |
1005 | if ( r->endDate() < event->dtStart().date() ) | 1013 | if ( r->endDate() < event->dtStart().date() ) |
1006 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1014 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1007 | else | 1015 | else |
1008 | mRecurrenceRange->setEndDate( r->endDate() ); | 1016 | mRecurrenceRange->setEndDate( r->endDate() ); |
1009 | } else | 1017 | } else |
1010 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1018 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1011 | } | 1019 | } |
1012 | 1020 | ||
1013 | mExceptions->setDates( event->exDates() ); | 1021 | mExceptions->setDates( event->exDates() ); |
1014 | } | 1022 | } |
1015 | 1023 | ||
1016 | void KOEditorRecurrence::writeEvent( Incidence *event ) | 1024 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
1017 | { | 1025 | { |
1018 | 1026 | ||
1019 | 1027 | ||
1020 | if ( !mEnabledCheck->isChecked() ) { | 1028 | if ( !mEnabledCheck->isChecked() ) { |
1021 | if ( event->doesRecur() ) | 1029 | if ( event->doesRecur() ) |
1022 | event->recurrence()->unsetRecurs(); | 1030 | event->recurrence()->unsetRecurs(); |
1023 | } else { | 1031 | } else { |
1024 | Recurrence *r = event->recurrence(); | 1032 | Recurrence *r = event->recurrence(); |
1025 | 1033 | ||
1026 | // clear out any old settings; | 1034 | // clear out any old settings; |
1027 | r->unsetRecurs(); | 1035 | r->unsetRecurs(); |
1028 | int duration = mRecurrenceRange->duration(); | 1036 | int duration = mRecurrenceRange->duration(); |
1029 | QDate endDate; | 1037 | QDate endDate; |
1030 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1038 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1031 | 1039 | ||
1032 | int recurrenceType = mRecurrenceChooser->type(); | 1040 | int recurrenceType = mRecurrenceChooser->type(); |
1033 | 1041 | ||
1034 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1042 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1035 | int freq = mDaily->frequency(); | 1043 | int freq = mDaily->frequency(); |
1036 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1044 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1037 | else r->setDaily( freq, endDate ); | 1045 | else r->setDaily( freq, endDate ); |
1038 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1046 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1039 | int freq = mWeekly->frequency(); | 1047 | int freq = mWeekly->frequency(); |
1040 | QBitArray days = mWeekly->days(); | 1048 | QBitArray days = mWeekly->days(); |
1041 | int j; | 1049 | int j; |
1042 | bool found = false; | 1050 | bool found = false; |
1043 | for (j = 0; j < 7 ; ++j ) { | 1051 | for (j = 0; j < 7 ; ++j ) { |
1044 | found |=days.at(j); | 1052 | found |=days.at(j); |
1045 | } | 1053 | } |
1046 | if ( !found ) { | 1054 | if ( !found ) { |
1047 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1055 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1048 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1056 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1049 | } | 1057 | } |
1050 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1058 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1051 | else r->setWeekly( freq, days, endDate ); | 1059 | else r->setWeekly( freq, days, endDate ); |
1052 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1060 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1053 | int freq = mMonthly->frequency(); | 1061 | int freq = mMonthly->frequency(); |
1054 | if ( mMonthly->byPos() ) { | 1062 | if ( mMonthly->byPos() ) { |
1055 | int pos = mMonthly->count(); | 1063 | int pos = mMonthly->count(); |
1056 | 1064 | ||
1057 | QBitArray days( 7 ); | 1065 | QBitArray days( 7 ); |
1058 | days.fill( false ); | 1066 | days.fill( false ); |
1059 | 1067 | ||
1060 | days.setBit( mMonthly->weekday() ); | 1068 | days.setBit( mMonthly->weekday() ); |
1061 | if ( duration != 0 ) | 1069 | if ( duration != 0 ) |
1062 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1070 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1063 | else | 1071 | else |
1064 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1072 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1065 | r->addMonthlyPos( pos, days ); | 1073 | r->addMonthlyPos( pos, days ); |
1066 | } else { | 1074 | } else { |
1067 | // it's by day | 1075 | // it's by day |