50 QObject *parent) |
56 QObject *parent) |
51 :QObject(parent), |
57 :QObject(parent), |
52 mCalenEditor(calenEditor), |
58 mCalenEditor(calenEditor), |
53 mEditorForm(form), |
59 mEditorForm(form), |
54 mCalenEditorModel(model), |
60 mCalenEditorModel(model), |
55 mCustomReminderTimeItem(NULL), |
61 mCustomReminderTimeItem(0), |
56 mReminderTimeAdded(false) |
62 mReminderTimeAdded(false) |
57 { |
63 { |
|
64 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_ENTRY ); |
58 mReminderItem = new HbDataFormModelItem(); |
65 mReminderItem = new HbDataFormModelItem(); |
59 mReminderItem->setType(HbDataFormModelItem::ComboBoxItem); |
66 mReminderItem->setType(HbDataFormModelItem::ComboBoxItem); |
60 mReminderItem->setData(HbDataFormModelItem::LabelRole, |
67 mReminderItem->setData(HbDataFormModelItem::LabelRole, |
61 hbTrId("txt_calendar_setlabel_reminder")); |
68 hbTrId("txt_calendar_setlabel_reminder")); |
62 // Add it to the model |
69 // Add it to the model |
63 mCalenEditorModel->appendDataFormItem(mReminderItem, |
70 mCalenEditorModel->appendDataFormItem(mReminderItem, |
64 mCalenEditorModel->invisibleRootItem()); |
71 mCalenEditorModel->invisibleRootItem()); |
|
72 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_EXIT ); |
65 } |
73 } |
66 |
74 |
67 /*! |
75 /*! |
68 Destructor |
76 Destructor |
69 */ |
77 */ |
70 CalenEditorReminderField::~CalenEditorReminderField() |
78 CalenEditorReminderField::~CalenEditorReminderField() |
71 { |
79 { |
|
80 OstTraceFunctionEntry0( DUP1_CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_ENTRY ); |
72 if(mReminderHash.count()) { |
81 if(mReminderHash.count()) { |
73 mReminderHash.clear(); |
82 mReminderHash.clear(); |
74 } |
83 } |
|
84 OstTraceFunctionExit0( DUP1_CALENEDITORREMINDERFIELD_CALENEDITORREMINDERFIELD_EXIT ); |
75 } |
85 } |
76 |
86 |
77 /*! |
87 /*! |
78 Set the reminder choices. |
88 Set the reminder choices. |
79 */ |
89 */ |
80 void CalenEditorReminderField::setReminderChoices() |
90 void CalenEditorReminderField::setReminderChoices() |
81 { |
91 { |
|
92 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETREMINDERCHOICES_ENTRY ); |
82 // Create the reminder choices |
93 // Create the reminder choices |
83 QStringList reminderChoices; |
94 QStringList reminderChoices; |
84 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
95 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off") |
85 << hbTrId("txt_calendar_setlabel_reminder_val_at_the_start") |
96 << hbTrId("txt_calendar_setlabel_reminder_val_at_the_start") |
86 << hbTrId("txt_calendar_setlabel_reminder_val_15_minutes_befo") |
97 << hbTrId("txt_calendar_setlabel_reminder_val_15_minutes_befo") |
87 << hbTrId("txt_calendar_setlabel_reminder_val_30_minutes_befo") |
98 << hbTrId("txt_calendar_setlabel_reminder_val_30_minutes_befo") |
88 << hbTrId("txt_calendar_setlabel_reminder_val_1_hour_before"); |
99 << hbTrId("txt_calendar_setlabel_reminder_val_1_hour_before"); |
89 |
100 |
90 mReminderItem->setContentWidgetData(QString("items"), reminderChoices); |
101 mReminderItem->setContentWidgetData("items", reminderChoices); |
|
102 mReminderItem->setContentWidgetData("objectName", "remainderItem"); |
91 |
103 |
92 // Build the hash map for the reminder. |
104 // Build the hash map for the reminder. |
93 mReminderHash[0] = -1; // OFF. |
105 mReminderHash[0] = -1; // OFF. |
94 mReminderHash[1] = 0; |
106 mReminderHash[1] = 0; |
95 mReminderHash[2] = 15; |
107 mReminderHash[2] = 15; |
96 mReminderHash[3] = 30; |
108 mReminderHash[3] = 30; |
97 mReminderHash[4] = 60; |
109 mReminderHash[4] = 60; |
98 mReminderItem->setEnabled(true); |
110 mReminderItem->setEnabled(true); |
|
111 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETREMINDERCHOICES_EXIT ); |
99 } |
112 } |
100 |
113 |
101 /*! |
114 /*! |
102 Adds reminder item to the model |
115 Adds reminder item to the model |
103 */ |
116 */ |
104 void CalenEditorReminderField::addItemToModel() |
117 void CalenEditorReminderField::addItemToModel() |
105 { |
118 { |
|
119 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_ADDITEMTOMODEL_ENTRY ); |
106 // Add reminder to the model |
120 // Add reminder to the model |
107 mCalenEditorModel->appendDataFormItem( mReminderItem, |
121 mCalenEditorModel->appendDataFormItem( mReminderItem, |
108 mCalenEditorModel->invisibleRootItem()); |
122 mCalenEditorModel->invisibleRootItem()); |
|
123 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_ADDITEMTOMODEL_EXIT ); |
109 } |
124 } |
110 |
125 |
111 /*! |
126 /*! |
112 Removes reminder item from the model |
127 Removes reminder item from the model |
113 */ |
128 */ |
114 void CalenEditorReminderField::removeItemFromModel() |
129 void CalenEditorReminderField::removeItemFromModel() |
115 { |
130 { |
|
131 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_REMOVEITEMFROMMODEL_ENTRY ); |
116 mCalenEditorModel->removeItem(modelIndex()); |
132 mCalenEditorModel->removeItem(modelIndex()); |
|
133 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_REMOVEITEMFROMMODEL_EXIT ); |
117 } |
134 } |
118 |
135 |
119 /*! |
136 /*! |
120 Populates reminder item with available choices to the user |
137 Populates reminder item with available choices to the user |
121 \param newEntry bool value to indicate if its a new entry |
138 \param newEntry bool value to indicate if its a new entry |
122 */ |
139 */ |
123 void CalenEditorReminderField::populateReminderItem(bool newEntry) |
140 void CalenEditorReminderField::populateReminderItem(bool newEntry) |
124 { |
141 { |
|
142 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_POPULATEREMINDERITEM_ENTRY ); |
125 AgendaAlarm reminder; |
143 AgendaAlarm reminder; |
126 bool pastEvent = false; |
144 bool pastEvent = false; |
127 |
145 |
128 // Set reference date to start date or repeat until date accordingly to |
146 // Set reference date to start date or repeat until date accordingly to |
129 // decide whether its a past event or not. |
147 // decide whether its a past event or not. |
280 mCalenEditor->editedEntry()->startTime().date().addDays( |
299 mCalenEditor->editedEntry()->startTime().date().addDays( |
281 -offset)); |
300 -offset)); |
282 reminderDateTimeForAllDay.setTime(mReminderTimeForAllDay); |
301 reminderDateTimeForAllDay.setTime(mReminderTimeForAllDay); |
283 int seconds = |
302 int seconds = |
284 reminderDateTimeForAllDay.secsTo(startDateTimeForAllDay); |
303 reminderDateTimeForAllDay.secsTo(startDateTimeForAllDay); |
285 int timeOffest = seconds / 60; |
304 int timeOffset = seconds / 60; |
286 mCustomReminderTimeItem->setEnabled(true); |
305 mCustomReminderTimeItem->setEnabled(true); |
287 reminder.setTimeOffset(timeOffest); |
306 reminder.setTimeOffset(timeOffset); |
288 reminder.setAlarmSoundName(QString(" ")); |
307 reminder.setAlarmSoundName(QString(" ")); |
289 } |
308 } |
290 } |
309 } |
291 // Set the reminder to the entry. |
310 // Set the reminder to the entry. |
292 mCalenEditor->editedEntry()->setAlarm(reminder); |
311 mCalenEditor->editedEntry()->setAlarm(reminder); |
293 if(!mCalenEditor->isNewEntry()) { |
312 if(!mCalenEditor->isNewEntry()) { |
294 mCalenEditor->addDiscardAction(); |
313 mCalenEditor->addDiscardAction(); |
295 } |
314 } |
|
315 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_HANDLEREMINDERINDEXCHANGED_EXIT ); |
296 } |
316 } |
297 |
317 |
298 /*! |
318 /*! |
299 Returns the mode index of the reminder item |
319 Returns the mode index of the reminder item |
300 \return Mode index of the reminder item |
320 \return Mode index of the reminder item |
301 */ |
321 */ |
302 QModelIndex CalenEditorReminderField::modelIndex() |
322 QModelIndex CalenEditorReminderField::modelIndex() |
303 { |
323 { |
|
324 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_MODELINDEX_ENTRY ); |
304 return mCalenEditorModel->indexFromItem(mReminderItem); |
325 return mCalenEditorModel->indexFromItem(mReminderItem); |
305 } |
326 } |
306 |
327 |
307 /*! |
328 /*! |
308 Set reminder off. |
329 Set reminder off. |
309 */ |
330 */ |
310 void CalenEditorReminderField::setReminderOff() |
331 void CalenEditorReminderField::setReminderOff() |
311 { |
332 { |
|
333 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETREMINDEROFF_ENTRY ); |
312 // Create the remindar choices |
334 // Create the remindar choices |
313 QStringList reminderChoices; |
335 QStringList reminderChoices; |
314 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
336 reminderChoices << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
315 mReminderItem->setContentWidgetData(QString("items"), reminderChoices); |
337 mReminderItem->setContentWidgetData(QString("items"), reminderChoices); |
316 mReminderItem->setEnabled(false); |
338 mReminderItem->setEnabled(false); |
|
339 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETREMINDEROFF_EXIT ); |
317 } |
340 } |
318 |
341 |
319 /*! |
342 /*! |
320 Set the default alarm for a new all day event. |
343 Set the default alarm for a new all day event. |
321 */ |
344 */ |
322 void CalenEditorReminderField::setDefaultAlarmForAllDay() |
345 void CalenEditorReminderField::setDefaultAlarmForAllDay() |
323 { |
346 { |
|
347 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETDEFAULTALARMFORALLDAY_ENTRY ); |
324 // Set default alarm if its a new entry. |
348 // Set default alarm if its a new entry. |
325 if (mCalenEditor->isNewEntry()) { |
349 if (mCalenEditor->isNewEntry()) { |
326 AgendaAlarm reminder; |
350 AgendaAlarm reminder; |
327 QDate defaultDate |
351 QDate defaultDate |
328 (mCalenEditor->editedEntry()->startTime().date().addDays(-1)); |
352 (mCalenEditor->editedEntry()->startTime().date().addDays(-1)); |
329 // Set default time. |
353 // Set default time as 6pm of the previous day. |
330 mReminderTimeForAllDay.setHMS(18, 0, 0, 0); |
354 mReminderTimeForAllDay.setHMS(18, 0, 0, 0); |
331 setDisplayTime(); |
355 setDisplayTime(); |
332 QDateTime startDateTimeForAllDay( |
356 QDateTime startDateTimeForAllDay( |
333 mCalenEditor->editedEntry()->startTime().date(), QTime(0, 0)); |
357 mCalenEditor->editedEntry()->startTime().date(), QTime(0, 0)); |
334 QDateTime defaultReminderDateTimeForAllDay |
358 QDateTime defaultReminderDateTimeForAllDay |
340 reminder.setAlarmSoundName(QString(" ")); |
364 reminder.setAlarmSoundName(QString(" ")); |
341 // Set the reminder to the entry as well as original entry. |
365 // Set the reminder to the entry as well as original entry. |
342 mCalenEditor->editedEntry()->setAlarm(reminder); |
366 mCalenEditor->editedEntry()->setAlarm(reminder); |
343 mCalenEditor->originalEntry()->setAlarm(reminder); |
367 mCalenEditor->originalEntry()->setAlarm(reminder); |
344 } |
368 } |
|
369 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETDEFAULTALARMFORALLDAY_EXIT ); |
345 } |
370 } |
346 |
371 |
347 /*! |
372 /*! |
348 Updates the reminder choices for an all day event. |
373 Updates the reminder choices for an all day event. |
349 \param referenceDate to indicate past or not. |
374 \param referenceDate to indicate past or not. |
350 */ |
375 */ |
351 void CalenEditorReminderField::updateReminderChoicesForAllDay(QDate referenceDate) |
376 void CalenEditorReminderField::updateReminderChoicesForAllDay(QDate referenceDate) |
352 { |
377 { |
|
378 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_ENTRY ); |
353 if (!mReminderTimeAdded){ |
379 if (!mReminderTimeAdded){ |
354 insertReminderTimeField(); |
380 insertReminderTimeField(); |
355 } |
381 } |
356 QStringList reminderChoicesForAllDay; |
382 QStringList reminderChoicesForAllDay; |
357 QDate tomorrow = QDate::currentDate().addDays(1); |
383 QDate tomorrow = QDate::currentDate().addDays(1); |
358 QDate theDayAfterTomorrow = QDate::currentDate().addDays(2); |
384 QDate theDayAfterTomorrow = QDate::currentDate().addDays(2); |
359 |
385 |
|
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. |
360 if (referenceDate < QDate::currentDate() || |
413 if (referenceDate < QDate::currentDate() || |
361 referenceDate == QDate::currentDate()) { |
414 referenceDate == QDate::currentDate()) { |
362 // Set reminder off for past event. |
415 // Set reminder off for past event. |
363 reminderChoicesForAllDay << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
416 reminderChoicesForAllDay << hbTrId("txt_calendar_setlabel_reminder_val_off"); |
364 mReminderItem->setContentWidgetData(QString("items"), |
417 mReminderItem->setContentWidgetData(QString("items"), |
365 reminderChoicesForAllDay); |
418 reminderChoicesForAllDay); |
366 mReminderItem->setEnabled(false); |
419 mReminderItem->setEnabled(false); |
367 removeReminderTimeField(); |
420 // Remove the reminder field if it was added |
|
421 if(mReminderTimeAdded) { |
|
422 removeReminderTimeField(); |
|
423 } |
368 } else if (theDayAfterTomorrow < referenceDate || |
424 } else if (theDayAfterTomorrow < referenceDate || |
369 theDayAfterTomorrow == referenceDate) { |
425 theDayAfterTomorrow == referenceDate) { |
|
426 // 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 |
370 reminderChoicesForAllDay |
428 reminderChoicesForAllDay |
371 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
429 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
372 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
430 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
373 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
431 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before") |
374 << hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
432 << hbTrId("txt_calendar_setlabel_reminder_val_2_days_before"); |
375 mReminderItem->setEnabled(true); |
433 mReminderItem->setEnabled(true); |
376 mCustomReminderTimeItem->setEnabled(true); |
434 mCustomReminderTimeItem->setEnabled(true); |
377 } else { |
435 mReminderItem->setContentWidgetData(QString("items"), |
|
436 reminderChoicesForAllDay); |
|
437 } 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 |
|
439 // and current time is before 6.00 pm. |
|
440 // The options are off, on event day and 1 day before |
378 reminderChoicesForAllDay |
441 reminderChoicesForAllDay |
379 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
442 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
380 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
443 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day") |
381 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before"); |
444 << hbTrId("txt_calendar_setlabel_reminder_val_1_day_before"); |
382 mReminderItem->setEnabled(true); |
445 mReminderItem->setEnabled(true); |
383 mCustomReminderTimeItem->setEnabled(true); |
446 mCustomReminderTimeItem->setEnabled(true); |
384 } |
|
385 if (mReminderItem->isEnabled()) { |
|
386 mReminderItem->setContentWidgetData(QString("items"), |
447 mReminderItem->setContentWidgetData(QString("items"), |
387 reminderChoicesForAllDay); |
448 reminderChoicesForAllDay); |
388 } |
449 }else { |
|
450 // 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. |
|
452 // The options are off and on event day |
|
453 reminderChoicesForAllDay |
|
454 << hbTrId("txt_calendar_setlabel_reminder_val_off") |
|
455 << hbTrId("txt_calendar_setlabel_reminder_val_on_event_day"); |
|
456 mReminderItem->setEnabled(true); |
|
457 mCustomReminderTimeItem->setEnabled(true); |
|
458 mReminderItem->setContentWidgetData(QString("items"), |
|
459 reminderChoicesForAllDay); |
|
460 } |
|
461 // Set the proper index based on the validity of the previous index |
|
462 int count = reminderItemsCount(); |
|
463 // By default, in case of reminder updation, its been agreed to set |
|
464 // ReminderOneDayBefore even though ReminderTwoDaysBefore holds good |
|
465 // If the ReminderOneDayBefore option is available set it or |
|
466 // else set it to ReminderOff |
|
467 if(count > ReminderOneDayBefore) { |
|
468 // Don't make the reminder off since |
|
469 // the valid reminder options are there in the combobox |
|
470 // So check for ReminderOff is needed |
|
471 if (update && |
|
472 (previousIndex == ReminderOff || previousIndex >= ReminderOneDayBefore)) { |
|
473 // If the index has to be updated check the previous index value |
|
474 // And set the default reminder as 1 day before. |
|
475 mReminderItem->setContentWidgetData("currentIndex", |
|
476 ReminderOneDayBefore); |
|
477 }else { |
|
478 // Set the previous index since the alarm is valid |
|
479 mReminderItem->setContentWidgetData("currentIndex", previousIndex); |
|
480 // Set the previous alarm also as the value will be changed to default value |
|
481 // when the current index is been changed |
|
482 mCalenEditor->editedEntry()->setAlarm(previousAlarm); |
|
483 // Get the alarm time from the offset |
|
484 QTime alarmTime = refDateTime.time(); |
|
485 // Set the alarm time and display it on the button |
|
486 mReminderTimeForAllDay.setHMS( |
|
487 alarmTime.hour(),alarmTime.minute(),alarmTime.second()); |
|
488 setDisplayTime(); |
|
489 } |
|
490 }else { |
|
491 // Enters this condition if the previous index set is not valid or |
|
492 // the index is ReminderOff |
|
493 mReminderItem->setContentWidgetData("currentIndex", ReminderOff); |
|
494 } |
|
495 |
|
496 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_UPDATEREMINDERCHOICESFORALLDAY_EXIT ); |
389 } |
497 } |
390 |
498 |
391 /*! |
499 /*! |
392 Insert the reminder time field for an all day event. |
500 Insert the reminder time field for an all day event. |
393 */ |
501 */ |
394 void CalenEditorReminderField::insertReminderTimeField() |
502 void CalenEditorReminderField::insertReminderTimeField() |
395 { |
503 { |
|
504 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_INSERTREMINDERTIMEFIELD_ENTRY ); |
396 HbDataFormModelItem::DataItemType itemType = |
505 HbDataFormModelItem::DataItemType itemType = |
397 static_cast<HbDataFormModelItem::DataItemType> (ReminderTimeOffset); |
506 static_cast<HbDataFormModelItem::DataItemType> (ReminderTimeOffset); |
398 |
507 |
399 // If all day item is not added then insert at one level before. |
508 // If all day item is not added then insert at one level before. |
400 int index = CalenEditorPrivate::ReminderTimeForAllDayItem; |
509 int index = CalenEditorPrivate::ReminderTimeForAllDayItem; |
414 |
523 |
415 mEditorForm->addConnection(mCustomReminderTimeItem, SIGNAL(clicked()), |
524 mEditorForm->addConnection(mCustomReminderTimeItem, SIGNAL(clicked()), |
416 this, SLOT(launchReminderTimePicker())); |
525 this, SLOT(launchReminderTimePicker())); |
417 setDisplayTime(); |
526 setDisplayTime(); |
418 mReminderTimeAdded = true; |
527 mReminderTimeAdded = true; |
|
528 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_INSERTREMINDERTIMEFIELD_EXIT ); |
419 } |
529 } |
420 |
530 |
421 /*! |
531 /*! |
422 Set the reminder time selected by the user. |
532 Set the reminder time selected by the user. |
423 */ |
533 */ |
424 void CalenEditorReminderField::setDisplayTime() |
534 void CalenEditorReminderField::setDisplayTime() |
425 { |
535 { |
|
536 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETDISPLAYTIME_ENTRY ); |
426 HbExtendedLocale locale = HbExtendedLocale::system(); |
537 HbExtendedLocale locale = HbExtendedLocale::system(); |
427 QString timeString = locale.format( |
538 QString timeString = locale.format( |
428 mReminderTimeForAllDay, |
539 mReminderTimeForAllDay, |
429 r_qtn_time_usual_with_zero); |
540 r_qtn_time_usual_with_zero); |
430 mCustomReminderTimeItem->setContentWidgetData("text", timeString); |
541 mCustomReminderTimeItem->setContentWidgetData("text", timeString); |
|
542 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETDISPLAYTIME_EXIT ); |
431 } |
543 } |
432 |
544 |
433 /*! |
545 /*! |
434 Remove the reminder time field if its not an all day event. |
546 Remove the reminder time field if its not an all day event. |
435 */ |
547 */ |
436 void CalenEditorReminderField::removeReminderTimeField() |
548 void CalenEditorReminderField::removeReminderTimeField() |
437 { |
549 { |
|
550 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_REMOVEREMINDERTIMEFIELD_ENTRY ); |
438 mReminderTimeAdded = false; |
551 mReminderTimeAdded = false; |
439 if (mCustomReminderTimeItem) { |
552 if (mCustomReminderTimeItem) { |
440 QModelIndex reminderIndex = |
553 QModelIndex reminderIndex = |
441 mCalenEditorModel->indexFromItem(mCustomReminderTimeItem); |
554 mCalenEditorModel->indexFromItem(mCustomReminderTimeItem); |
442 mCalenEditorModel->removeItem( |
555 mCalenEditorModel->removeItem( |
443 mCalenEditorModel->index( |
556 mCalenEditorModel->index( |
444 reminderIndex.row(), 0)); |
557 reminderIndex.row(), 0)); |
445 mCustomReminderTimeItem = NULL; |
558 mCustomReminderTimeItem = 0; |
446 } |
559 } |
|
560 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_REMOVEREMINDERTIMEFIELD_EXIT ); |
447 } |
561 } |
448 |
562 |
449 /*! |
563 /*! |
450 Launches time picker to select time. |
564 Launches time picker to select time. |
451 */ |
565 */ |
452 void CalenEditorReminderField::launchReminderTimePicker() |
566 void CalenEditorReminderField::launchReminderTimePicker() |
453 { |
567 { |
454 mTimePicker = new HbDateTimePicker(mReminderTimeForAllDay); |
568 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_LAUNCHREMINDERTIMEPICKER_ENTRY ); |
455 mTimePicker->setTime(mReminderTimeForAllDay); |
569 |
456 HbDialog *popUp = new HbDialog(); |
570 HbDialog *popUp = new HbDialog(); |
457 popUp->setDismissPolicy(HbDialog::NoDismiss); |
571 popUp->setDismissPolicy(HbDialog::NoDismiss); |
458 popUp->setTimeout(HbDialog::NoTimeout); |
572 popUp->setTimeout(HbDialog::NoTimeout); |
|
573 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
574 popUp->setHeadingWidget( new HbLabel( |
|
575 hbTrId("Reminder Time"))); |
|
576 |
|
577 HbExtendedLocale locale = HbExtendedLocale::system(); |
|
578 mTimePicker = new HbDateTimePicker(mReminderTimeForAllDay); |
|
579 if(locale.timeStyle() == HbExtendedLocale::Time12) { |
|
580 mTimePicker->setDisplayFormat("hh:mm ap"); |
|
581 }else { |
|
582 mTimePicker->setDisplayFormat("hh:mm"); |
|
583 } |
|
584 mTimePicker->setTime(mReminderTimeForAllDay); |
459 popUp->setContentWidget(mTimePicker); |
585 popUp->setContentWidget(mTimePicker); |
460 popUp->setHeadingWidget( new HbLabel( |
586 |
461 hbTrId("Reminder Time"))); |
587 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok"), popUp); |
462 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
|
463 popUp->addAction(okAction); |
588 popUp->addAction(okAction); |
464 connect(okAction, SIGNAL(triggered()), this, SLOT(setReminderTimeForAllDay())); |
589 connect(okAction, SIGNAL(triggered()), this, SLOT(setReminderTimeForAllDay())); |
465 connect(okAction, SIGNAL(triggered()), popUp, SLOT(close())); |
|
466 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), |
590 popUp->addAction(new HbAction(hbTrId("txt_common_button_cancel"), |
467 popUp)); |
591 popUp)); |
468 popUp->open(); |
592 popUp->open(); |
|
593 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_LAUNCHREMINDERTIMEPICKER_EXIT ); |
469 } |
594 } |
470 |
595 |
471 /*! |
596 /*! |
472 Set the reminder time chosen. |
597 Set the reminder time chosen. |
473 */ |
598 */ |
474 void CalenEditorReminderField::setReminderTimeForAllDay() |
599 void CalenEditorReminderField::setReminderTimeForAllDay() |
475 { |
600 { |
|
601 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETREMINDERTIMEFORALLDAY_ENTRY ); |
476 mReminderTimeForAllDay = mTimePicker->time(); |
602 mReminderTimeForAllDay = mTimePicker->time(); |
477 if (mReminderTimeForAllDay.isValid()) { |
603 if (mReminderTimeForAllDay.isValid()) { |
478 // Change the time displayed to that selected by the user. |
604 // Change the time displayed to that selected by the user. |
479 setDisplayTime(); |
605 setDisplayTime(); |
480 handleReminderIndexChanged(currentReminderIndex()); |
606 handleReminderIndexChanged(currentReminderIndex()); |
481 } |
607 } |
|
608 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETREMINDERTIMEFORALLDAY_EXIT ); |
482 } |
609 } |
483 |
610 |
484 /*! |
611 /*! |
485 Checks if reminder field is enabled or not. |
612 Checks if reminder field is enabled or not. |
486 */ |
613 */ |
487 bool CalenEditorReminderField::isReminderFieldEnabled() |
614 bool CalenEditorReminderField::isReminderFieldEnabled() |
488 { |
615 { |
|
616 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_ISREMINDERFIELDENABLED_ENTRY ); |
489 return mReminderItem->isEnabled(); |
617 return mReminderItem->isEnabled(); |
490 } |
618 } |
491 |
619 |
492 /*! |
620 /*! |
493 Returns the number of items present in the reminder option. |
621 Returns the number of items present in the reminder option. |
494 */ |
622 */ |
495 int CalenEditorReminderField::reminderItemsCount() |
623 int CalenEditorReminderField::reminderItemsCount() |
496 { |
624 { |
|
625 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_REMINDERITEMSCOUNT_ENTRY ); |
497 QVariant strings = mReminderItem->contentWidgetData("items"); |
626 QVariant strings = mReminderItem->contentWidgetData("items"); |
498 QStringList stringList(strings.toStringList()); |
627 QStringList stringList(strings.toStringList()); |
499 int count = stringList.count(); |
628 int count = stringList.count(); |
|
629 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_REMINDERITEMSCOUNT_EXIT ); |
500 return count; |
630 return count; |
501 } |
631 } |
502 |
632 |
503 /*! |
633 /*! |
504 Returns the current chosen index. |
634 Returns the current chosen index. |
505 */ |
635 */ |
506 int CalenEditorReminderField::currentReminderIndex() |
636 int CalenEditorReminderField::currentReminderIndex() |
507 { |
637 { |
|
638 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_CURRENTREMINDERINDEX_ENTRY ); |
508 QVariant countVariant = mReminderItem->contentWidgetData("currentIndex"); |
639 QVariant countVariant = mReminderItem->contentWidgetData("currentIndex"); |
509 int index = countVariant.toInt(); |
640 int index = countVariant.toInt(); |
|
641 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_CURRENTREMINDERINDEX_EXIT ); |
510 return index; |
642 return index; |
511 } |
643 } |
512 |
644 |
513 /*! |
645 /*! |
514 Sets the chosen index as current index. |
646 Sets the chosen index as current index. |
515 /param index indicates the idex value to be set. |
647 /param index indicates the idex value to be set. |
516 */ |
648 */ |
517 void CalenEditorReminderField::setCurrentIndex(int index) |
649 void CalenEditorReminderField::setCurrentIndex(int index) |
518 { |
650 { |
|
651 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_SETCURRENTINDEX_ENTRY ); |
519 mReminderItem->setContentWidgetData("currentIndex", index); |
652 mReminderItem->setContentWidgetData("currentIndex", index); |
|
653 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_SETCURRENTINDEX_EXIT ); |
520 } |
654 } |
521 |
655 |
522 /*! |
656 /*! |
523 Disables the reminder time field. |
657 Disables the reminder time field. |
524 */ |
658 */ |
525 void CalenEditorReminderField::disableReminderTimeField() |
659 void CalenEditorReminderField::disableReminderTimeField() |
526 { |
660 { |
|
661 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_DISABLEREMINDERTIMEFIELD_ENTRY ); |
527 if (mReminderTimeAdded) { |
662 if (mReminderTimeAdded) { |
528 mCustomReminderTimeItem->setEnabled(false); |
663 mCustomReminderTimeItem->setEnabled(false); |
529 } |
664 } |
|
665 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_DISABLEREMINDERTIMEFIELD_EXIT ); |
530 } |
666 } |
531 |
667 |
532 /*! |
668 /*! |
533 Checks if reminder time field is added or not. |
669 Checks if reminder time field is added or not. |
534 */ |
670 */ |
535 bool CalenEditorReminderField::isReminderTimeForAllDayAdded() |
671 bool CalenEditorReminderField::isReminderTimeForAllDayAdded() |
536 { |
672 { |
|
673 OstTraceFunctionEntry0( CALENEDITORREMINDERFIELD_ISREMINDERTIMEFORALLDAYADDED_ENTRY ); |
|
674 OstTraceFunctionExit0( CALENEDITORREMINDERFIELD_ISREMINDERTIMEFORALLDAYADDED_EXIT ); |
537 return mReminderTimeAdded; |
675 return mReminderTimeAdded; |
538 } |
676 } |
539 |
677 |
540 // End of file --Don't remove this. |
678 // End of file --Don't remove this. |