123 = qobject_cast<HbComboBox *> (item->dataItemContentWidget()); |
126 = qobject_cast<HbComboBox *> (item->dataItemContentWidget()); |
124 |
127 |
125 // Set the user roles for the combobox items so that we depend on these |
128 // Set the user roles for the combobox items so that we depend on these |
126 // roles to identify the correct repeat type when repeat choices are |
129 // roles to identify the correct repeat type when repeat choices are |
127 // dynamically removed or added |
130 // dynamically removed or added |
128 mRepeatComboBox->setItemData(RepeatOnce, RepeatOnce, Qt::UserRole+100); |
131 mRepeatComboBox->setItemData(RepeatOnce, RepeatOnce, userRole); |
129 mRepeatComboBox->setItemData(RepeatDaily, RepeatDaily, Qt::UserRole+100); |
132 mRepeatComboBox->setItemData(RepeatDaily, RepeatDaily, userRole); |
130 mRepeatComboBox->setItemData(RepeatWorkdays, |
133 mRepeatComboBox->setItemData(RepeatWorkdays, |
131 RepeatWorkdays, Qt::UserRole+100); |
134 RepeatWorkdays, userRole); |
132 mRepeatComboBox->setItemData(RepeatWeekly, RepeatWeekly, Qt::UserRole+100); |
135 mRepeatComboBox->setItemData(RepeatWeekly, RepeatWeekly, userRole); |
133 mRepeatComboBox->setItemData(RepeatBiWeekly, |
136 mRepeatComboBox->setItemData(RepeatBiWeekly, |
134 RepeatBiWeekly, Qt::UserRole+100); |
137 RepeatBiWeekly, userRole); |
135 mRepeatComboBox->setItemData(RepeatMonthly, |
138 mRepeatComboBox->setItemData(RepeatMonthly, |
136 RepeatMonthly, Qt::UserRole+100); |
139 RepeatMonthly, userRole); |
137 mRepeatComboBox->setItemData(RepeatYearly, RepeatYearly, Qt::UserRole+100); |
140 mRepeatComboBox->setItemData(RepeatYearly, RepeatYearly, userRole); |
138 |
141 |
139 if (mCalenEditor->editedEntry()->isRepeating()) { |
142 if (mCalenEditor->editedEntry()->isRepeating()) { |
140 switch (mCalenEditor->editedEntry()->repeatRule().type()) { |
143 switch (mCalenEditor->editedEntry()->repeatRule().type()) { |
141 case AgendaRepeatRule::DailyRule: { |
144 case AgendaRepeatRule::DailyRule: { |
142 mRepeatComboBox->setCurrentIndex(1); |
145 mRepeatComboBox->setCurrentIndex(1); |
176 // Set the Original entry value also. |
179 // Set the Original entry value also. |
177 mCalenEditor->originalEntry()->setRepeatRule( |
180 mCalenEditor->originalEntry()->setRepeatRule( |
178 AgendaRepeatRule( |
181 AgendaRepeatRule( |
179 AgendaRepeatRule::InvalidRule)); |
182 AgendaRepeatRule::InvalidRule)); |
180 } |
183 } |
181 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
182 SLOT(handleRepeatIndexChanged(int))); |
|
183 |
184 |
184 // Update the repeat choices depending upon the duration |
185 // Update the repeat choices depending upon the duration |
185 updateRepeatChoices(); |
186 updateRepeatChoices(); |
|
187 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
188 SLOT(handleRepeatIndexChanged(int))); |
186 } |
189 } |
187 |
190 |
188 /*! |
191 /*! |
189 Triggerd from tapping on reminder item. |
192 Triggerd from tapping on reminder item. |
190 Handles the reminder time change and updates the same in the event. |
193 Handles the reminder time change and updates the same in the event. |
349 /*! |
358 /*! |
350 Launches the date picker by tapping on the repaet until pushbutton |
359 Launches the date picker by tapping on the repaet until pushbutton |
351 */ |
360 */ |
352 void CalenEditorRepeatField::launchRepeatUntilDatePicker() |
361 void CalenEditorRepeatField::launchRepeatUntilDatePicker() |
353 { |
362 { |
|
363 HbDialog *popUp = new HbDialog(); |
|
364 popUp->setDismissPolicy(HbDialog::NoDismiss); |
|
365 popUp->setTimeout(HbDialog::NoTimeout); |
|
366 popUp->setHeadingWidget( new HbLabel( |
|
367 hbTrId("txt_calendar_title_repeat_until"))); |
|
368 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
369 |
354 if (mDatePicker) { |
370 if (mDatePicker) { |
355 mDatePicker = NULL; |
371 mDatePicker = NULL; |
356 } |
372 } |
357 if (mRepeatRuleType == AgendaRepeatRule::DailyRule) { |
373 if (mRepeatRuleType == AgendaRepeatRule::DailyRule) { |
358 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addDays(1); |
374 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addDays(1); |
359 mDatePicker = new HbDateTimePicker(mRepeatUntilDate); |
375 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
360 mDatePicker->setMinimumDate(minDate); |
376 mDatePicker->setMinimumDate(minDate); |
361 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
377 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
362 mDatePicker->setDate(mRepeatUntilDate); |
378 mDatePicker->setDate(mRepeatUntilDate); |
363 } else if (mRepeatRuleType == AgendaRepeatRule::WeeklyRule) { |
379 } else if (mRepeatRuleType == AgendaRepeatRule::WeeklyRule) { |
364 QDate minDate; |
380 QDate minDate; |
365 if (!mIsBiWeekly || mIsWorkdays) { |
381 if (!mIsBiWeekly || mIsWorkdays) { |
366 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(7); |
382 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(7); |
367 } else { |
383 } else { |
368 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(14); |
384 minDate = mCalenEditor->editedEntry()->endTime().date().addDays(14); |
369 } |
385 } |
370 mDatePicker = new HbDateTimePicker(mRepeatUntilDate); |
386 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
371 mDatePicker->setMinimumDate(minDate); |
387 mDatePicker->setMinimumDate(minDate); |
372 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
388 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
373 mDatePicker->setDate(mRepeatUntilDate); |
389 mDatePicker->setDate(mRepeatUntilDate); |
374 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
390 } else if (mRepeatRuleType == AgendaRepeatRule::MonthlyRule) { |
375 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addMonths(1); |
391 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addMonths(1); |
376 mDatePicker = new HbDateTimePicker(mRepeatUntilDate); |
392 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
377 mDatePicker->setMinimumDate(minDate); |
393 mDatePicker->setMinimumDate(minDate); |
378 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
394 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
379 mDatePicker->setDate(mRepeatUntilDate); |
395 mDatePicker->setDate(mRepeatUntilDate); |
380 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
396 } else if (mRepeatRuleType == AgendaRepeatRule::YearlyRule) { |
381 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addYears(1); |
397 QDate minDate = mCalenEditor->editedEntry()->endTime().date().addYears(1); |
382 mDatePicker = new HbDateTimePicker(mRepeatUntilDate); |
398 mDatePicker = new HbDateTimePicker(mRepeatUntilDate, popUp); |
383 mDatePicker->setMinimumDate(minDate); |
399 mDatePicker->setMinimumDate(minDate); |
384 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
400 mDatePicker->setMaximumDate(QDate(31, 12, 2100)); |
385 mDatePicker->setDate(mRepeatUntilDate); |
401 mDatePicker->setDate(mRepeatUntilDate); |
386 } |
402 } |
387 HbDialog popUp; |
403 popUp->setContentWidget(mDatePicker); |
388 popUp.setDismissPolicy(HbDialog::NoDismiss); |
404 |
389 popUp.setTimeout(HbDialog::NoTimeout); |
|
390 popUp.setContentWidget(mDatePicker); |
|
391 popUp.setHeadingWidget( new HbLabel( |
|
392 hbTrId("txt_calendar_title_repeat_until"))); |
|
393 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
405 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
394 popUp.setPrimaryAction(okAction); |
406 popUp->addAction(okAction); |
395 connect(okAction, SIGNAL(triggered()), this, SLOT(setRepeatUntilDate())); |
407 connect(okAction, SIGNAL(triggered()), this, SLOT(setRepeatUntilDate())); |
396 connect(okAction, SIGNAL(triggered()), &popUp, SLOT(close())); |
408 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), popUp)); |
397 popUp.setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"), |
409 popUp->open(); |
398 &popUp)); |
|
399 popUp.exec(); |
|
400 } |
410 } |
401 |
411 |
402 /*! |
412 /*! |
403 Sets the repeat until date on the repeat until item |
413 Sets the repeat until date on the repeat until item |
404 */ |
414 */ |
409 HbExtendedLocale locale = HbExtendedLocale::system(); |
419 HbExtendedLocale locale = HbExtendedLocale::system(); |
410 QString dateString = locale.format(mRepeatUntilDate, |
420 QString dateString = locale.format(mRepeatUntilDate, |
411 r_qtn_date_usual_with_zero); |
421 r_qtn_date_usual_with_zero); |
412 mCustomRepeatUntilItem->setContentWidgetData("text", dateString); |
422 mCustomRepeatUntilItem->setContentWidgetData("text", dateString); |
413 } |
423 } |
|
424 mCalenEditor->updateReminderChoices(); |
|
425 } |
|
426 |
|
427 /*! |
|
428 Returns the repeatuntildate displayed. |
|
429 */ |
|
430 QDate CalenEditorRepeatField::repeatUntilDate() |
|
431 { |
|
432 return mRepeatUntilDate; |
414 } |
433 } |
415 |
434 |
416 /*! |
435 /*! |
417 Updates the repeat choices depending on the meeting duration |
436 Updates the repeat choices depending on the meeting duration |
418 */ |
437 */ |
419 void CalenEditorRepeatField::updateRepeatChoices() |
438 void CalenEditorRepeatField::updateRepeatChoices() |
420 { |
439 { |
|
440 if (!mRepeatComboBox) { |
|
441 return; |
|
442 } |
421 // Clear all the choices and add it again. If we dont do it |
443 // Clear all the choices and add it again. If we dont do it |
422 // as user would have changed the end times many times and we would have |
444 // as user would have changed the end times many times and we would have |
423 // deleted repeat options depending upon that |
445 // deleted repeat options depending upon that |
424 // Get the current choice |
446 // Get the current choice |
425 int choice = mRepeatComboBox->currentIndex(); |
447 int choice = mRepeatComboBox->currentIndex(); |
426 int previousCount = mRepeatComboBox->count(); |
448 int previousCount = mRepeatComboBox->count(); |
427 mRepeatComboBox->clear(); |
449 mRepeatComboBox->clear(); |
428 QStringList repeatChoices; |
450 QStringList repeatChoices; |
429 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
451 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
430 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
452 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
431 // TODO : add text ID for workdays |
453 << hbTrId("txt_calendar_setlabel_repeat_val_workdays") |
432 << hbTrId("Workdays") |
|
433 << hbTrId("txt_calendar_setlabel_repeat_val_weekly") |
454 << hbTrId("txt_calendar_setlabel_repeat_val_weekly") |
434 << hbTrId("txt_calendar_setlabel_repeat_val_fortnightly") |
455 << hbTrId("txt_calendar_setlabel_repeat_val_fortnightly") |
435 << hbTrId("txt_calendar_setlabel_repeat_val_monthly") |
456 << hbTrId("txt_calendar_setlabel_repeat_val_monthly") |
436 << hbTrId("txt_calendar_setlabel_repeat_val_yearly"); |
457 << hbTrId("txt_calendar_setlabel_repeat_val_yearly"); |
437 mRepeatComboBox->addItems(repeatChoices); |
458 mRepeatComboBox->addItems(repeatChoices); |
438 // Set the user roles for the combobox items so that we depend on these |
459 // Set the user roles for the combobox items so that we depend on these |
439 // roles to identify the correct repeat type when repeat choices are |
460 // roles to identify the correct repeat type when repeat choices are |
440 // dynamically removed or added |
461 // dynamically removed or added |
441 mRepeatComboBox->setItemData(RepeatOnce, RepeatOnce, Qt::UserRole + 100); |
462 mRepeatComboBox->setItemData(RepeatOnce, RepeatOnce, userRole); |
442 mRepeatComboBox->setItemData(RepeatDaily, RepeatDaily, |
463 mRepeatComboBox->setItemData(RepeatDaily, RepeatDaily, |
443 Qt::UserRole + 100); |
464 userRole); |
444 mRepeatComboBox->setItemData(RepeatWorkdays, |
465 mRepeatComboBox->setItemData(RepeatWorkdays, |
445 RepeatWorkdays, Qt::UserRole+100); |
466 RepeatWorkdays, userRole); |
446 mRepeatComboBox->setItemData(RepeatWeekly, RepeatWeekly, |
467 mRepeatComboBox->setItemData(RepeatWeekly, RepeatWeekly, |
447 Qt::UserRole + 100); |
468 userRole); |
448 mRepeatComboBox->setItemData(RepeatBiWeekly, RepeatBiWeekly, |
469 mRepeatComboBox->setItemData(RepeatBiWeekly, RepeatBiWeekly, |
449 Qt::UserRole + 100); |
470 userRole); |
450 mRepeatComboBox->setItemData(RepeatMonthly, RepeatMonthly, |
471 mRepeatComboBox->setItemData(RepeatMonthly, RepeatMonthly, |
451 Qt::UserRole + 100); |
472 userRole); |
452 mRepeatComboBox->setItemData(RepeatYearly, RepeatYearly, |
473 mRepeatComboBox->setItemData(RepeatYearly, RepeatYearly, |
453 Qt::UserRole + 100); |
474 userRole); |
454 |
475 |
455 int totalCount = mRepeatComboBox->count(); |
476 int totalCount = mRepeatComboBox->count(); |
456 |
477 |
457 if (previousCount < totalCount && choice > 0) { |
478 if (previousCount < totalCount && choice > 0) { |
458 choice += (totalCount - previousCount); |
479 choice += (totalCount - previousCount); |