161 } |
198 } |
162 |
199 |
163 if (mCalenEditor->isAllDayEvent()) { |
200 if (mCalenEditor->isAllDayEvent()) { |
164 updateReminderChoicesForAllDay(referenceDate); |
201 updateReminderChoicesForAllDay(referenceDate); |
165 } else { |
202 } else { |
|
203 if((referenceDate == QDate::currentDate()) |
|
204 && !pastEvent) { |
|
205 UpdateReminderChoicesForSameDay(mCalenEditor->editedEntry()->startTime().time()); |
|
206 sameDay = true; |
|
207 } |
|
208 else { |
166 setReminderChoices(); |
209 setReminderChoices(); |
|
210 } |
167 } |
211 } |
168 // Set the default reminder value to 15 minutes |
212 // Set the default reminder value to 15 minutes |
169 if (newEntry) { |
213 if (newEntry) { |
170 if (!pastEvent) { |
214 if (!pastEvent) { |
171 mReminderItem->setContentWidgetData("currentIndex", 2); |
215 int defaultIndex = Reminder15MinsBefore; |
|
216 if (reminderItemsCount() == (ReminderAtStart + 1)) //If 15MinsBefore option is not available |
|
217 defaultIndex = ReminderAtStart; |
|
218 |
|
219 setCurrentIndex(defaultIndex); |
172 // Save the reminder alarm for the entry |
220 // Save the reminder alarm for the entry |
173 reminder.setTimeOffset(mReminderHash.value(2)); |
221 reminder.setTimeOffset(mReminderHash.value(defaultIndex)); |
174 reminder.setAlarmSoundName(QString(" ")); |
222 reminder.setAlarmSoundName(QString(" ")); |
175 // Set the reminder to the entry as well as original entry. |
223 // Set the reminder to the entry as well as original entry. |
176 mCalenEditor->editedEntry()->setAlarm(reminder); |
224 mCalenEditor->editedEntry()->setAlarm(reminder); |
177 mCalenEditor->originalEntry()->setAlarm(reminder); |
225 mCalenEditor->originalEntry()->setAlarm(reminder); |
178 } else { |
226 } else { |
179 mReminderItem->setContentWidgetData("currentIndex", 0); |
227 setReminderOff(); |
180 mReminderItem->setEnabled(false); |
|
181 } |
228 } |
182 } else { |
229 } else { |
|
230 int offsetInMins = mCalenEditor->editedEntry()->alarm().timeOffset(); |
183 // If the alarm is not null, |
231 // If the alarm is not null, |
184 // Check if all day event or not and then set the choices accordingly. |
232 // Check if all day event or not and then set the choices accordingly. |
185 if (mCalenEditor->editedEntry()->alarm().isNull()) { |
233 if (mCalenEditor->editedEntry()->alarm().isNull()) { |
186 // Alarm is set off |
234 // Alarm is set off |
187 mReminderItem->setContentWidgetData("currentIndex", ReminderOff); |
235 setCurrentIndex(ReminderOff); |
188 if(mReminderTimeAdded) { |
236 if(mReminderTimeAdded) { |
189 removeReminderTimeField(); |
237 removeReminderTimeField(); |
190 } |
238 } |
191 } else if (!mCalenEditor->isAllDayEvent()) { |
239 } else if (!mCalenEditor->isAllDayEvent()) { |
192 // Get the reminder offset value. |
240 QTime currentTime = QTime::currentTime(); |
193 int reminderOffset = |
241 |
194 mCalenEditor->editedEntry()->alarm().timeOffset(); |
242 //TODO: Still need confirmation for proper behaviour when entry is edited after alarm has expired. |
195 // Get the index value for the reminder combo box from the hash |
243 if (!repeatingEntry && sameDay && (currentTime.addSecs(offsetInMins * 60) >= mCalenEditor->editedEntry()->startTime().time())) { |
196 // table. |
244 setCurrentIndex(ReminderOff); //Alarm has expired already, so making it off. |
197 int index = mReminderHash.key(reminderOffset); |
245 //The slot for index 0 is not called, since after UpdateReminderChoicesForSameDay() |
198 mReminderItem->setContentWidgetData("currentIndex", index); |
246 //index is 0 itself and there is no change. So explicitly calling it here. |
|
247 handleReminderIndexChanged(0); |
|
248 } |
|
249 else { |
|
250 setSavedMeetingReminderIndex(); |
|
251 } |
199 } else { |
252 } else { |
200 // Insert reminder time field and display entry's reminder time. |
253 // Insert reminder time field and display entry's reminder time. |
201 // If past then disable the field. |
254 // If past then disable the field. |
202 if (!mReminderTimeAdded) { |
255 if (!mReminderTimeAdded) { |
203 insertReminderTimeField(); |
256 insertReminderTimeField(); |
204 } |
257 } |
205 if (pastEvent && mReminderTimeAdded) { |
258 if (pastEvent && mReminderTimeAdded) { |
206 mCustomReminderTimeItem->setEnabled(false); |
259 mCustomReminderTimeItem->setEnabled(false); |
207 } |
260 } |
208 QStringList reminderChoicesForAllDay; |
261 // Get the appropriate reminder index depending on the value of time offset. |
209 reminderChoicesForAllDay << hbTrId("txt_calendar_setlabel_reminder_val_off") |
262 int index = getReminderIndexBasedOnEntryAlarm(); |
210 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
263 mReminderItem->setContentWidgetData("currentIndex", index); |
211 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
|
212 << hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
|
213 mReminderItem->setContentWidgetData(QString("items"), |
|
214 reminderChoicesForAllDay); |
|
215 QTime referenceTime(0, 0, 0); |
|
216 // Set the appropriate reminder depending on the value of time offset. |
|
217 reminder = mCalenEditor->editedEntry()->alarm(); |
|
218 int offsetInMins = reminder.timeOffset(); |
|
219 if (offsetInMins < 0 || offsetInMins == 0) { |
|
220 mReminderItem->setContentWidgetData("currentIndex", ReminderOnEventDay); |
|
221 mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
222 * 60)); |
|
223 } else if (offsetInMins < numberOfMinutesInADay) { |
|
224 mReminderItem->setContentWidgetData("currentIndex", ReminderOneDayBefore); |
|
225 mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
226 * 60)); |
|
227 } else { |
|
228 mReminderItem->setContentWidgetData("currentIndex", ReminderTwoDaysBefore); |
|
229 offsetInMins %= (24 * 60); |
|
230 mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
231 * 60)); |
|
232 } |
|
233 setDisplayTime(); |
264 setDisplayTime(); |
234 } |
265 } |
235 if (pastEvent) { |
266 if (pastEvent) { |
236 mReminderItem->setEnabled(false); |
267 mReminderItem->setEnabled(false); |
237 } |
268 } |
368 } |
404 } |
369 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETDEFAULTALARMFORALLDAY_EXIT ); |
405 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETDEFAULTALARMFORALLDAY_EXIT ); |
370 } |
406 } |
371 |
407 |
372 /*! |
408 /*! |
|
409 Update the reminder choices when the meeting is on same day, |
|
410 based on the time available from current time to start time of the event. |
|
411 */ |
|
412 void CalenEditorReminderField::UpdateReminderChoicesForSameDay(QTime startTime) |
|
413 { |
|
414 QTime currentTime = QTime::currentTime(); |
|
415 int offset = currentTime.secsTo(startTime); |
|
416 |
|
417 // Disconnect the slot and connect it back again at end to avoid unnecessary |
|
418 // calls to handleReminderIndexChanged slot. Or else the slot gets called |
|
419 // when we add all of items to the repeat combobox. |
|
420 mEditorForm->removeConnection(mReminderItem, |
|
421 SIGNAL(currentIndexChanged(int)), this, |
|
422 SLOT(handleReminderIndexChanged(int))); |
|
423 |
|
424 //The event start time is within 15mins from current time of today, |
|
425 //then we cannot have alarms "15 mins before", "30mins before" and "1 hour before" |
|
426 if (offset <= SecsIn15Mins) |
|
427 { |
|
428 QStringList reminderChoices; |
|
429 //First to clear all items, we just set items with empty list. |
|
430 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
431 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
432 << hbTrId("txt_calendar_setlabel_reminder_val_at_the_start"); |
|
433 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
434 } |
|
435 //The event start time is within half and hour from current time of today |
|
436 //then we cannot have alarms "30mins before" and "1 hour before" |
|
437 else if (offset <= SecsIn30Mins) |
|
438 { |
|
439 QStringList reminderChoices; |
|
440 //First to clear all items, we just set items with empty list. |
|
441 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
442 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
443 << hbTrId("txt_calendar_setlabel_reminder_val_at_the_start") |
|
444 << hbTrId("txt_calendar_setlabel_reminder_val_15_minutes_befo"); |
|
445 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
446 } |
|
447 //The event start time is within an hour of the current time of today, |
|
448 //then cannot have alarm "1 hour before". |
|
449 else if (offset <= SecsInOneHour) |
|
450 { |
|
451 QStringList reminderChoices; |
|
452 //First to clear all items, we just set items with empty list. |
|
453 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
454 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
455 << hbTrId("txt_calendar_setlabel_reminder_val_at_the_start") |
|
456 << hbTrId("txt_calendar_setlabel_reminder_val_15_minutes_befo") |
|
457 << hbTrId("txt_calendar_setlabel_reminder_val_30_minutes_befo"); |
|
458 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
459 } |
|
460 // The event start time is more than one hour from current time |
|
461 // then we can have all choices for alarm. |
|
462 else |
|
463 { |
|
464 QStringList reminderChoices; |
|
465 //First to clear all items, we just set items with empty list. |
|
466 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
467 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
468 << hbTrId("txt_calendar_setlabel_reminder_val_at_the_start") |
|
469 << hbTrId("txt_calendar_setlabel_reminder_val_15_minutes_befo") |
|
470 << hbTrId("txt_calendar_setlabel_reminder_val_30_minutes_befo") |
|
471 << hbTrId("txt_calendar_setlabel_reminder_val_1_hour_before"); |
|
472 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
473 } |
|
474 mReminderItem->setEnabled(true); |
|
475 mEditorForm->addConnection(mReminderItem, |
|
476 SIGNAL(currentIndexChanged(int)), this, |
|
477 SLOT(handleReminderIndexChanged(int))); |
|
478 } |
|
479 |
|
480 /*! |
373 Updates the reminder choices for an all day event. |
481 Updates the reminder choices for an all day event. |
374 \param referenceDate to indicate past or not. |
482 \param referenceDate to indicate past or not. |
375 */ |
483 */ |
376 void CalenEditorReminderField::updateReminderChoicesForAllDay(QDate referenceDate) |
484 void CalenEditorReminderField::updateReminderChoicesForAllDay(QDate referenceDate) |
377 { |
485 { |
378 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_ENTRY ); |
486 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_ENTRY ); |
379 if (!mReminderTimeAdded){ |
487 if (!mReminderTimeAdded){ |
380 insertReminderTimeField(); |
488 insertReminderTimeField(); |
381 } |
489 } |
|
490 // This functions rearranges the reminder options based on the date and time |
|
491 // To avoid the unecessary call to handleReminderIndexChanged |
|
492 // the connection is removed. |
|
493 mEditorForm->removeConnection(mReminderItem, |
|
494 SIGNAL(currentIndexChanged(int)), this, |
|
495 SLOT(handleReminderIndexChanged(int))); |
|
496 |
|
497 // Since the combox box is not updated as per the current datetime |
|
498 // there can be a conflict between the previousIndex set on the combobox |
|
499 // and the actual index. This comes while populating an existing entry. |
|
500 // So the index has to be taken from the entry alarm |
|
501 |
|
502 AgendaAlarm actualAlarm = mCalenEditor->editedEntry()->alarm(); |
|
503 // Get the actual alarm index from the entry alarm which is been set |
|
504 int actualIndex = getReminderIndexBasedOnEntryAlarm(); |
|
505 int offsetInMins = actualAlarm.timeOffset(); |
|
506 |
|
507 // Calculate the alarm time |
|
508 QDateTime alarmDateTime; |
|
509 alarmDateTime.setDate(referenceDate); |
|
510 alarmDateTime.setTime(mCalenEditor->editedEntry()->startTime().time()); |
|
511 QTime checkTime = alarmDateTime.time().addSecs(-(offsetInMins * 60)); |
|
512 alarmDateTime.setTime(checkTime); |
|
513 |
|
514 // The combox is updated based on the reference date which is beed passed. |
|
515 // And the reminder time has to be set acoordingly |
382 QStringList reminderChoicesForAllDay; |
516 QStringList reminderChoicesForAllDay; |
383 QDate tomorrow = QDate::currentDate().addDays(1); |
517 QDate tomorrow = QDate::currentDate().addDays(1); |
384 QDate theDayAfterTomorrow = QDate::currentDate().addDays(2); |
518 QDate theDayAfterTomorrow = QDate::currentDate().addDays(2); |
385 |
519 |
386 // Get the previous index to retain if the alarm is valid |
|
387 QVariant countVariant = mReminderItem->contentWidgetData("currentIndex"); |
|
388 int previousIndex = countVariant.toInt(); |
|
389 AgendaAlarm previousAlarm = mCalenEditor->editedEntry()->alarm(); |
|
390 |
|
391 // Update the reminder choices only if the alarm set is not valid |
|
392 // Get the alarm offset to check for the validity |
|
393 int offset = mCalenEditor->editedEntry()->alarm().timeOffset(); |
|
394 bool update = true; |
|
395 |
|
396 // Calculate the alarm time |
|
397 QDateTime refDateTime; |
|
398 refDateTime.setDate(referenceDate); |
|
399 refDateTime.setTime(mCalenEditor->editedEntry()->startTime().time()); |
|
400 QTime checkTime = refDateTime.time().addSecs(-(offset * 60)); |
|
401 refDateTime.setTime(checkTime); |
|
402 // Check for valid alarm offset |
|
403 if(offset >= 0) { |
|
404 // If the alarm which was already set is valid, |
|
405 // then dont update the reminder choices |
|
406 if ((refDateTime > QDateTime::currentDateTime()) || |
|
407 (refDateTime.date() == QDate::currentDate() && ( |
|
408 refDateTime.time() > QTime::currentTime()))) { |
|
409 update = false; |
|
410 } |
|
411 } |
|
412 // If the event is on a past date the default alarm will be off. |
520 // If the event is on a past date the default alarm will be off. |
413 if (referenceDate < QDate::currentDate() || |
521 if (referenceDate < QDate::currentDate() || |
414 referenceDate == QDate::currentDate()) { |
522 referenceDate == QDate::currentDate()) { |
415 // Set reminder off for past event. |
523 // Set reminder off for past event. |
416 reminderChoicesForAllDay << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
524 reminderChoicesForAllDay << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
417 mReminderItem->setContentWidgetData(QString("items"), |
525 mReminderItem->setContentWidgetData(QString("items"), |
418 reminderChoicesForAllDay); |
526 reminderChoicesForAllDay); |
419 mReminderItem->setEnabled(false); |
527 mReminderItem->setEnabled(false); |
420 // Remove the reminder field if it was added |
528 // Remove the reminder field if it was added |
421 if(mReminderTimeAdded) { |
529 if(mReminderTimeAdded) { |
422 removeReminderTimeField(); |
530 removeReminderTimeField(); |
423 } |
531 } |
424 } else if (theDayAfterTomorrow < referenceDate || |
532 } else if (theDayAfterTomorrow < referenceDate) { |
425 theDayAfterTomorrow == referenceDate) { |
|
426 // If the event is on a future date which is two days after the current date |
533 // If the event is on a future date which is two days after the current date |
427 // The options are off, on event day, 1 day before and 2 days before |
534 // The options are off, on event day, 1 day before and 2 days before |
428 reminderChoicesForAllDay |
535 reminderChoicesForAllDay |
|
536 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
537 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
|
538 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
|
539 << hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
|
540 mReminderItem->setEnabled(true); |
|
541 mCustomReminderTimeItem->setEnabled(true); |
|
542 mReminderItem->setContentWidgetData(QString("items"), |
|
543 reminderChoicesForAllDay); |
|
544 } else if (theDayAfterTomorrow == referenceDate) { |
|
545 // If the event is on a future date which is two days after the current date |
|
546 // If the current time is before 6.00 pm (default for 2 days before) |
|
547 // The options are off, on event day, 1 day before and 2 days before |
|
548 if (QTime::currentTime() < QTime(18, 0, 0, 0)) { |
|
549 reminderChoicesForAllDay |
429 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
550 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
430 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
551 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
431 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
552 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
432 << hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
553 << hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
|
554 }else { |
|
555 // If the event is on a future date which is two days after the current date |
|
556 // the current time is after 6.00 pm (default for 2 days before) |
|
557 // If its after the default time don't show the 2 days before option |
|
558 reminderChoicesForAllDay |
|
559 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
560 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
|
561 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before"); |
|
562 } |
433 mReminderItem->setEnabled(true); |
563 mReminderItem->setEnabled(true); |
434 mCustomReminderTimeItem->setEnabled(true); |
564 mCustomReminderTimeItem->setEnabled(true); |
435 mReminderItem->setContentWidgetData(QString("items"), |
565 mReminderItem->setContentWidgetData(QString("items"), |
436 reminderChoicesForAllDay); |
566 reminderChoicesForAllDay); |
437 } else if (QTime::currentTime() < QTime(18, 0, 0, 0)) { |
567 }else if (QTime::currentTime() < QTime(18, 0, 0, 0)) { |
438 // If the event is on a future date which is one day after the current date |
568 // If the event is on a future date which is one day after the current date |
439 // and current time is before 6.00 pm. |
569 // and current time is before 6.00 pm. |
440 // The options are off, on event day and 1 day before |
570 // The options are off, on event day and 1 day before |
441 reminderChoicesForAllDay |
571 reminderChoicesForAllDay |
442 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
572 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
443 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
573 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
444 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before"); |
574 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before"); |
445 mReminderItem->setEnabled(true); |
575 mReminderItem->setEnabled(true); |
446 mCustomReminderTimeItem->setEnabled(true); |
576 mCustomReminderTimeItem->setEnabled(true); |
447 mReminderItem->setContentWidgetData(QString("items"), |
577 mReminderItem->setContentWidgetData(QString("items"), |
448 reminderChoicesForAllDay); |
578 reminderChoicesForAllDay); |
449 }else { |
579 }else { |
450 // If the event is on a future date which is one day after the current date |
580 // If the event is on a future date which is one day after the current date |
451 // and current time is after 6.00 pm. |
581 // and current time is after 6.00 pm. |
452 // The options are off and on event day |
582 // The options are off and on event day |
453 reminderChoicesForAllDay |
583 reminderChoicesForAllDay |
454 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
584 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
455 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day"); |
585 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day"); |
456 mReminderItem->setEnabled(true); |
586 mReminderItem->setEnabled(true); |
457 mCustomReminderTimeItem->setEnabled(true); |
587 mCustomReminderTimeItem->setEnabled(true); |
458 mReminderItem->setContentWidgetData(QString("items"), |
588 mReminderItem->setContentWidgetData(QString("items"), |
459 reminderChoicesForAllDay); |
589 reminderChoicesForAllDay); |
460 } |
590 } |
461 // Set the proper index based on the validity of the previous index |
591 // Get the count of the reminder options after the rearrangement |
|
592 // based on the date and time |
462 int count = reminderItemsCount(); |
593 int count = reminderItemsCount(); |
463 // By default, in case of reminder updation, its been agreed to set |
594 // Set the reminder index |
464 // ReminderOneDayBefore even though ReminderTwoDaysBefore holds good |
595 |
465 // If the ReminderOneDayBefore option is available set it or |
596 if (count <= actualIndex || |
466 // else set it to ReminderOff |
597 alarmDateTime < QDateTime::currentDateTime() || |
467 if(count > ReminderOneDayBefore) { |
598 actualIndex == ReminderOff) { |
468 // Don't make the reminder off since |
599 // This will be executed when the actual index is not |
469 // the valid reminder options are there in the combobox |
600 // available in the combobox or the alarm time is already passed |
470 // So check for ReminderOff is needed |
601 // or the actual alarm is off |
471 if (update && |
602 // So set it as off |
472 (previousIndex == ReminderOff || previousIndex >= ReminderOneDayBefore)) { |
603 mReminderItem->setContentWidgetData("currentIndex", ReminderOff); |
473 // If the index has to be updated check the previous index value |
604 actualAlarm = AgendaAlarm(); |
474 // And set the default reminder as 1 day before. |
605 mCalenEditor->editedEntry()->setAlarm(actualAlarm); |
475 mReminderItem->setContentWidgetData("currentIndex", |
606 removeReminderTimeField(); |
476 ReminderOneDayBefore); |
607 }else { |
477 }else { |
608 // Set the actual reminder index |
478 // Set the previous index since the alarm is valid |
609 mReminderItem->setContentWidgetData("currentIndex", actualIndex); |
479 mReminderItem->setContentWidgetData("currentIndex", previousIndex); |
610 if( actualIndex != ReminderOff) { |
480 // Set the previous alarm also as the value will be changed to default value |
611 if(!mReminderTimeAdded) { |
481 // when the current index is been changed |
612 insertReminderTimeField(); |
482 mCalenEditor->editedEntry()->setAlarm(previousAlarm); |
613 } |
|
614 mCalenEditor->editedEntry()->setAlarm(actualAlarm); |
483 // Get the alarm time from the offset |
615 // Get the alarm time from the offset |
484 QTime alarmTime = refDateTime.time(); |
616 QTime alarmTime = alarmDateTime.time(); |
485 // Set the alarm time and display it on the button |
617 // Set the alarm time and display it on the button |
486 mReminderTimeForAllDay.setHMS( |
618 mReminderTimeForAllDay.setHMS( |
487 alarmTime.hour(),alarmTime.minute(),alarmTime.second()); |
619 alarmTime.hour(),alarmTime.minute(),alarmTime.second()); |
488 setDisplayTime(); |
620 setDisplayTime(); |
489 } |
621 }else { |
490 }else { |
622 actualAlarm = AgendaAlarm(); |
491 // Enters this condition if the previous index set is not valid or |
623 removeReminderTimeField(); |
492 // the index is ReminderOff |
624 } |
493 mReminderItem->setContentWidgetData("currentIndex", ReminderOff); |
625 } |
494 } |
626 // Connect the slot for the index change |
495 |
627 mEditorForm->addConnection(mReminderItem, |
|
628 SIGNAL(currentIndexChanged(int)), this, |
|
629 SLOT(handleReminderIndexChanged(int))); |
|
630 |
496 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_EXIT ); |
631 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_EXIT ); |
|
632 } |
|
633 |
|
634 /*! |
|
635 Gets the reminder index for all day events based on the alarm |
|
636 which is saved for the entry |
|
637 */ |
|
638 int CalenEditorReminderField::getReminderIndexBasedOnEntryAlarm() |
|
639 { |
|
640 // Get the appropriate reminder index depending on the value of time offset. |
|
641 AgendaAlarm actualAlarm = mCalenEditor->editedEntry()->alarm(); |
|
642 QTime referenceTime(0, 0, 0); |
|
643 int index = ReminderOff; |
|
644 int offsetInMins = actualAlarm.timeOffset(); |
|
645 if(offsetInMins == -1) { |
|
646 index = ReminderOff; |
|
647 }else if (offsetInMins < 0 || offsetInMins == 0) { |
|
648 index = ReminderOnEventDay; |
|
649 mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
650 * 60)); |
|
651 } else if (offsetInMins <= numberOfMinutesInADay) { |
|
652 index = ReminderOneDayBefore; |
|
653 mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
654 * 60)); |
|
655 } else { |
|
656 index = ReminderTwoDaysBefore; |
|
657 offsetInMins %= (24 * 60); |
|
658 mReminderTimeForAllDay = referenceTime.addSecs(-(offsetInMins |
|
659 * 60)); |
|
660 } |
|
661 return index; |
497 } |
662 } |
498 |
663 |
499 /*! |
664 /*! |
500 Insert the reminder time field for an all day event. |
665 Insert the reminder time field for an all day event. |
501 */ |
666 */ |