93 mEditorForm(form), |
93 mEditorForm(form), |
94 mCalenEditorModel(model), |
94 mCalenEditorModel(model), |
95 mRepeatItem(0), |
95 mRepeatItem(0), |
96 mRepeatComboBox(0), |
96 mRepeatComboBox(0), |
97 mCustomRepeatUntilItem(0), |
97 mCustomRepeatUntilItem(0), |
|
98 mRepeatRoleValue(0), |
98 mIsBiWeekly(false), |
99 mIsBiWeekly(false), |
99 mIsWorkdays(false), |
100 mIsWorkdays(false), |
100 mRepeatUntilItemAdded(false) |
101 mRepeatUntilItemAdded(false) |
101 { |
102 { |
102 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_CALENEDITORREPEATFIELD_ENTRY ); |
103 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_CALENEDITORREPEATFIELD_ENTRY ); |
228 // Set the Original entry value also. |
229 // Set the Original entry value also. |
229 mCalenEditor->originalEntry()->setRepeatRule( |
230 mCalenEditor->originalEntry()->setRepeatRule( |
230 AgendaRepeatRule( |
231 AgendaRepeatRule( |
231 AgendaRepeatRule::InvalidRule)); |
232 AgendaRepeatRule::InvalidRule)); |
232 } |
233 } |
233 |
234 // Connect the slot once the updation of mRepeatComboBox is done |
|
235 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
236 SLOT(handleRepeatIndexChanged(int))); |
234 // Update the repeat choices depending upon the duration |
237 // Update the repeat choices depending upon the duration |
235 updateRepeatChoices(); |
238 updateRepeatChoices(); |
236 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
237 SLOT(handleRepeatIndexChanged(int))); |
|
238 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_POPULATEREPEATITEM_EXIT ); |
239 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_POPULATEREPEATITEM_EXIT ); |
|
240 } |
|
241 |
|
242 /*! |
|
243 Removes the repeat until item from the model |
|
244 and removed the connection for date picker launch too. |
|
245 */ |
|
246 void CalenEditorRepeatField::removeRepeatUntilItem() |
|
247 { |
|
248 mRepeatRuleType = AgendaRepeatRule::InvalidRule; |
|
249 if (mRepeatUntilItemAdded) { |
|
250 mEditorForm->removeConnection(mCustomRepeatUntilItem, SIGNAL(clicked()), |
|
251 this, SLOT(launchRepeatUntilDatePicker())); |
|
252 QModelIndex repeatIndex = |
|
253 mCalenEditorModel->indexFromItem(mRepeatItem); |
|
254 mCalenEditorModel->removeItem( |
|
255 mCalenEditorModel->index( |
|
256 repeatIndex.row()+ 1, 0)); |
|
257 mRepeatUntilItemAdded = false; |
|
258 mCustomRepeatUntilItem = 0; |
|
259 } |
239 } |
260 } |
240 |
261 |
241 /*! |
262 /*! |
242 Triggerd from tapping on reminder item. |
263 Triggerd from tapping on reminder item. |
243 Handles the reminder time change and updates the same in the event. |
264 Handles the reminder time change and updates the same in the event. |
251 |
272 |
252 HbExtendedLocale locale = HbExtendedLocale::system(); |
273 HbExtendedLocale locale = HbExtendedLocale::system(); |
253 // Get the user role we have set for this index |
274 // Get the user role we have set for this index |
254 QVariant role = mRepeatComboBox->itemData(index, userRole); |
275 QVariant role = mRepeatComboBox->itemData(index, userRole); |
255 int value = role.toInt(); |
276 int value = role.toInt(); |
256 switch (value) { |
277 |
|
278 // Boolean to check if the repeating property of the entry is changed. |
|
279 // based on the value and mRepeatUntilItemAdded |
|
280 // ie. From repeating to non repeating OR vice versa OR No change |
|
281 bool repeatPropertyChange = false; |
|
282 if (value > 0 && value <= 6 && !mRepeatUntilItemAdded) { |
|
283 // Non repeating to repeating |
|
284 repeatPropertyChange = true; |
|
285 }else if(mRepeatUntilItemAdded && value == 0) { |
|
286 // Repeating to non repeating |
|
287 repeatPropertyChange = true; |
|
288 }else { |
|
289 // No change in repeat value |
|
290 repeatPropertyChange = false; |
|
291 } |
|
292 QDate repeatUntilDate = mRepeatUntilDate; |
|
293 |
|
294 if (value != mRepeatRoleValue) |
|
295 { |
|
296 mRepeatRoleValue = value; |
|
297 switch (value) { |
257 case DailyRole: { |
298 case DailyRole: { |
258 if (!mRepeatUntilItemAdded) { |
299 if (!mRepeatUntilItemAdded) { |
259 insertRepeatUntilItem(); |
300 insertRepeatUntilItem(); |
260 } |
301 } |
261 if (mCustomRepeatUntilItem) { |
302 if (mCustomRepeatUntilItem) { |
291 // Show default repeat until date till one year for weekly rule |
332 // Show default repeat until date till one year for weekly rule |
292 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
333 mRepeatUntilDate = mCalenEditor->editedEntry()->startTime().date().addYears(1); |
293 mCustomRepeatUntilItem->setContentWidgetData( "text", |
334 mCustomRepeatUntilItem->setContentWidgetData( "text", |
294 locale.format( mRepeatUntilDate, |
335 locale.format( mRepeatUntilDate, |
295 r_qtn_date_usual_with_zero)); |
336 r_qtn_date_usual_with_zero)); |
296 |
|
297 } |
337 } |
298 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
338 mRepeatRuleType = AgendaRepeatRule::WeeklyRule; |
299 } |
339 } |
300 break; |
340 break; |
301 case BiWeeklyRole: { |
341 case BiWeeklyRole: { |
340 } |
380 } |
341 mRepeatRuleType = AgendaRepeatRule::YearlyRule; |
381 mRepeatRuleType = AgendaRepeatRule::YearlyRule; |
342 } |
382 } |
343 break; |
383 break; |
344 default: { |
384 default: { |
345 mRepeatRuleType = AgendaRepeatRule::InvalidRule; |
385 removeRepeatUntilItem(); |
346 if (mRepeatUntilItemAdded) { |
|
347 QModelIndex repeatIndex = |
|
348 mCalenEditorModel->indexFromItem(mRepeatItem); |
|
349 mCalenEditorModel->removeItem( |
|
350 mCalenEditorModel->index( |
|
351 repeatIndex.row()+ 1, 0)); |
|
352 mRepeatUntilItemAdded = false; |
|
353 mCustomRepeatUntilItem = 0; |
|
354 } |
|
355 } |
386 } |
356 break; |
387 break; |
|
388 } |
357 } |
389 } |
358 if(!mCalenEditor->isNewEntry()) { |
390 if(!mCalenEditor->isNewEntry()) { |
359 mCalenEditor->addDiscardAction(); |
391 mCalenEditor->addDiscardAction(); |
360 } |
392 } |
361 mCalenEditor->updateReminderChoices(); |
393 // Depending on repeatPropertyChange value and the repeatuntil date change |
|
394 // the reminder choices are updated |
|
395 if(repeatPropertyChange || repeatUntilDate != mRepeatUntilDate) { |
|
396 mCalenEditor->updateReminderChoices(); |
|
397 } |
362 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_EXIT ); |
398 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_HANDLEREPEATINDEXCHANGED_EXIT ); |
363 } |
399 } |
364 |
400 |
365 /*! |
401 /*! |
366 Returns model index of the repeat item |
402 Returns model index of the repeat item |
510 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_ENTRY ); |
546 OstTraceFunctionEntry0( CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_ENTRY ); |
511 if (!mRepeatComboBox) { |
547 if (!mRepeatComboBox) { |
512 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_EXIT ); |
548 OstTraceFunctionExit0( CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_EXIT ); |
513 return; |
549 return; |
514 } |
550 } |
|
551 // Disconnect the slot and connect it back again at end to avoid unnecessary |
|
552 // calls to handleRepeatIndexChanged slot. Or else the slot gets called |
|
553 // when we add all of items to the repeat combobox. |
|
554 disconnect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
555 SLOT(handleRepeatIndexChanged(int))); |
515 // Clear all the choices and add it again. If we dont do it |
556 // Clear all the choices and add it again. If we dont do it |
516 // as user would have changed the end times many times and we would have |
557 // as user would have changed the end times many times and we would have |
517 // deleted repeat options depending upon that |
558 // deleted repeat options depending upon that |
518 // Get the current choice |
559 // Get the current choice |
519 int choice = mRepeatComboBox->currentIndex(); |
560 int choice = mRepeatComboBox->currentIndex(); |
|
561 |
|
562 QVariant role = mRepeatComboBox->itemData(choice, userRole); |
|
563 mRepeatRoleValue = role.toInt(); |
|
564 |
520 int previousCount = mRepeatComboBox->count(); |
565 int previousCount = mRepeatComboBox->count(); |
521 mRepeatComboBox->clear(); |
566 mRepeatComboBox->clear(); |
522 QStringList repeatChoices; |
567 QStringList repeatChoices; |
523 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
568 repeatChoices << hbTrId("txt_calendar_setlabel_repeat_val_only_once") |
524 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
569 << hbTrId("txt_calendar_setlabel_repeat_val_daily") |
569 mRepeatComboBox->removeItem(RepeatMonthly); |
614 mRepeatComboBox->removeItem(RepeatMonthly); |
570 mRepeatComboBox->removeItem(RepeatBiWeekly); |
615 mRepeatComboBox->removeItem(RepeatBiWeekly); |
571 mRepeatComboBox->removeItem(RepeatWeekly); |
616 mRepeatComboBox->removeItem(RepeatWeekly); |
572 mRepeatComboBox->removeItem(RepeatWorkdays); |
617 mRepeatComboBox->removeItem(RepeatWorkdays); |
573 mRepeatComboBox->removeItem(RepeatDaily); |
618 mRepeatComboBox->removeItem(RepeatDaily); |
|
619 //Remove the repeat until item too. |
|
620 removeRepeatUntilItem(); |
574 } else if (mCalenEditor->editedEntry()->endTime() |
621 } else if (mCalenEditor->editedEntry()->endTime() |
575 >= (mCalenEditor->editedEntry()->startTime().addMonths(1))) { |
622 >= (mCalenEditor->editedEntry()->startTime().addMonths(1))) { |
576 isRemovedItem = true; |
623 isRemovedItem = true; |
577 numberOfItemRemoved = 5; |
624 numberOfItemRemoved = 5; |
578 // Remove all the options except "Repeat Once" |
625 // Remove all the options except "Repeat Once" |
615 } |
662 } |
616 int count = mRepeatComboBox->count(); |
663 int count = mRepeatComboBox->count(); |
617 if (choice >= count) { |
664 if (choice >= count) { |
618 choice = count - 1; |
665 choice = count - 1; |
619 } |
666 } |
|
667 |
|
668 //Connecting back the slot for repeat index change before setting index. |
|
669 connect(mRepeatComboBox, SIGNAL(currentIndexChanged(int)), this, |
|
670 SLOT(handleRepeatIndexChanged(int))); |
620 // Set the previous user's choice |
671 // Set the previous user's choice |
621 mRepeatComboBox->setCurrentIndex(choice); |
672 mRepeatComboBox->setCurrentIndex(choice); |
622 OstTraceFunctionExit0( DUP1_CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_EXIT ); |
673 OstTraceFunctionExit0( DUP1_CALENEDITORREPEATFIELD_UPDATEREPEATCHOICES_EXIT ); |
623 } |
674 } |
624 |
675 |