288 // (other items were commented in a header). |
289 // (other items were commented in a header). |
289 // ---------------------------------------------------------------------------- |
290 // ---------------------------------------------------------------------------- |
290 // |
291 // |
291 void CalenDeleteUi::DeleteCurrentEntryL() |
292 void CalenDeleteUi::DeleteCurrentEntryL() |
292 { |
293 { |
293 TRACE_ENTRY_POINT; |
294 TRACE_ENTRY_POINT; |
294 |
295 |
295 bool deleted( false ); |
296 // Make sure we're focused on an entry. |
296 TCalenNotification notification = ECalenNotifyDeleteFailed; |
297 if (iController.context().instanceId().mEntryLocalUid) { |
297 |
298 // Fetch the entry |
298 // Make sure we're focused on an entry. |
299 AgendaEntry entry = iController.Services().agendaInterface()->fetchById( |
299 if (iController.context().instanceId().mEntryLocalUid) { |
300 iController.context().instanceId().mEntryLocalUid); |
300 // Fetch the entry |
301 // Check if the entry is a To-Do |
301 AgendaEntry entry = iController.Services().agendaInterface()->fetchById( |
302 if (AgendaEntry::TypeTodo == entry.type()) { |
302 iController.context().instanceId().mEntryLocalUid); |
303 showDeleteQuery(EDeleteToDo); |
303 |
304 } else { |
304 // Check if the entry is a To-Do |
305 // Show the repeat entry delete query for repeating entries except Anniversary |
305 if (AgendaEntry::TypeTodo == entry.type()) { |
306 // Even though the anniversary is repeating |
306 if(!entry.isNull()) { |
307 // all the instances will be deleted |
307 deleted = DeleteEntryL(entry); |
308 if ((entry.isRepeating() || !entry.recurrenceId().isNull()) |
308 if(deleted) { |
309 && (AgendaEntry::TypeAnniversary != entry.type())) { |
309 // Delete is successful |
310 // Show a confirmation note whether the user |
310 notification = ECalenNotifyEntryDeleted; |
311 // wants to delete the single instance or all of them |
311 } |
312 showRepeatingEntryDeleteQuery(); |
312 } |
313 } else { |
313 } |
314 // If the entry is not a repeating entry, |
314 else { |
315 // delete it directly |
315 if (entry.isRepeating() || !entry.recurrenceId().isNull()) { |
316 // Save the entry for later reference in the slot |
316 // Show a confirmation note whether the user |
317 showDeleteQuery(EDeleteEntry); |
317 // wants to delete the single instance or all of them |
318 } |
318 showRepeatingEntryDeleteQuery(); |
319 } |
319 } else { |
320 } |
320 // If the entry is not a repeating entry, |
321 TRACE_EXIT_POINT; |
321 // delete it directly |
|
322 deleted = DeleteEntryL(entry); |
|
323 if (deleted) { |
|
324 // Delete is successful |
|
325 notification = ECalenNotifyEntryDeleted; |
|
326 } |
|
327 } |
|
328 } |
|
329 } |
|
330 |
|
331 iController.BroadcastNotification( notification ); |
|
332 |
|
333 TRACE_EXIT_POINT; |
|
334 } |
322 } |
335 |
323 |
336 // ---------------------------------------------------------------------------- |
324 // ---------------------------------------------------------------------------- |
337 // CalenDeleteUi::DeleteAllEntriesL |
325 // CalenDeleteUi::DeleteAllEntriesL |
338 // Deletes all entries |
326 // Deletes all entries |
339 // (other items were commented in a header). |
327 // (other items were commented in a header). |
340 // ---------------------------------------------------------------------------- |
328 // ---------------------------------------------------------------------------- |
341 // |
329 // |
342 void CalenDeleteUi::DeleteAllEntriesL() |
330 void CalenDeleteUi::DeleteAllEntriesL() |
343 { |
331 { |
344 TRACE_ENTRY_POINT; |
332 if(iIsDeleting) { |
345 |
333 return; |
346 ASSERT( !iIsDeleting ); |
334 } |
347 |
335 |
348 const int buttonId = CalenActionUiUtils::showDeleteConfirmationQueryL( |
336 showDeleteQuery(EDeleteAll ); |
349 CalenActionUiUtils::EDeleteAll ); |
337 } |
350 if( buttonId ) |
|
351 { |
|
352 HandleDeleteMultipleEventsL( AgendaUtil::minTime(), AgendaUtil::maxTime(),1 ); |
|
353 } |
|
354 else |
|
355 { |
|
356 // notify delete failed |
|
357 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
358 } |
|
359 |
|
360 TRACE_EXIT_POINT; |
|
361 } |
|
362 |
338 |
363 // ---------------------------------------------------------------------------- |
339 // ---------------------------------------------------------------------------- |
364 // CalenDeleteUi::DeleteEntriesBeforeDateL |
340 // CalenDeleteUi::DeleteEntriesBeforeDateL |
365 // Deletes all entries before a set date. |
341 // Deletes all entries before a set date. |
366 // (other items were commented in a header). |
342 // (other items were commented in a header). |
367 // ---------------------------------------------------------------------------- |
343 // ---------------------------------------------------------------------------- |
368 // |
344 // |
369 void CalenDeleteUi::DeleteEntriesBeforeDateL() |
345 void CalenDeleteUi::DeleteEntriesBeforeDateL() |
370 { |
346 { |
371 TRACE_ENTRY_POINT; |
347 TRACE_ENTRY_POINT; |
372 |
348 if(iIsDeleting) { |
373 ASSERT( !iIsDeleting ); |
349 return; |
374 |
350 } |
375 TCalenNotification notification = ECalenNotifyDeleteFailed; |
|
376 |
|
377 // launch the datepicker |
351 // launch the datepicker |
378 mIsDateValid = false; |
|
379 dateQuery(); |
352 dateQuery(); |
380 |
353 TRACE_EXIT_POINT; |
381 if( mIsDateValid ) |
354 } |
382 { |
355 |
383 // Do delete only if inputted day is after beginning of range |
356 // ---------------------------------------------------------------------------- |
384 if( mDateTime > AgendaUtil::minTime() ) |
357 // CalenDeleteUi::dateQuery |
385 { |
358 // Launches the popup for the date selection |
386 // Two pass delete: |
359 // (other items were commented in a header). |
387 // 1. pass |
360 // ---------------------------------------------------------------------------- |
388 // To prevent destroying entries starting and ending midnight |
361 // |
389 // subtract one second and do delete on that range. |
|
390 mDateTime = mDateTime.addSecs(-1); |
|
391 mDateTime = ( mDateTime > AgendaUtil::minTime()? mDateTime : AgendaUtil::minTime()); |
|
392 |
|
393 HandleDeleteMultipleEventsL( AgendaUtil::minTime(), |
|
394 mDateTime,1 ); |
|
395 notification = ECalenNotifyMultipleEntriesDeleted; |
|
396 } |
|
397 } |
|
398 |
|
399 iController.BroadcastNotification( notification ); |
|
400 TRACE_EXIT_POINT; |
|
401 } |
|
402 |
|
403 void CalenDeleteUi::dateQuery() |
362 void CalenDeleteUi::dateQuery() |
404 { |
363 { |
405 // Create a popup with datepicker to select the date. |
364 // Create a popup with datepicker to select the date. |
|
365 HbDialog *popUp = new HbDialog(); |
|
366 popUp->setDismissPolicy(HbDialog::NoDismiss); |
|
367 popUp->setTimeout(HbDialog::NoTimeout ); |
|
368 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
369 popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_set_date"))); |
|
370 |
406 QDateTime currentDateTime(CalenDateUtils::today()); |
371 QDateTime currentDateTime(CalenDateUtils::today()); |
407 QDate currentDate(currentDateTime.date()); |
372 QDate currentDate(currentDateTime.date()); |
408 mDatePicker = new HbDateTimePicker(currentDate); |
373 if(mDatePicker) { |
|
374 mDatePicker = NULL; |
|
375 } |
|
376 mDatePicker = new HbDateTimePicker(popUp); |
409 mDatePicker->setMinimumDate(CalenDateUtils::minTime().date()); |
377 mDatePicker->setMinimumDate(CalenDateUtils::minTime().date()); |
410 mDatePicker->setMaximumDate(currentDate); |
378 mDatePicker->setMaximumDate(currentDate); |
411 HbDialog popUp; |
379 mDatePicker->setDate(currentDate); |
412 popUp.setDismissPolicy(HbDialog::NoDismiss); |
380 |
413 popUp.setTimeout(HbDialog::NoTimeout ); |
381 popUp->setContentWidget(mDatePicker); |
414 popUp.setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_set_date"))); |
382 mDeleteAction = new HbAction( |
415 popUp.setContentWidget(mDatePicker); |
383 hbTrId("txt_calendar_button_dialog_delete"), popUp); |
416 HbAction *okAction = new HbAction(hbTrId("txt_calendar_button_dialog_delete")); |
384 popUp->addAction(mDeleteAction); |
417 popUp.setPrimaryAction(okAction); |
385 mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"),popUp); |
418 connect(okAction,SIGNAL(triggered()),this,SLOT(getSelectedDate())); |
386 popUp->addAction(mCancelAction); |
419 connect(okAction,SIGNAL(triggered()),&popUp,SLOT(close())); |
387 // Show the popup |
420 popUp.setSecondaryAction(new HbAction(hbTrId("txt_common_button_cancel"),&popUp)); |
388 popUp->open(this, SLOT(handleDateQuery(HbAction*))); |
421 popUp.exec(); |
389 } |
422 } |
390 |
423 |
391 // ---------------------------------------------------------------------------- |
|
392 // CalenDeleteUi::handleDateQuery |
|
393 // Handles the selection for the date query |
|
394 // (other items were commented in a header). |
|
395 // ---------------------------------------------------------------------------- |
|
396 // |
|
397 void CalenDeleteUi::handleDateQuery(HbAction* action) |
|
398 { |
|
399 if(action == mDeleteAction) { |
|
400 // User selected the date before which all the entries has to be deleted |
|
401 QDate selectedDate(mDatePicker->date()); |
|
402 // Check if the date is within the range. |
|
403 if(selectedDate.isValid()) { |
|
404 QTime time(0,0,0,0); |
|
405 QDateTime dateTime; |
|
406 dateTime.setDate(selectedDate); |
|
407 dateTime.setTime(time); |
|
408 // Do delete only if inputted day is after beginning of range |
|
409 if(dateTime > AgendaUtil::minTime()) { |
|
410 // Two pass delete: |
|
411 // 1. pass |
|
412 // To prevent destroying entries starting and ending midnight |
|
413 // subtract one second and do delete on that range. |
|
414 dateTime = dateTime.addSecs(-1); |
|
415 dateTime = ( dateTime > AgendaUtil::minTime()? |
|
416 dateTime : AgendaUtil::minTime()); |
|
417 |
|
418 HandleDeleteMultipleEventsL( AgendaUtil::minTime(), |
|
419 dateTime, 1); |
|
420 }else { |
|
421 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
422 } |
|
423 } |
|
424 }else { |
|
425 // User pressed cancel |
|
426 handleDeleteCancel(); |
|
427 } |
|
428 // Reset the member variables |
|
429 mDeleteAction = NULL; |
|
430 mCancelAction = NULL; |
|
431 } |
|
432 // ---------------------------------------------------------------------------- |
|
433 // CalenDeleteUi::showRepeatingEntryDeleteQuery |
|
434 // Launches the popup for deleting the repeating entry |
|
435 // (other items were commented in a header). |
|
436 // ---------------------------------------------------------------------------- |
|
437 // |
424 void CalenDeleteUi::showRepeatingEntryDeleteQuery() |
438 void CalenDeleteUi::showRepeatingEntryDeleteQuery() |
425 { |
439 { |
426 HbDialog popUp; |
440 HbDialog *popUp = new HbDialog(); |
427 popUp.setDismissPolicy(HbDialog::NoDismiss); |
441 popUp->setDismissPolicy(HbDialog::NoDismiss); |
428 popUp.setTimeout(HbDialog::NoTimeout); |
442 popUp->setTimeout(HbDialog::NoTimeout); |
|
443 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
429 |
444 |
430 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
445 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
431 HbWidget *editWidget = new HbWidget(); |
446 HbWidget *editWidget = new HbWidget(); |
432 editWidget->setLayout(layout); |
447 editWidget->setLayout(layout); |
433 |
448 |
439 |
454 |
440 editButtonList->setItems(list); |
455 editButtonList->setItems(list); |
441 |
456 |
442 layout->addItem(editButtonList); |
457 layout->addItem(editButtonList); |
443 |
458 |
444 popUp.setContentWidget(editWidget); |
459 popUp->setContentWidget(editWidget); |
445 popUp.setHeadingWidget(new HbLabel( |
460 popUp->setHeadingWidget(new HbLabel( |
446 hbTrId("txt_calendar_title_delete_repeated_entry"))); |
461 hbTrId("txt_calendar_title_delete_repeated_entry"))); |
447 |
462 |
448 connect(editButtonList, SIGNAL(itemSelected(int)), this, |
463 // Add cancel action |
449 SLOT(handleRepeatedEntryDelete(int))); |
|
450 connect(editButtonList, SIGNAL(itemSelected(int)), &popUp, SLOT(close())); |
|
451 |
|
452 // Create secondary action |
|
453 HbAction *cancelAction = new HbAction( |
464 HbAction *cancelAction = new HbAction( |
454 hbTrId("txt_calendar_button_softkey1_cancel")); |
465 hbTrId("txt_calendar_button_softkey1_cancel")); |
455 popUp.setSecondaryAction(cancelAction); |
466 popUp->addAction(cancelAction); |
456 connect(cancelAction, SIGNAL(triggered()), this, SLOT(handleCancel())); |
467 connect(editButtonList, SIGNAL(itemSelected(int)), this, |
457 connect(cancelAction, SIGNAL(triggered()), &popUp, SLOT(close())); |
468 SLOT(handleRepeatedEntryDelete(int))); |
|
469 connect(editButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close())); |
|
470 connect(cancelAction, SIGNAL(triggered()), this, |
|
471 SLOT(handleDeleteCancel())); |
458 |
472 |
459 // Show the popup |
473 // Show the popup |
460 popUp.exec(); |
474 popUp->open(); |
461 } |
475 } |
462 |
476 |
463 void CalenDeleteUi::getSelectedDate() |
477 // ---------------------------------------------------------------------------- |
464 { |
478 // CalenDeleteUi::handleDeleteCancel |
465 QDate selectedDate(mDatePicker->date()); |
479 // Handles the cancel action |
466 |
480 // (other items were commented in a header). |
467 // Check if the date is within the range. |
481 // ---------------------------------------------------------------------------- |
468 if(selectedDate.isValid()) |
482 // |
469 { |
483 void CalenDeleteUi::handleDeleteCancel() |
470 QTime time(0,0,0,0); |
484 { |
471 mDateTime.setDate(selectedDate); |
485 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
472 mDateTime.setTime(time); |
486 } |
473 mIsDateValid = true; |
|
474 } |
|
475 } |
|
476 |
487 |
477 void CalenDeleteUi::handleRepeatedEntryDelete(int index) |
488 void CalenDeleteUi::handleRepeatedEntryDelete(int index) |
478 { |
489 { |
479 // Fetch the entry |
490 // Fetch the entry |
480 // Find all possible instances |
491 // Find all possible instances |
481 AgendaEntry instance = CalenActionUiUtils::findPossibleInstanceL( |
492 AgendaEntry instance = CalenActionUiUtils::findPossibleInstanceL( |
482 iController.context().instanceId(), |
493 iController.context().instanceId(), |
483 iController.Services().agendaInterface()); |
494 iController.Services().agendaInterface()); |
484 |
495 |
485 if (!instance.isNull()) { |
496 if (!instance.isNull()) { |
486 connect(iController.Services().agendaInterface(), SIGNAL(entryDeleted(ulong)), |
497 connect(iController.Services().agendaInterface(), |
487 this, SLOT(entryDeleted(ulong))); |
498 SIGNAL(entryDeleted(ulong)), |
488 switch(index) { |
499 this, SLOT(entryDeleted(ulong))); |
489 case 0: |
500 switch(index) { |
490 // User wants to delete only this occurence |
501 case 0: |
491 iController.Services().agendaInterface()->deleteRepeatedEntry(instance, AgendaUtil::ThisOnly); |
502 // User wants to delete only this occurence |
492 break; |
503 iController.Services().agendaInterface()->deleteRepeatedEntry( |
493 case 1: |
504 instance, AgendaUtil::ThisOnly); |
494 // User wants to delete all the occurences |
505 break; |
495 iController.Services().agendaInterface()->deleteRepeatedEntry(instance, AgendaUtil::ThisAndAll); |
506 case 1: |
496 break; |
507 // User wants to delete all the occurences |
|
508 iController.Services().agendaInterface()->deleteRepeatedEntry( |
|
509 instance, AgendaUtil::ThisAndAll); |
|
510 break; |
|
511 } |
|
512 } |
|
513 } |
|
514 |
|
515 // ---------------------------------------------------------------------------- |
|
516 // CalenDeleteUi::showDeleteQuery |
|
517 // Launches the popup for deleting the instance/instances |
|
518 // (other items were commented in a header). |
|
519 // ---------------------------------------------------------------------------- |
|
520 // |
|
521 void CalenDeleteUi::showDeleteQuery(const TDeleteConfirmationType type, |
|
522 const int count) |
|
523 { |
|
524 HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
525 popup->setDismissPolicy(HbDialog::NoDismiss); |
|
526 popup->setTimeout(HbDialog::NoTimeout); |
|
527 popup->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
528 |
|
529 QString text = 0; |
|
530 |
|
531 switch(type) |
|
532 { |
|
533 case EDeleteEntry: |
|
534 { |
|
535 text.append(hbTrId("txt_calendar_info_delete_meeting")); |
|
536 break; |
|
537 } |
|
538 case EDeleteToDo: |
|
539 { |
|
540 text.append(hbTrId("txt_calendar_info_delete_todo_note")); |
|
541 break; |
|
542 } |
|
543 case EDeleteToDos: |
|
544 {//"Delete %N to-do notes?" |
|
545 // TODO: Add the text id |
|
546 text.append("Delete %N to-do's?").arg(count); |
|
547 break; |
|
548 } |
|
549 case EDeleteAll: |
|
550 { |
|
551 text.append(hbTrId("txt_calendar_info_delete_all_calendar_entries")); |
|
552 break; |
|
553 } |
|
554 default: |
|
555 break; |
497 } |
556 } |
498 } |
557 |
|
558 popup->setText(text); |
|
559 |
|
560 QList<QAction*> list = popup->actions(); |
|
561 for(int i=0; i < list.count(); i++) |
|
562 { |
|
563 popup->removeAction(list[i]); |
|
564 } |
|
565 mDeleteAction = new HbAction( |
|
566 hbTrId("txt_calendar_button_dialog_delete"), popup); |
|
567 popup->addAction(mDeleteAction); |
|
568 mCancelAction = new HbAction(hbTrId("txt_calendar_button_cancel"), popup); |
|
569 popup->addAction(mCancelAction); |
|
570 popup->open(this, SLOT(handleDeletion(HbAction*))); |
|
571 } |
|
572 |
|
573 // ---------------------------------------------------------------------------- |
|
574 // CalenDeleteUi::handleDeletion |
|
575 // Deletes the entries based on the user selection |
|
576 // (other items were commented in a header). |
|
577 // ---------------------------------------------------------------------------- |
|
578 // |
|
579 void CalenDeleteUi::handleDeletion(HbAction* action) |
|
580 { |
|
581 TCalenNotification notification = ECalenNotifyDeleteFailed; |
|
582 |
|
583 if(action == mDeleteAction) { |
|
584 |
|
585 switch (mDeleteCommand) { |
|
586 |
|
587 case ECalenDeleteCurrentEntry: |
|
588 { |
|
589 // Get the entry id |
|
590 ulong id = iController.context().instanceId().mEntryLocalUid; |
|
591 connect(iController.Services().agendaInterface(), |
|
592 SIGNAL(entryDeleted(ulong)), |
|
593 this, SLOT(entryDeleted(ulong))); |
|
594 // Delete the entry if the delete button is been pressed |
|
595 iController.Services().agendaInterface()->deleteEntry(id); |
|
596 } |
|
597 break; |
|
598 |
|
599 case ECalenDeleteSeries: |
|
600 case ECalenDeleteCurrentOccurrence: |
|
601 { |
|
602 AgendaEntry instance = |
|
603 CalenActionUiUtils::findPossibleInstanceL( |
|
604 iController.context().instanceId(), |
|
605 iController.Services().agendaInterface() ); |
|
606 if(!instance.isNull()) { |
|
607 QDateTime recId = instance.recurrenceId().toUTC(); |
|
608 const bool child = recId.isNull(); |
|
609 connect(iController.Services().agendaInterface(), |
|
610 SIGNAL(entryDeleted(ulong)), |
|
611 this, SLOT(entryDeleted(ulong))); |
|
612 if( !child || mRecurrenceRange == AgendaUtil::ThisOnly |
|
613 || mRecurrenceRange == AgendaUtil::ThisAndAll) { |
|
614 iController.Services().agendaInterface()->deleteRepeatedEntry( |
|
615 instance, mRecurrenceRange ); |
|
616 } |
|
617 } |
|
618 } |
|
619 break; |
|
620 |
|
621 case ECalenDeleteAllEntries: |
|
622 { |
|
623 HandleDeleteMultipleEventsL( AgendaUtil::minTime(), |
|
624 AgendaUtil::maxTime(),1 ); |
|
625 } |
|
626 break; |
|
627 |
|
628 default: |
|
629 break; |
|
630 |
|
631 } |
|
632 } |
|
633 // If the user presses cancel button the notification will be |
|
634 // ECalenNotifyDeleteFailed as default. |
|
635 // Notify the status |
|
636 iController.BroadcastNotification(notification); |
|
637 |
|
638 // Reset the member variables |
|
639 mDeleteAction = NULL; |
|
640 mCancelAction = NULL; |
499 } |
641 } |
500 |
642 |
501 void CalenDeleteUi::entryDeleted(ulong id) |
643 void CalenDeleteUi::entryDeleted(ulong id) |
502 { |
644 { |
503 if (iController.context().instanceId().mEntryLocalUid == id) { |
645 if (iController.context().instanceId().mEntryLocalUid == id) { |
637 // CalenDeleteUi::DeleteSingleInstanceL |
780 // CalenDeleteUi::DeleteSingleInstanceL |
638 // Delete the given instance. Ask the user whether to delete the series or the instance. |
781 // Delete the given instance. Ask the user whether to delete the series or the instance. |
639 // (other items were commented in a header). |
782 // (other items were commented in a header). |
640 // ----------------------------------------------------------------------------- |
783 // ----------------------------------------------------------------------------- |
641 // |
784 // |
642 TBool CalenDeleteUi::DeleteSingleInstanceL( AgendaEntry& aInstance ) |
785 void CalenDeleteUi::DeleteSingleInstanceL( AgendaEntry& aInstance ) |
643 { |
786 { |
644 TRACE_ENTRY_POINT; |
787 TRACE_ENTRY_POINT; |
645 TRACE_EXIT_POINT; |
788 DoDeleteSingleInstanceL( aInstance, EFalse, AgendaUtil::ThisAndAll ); |
646 return DoDeleteSingleInstanceL( aInstance, EFalse, AgendaUtil::ThisAndAll ); |
789 TRACE_EXIT_POINT; |
647 } |
790 } |
648 |
791 |
649 // ----------------------------------------------------------------------------- |
792 // ----------------------------------------------------------------------------- |
650 // CalenDeleteUi::DeleteSingleInstanceL |
793 // CalenDeleteUi::DeleteSingleInstanceL |
651 // Delete the given instance. Delete the entry range given by aRepeatType. |
794 // Delete the given instance. Delete the entry range given by aRepeatType. |
652 // (other items were commented in a header). |
795 // (other items were commented in a header). |
653 // ----------------------------------------------------------------------------- |
796 // ----------------------------------------------------------------------------- |
654 // |
797 // |
655 TBool CalenDeleteUi::DeleteSingleInstanceL( AgendaEntry& aInstance, |
798 void CalenDeleteUi::DeleteSingleInstanceL( AgendaEntry& aInstance, |
656 AgendaUtil::RecurrenceRange aRepeatType ) |
799 AgendaUtil::RecurrenceRange aRepeatType ) |
657 { |
800 { |
658 TRACE_ENTRY_POINT; |
801 TRACE_ENTRY_POINT; |
659 TRACE_EXIT_POINT; |
802 DoDeleteSingleInstanceL( aInstance, ETrue, aRepeatType ); |
660 return DoDeleteSingleInstanceL( aInstance, ETrue, aRepeatType ); |
803 TRACE_EXIT_POINT; |
|
804 |
661 } |
805 } |
662 |
806 |
663 // ----------------------------------------------------------------------------- |
807 // ----------------------------------------------------------------------------- |
664 // CalenDeleteUi::DoDeleteSingleInstanceL |
808 // CalenDeleteUi::DoDeleteSingleInstanceL |
665 // Performs the deletion of the instance. If aHasRepeatType is EFalse, the user |
809 // Performs the deletion of the instance. If aHasRepeatType is EFalse, the user |
667 // aRepeatType is ignored. If aHasRepeatType is ETrue, aRepeatType determines |
811 // aRepeatType is ignored. If aHasRepeatType is ETrue, aRepeatType determines |
668 // whether to delete the instance or the entire series. |
812 // whether to delete the instance or the entire series. |
669 // (other items were commented in a header). |
813 // (other items were commented in a header). |
670 // ----------------------------------------------------------------------------- |
814 // ----------------------------------------------------------------------------- |
671 // |
815 // |
672 TBool CalenDeleteUi::DoDeleteSingleInstanceL( AgendaEntry& aInstance, |
816 void CalenDeleteUi::DoDeleteSingleInstanceL( |
673 bool aHasRepeatType, |
817 AgendaEntry& aInstance, |
674 AgendaUtil::RecurrenceRange aRepeatType ) |
818 bool aHasRepeatType, |
675 { |
819 AgendaUtil::RecurrenceRange aRepeatType ) |
676 TRACE_ENTRY_POINT; |
820 { |
677 |
821 TRACE_ENTRY_POINT; |
678 bool repeating = aInstance.isRepeating(); |
822 bool repeating = aInstance.isRepeating(); |
679 |
823 |
680 if( !repeating ) |
824 if( !repeating ) { |
681 { |
825 // Even though there is no RRule, the entry might |
682 // Even though there is no RRule, the entry might |
826 // have a list of rdates. |
683 // have a list of rdates. |
827 QList<QDate> rDates = aInstance.rDates(); |
684 QList<QDate> rDates = aInstance.rDates(); |
828 repeating = ( rDates.count() > 0 ); |
685 repeating = ( rDates.count() > 0 ); |
829 } |
686 } |
830 QDateTime recId = aInstance.recurrenceId().toUTC(); |
687 QDateTime recId = aInstance.recurrenceId().toUTC(); |
831 const bool child = recId.isNull(); |
688 const bool child = recId.isNull(); |
832 |
689 |
833 if( !aHasRepeatType ) { |
690 if( !aHasRepeatType ) |
834 aRepeatType = AgendaUtil::ThisAndAll; |
691 { |
835 } |
692 aRepeatType = AgendaUtil::ThisAndAll; |
836 // For later reference in handleDeletion() |
693 } |
837 mRecurrenceRange = aRepeatType; |
694 |
838 |
695 bool doDelete( ETrue ); |
839 if( !aHasRepeatType && ( child || repeating ) && |
696 |
840 ( aInstance.type() != AgendaEntry::TypeAnniversary ) ) { |
697 if( !aHasRepeatType && ( child || repeating ) && ( aInstance.type() != AgendaEntry::TypeAnniversary ) ) |
841 showRepeatingEntryDeleteQuery(); |
698 { |
842 } |
699 //doDelete = CalenActionUiUtils::ShowRepeatTypeQueryL( aRepeatType, |
843 else |
700 // CalenActionUiUtils::EDelete ); |
|
701 } |
|
702 else |
|
703 { |
|
704 doDelete = CalenActionUiUtils::showDeleteConfirmationQueryL(aInstance.type() == AgendaEntry::TypeTodo ? |
|
705 CalenActionUiUtils::EDeleteToDo : |
|
706 CalenActionUiUtils::EDeleteEntry ); |
|
707 } |
|
708 |
|
709 if( doDelete ) |
|
710 { |
|
711 if( !child || aRepeatType == AgendaUtil::ThisOnly ) |
|
712 { |
|
713 iController.Services().agendaInterface()->deleteRepeatedEntry( aInstance, aRepeatType ); |
|
714 } |
|
715 else if( aRepeatType == AgendaUtil::ThisAndAll ) |
|
716 { |
|
717 iController.Services().agendaInterface()->deleteRepeatedEntry( aInstance, aRepeatType ); |
|
718 } |
|
719 } |
|
720 |
|
721 TRACE_EXIT_POINT; |
|
722 return doDelete; |
|
723 } |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CalenDeleteUi::DeleteEntryL |
|
727 // Deletes an entry from the database |
|
728 // (other items were commented in a header). |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 TBool CalenDeleteUi::DeleteEntryL( AgendaEntry& entry ) |
|
732 { |
|
733 TRACE_ENTRY_POINT; |
|
734 |
|
735 TBool doDelete = CalenActionUiUtils::showDeleteConfirmationQueryL(entry.type() == AgendaEntry::TypeTodo ? |
|
736 CalenActionUiUtils::EDeleteToDo : |
|
737 CalenActionUiUtils::EDeleteEntry ); |
|
738 |
|
739 if( doDelete ) |
|
740 { |
|
741 iController.Services().agendaInterface()->deleteEntry(entry.id()); |
|
742 } |
|
743 |
|
744 TRACE_EXIT_POINT; |
|
745 return doDelete; |
|
746 } |
|
747 |
|
748 // ----------------------------------------------------------------------------- |
|
749 // CalenDeleteUi::ShowMultipleEntriesDeleteQueryL |
|
750 // For displaying multiple entries deletion confirmation query |
|
751 // ----------------------------------------------------------------------------- |
|
752 // |
|
753 TInt CalenDeleteUi::ShowMultipleEntriesDeleteQueryL(int aCount) |
|
754 { |
844 { |
755 TRACE_ENTRY_POINT; |
845 showDeleteQuery(aInstance.type() == AgendaEntry::TypeTodo ? |
756 if( aCount > 1 ) |
846 EDeleteToDo : |
757 { |
847 EDeleteEntry ); |
758 TRACE_EXIT_POINT; |
848 } |
759 return CalenActionUiUtils::showDeleteConfirmationQueryL(CalenActionUiUtils::EDeleteToDos, aCount ); |
849 TRACE_EXIT_POINT; |
760 } |
850 } |
761 else if( aCount == 1 ) |
851 |
762 { |
|
763 TRACE_EXIT_POINT; |
|
764 return CalenActionUiUtils::showDeleteConfirmationQueryL(CalenActionUiUtils::EDeleteToDo); |
|
765 } |
|
766 else |
|
767 { |
|
768 TRACE_EXIT_POINT; |
|
769 return 0; //return 0 for other invalid aCount value ( < 0 ) |
|
770 } |
|
771 |
|
772 } |
|
773 |
852 |
774 // ----------------------------------------------------------------------------- |
853 // ----------------------------------------------------------------------------- |
775 // CalenDeleteUi::DialogDismissedL |
854 // CalenDeleteUi::DialogDismissedL |
776 // From MProgressDialogCallback |
855 // From MProgressDialogCallback |
777 // Callback method |
856 // Callback method |