Diffstat (limited to 'korganizer/koeditorrecurrence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 125 |
1 files changed, 74 insertions, 51 deletions
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index 98356fe..ffc0fac 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -115,449 +115,448 @@ RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : | |||
115 | 115 | ||
116 | QHBox *dayBox = new QHBox( this ); | 116 | QHBox *dayBox = new QHBox( this ); |
117 | topLayout->addWidget( dayBox, 1, AlignVCenter ); | 117 | topLayout->addWidget( dayBox, 1, AlignVCenter ); |
118 | // TODO: Respect start of week setting | 118 | // TODO: Respect start of week setting |
119 | for ( int i = 0; i < 7; ++i ) { | 119 | for ( int i = 0; i < 7; ++i ) { |
120 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); | 120 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); |
121 | if ( KOPrefs::instance()->mCompactDialogs ) { | 121 | if ( KOPrefs::instance()->mCompactDialogs ) { |
122 | weekDayName = weekDayName.left( 1 ); | 122 | weekDayName = weekDayName.left( 1 ); |
123 | } | 123 | } |
124 | mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox ); | 124 | mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox ); |
125 | } | 125 | } |
126 | 126 | ||
127 | topLayout->addStretch( 1 ); | 127 | topLayout->addStretch( 1 ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void RecurWeekly::setDays( const QBitArray &days ) | 130 | void RecurWeekly::setDays( const QBitArray &days ) |
131 | { | 131 | { |
132 | for ( int i = 0; i < 7; ++i ) { | 132 | for ( int i = 0; i < 7; ++i ) { |
133 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); | 133 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | QBitArray RecurWeekly::days() | 137 | QBitArray RecurWeekly::days() |
138 | { | 138 | { |
139 | QBitArray days( 7 ); | 139 | QBitArray days( 7 ); |
140 | 140 | ||
141 | for ( int i = 0; i < 7; ++i ) { | 141 | for ( int i = 0; i < 7; ++i ) { |
142 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); | 142 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); |
143 | } | 143 | } |
144 | 144 | ||
145 | return days; | 145 | return days; |
146 | } | 146 | } |
147 | 147 | ||
148 | /////////////////////////// RecurMonthly /////////////////////////////// | 148 | /////////////////////////// RecurMonthly /////////////////////////////// |
149 | 149 | ||
150 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : | 150 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : |
151 | RecurBase( parent, name ) | 151 | RecurBase( parent, name ) |
152 | { | 152 | { |
153 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 153 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
154 | topLayout->setSpacing( KDialog::spacingHint() ); | 154 | topLayout->setSpacing( KDialog::spacingHint() ); |
155 | 155 | ||
156 | 156 | ||
157 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 157 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); |
158 | 158 | ||
159 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 159 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
160 | freqLayout->addWidget( preLabel ); | 160 | freqLayout->addWidget( preLabel ); |
161 | 161 | ||
162 | freqLayout->addWidget( frequencyEdit() ); | 162 | freqLayout->addWidget( frequencyEdit() ); |
163 | 163 | ||
164 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); | 164 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); |
165 | freqLayout->addWidget( postLabel ); | 165 | freqLayout->addWidget( postLabel ); |
166 | 166 | ||
167 | 167 | ||
168 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 168 | QButtonGroup *buttonGroup = new QButtonGroup( this ); |
169 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 169 | buttonGroup->setFrameStyle( QFrame::NoFrame ); |
170 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 170 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
171 | 171 | ||
172 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 172 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); |
173 | buttonLayout->setSpacing( KDialog::spacingHint() ); | 173 | buttonLayout->setSpacing( KDialog::spacingHint() ); |
174 | 174 | ||
175 | 175 | ||
176 | QString recurOnText; | 176 | QString recurOnText; |
177 | if ( !KOPrefs::instance()->mCompactDialogs ) { | 177 | if ( !KOPrefs::instance()->mCompactDialogs ) { |
178 | recurOnText = i18n("Recur on the"); | 178 | recurOnText = i18n("Recur on the"); |
179 | } | 179 | } |
180 | 180 | ||
181 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); | 181 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); |
182 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); | 182 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); |
183 | 183 | ||
184 | mByDayCombo = new QComboBox( buttonGroup ); | 184 | mByDayCombo = new QComboBox( buttonGroup ); |
185 | mByDayCombo->setSizeLimit( 7 ); | 185 | mByDayCombo->setSizeLimit( 7 ); |
186 | mByDayCombo->insertItem( i18n("1st") ); | 186 | mByDayCombo->insertItem( i18n("1st") ); |
187 | mByDayCombo->insertItem( i18n("2nd") ); | 187 | mByDayCombo->insertItem( i18n("2nd") ); |
188 | mByDayCombo->insertItem( i18n("3rd") ); | 188 | mByDayCombo->insertItem( i18n("3rd") ); |
189 | mByDayCombo->insertItem( i18n("4th") ); | 189 | mByDayCombo->insertItem( i18n("4th") ); |
190 | mByDayCombo->insertItem( i18n("5th") ); | 190 | mByDayCombo->insertItem( i18n("5th") ); |
191 | mByDayCombo->insertItem( i18n("6th") ); | 191 | mByDayCombo->insertItem( i18n("6th") ); |
192 | mByDayCombo->insertItem( i18n("7th") ); | 192 | mByDayCombo->insertItem( i18n("7th") ); |
193 | mByDayCombo->insertItem( i18n("8th") ); | 193 | mByDayCombo->insertItem( i18n("8th") ); |
194 | mByDayCombo->insertItem( i18n("9th") ); | 194 | mByDayCombo->insertItem( i18n("9th") ); |
195 | mByDayCombo->insertItem( i18n("10th") ); | 195 | mByDayCombo->insertItem( i18n("10th") ); |
196 | mByDayCombo->insertItem( i18n("11th") ); | 196 | mByDayCombo->insertItem( i18n("11th") ); |
197 | mByDayCombo->insertItem( i18n("12th") ); | 197 | mByDayCombo->insertItem( i18n("12th") ); |
198 | mByDayCombo->insertItem( i18n("13th") ); | 198 | mByDayCombo->insertItem( i18n("13th") ); |
199 | mByDayCombo->insertItem( i18n("14th") ); | 199 | mByDayCombo->insertItem( i18n("14th") ); |
200 | mByDayCombo->insertItem( i18n("15th") ); | 200 | mByDayCombo->insertItem( i18n("15th") ); |
201 | mByDayCombo->insertItem( i18n("16th") ); | 201 | mByDayCombo->insertItem( i18n("16th") ); |
202 | mByDayCombo->insertItem( i18n("17th") ); | 202 | mByDayCombo->insertItem( i18n("17th") ); |
203 | mByDayCombo->insertItem( i18n("18th") ); | 203 | mByDayCombo->insertItem( i18n("18th") ); |
204 | mByDayCombo->insertItem( i18n("19th") ); | 204 | mByDayCombo->insertItem( i18n("19th") ); |
205 | mByDayCombo->insertItem( i18n("20th") ); | 205 | mByDayCombo->insertItem( i18n("20th") ); |
206 | mByDayCombo->insertItem( i18n("21st") ); | 206 | mByDayCombo->insertItem( i18n("21st") ); |
207 | mByDayCombo->insertItem( i18n("22nd") ); | 207 | mByDayCombo->insertItem( i18n("22nd") ); |
208 | mByDayCombo->insertItem( i18n("23rd") ); | 208 | mByDayCombo->insertItem( i18n("23rd") ); |
209 | mByDayCombo->insertItem( i18n("24th") ); | 209 | mByDayCombo->insertItem( i18n("24th") ); |
210 | mByDayCombo->insertItem( i18n("25th") ); | 210 | mByDayCombo->insertItem( i18n("25th") ); |
211 | mByDayCombo->insertItem( i18n("26th") ); | 211 | mByDayCombo->insertItem( i18n("26th") ); |
212 | mByDayCombo->insertItem( i18n("27th") ); | 212 | mByDayCombo->insertItem( i18n("27th") ); |
213 | mByDayCombo->insertItem( i18n("28th") ); | 213 | mByDayCombo->insertItem( i18n("28th") ); |
214 | mByDayCombo->insertItem( i18n("29th") ); | 214 | mByDayCombo->insertItem( i18n("29th") ); |
215 | mByDayCombo->insertItem( i18n("30th") ); | 215 | mByDayCombo->insertItem( i18n("30th") ); |
216 | mByDayCombo->insertItem( i18n("31st") ); | 216 | mByDayCombo->insertItem( i18n("31st") ); |
217 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); | 217 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); |
218 | 218 | ||
219 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); | 219 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); |
220 | buttonLayout->addWidget( byDayLabel, 0, 2 ); | 220 | buttonLayout->addWidget( byDayLabel, 0, 2 ); |
221 | 221 | ||
222 | 222 | ||
223 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); | 223 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); |
224 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); | 224 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); |
225 | 225 | ||
226 | mByPosCountCombo = new QComboBox( buttonGroup ); | 226 | mByPosCountCombo = new QComboBox( buttonGroup ); |
227 | mByPosCountCombo->insertItem( i18n("1st") ); | 227 | mByPosCountCombo->insertItem( i18n("1st") ); |
228 | mByPosCountCombo->insertItem( i18n("2nd") ); | 228 | mByPosCountCombo->insertItem( i18n("2nd") ); |
229 | mByPosCountCombo->insertItem( i18n("3rd") ); | 229 | mByPosCountCombo->insertItem( i18n("3rd") ); |
230 | mByPosCountCombo->insertItem( i18n("4th") ); | 230 | mByPosCountCombo->insertItem( i18n("4th") ); |
231 | mByPosCountCombo->insertItem( i18n("5th") ); | 231 | mByPosCountCombo->insertItem( i18n("5th") ); |
232 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); | 232 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); |
233 | 233 | ||
234 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); | 234 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); |
235 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); | 235 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); |
236 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); | 236 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); |
237 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); | 237 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); |
238 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); | 238 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); |
239 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); | 239 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); |
240 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); | 240 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); |
241 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); | 241 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); |
242 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); | 242 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); |
243 | } | 243 | } |
244 | 244 | ||
245 | void RecurMonthly::setByDay( int day ) | 245 | void RecurMonthly::setByDay( int day ) |
246 | { | 246 | { |
247 | mByDayRadio->setChecked( true ); | 247 | mByDayRadio->setChecked( true ); |
248 | mByDayCombo->setCurrentItem( day ); | 248 | mByDayCombo->setCurrentItem( day ); |
249 | } | 249 | } |
250 | 250 | ||
251 | void RecurMonthly::setByPos( int count, int weekday ) | 251 | void RecurMonthly::setByPos( int count, int weekday ) |
252 | { | 252 | { |
253 | mByPosRadio->setChecked( true ); | 253 | mByPosRadio->setChecked( true ); |
254 | mByPosCountCombo->setCurrentItem( count ); | 254 | mByPosCountCombo->setCurrentItem( count ); |
255 | mByPosWeekdayCombo->setCurrentItem( weekday ); | 255 | mByPosWeekdayCombo->setCurrentItem( weekday ); |
256 | } | 256 | } |
257 | 257 | ||
258 | bool RecurMonthly::byDay() | 258 | bool RecurMonthly::byDay() |
259 | { | 259 | { |
260 | return mByDayRadio->isChecked(); | 260 | return mByDayRadio->isChecked(); |
261 | } | 261 | } |
262 | 262 | ||
263 | bool RecurMonthly::byPos() | 263 | bool RecurMonthly::byPos() |
264 | { | 264 | { |
265 | return mByPosRadio->isChecked(); | 265 | return mByPosRadio->isChecked(); |
266 | } | 266 | } |
267 | 267 | ||
268 | int RecurMonthly::day() | 268 | int RecurMonthly::day() |
269 | { | 269 | { |
270 | return mByDayCombo->currentItem() + 1; | 270 | return mByDayCombo->currentItem() + 1; |
271 | } | 271 | } |
272 | 272 | ||
273 | int RecurMonthly::count() | 273 | int RecurMonthly::count() |
274 | { | 274 | { |
275 | return mByPosCountCombo->currentItem() + 1; | 275 | return mByPosCountCombo->currentItem() + 1; |
276 | } | 276 | } |
277 | 277 | ||
278 | int RecurMonthly::weekday() | 278 | int RecurMonthly::weekday() |
279 | { | 279 | { |
280 | return mByPosWeekdayCombo->currentItem(); | 280 | return mByPosWeekdayCombo->currentItem(); |
281 | } | 281 | } |
282 | 282 | ||
283 | /////////////////////////// RecurYearly /////////////////////////////// | 283 | /////////////////////////// RecurYearly /////////////////////////////// |
284 | 284 | ||
285 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | 285 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : |
286 | RecurBase( parent, name ) | 286 | RecurBase( parent, name ) |
287 | { | 287 | { |
288 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 288 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
289 | topLayout->setSpacing( KDialog::spacingHint() ); | 289 | topLayout->setSpacing( KDialog::spacingHint() ); |
290 | 290 | ||
291 | 291 | ||
292 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 292 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); |
293 | 293 | ||
294 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 294 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
295 | freqLayout->addWidget( preLabel ); | 295 | freqLayout->addWidget( preLabel ); |
296 | 296 | ||
297 | freqLayout->addWidget( frequencyEdit() ); | 297 | freqLayout->addWidget( frequencyEdit() ); |
298 | 298 | ||
299 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); | 299 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); |
300 | freqLayout->addWidget( postLabel ); | 300 | freqLayout->addWidget( postLabel ); |
301 | 301 | ||
302 | 302 | ||
303 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 303 | QButtonGroup *buttonGroup = new QButtonGroup( this ); |
304 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 304 | buttonGroup->setFrameStyle( QFrame::NoFrame ); |
305 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 305 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
306 | 306 | ||
307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 307 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); |
308 | |||
309 | QString recurInMonthText; | ||
310 | if ( !KOPrefs::instance()->mCompactDialogs ) { | ||
311 | recurInMonthText = i18n("Recur in the month of"); | ||
312 | } | ||
313 | |||
314 | mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup); | ||
315 | buttonLayout->addWidget( mByMonthRadio, 0, 0 ); | ||
316 | 308 | ||
309 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); | ||
310 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); | ||
311 | mByDayLabel = new QLabel( i18n(" 1 of "), buttonGroup ); | ||
312 | |||
313 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); | ||
317 | mByMonthCombo = new QComboBox( buttonGroup ); | 314 | mByMonthCombo = new QComboBox( buttonGroup ); |
318 | mByMonthCombo->insertItem( i18n("January") ); | 315 | mByMonthCombo->insertItem( i18n("January") ); |
319 | mByMonthCombo->insertItem( i18n("February") ); | 316 | mByMonthCombo->insertItem( i18n("February") ); |
320 | mByMonthCombo->insertItem( i18n("March") ); | 317 | mByMonthCombo->insertItem( i18n("March") ); |
321 | mByMonthCombo->insertItem( i18n("April") ); | 318 | mByMonthCombo->insertItem( i18n("April") ); |
322 | mByMonthCombo->insertItem( i18n("May") ); | 319 | mByMonthCombo->insertItem( i18n("May") ); |
323 | mByMonthCombo->insertItem( i18n("June") ); | 320 | mByMonthCombo->insertItem( i18n("June") ); |
324 | mByMonthCombo->insertItem( i18n("July") ); | 321 | mByMonthCombo->insertItem( i18n("July") ); |
325 | mByMonthCombo->insertItem( i18n("August") ); | 322 | mByMonthCombo->insertItem( i18n("August") ); |
326 | mByMonthCombo->insertItem( i18n("September") ); | 323 | mByMonthCombo->insertItem( i18n("September") ); |
327 | mByMonthCombo->insertItem( i18n("October") ); | 324 | mByMonthCombo->insertItem( i18n("October") ); |
328 | mByMonthCombo->insertItem( i18n("November") ); | 325 | mByMonthCombo->insertItem( i18n("November") ); |
329 | mByMonthCombo->insertItem( i18n("December") ); | 326 | mByMonthCombo->insertItem( i18n("December") ); |
330 | buttonLayout->addWidget( mByMonthCombo, 0, 1 ); | 327 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); |
331 | 328 | if ( QApplication::desktop()->width() <= 640 ) { | |
332 | mByMonthCombo->setSizeLimit( 6 ); | 329 | mByMonthCombo->setSizeLimit( 6 ); |
333 | 330 | } | |
334 | buttonLayout->setRowStretch( 1, 1 ); | 331 | |
335 | 332 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); | |
336 | QString recurOnDayText; | 333 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); |
337 | if ( KOPrefs::instance()->mCompactDialogs ) { | 334 | mDayOfLabel = new QLabel( i18n("1 of the year"), buttonGroup ); |
338 | recurOnDayText = i18n("This day"); | 335 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); |
339 | } else { | 336 | |
340 | recurOnDayText = i18n("Recur on this day"); | ||
341 | } | ||
342 | |||
343 | mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup); | ||
344 | buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 ); | ||
345 | } | 337 | } |
346 | 338 | ||
347 | void RecurYearly::setByDay() | 339 | void RecurYearly::setByDay( int doy ) |
348 | { | 340 | { |
349 | mByDayRadio->setChecked( true ); | 341 | mByDayRadio->setChecked( true ); |
342 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); | ||
350 | } | 343 | } |
351 | 344 | ||
352 | void RecurYearly::setByMonth( int month ) | 345 | void RecurYearly::setByMonth( int month, int day ) |
353 | { | 346 | { |
354 | mByMonthRadio->setChecked( true ); | 347 | mByMonthRadio->setChecked( true ); |
355 | mByMonthCombo->setCurrentItem( month - 1 ); | 348 | mByMonthCombo->setCurrentItem( month - 1 ); |
349 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); | ||
350 | mDay = day; | ||
356 | } | 351 | } |
357 | 352 | ||
358 | bool RecurYearly::byMonth() | 353 | bool RecurYearly::byMonth() |
359 | { | 354 | { |
360 | return mByMonthRadio->isChecked(); | 355 | return mByMonthRadio->isChecked(); |
361 | } | 356 | } |
362 | 357 | ||
363 | bool RecurYearly::byDay() | 358 | bool RecurYearly::byDay() |
364 | { | 359 | { |
365 | return mByDayRadio->isChecked(); | 360 | return mByDayRadio->isChecked(); |
366 | } | 361 | } |
367 | 362 | ||
368 | int RecurYearly::month() | 363 | int RecurYearly::month() |
369 | { | 364 | { |
370 | return mByMonthCombo->currentItem() + 1; | 365 | return mByMonthCombo->currentItem() + 1; |
371 | } | 366 | } |
367 | int RecurYearly::day() | ||
368 | { | ||
369 | return mDay;//mByDayCombo->currentItem() + 1; | ||
370 | } | ||
372 | 371 | ||
373 | //////////////////////////// ExceptionsWidget ////////////////////////// | 372 | //////////////////////////// ExceptionsWidget ////////////////////////// |
374 | 373 | ||
375 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : | 374 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : |
376 | QWidget( parent, name ) | 375 | QWidget( parent, name ) |
377 | { | 376 | { |
378 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 377 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
379 | 378 | ||
380 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), | 379 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), |
381 | this ); | 380 | this ); |
382 | topLayout->addWidget( groupBox ); | 381 | topLayout->addWidget( groupBox ); |
383 | 382 | ||
384 | QWidget *box = new QWidget( groupBox ); | 383 | QWidget *box = new QWidget( groupBox ); |
385 | 384 | ||
386 | QGridLayout *boxLayout = new QGridLayout( box ); | 385 | QGridLayout *boxLayout = new QGridLayout( box ); |
387 | 386 | ||
388 | mExceptionDateEdit = new KDateEdit( box ); | 387 | mExceptionDateEdit = new KDateEdit( box ); |
389 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); | 388 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); |
390 | 389 | ||
391 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); | 390 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); |
392 | boxLayout->addWidget( addExceptionButton, 1, 0 ); | 391 | boxLayout->addWidget( addExceptionButton, 1, 0 ); |
393 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); | 392 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); |
394 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); | 393 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); |
395 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); | 394 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); |
396 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); | 395 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); |
397 | 396 | ||
398 | mExceptionList = new QListBox( box ); | 397 | mExceptionList = new QListBox( box ); |
399 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); | 398 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); |
400 | 399 | ||
401 | boxLayout->setRowStretch( 4, 1 ); | 400 | boxLayout->setRowStretch( 4, 1 ); |
402 | boxLayout->setColStretch( 1, 3 ); | 401 | boxLayout->setColStretch( 1, 3 ); |
403 | 402 | ||
404 | connect( addExceptionButton, SIGNAL( clicked() ), | 403 | connect( addExceptionButton, SIGNAL( clicked() ), |
405 | SLOT( addException() ) ); | 404 | SLOT( addException() ) ); |
406 | connect( changeExceptionButton, SIGNAL( clicked() ), | 405 | connect( changeExceptionButton, SIGNAL( clicked() ), |
407 | SLOT( changeException() ) ); | 406 | SLOT( changeException() ) ); |
408 | connect( deleteExceptionButton, SIGNAL( clicked() ), | 407 | connect( deleteExceptionButton, SIGNAL( clicked() ), |
409 | SLOT( deleteException() ) ); | 408 | SLOT( deleteException() ) ); |
410 | if ( QApplication::desktop()->width() < 480 ) { | 409 | if ( QApplication::desktop()->width() < 480 ) { |
411 | setMinimumWidth( 220 ); | 410 | setMinimumWidth( 220 ); |
412 | } else { | 411 | } else { |
413 | setMinimumWidth( 440 ); | 412 | setMinimumWidth( 440 ); |
414 | mExceptionDateEdit->setMinimumWidth( 200 ); | 413 | mExceptionDateEdit->setMinimumWidth( 200 ); |
415 | } | 414 | } |
416 | } | 415 | } |
417 | 416 | ||
418 | void ExceptionsWidget::setDefaults( const QDateTime &from ) | 417 | void ExceptionsWidget::setDefaults( const QDateTime &from ) |
419 | { | 418 | { |
420 | mExceptionDateEdit->setDate( from.date() ); | 419 | mExceptionDateEdit->setDate( from.date() ); |
421 | } | 420 | } |
422 | 421 | ||
423 | void ExceptionsWidget::addException() | 422 | void ExceptionsWidget::addException() |
424 | { | 423 | { |
425 | QDate date = mExceptionDateEdit->date(); | 424 | QDate date = mExceptionDateEdit->date(); |
426 | QString dateStr = KGlobal::locale()->formatDate( date ); | 425 | QString dateStr = KGlobal::locale()->formatDate( date ); |
427 | if( !mExceptionList->findItem( dateStr ) ) { | 426 | if( !mExceptionList->findItem( dateStr ) ) { |
428 | mExceptionDates.append( date ); | 427 | mExceptionDates.append( date ); |
429 | mExceptionList->insertItem( dateStr ); | 428 | mExceptionList->insertItem( dateStr ); |
430 | } | 429 | } |
431 | } | 430 | } |
432 | 431 | ||
433 | void ExceptionsWidget::changeException() | 432 | void ExceptionsWidget::changeException() |
434 | { | 433 | { |
435 | int pos = mExceptionList->currentItem(); | 434 | int pos = mExceptionList->currentItem(); |
436 | if ( pos < 0 ) return; | 435 | if ( pos < 0 ) return; |
437 | 436 | ||
438 | QDate date = mExceptionDateEdit->date(); | 437 | QDate date = mExceptionDateEdit->date(); |
439 | mExceptionDates[ pos ] = date; | 438 | mExceptionDates[ pos ] = date; |
440 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); | 439 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); |
441 | } | 440 | } |
442 | 441 | ||
443 | void ExceptionsWidget::deleteException() | 442 | void ExceptionsWidget::deleteException() |
444 | { | 443 | { |
445 | int pos = mExceptionList->currentItem(); | 444 | int pos = mExceptionList->currentItem(); |
446 | if ( pos < 0 ) return; | 445 | if ( pos < 0 ) return; |
447 | 446 | ||
448 | mExceptionDates.remove( mExceptionDates.at( pos ) ); | 447 | mExceptionDates.remove( mExceptionDates.at( pos ) ); |
449 | mExceptionList->removeItem( pos ); | 448 | mExceptionList->removeItem( pos ); |
450 | } | 449 | } |
451 | 450 | ||
452 | void ExceptionsWidget::setDates( const DateList &dates ) | 451 | void ExceptionsWidget::setDates( const DateList &dates ) |
453 | { | 452 | { |
454 | mExceptionList->clear(); | 453 | mExceptionList->clear(); |
455 | mExceptionDates.clear(); | 454 | mExceptionDates.clear(); |
456 | DateList::ConstIterator dit; | 455 | DateList::ConstIterator dit; |
457 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { | 456 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { |
458 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); | 457 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); |
459 | mExceptionDates.append( *dit ); | 458 | mExceptionDates.append( *dit ); |
460 | } | 459 | } |
461 | } | 460 | } |
462 | 461 | ||
463 | DateList ExceptionsWidget::dates() | 462 | DateList ExceptionsWidget::dates() |
464 | { | 463 | { |
465 | return mExceptionDates; | 464 | return mExceptionDates; |
466 | } | 465 | } |
467 | 466 | ||
468 | ///////////////////////// ExceptionsDialog /////////////////////////// | 467 | ///////////////////////// ExceptionsDialog /////////////////////////// |
469 | 468 | ||
470 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : | 469 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : |
471 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) | 470 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) |
472 | { | 471 | { |
473 | mExceptions = new ExceptionsWidget( this ); | 472 | mExceptions = new ExceptionsWidget( this ); |
474 | setMainWidget( mExceptions ); | 473 | setMainWidget( mExceptions ); |
475 | resize(220,10); | 474 | resize(220,10); |
476 | } | 475 | } |
477 | 476 | ||
478 | void ExceptionsDialog::setDefaults( const QDateTime &from ) | 477 | void ExceptionsDialog::setDefaults( const QDateTime &from ) |
479 | { | 478 | { |
480 | mExceptions->setDefaults( from ); | 479 | mExceptions->setDefaults( from ); |
481 | } | 480 | } |
482 | 481 | ||
483 | void ExceptionsDialog::setDates( const DateList &dates ) | 482 | void ExceptionsDialog::setDates( const DateList &dates ) |
484 | { | 483 | { |
485 | mExceptions->setDates( dates ); | 484 | mExceptions->setDates( dates ); |
486 | } | 485 | } |
487 | 486 | ||
488 | DateList ExceptionsDialog::dates() | 487 | DateList ExceptionsDialog::dates() |
489 | { | 488 | { |
490 | return mExceptions->dates(); | 489 | return mExceptions->dates(); |
491 | } | 490 | } |
492 | 491 | ||
493 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// | 492 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// |
494 | 493 | ||
495 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | 494 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, |
496 | const char *name ) | 495 | const char *name ) |
497 | : QWidget( parent, name ) | 496 | : QWidget( parent, name ) |
498 | { | 497 | { |
499 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 498 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
500 | 499 | ||
501 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), | 500 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), |
502 | this ); | 501 | this ); |
503 | topLayout->addWidget( mRangeGroupBox ); | 502 | topLayout->addWidget( mRangeGroupBox ); |
504 | 503 | ||
505 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); | 504 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); |
506 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); | 505 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); |
507 | rangeLayout->setSpacing( KDialog::spacingHint() ); | 506 | rangeLayout->setSpacing( KDialog::spacingHint() ); |
508 | 507 | ||
509 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); | 508 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); |
510 | rangeLayout->addWidget( mStartDateLabel ); | 509 | rangeLayout->addWidget( mStartDateLabel ); |
511 | 510 | ||
512 | QButtonGroup *rangeButtonGroup = new QButtonGroup; | 511 | QButtonGroup *rangeButtonGroup = new QButtonGroup; |
513 | 512 | ||
514 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); | 513 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); |
515 | rangeButtonGroup->insert( mNoEndDateButton ); | 514 | rangeButtonGroup->insert( mNoEndDateButton ); |
516 | rangeLayout->addWidget( mNoEndDateButton ); | 515 | rangeLayout->addWidget( mNoEndDateButton ); |
517 | 516 | ||
518 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); | 517 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); |
519 | durationLayout->setSpacing( KDialog::spacingHint() ); | 518 | durationLayout->setSpacing( KDialog::spacingHint() ); |
520 | 519 | ||
521 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); | 520 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); |
522 | rangeButtonGroup->insert( mEndDurationButton ); | 521 | rangeButtonGroup->insert( mEndDurationButton ); |
523 | durationLayout->addWidget( mEndDurationButton ); | 522 | durationLayout->addWidget( mEndDurationButton ); |
524 | 523 | ||
525 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); | 524 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); |
526 | durationLayout->addWidget( mEndDurationEdit ); | 525 | durationLayout->addWidget( mEndDurationEdit ); |
527 | 526 | ||
528 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); | 527 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); |
529 | durationLayout ->addWidget( endDurationLabel ); | 528 | durationLayout ->addWidget( endDurationLabel ); |
530 | 529 | ||
531 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); | 530 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); |
532 | endDateLayout->setSpacing( KDialog::spacingHint() ); | 531 | endDateLayout->setSpacing( KDialog::spacingHint() ); |
533 | 532 | ||
534 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); | 533 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); |
535 | rangeButtonGroup->insert( mEndDateButton ); | 534 | rangeButtonGroup->insert( mEndDateButton ); |
536 | endDateLayout->addWidget( mEndDateButton ); | 535 | endDateLayout->addWidget( mEndDateButton ); |
537 | 536 | ||
538 | mEndDateEdit = new KDateEdit( rangeBox ); | 537 | mEndDateEdit = new KDateEdit( rangeBox ); |
539 | endDateLayout->addWidget( mEndDateEdit ); | 538 | endDateLayout->addWidget( mEndDateEdit ); |
540 | 539 | ||
541 | endDateLayout->addStretch( 1 ); | 540 | endDateLayout->addStretch( 1 ); |
542 | 541 | ||
543 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), | 542 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), |
544 | SLOT( showCurrentRange() ) ); | 543 | SLOT( showCurrentRange() ) ); |
545 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), | 544 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), |
546 | SLOT( showCurrentRange() ) ); | 545 | SLOT( showCurrentRange() ) ); |
547 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), | 546 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), |
548 | SLOT( showCurrentRange() ) ); | 547 | SLOT( showCurrentRange() ) ); |
549 | } | 548 | } |
550 | 549 | ||
551 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 550 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
552 | { | 551 | { |
553 | mNoEndDateButton->setChecked( true ); | 552 | mNoEndDateButton->setChecked( true ); |
554 | 553 | ||
555 | setDateTimes( from ); | 554 | setDateTimes( from ); |
556 | mEndDateEdit->setDate( from.date() ); | 555 | mEndDateEdit->setDate( from.date() ); |
557 | } | 556 | } |
558 | 557 | ||
559 | void RecurrenceRangeWidget::setDuration( int duration ) | 558 | void RecurrenceRangeWidget::setDuration( int duration ) |
560 | { | 559 | { |
561 | if ( duration == -1 ) { | 560 | if ( duration == -1 ) { |
562 | mNoEndDateButton->setChecked( true ); | 561 | mNoEndDateButton->setChecked( true ); |
563 | } else if ( duration == 0 ) { | 562 | } else if ( duration == 0 ) { |
@@ -655,462 +654,486 @@ RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | |||
655 | 654 | ||
656 | if ( KOPrefs::instance()->mCompactDialogs ) { | 655 | if ( KOPrefs::instance()->mCompactDialogs ) { |
657 | mTypeCombo = new QComboBox( this ); | 656 | mTypeCombo = new QComboBox( this ); |
658 | mTypeCombo->insertItem( i18n("Daily") ); | 657 | mTypeCombo->insertItem( i18n("Daily") ); |
659 | mTypeCombo->insertItem( i18n("Weekly") ); | 658 | mTypeCombo->insertItem( i18n("Weekly") ); |
660 | mTypeCombo->insertItem( i18n("Monthly") ); | 659 | mTypeCombo->insertItem( i18n("Monthly") ); |
661 | mTypeCombo->insertItem( i18n("Yearly") ); | 660 | mTypeCombo->insertItem( i18n("Yearly") ); |
662 | 661 | ||
663 | topLayout->addWidget( mTypeCombo ); | 662 | topLayout->addWidget( mTypeCombo ); |
664 | 663 | ||
665 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 664 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
666 | } else { | 665 | } else { |
667 | mTypeCombo = 0; | 666 | mTypeCombo = 0; |
668 | 667 | ||
669 | QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); | 668 | QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); |
670 | ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); | 669 | ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); |
671 | topLayout->addWidget( ruleButtonGroup ); | 670 | topLayout->addWidget( ruleButtonGroup ); |
672 | 671 | ||
673 | mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); | 672 | mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); |
674 | mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); | 673 | mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); |
675 | mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); | 674 | mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); |
676 | mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); | 675 | mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); |
677 | 676 | ||
678 | connect( mDailyButton, SIGNAL( toggled( bool ) ), | 677 | connect( mDailyButton, SIGNAL( toggled( bool ) ), |
679 | SLOT( emitChoice() ) ); | 678 | SLOT( emitChoice() ) ); |
680 | connect( mWeeklyButton, SIGNAL( toggled( bool ) ), | 679 | connect( mWeeklyButton, SIGNAL( toggled( bool ) ), |
681 | SLOT( emitChoice() ) ); | 680 | SLOT( emitChoice() ) ); |
682 | connect( mMonthlyButton, SIGNAL( toggled( bool ) ), | 681 | connect( mMonthlyButton, SIGNAL( toggled( bool ) ), |
683 | SLOT( emitChoice() ) ); | 682 | SLOT( emitChoice() ) ); |
684 | connect( mYearlyButton, SIGNAL( toggled( bool ) ), | 683 | connect( mYearlyButton, SIGNAL( toggled( bool ) ), |
685 | SLOT( emitChoice() ) ); | 684 | SLOT( emitChoice() ) ); |
686 | } | 685 | } |
687 | } | 686 | } |
688 | 687 | ||
689 | int RecurrenceChooser::type() | 688 | int RecurrenceChooser::type() |
690 | { | 689 | { |
691 | if ( mTypeCombo ) { | 690 | if ( mTypeCombo ) { |
692 | return mTypeCombo->currentItem(); | 691 | return mTypeCombo->currentItem(); |
693 | } else { | 692 | } else { |
694 | if ( mDailyButton->isChecked() ) return Daily; | 693 | if ( mDailyButton->isChecked() ) return Daily; |
695 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 694 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
696 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 695 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
697 | else return Yearly; | 696 | else return Yearly; |
698 | } | 697 | } |
699 | } | 698 | } |
700 | 699 | ||
701 | void RecurrenceChooser::setType( int type ) | 700 | void RecurrenceChooser::setType( int type ) |
702 | { | 701 | { |
703 | if ( mTypeCombo ) { | 702 | if ( mTypeCombo ) { |
704 | mTypeCombo->setCurrentItem( type ); | 703 | mTypeCombo->setCurrentItem( type ); |
705 | } else { | 704 | } else { |
706 | switch ( type ) { | 705 | switch ( type ) { |
707 | case Daily: | 706 | case Daily: |
708 | mDailyButton->setChecked( true ); | 707 | mDailyButton->setChecked( true ); |
709 | break; | 708 | break; |
710 | case Weekly: | 709 | case Weekly: |
711 | mWeeklyButton->setChecked( true ); | 710 | mWeeklyButton->setChecked( true ); |
712 | break; | 711 | break; |
713 | case Monthly: | 712 | case Monthly: |
714 | mMonthlyButton->setChecked( true ); | 713 | mMonthlyButton->setChecked( true ); |
715 | break; | 714 | break; |
716 | case Yearly: | 715 | case Yearly: |
717 | default: | 716 | default: |
718 | mYearlyButton->setChecked( true ); | 717 | mYearlyButton->setChecked( true ); |
719 | break; | 718 | break; |
720 | } | 719 | } |
721 | } | 720 | } |
722 | } | 721 | } |
723 | 722 | ||
724 | void RecurrenceChooser::emitChoice() | 723 | void RecurrenceChooser::emitChoice() |
725 | { | 724 | { |
726 | emit chosen ( type() ); | 725 | emit chosen ( type() ); |
727 | } | 726 | } |
728 | 727 | ||
729 | /////////////////////////////// Main Widget ///////////////////////////// | 728 | /////////////////////////////// Main Widget ///////////////////////////// |
730 | 729 | ||
731 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 730 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
732 | QWidget( parent, name ) | 731 | QWidget( parent, name ) |
733 | { | 732 | { |
734 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 733 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
735 | topLayout->setSpacing( KDialog::spacingHint() ); | 734 | topLayout->setSpacing( KDialog::spacingHint() ); |
736 | 735 | ||
737 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 736 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
738 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 737 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
739 | SLOT( setEnabled( bool ) ) ); | 738 | SLOT( setEnabled( bool ) ) ); |
740 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 739 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
741 | 740 | ||
742 | 741 | ||
743 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), | 742 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), |
744 | this ); | 743 | this ); |
745 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 744 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
746 | 745 | ||
747 | if ( KOPrefs::instance()->mCompactDialogs ) { | 746 | if ( KOPrefs::instance()->mCompactDialogs ) { |
748 | mTimeGroupBox->hide(); | 747 | mTimeGroupBox->hide(); |
749 | } | 748 | } |
750 | 749 | ||
751 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 750 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
752 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 751 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
753 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 752 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
754 | 753 | ||
755 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 754 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
756 | // mDateTimeLabel = new QLabel( timeFrame ); | 755 | // mDateTimeLabel = new QLabel( timeFrame ); |
757 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 756 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
758 | 757 | ||
759 | Qt::Orientation orientation; | 758 | Qt::Orientation orientation; |
760 | if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; | 759 | if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; |
761 | else orientation = Vertical; | 760 | else orientation = Vertical; |
762 | 761 | ||
763 | mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); | 762 | mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); |
764 | if ( KOPrefs::instance()->mCompactDialogs ) { | 763 | if ( KOPrefs::instance()->mCompactDialogs ) { |
765 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 764 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
766 | } else { | 765 | } else { |
767 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 766 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
768 | } | 767 | } |
769 | 768 | ||
770 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 769 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
771 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 770 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
772 | SLOT( showCurrentRule( int ) ) ); | 771 | SLOT( showCurrentRule( int ) ) ); |
773 | 772 | ||
774 | if ( !KOPrefs::instance()->mCompactDialogs ) { | 773 | if ( !KOPrefs::instance()->mCompactDialogs ) { |
775 | QFrame *ruleSepFrame = new QFrame( mRuleBox ); | 774 | QFrame *ruleSepFrame = new QFrame( mRuleBox ); |
776 | ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); | 775 | ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); |
777 | } | 776 | } |
778 | 777 | ||
779 | mRuleStack = new QWidgetStack( mRuleBox ); | 778 | mRuleStack = new QWidgetStack( mRuleBox ); |
780 | 779 | ||
781 | mDaily = new RecurDaily( mRuleStack ); | 780 | mDaily = new RecurDaily( mRuleStack ); |
782 | mRuleStack->addWidget( mDaily, 0 ); | 781 | mRuleStack->addWidget( mDaily, 0 ); |
783 | 782 | ||
784 | mWeekly = new RecurWeekly( mRuleStack ); | 783 | mWeekly = new RecurWeekly( mRuleStack ); |
785 | mRuleStack->addWidget( mWeekly, 0 ); | 784 | mRuleStack->addWidget( mWeekly, 0 ); |
786 | 785 | ||
787 | mMonthly = new RecurMonthly( mRuleStack ); | 786 | mMonthly = new RecurMonthly( mRuleStack ); |
788 | mRuleStack->addWidget( mMonthly, 0 ); | 787 | mRuleStack->addWidget( mMonthly, 0 ); |
789 | 788 | ||
790 | mYearly = new RecurYearly( mRuleStack ); | 789 | mYearly = new RecurYearly( mRuleStack ); |
791 | mRuleStack->addWidget( mYearly, 0 ); | 790 | mRuleStack->addWidget( mYearly, 0 ); |
792 | 791 | ||
793 | showCurrentRule( mRecurrenceChooser->type() ); | 792 | showCurrentRule( mRecurrenceChooser->type() ); |
794 | 793 | ||
795 | if ( KOPrefs::instance()->mCompactDialogs ) { | 794 | if ( KOPrefs::instance()->mCompactDialogs ) { |
796 | mRecurrenceRangeWidget = 0; | 795 | mRecurrenceRangeWidget = 0; |
797 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 796 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
798 | mRecurrenceRange = mRecurrenceRangeDialog; | 797 | mRecurrenceRange = mRecurrenceRangeDialog; |
799 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 798 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
800 | this ); | 799 | this ); |
801 | 800 | ||
802 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 801 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
803 | SLOT( showRecurrenceRangeDialog() ) ); | 802 | SLOT( showRecurrenceRangeDialog() ) ); |
804 | 803 | ||
805 | mExceptionsWidget = 0; | 804 | mExceptionsWidget = 0; |
806 | mExceptionsDialog = new ExceptionsDialog( this ); | 805 | mExceptionsDialog = new ExceptionsDialog( this ); |
807 | mExceptions = mExceptionsDialog; | 806 | mExceptions = mExceptionsDialog; |
808 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 807 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
809 | if ( QApplication::desktop()->width() < 320 ) { | 808 | if ( QApplication::desktop()->width() < 320 ) { |
810 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 809 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
811 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 810 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
812 | } else { | 811 | } else { |
813 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 812 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
814 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 813 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
815 | } | 814 | } |
816 | connect( mExceptionsButton, SIGNAL( clicked() ), | 815 | connect( mExceptionsButton, SIGNAL( clicked() ), |
817 | SLOT( showExceptionsDialog() ) ); | 816 | SLOT( showExceptionsDialog() ) ); |
818 | 817 | ||
819 | } else { | 818 | } else { |
820 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 819 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
821 | mRecurrenceRangeDialog = 0; | 820 | mRecurrenceRangeDialog = 0; |
822 | mRecurrenceRange = mRecurrenceRangeWidget; | 821 | mRecurrenceRange = mRecurrenceRangeWidget; |
823 | mRecurrenceRangeButton = 0; | 822 | mRecurrenceRangeButton = 0; |
824 | topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); | 823 | topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); |
825 | 824 | ||
826 | mExceptionsWidget = new ExceptionsWidget( this ); | 825 | mExceptionsWidget = new ExceptionsWidget( this ); |
827 | mExceptionsDialog = 0; | 826 | mExceptionsDialog = 0; |
828 | mExceptions = mExceptionsWidget; | 827 | mExceptions = mExceptionsWidget; |
829 | mExceptionsButton = 0; | 828 | mExceptionsButton = 0; |
830 | topLayout->addWidget( mExceptionsWidget, 3, 1 ); | 829 | topLayout->addWidget( mExceptionsWidget, 3, 1 ); |
831 | } | 830 | } |
832 | } | 831 | } |
833 | 832 | ||
834 | KOEditorRecurrence::~KOEditorRecurrence() | 833 | KOEditorRecurrence::~KOEditorRecurrence() |
835 | { | 834 | { |
836 | } | 835 | } |
837 | 836 | ||
838 | void KOEditorRecurrence::setEnabled( bool enabled ) | 837 | void KOEditorRecurrence::setEnabled( bool enabled ) |
839 | { | 838 | { |
840 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 839 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
841 | 840 | ||
842 | mTimeGroupBox->setEnabled( enabled ); | 841 | mTimeGroupBox->setEnabled( enabled ); |
843 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 842 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
844 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 843 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
845 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 844 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
846 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 845 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
846 | mRuleBox->setEnabled( enabled ); | ||
847 | } | 847 | } |
848 | 848 | ||
849 | void KOEditorRecurrence::showCurrentRule( int current ) | 849 | void KOEditorRecurrence::showCurrentRule( int current ) |
850 | { | 850 | { |
851 | switch ( current ) { | 851 | switch ( current ) { |
852 | case Daily: | 852 | case Daily: |
853 | mRuleStack->raiseWidget( mDaily ); | 853 | mRuleStack->raiseWidget( mDaily ); |
854 | break; | 854 | break; |
855 | case Weekly: | 855 | case Weekly: |
856 | mRuleStack->raiseWidget( mWeekly ); | 856 | mRuleStack->raiseWidget( mWeekly ); |
857 | break; | 857 | break; |
858 | case Monthly: | 858 | case Monthly: |
859 | mRuleStack->raiseWidget( mMonthly ); | 859 | mRuleStack->raiseWidget( mMonthly ); |
860 | break; | 860 | break; |
861 | default: | 861 | default: |
862 | case Yearly: | 862 | case Yearly: |
863 | mRuleStack->raiseWidget( mYearly ); | 863 | mRuleStack->raiseWidget( mYearly ); |
864 | break; | 864 | break; |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 868 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
869 | { | 869 | { |
870 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 870 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
871 | 871 | ||
872 | mRecurrenceRange->setDateTimes( start, end ); | 872 | mRecurrenceRange->setDateTimes( start, end ); |
873 | mExceptions->setDefaults( end ); | 873 | mExceptions->setDefaults( end ); |
874 | 874 | ||
875 | } | 875 | } |
876 | 876 | ||
877 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 877 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) |
878 | { | 878 | { |
879 | 879 | ||
880 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 880 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
881 | setDateTimes( from, to ); | 881 | setDateTimes( from, to ); |
882 | 882 | ||
883 | bool enabled = false; | 883 | bool enabled = false; |
884 | mEnabledCheck->setChecked( enabled ); | 884 | mEnabledCheck->setChecked( enabled ); |
885 | setEnabled( enabled ); | 885 | setEnabled( enabled ); |
886 | 886 | ||
887 | mExceptions->setDefaults( to ); | 887 | mExceptions->setDefaults( to ); |
888 | mRecurrenceRange->setDefaults( to ); | 888 | mRecurrenceRange->setDefaults( to ); |
889 | 889 | ||
890 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 890 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
891 | showCurrentRule( mRecurrenceChooser->type() ); | 891 | showCurrentRule( mRecurrenceChooser->type() ); |
892 | 892 | ||
893 | mDaily->setFrequency( 1 ); | 893 | mDaily->setFrequency( 1 ); |
894 | 894 | ||
895 | mWeekly->setFrequency( 1 ); | 895 | mWeekly->setFrequency( 1 ); |
896 | QBitArray days( 7 ); | 896 | QBitArray days( 7 ); |
897 | days.fill( 0 ); | 897 | days.fill( 0 ); |
898 | days.setBit( from.date().dayOfWeek()- 1); | ||
898 | mWeekly->setDays( days ); | 899 | mWeekly->setDays( days ); |
899 | |||
900 | mMonthly->setFrequency( 1 ); | 900 | mMonthly->setFrequency( 1 ); |
901 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | ||
901 | mMonthly->setByDay( from.date().day()-1 ); | 902 | mMonthly->setByDay( from.date().day()-1 ); |
902 | |||
903 | mYearly->setFrequency( 1 ); | 903 | mYearly->setFrequency( 1 ); |
904 | mYearly->setByDay(); | 904 | mYearly->setByDay( from.date().dayOfYear() ); |
905 | mYearly->setByMonth( from.date().month(), from.date().day() ); | ||
905 | } | 906 | } |
906 | 907 | ||
907 | void KOEditorRecurrence::readEvent(Event *event) | 908 | void KOEditorRecurrence::readEvent(Event *event) |
908 | { | 909 | { |
910 | setDefaults( event->dtStart(), event->dtEnd(), true ); | ||
909 | QBitArray rDays( 7 ); | 911 | QBitArray rDays( 7 ); |
910 | QPtrList<Recurrence::rMonthPos> rmp; | 912 | QPtrList<Recurrence::rMonthPos> rmp; |
911 | QPtrList<int> rmd; | 913 | QPtrList<int> rmd; |
912 | int day = 0; | 914 | int day = 0; |
913 | int count = 0; | 915 | int count = 0; |
914 | int month = 0; | 916 | int month = 0; |
915 | setDateTimes( event->dtStart(), event->dtEnd() ); | 917 | setDateTimes( event->dtStart(), event->dtEnd() ); |
916 | 918 | ||
917 | Recurrence *r = event->recurrence(); | 919 | Recurrence *r = event->recurrence(); |
918 | int f = r->frequency(); | 920 | int f = r->frequency(); |
919 | 921 | ||
920 | int recurs = r->doesRecur(); | 922 | int recurs = r->doesRecur(); |
921 | 923 | ||
922 | mEnabledCheck->setChecked( recurs ); | 924 | mEnabledCheck->setChecked( recurs ); |
923 | setEnabled( recurs ); | 925 | setEnabled( recurs ); |
924 | 926 | ||
925 | int recurrenceType = RecurrenceChooser::Weekly; | 927 | int recurrenceType = RecurrenceChooser::Weekly; |
926 | 928 | ||
927 | switch ( recurs ) { | 929 | switch ( recurs ) { |
928 | case Recurrence::rNone: | 930 | case Recurrence::rNone: |
929 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 931 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
930 | break; | 932 | break; |
931 | case Recurrence::rDaily: | 933 | case Recurrence::rDaily: |
932 | recurrenceType = RecurrenceChooser::Daily; | 934 | recurrenceType = RecurrenceChooser::Daily; |
933 | mDaily->setFrequency( f ); | 935 | mDaily->setFrequency( f ); |
934 | break; | 936 | break; |
935 | case Recurrence::rWeekly: | 937 | case Recurrence::rWeekly: |
936 | recurrenceType = RecurrenceChooser::Weekly; | 938 | recurrenceType = RecurrenceChooser::Weekly; |
937 | mWeekly->setFrequency( f ); | 939 | mWeekly->setFrequency( f ); |
938 | mWeekly->setDays( r->days() ); | 940 | mWeekly->setDays( r->days() ); |
939 | break; | 941 | break; |
940 | case Recurrence::rMonthlyPos: | 942 | case Recurrence::rMonthlyPos: |
941 | // we only handle one possibility in the list right now, | 943 | // we only handle one possibility in the list right now, |
942 | // so I have hardcoded calls with first(). If we make the GUI | 944 | // so I have hardcoded calls with first(). If we make the GUI |
943 | // more extended, this can be changed. | 945 | // more extended, this can be changed. |
944 | recurrenceType = RecurrenceChooser::Monthly; | 946 | recurrenceType = RecurrenceChooser::Monthly; |
945 | 947 | ||
946 | rmp = r->monthPositions(); | 948 | rmp = r->monthPositions(); |
947 | if ( rmp.first()->negative ) | 949 | if ( rmp.first()->negative ) |
948 | count = 5 - rmp.first()->rPos - 1; | 950 | count = 5 - rmp.first()->rPos - 1; |
949 | else | 951 | else |
950 | count = rmp.first()->rPos - 1; | 952 | count = rmp.first()->rPos - 1; |
951 | day = 0; | 953 | day = 0; |
952 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 954 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
953 | mMonthly->setByPos( count, day ); | 955 | mMonthly->setByPos( count, day ); |
954 | 956 | ||
955 | mMonthly->setFrequency( f ); | 957 | mMonthly->setFrequency( f ); |
956 | 958 | ||
957 | break; | 959 | break; |
958 | case Recurrence::rMonthlyDay: | 960 | case Recurrence::rMonthlyDay: |
959 | recurrenceType = RecurrenceChooser::Monthly; | 961 | recurrenceType = RecurrenceChooser::Monthly; |
960 | 962 | ||
961 | rmd = r->monthDays(); | 963 | rmd = r->monthDays(); |
962 | day = *rmd.first() - 1; | 964 | day = *rmd.first() - 1; |
963 | mMonthly->setByDay( day ); | 965 | mMonthly->setByDay( day ); |
964 | 966 | ||
965 | mMonthly->setFrequency( f ); | 967 | mMonthly->setFrequency( f ); |
966 | 968 | ||
967 | break; | 969 | break; |
968 | case Recurrence::rYearlyMonth: | 970 | case Recurrence::rYearlyMonth: |
969 | case Recurrence::rYearlyDay: | 971 | { |
970 | recurrenceType = RecurrenceChooser::Yearly; | 972 | recurrenceType = RecurrenceChooser::Yearly; |
971 | 973 | qDebug("Recurrence::rYearlyMonth: "); | |
972 | rmd = r->yearNums(); | 974 | day = event->dtStart().date().day(); |
973 | month = *rmd.first(); | 975 | rmd = r->yearNums(); |
974 | if ( month == event->dtStart().date().month() ) { | 976 | if ( rmd.count() > 0 ) |
975 | mYearly->setByDay(); | 977 | month = *rmd.first(); |
976 | } else { | 978 | else |
977 | mYearly->setByMonth( month ); | 979 | month = event->dtStart().date().month() ; |
978 | } | 980 | mYearly->setByMonth( month, day ); |
981 | #if 0 | ||
982 | qDebug("2day = %d ",day ); | ||
983 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | ||
984 | int month; | ||
985 | if ( !monthlist.isEmpty() ) { | ||
986 | month = monthlist.first()->rPos ; | ||
987 | } else { | ||
988 | month = event->dtStart().date().month() ; | ||
989 | } | ||
990 | mYearly->setByMonth( day, month ); | ||
991 | #endif | ||
992 | mYearly->setFrequency( f ); | ||
993 | } | ||
979 | 994 | ||
980 | mYearly->setFrequency( f ); | ||
981 | break; | 995 | break; |
996 | case Recurrence::rYearlyDay: | ||
997 | qDebug("Recurrence::rYearlyDay: "); | ||
998 | recurrenceType = RecurrenceChooser::Yearly; | ||
999 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | ||
1000 | mYearly->setFrequency( f ); | ||
1001 | break; | ||
982 | default: | 1002 | default: |
983 | setDefaults( event->dtStart(), event->dtEnd(), true ); | 1003 | setDefaults( event->dtStart(), event->dtEnd(), true ); |
984 | break; | 1004 | break; |
985 | } | 1005 | } |
986 | 1006 | ||
987 | mRecurrenceChooser->setType( recurrenceType ); | 1007 | mRecurrenceChooser->setType( recurrenceType ); |
988 | showCurrentRule( recurrenceType ); | 1008 | showCurrentRule( recurrenceType ); |
989 | 1009 | ||
990 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 1010 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
991 | 1011 | ||
992 | if ( r->doesRecur() ) { | 1012 | if ( r->doesRecur() ) { |
993 | mRecurrenceRange->setDuration( r->duration() ); | 1013 | mRecurrenceRange->setDuration( r->duration() ); |
994 | if ( r->duration() == 0 ) | 1014 | if ( r->duration() == 0 ) |
995 | { | 1015 | { |
996 | if ( r->endDate() < event->dtStart().date() ) | 1016 | if ( r->endDate() < event->dtStart().date() ) |
997 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1017 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
998 | else | 1018 | else |
999 | mRecurrenceRange->setEndDate( r->endDate() ); | 1019 | mRecurrenceRange->setEndDate( r->endDate() ); |
1000 | } else | 1020 | } else |
1001 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1021 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1002 | } | 1022 | } |
1003 | 1023 | ||
1004 | mExceptions->setDates( event->exDates() ); | 1024 | mExceptions->setDates( event->exDates() ); |
1005 | } | 1025 | } |
1006 | 1026 | ||
1007 | void KOEditorRecurrence::writeEvent( Event *event ) | 1027 | void KOEditorRecurrence::writeEvent( Event *event ) |
1008 | { | 1028 | { |
1009 | Recurrence *r = event->recurrence(); | 1029 | Recurrence *r = event->recurrence(); |
1010 | 1030 | ||
1011 | // clear out any old settings; | 1031 | // clear out any old settings; |
1012 | r->unsetRecurs(); | 1032 | r->unsetRecurs(); |
1013 | 1033 | ||
1014 | if ( mEnabledCheck->isChecked() ) { | 1034 | if ( mEnabledCheck->isChecked() ) { |
1015 | int duration = mRecurrenceRange->duration(); | 1035 | int duration = mRecurrenceRange->duration(); |
1016 | QDate endDate; | 1036 | QDate endDate; |
1017 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1037 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1018 | 1038 | ||
1019 | int recurrenceType = mRecurrenceChooser->type(); | 1039 | int recurrenceType = mRecurrenceChooser->type(); |
1020 | 1040 | ||
1021 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1041 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1022 | int freq = mDaily->frequency(); | 1042 | int freq = mDaily->frequency(); |
1023 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1043 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1024 | else r->setDaily( freq, endDate ); | 1044 | else r->setDaily( freq, endDate ); |
1025 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1045 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1026 | int freq = mWeekly->frequency(); | 1046 | int freq = mWeekly->frequency(); |
1027 | QBitArray days = mWeekly->days(); | 1047 | QBitArray days = mWeekly->days(); |
1028 | int j; | 1048 | int j; |
1029 | bool found = false; | 1049 | bool found = false; |
1030 | for (j = 0; j < 7 ; ++j ) { | 1050 | for (j = 0; j < 7 ; ++j ) { |
1031 | found |=days.at(j); | 1051 | found |=days.at(j); |
1032 | } | 1052 | } |
1033 | if ( !found ) { | 1053 | if ( !found ) { |
1034 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1054 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1035 | qDebug("bit set %d "); | 1055 | qDebug("bit set %d "); |
1036 | } | 1056 | } |
1037 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1057 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1038 | else r->setWeekly( freq, days, endDate ); | 1058 | else r->setWeekly( freq, days, endDate ); |
1039 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1059 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1040 | int freq = mMonthly->frequency(); | 1060 | int freq = mMonthly->frequency(); |
1041 | if ( mMonthly->byPos() ) { | 1061 | if ( mMonthly->byPos() ) { |
1042 | int pos = mMonthly->count(); | 1062 | int pos = mMonthly->count(); |
1043 | 1063 | ||
1044 | QBitArray days( 7 ); | 1064 | QBitArray days( 7 ); |
1045 | days.fill( false ); | 1065 | days.fill( false ); |
1046 | 1066 | ||
1047 | days.setBit( mMonthly->weekday() ); | 1067 | days.setBit( mMonthly->weekday() ); |
1048 | if ( duration != 0 ) | 1068 | if ( duration != 0 ) |
1049 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1069 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1050 | else | 1070 | else |
1051 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1071 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1052 | r->addMonthlyPos( pos, days ); | 1072 | r->addMonthlyPos( pos, days ); |
1053 | } else { | 1073 | } else { |
1054 | // it's by day | 1074 | // it's by day |
1055 | int day = mMonthly->day(); | 1075 | int day = mMonthly->day(); |
1056 | 1076 | ||
1057 | if ( duration != 0 ) { | 1077 | if ( duration != 0 ) { |
1058 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1078 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1059 | } else { | 1079 | } else { |
1060 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1080 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1061 | } | 1081 | } |
1062 | r->addMonthlyDay( day ); | 1082 | r->addMonthlyDay( day ); |
1063 | } | 1083 | } |
1064 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1084 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1085 | qDebug("RecurrenceChooser::Yearly "); | ||
1065 | int freq = mYearly->frequency(); | 1086 | int freq = mYearly->frequency(); |
1066 | 1087 | if ( mYearly->byDay() ) { | |
1067 | int month; | 1088 | if ( duration != 0 ) { |
1068 | if ( mYearly->byMonth() ) { | 1089 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1069 | month = mYearly->month(); | 1090 | } else { |
1070 | } else { | 1091 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1071 | month = event->dtStart().date().month(); | 1092 | } |
1072 | } | 1093 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1073 | if ( duration != 0 ) { | ||
1074 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | ||
1075 | } else { | 1094 | } else { |
1076 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1095 | if ( duration != 0 ) { |
1096 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | ||
1097 | } else { | ||
1098 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | ||
1099 | } | ||
1100 | r->addYearlyNum( mYearly->month() ); | ||
1077 | } | 1101 | } |
1078 | 1102 | ||
1079 | r->addYearlyNum( month ); | ||
1080 | } | 1103 | } |
1081 | 1104 | ||
1082 | event->setExDates( mExceptions->dates() ); | 1105 | event->setExDates( mExceptions->dates() ); |
1083 | } | 1106 | } |
1084 | } | 1107 | } |
1085 | 1108 | ||
1086 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1109 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1087 | { | 1110 | { |
1088 | mDateTimeLabel->setText( str ); | 1111 | mDateTimeLabel->setText( str ); |
1089 | } | 1112 | } |
1090 | 1113 | ||
1091 | bool KOEditorRecurrence::validateInput() | 1114 | bool KOEditorRecurrence::validateInput() |
1092 | { | 1115 | { |
1093 | // Check input here | 1116 | // Check input here |
1094 | 1117 | ||
1095 | return true; | 1118 | return true; |
1096 | } | 1119 | } |
1097 | 1120 | ||
1098 | void KOEditorRecurrence::showExceptionsDialog() | 1121 | void KOEditorRecurrence::showExceptionsDialog() |
1099 | { | 1122 | { |
1100 | DateList dates = mExceptions->dates(); | 1123 | DateList dates = mExceptions->dates(); |
1101 | int result = mExceptionsDialog->exec(); | 1124 | int result = mExceptionsDialog->exec(); |
1102 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1125 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1103 | } | 1126 | } |
1104 | 1127 | ||
1105 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1128 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1106 | { | 1129 | { |
1107 | int duration = mRecurrenceRange->duration(); | 1130 | int duration = mRecurrenceRange->duration(); |
1108 | QDate endDate = mRecurrenceRange->endDate(); | 1131 | QDate endDate = mRecurrenceRange->endDate(); |
1109 | 1132 | ||
1110 | int result = mRecurrenceRangeDialog->exec(); | 1133 | int result = mRecurrenceRangeDialog->exec(); |
1111 | if ( result == QDialog::Rejected ) { | 1134 | if ( result == QDialog::Rejected ) { |
1112 | mRecurrenceRange->setDuration( duration ); | 1135 | mRecurrenceRange->setDuration( duration ); |
1113 | mRecurrenceRange->setEndDate( endDate ); | 1136 | mRecurrenceRange->setEndDate( endDate ); |
1114 | } | 1137 | } |
1115 | 1138 | ||
1116 | } | 1139 | } |