226 notificationArray.Append(ECalenNotifyCalendarInfoCreated); |
225 notificationArray.Append(ECalenNotifyCalendarInfoCreated); |
227 notificationArray.Append(ECalenNotifyCalendarInfoUpdated); |
226 notificationArray.Append(ECalenNotifyCalendarInfoUpdated); |
228 notificationArray.Append(ECalenNotifyCalendarFileDeleted); |
227 notificationArray.Append(ECalenNotifyCalendarFileDeleted); |
229 iController.RegisterForNotificationsL(this, notificationArray); |
228 iController.RegisterForNotificationsL(this, notificationArray); |
230 |
229 |
|
230 notificationArray.Close(); |
|
231 |
231 iConflictOccured = EFalse; |
232 iConflictOccured = EFalse; |
|
233 |
|
234 TCallBack callBackDeleteQuery(CCalenMultipleDbUi::DoAsyncDeleteTemL, this); |
|
235 iAsyncDeletequery = new(ELeave) CAsyncCallBack(callBackDeleteQuery,CActive::EPriorityStandard); |
232 |
236 |
233 TRACE_EXIT_POINT; |
237 TRACE_EXIT_POINT; |
234 } |
238 } |
235 |
239 |
236 // ---------------------------------------------------------------------------- |
240 // ---------------------------------------------------------------------------- |
249 iNaviContainer->Pop(); // Remove navi pane used by settings view |
253 iNaviContainer->Pop(); // Remove navi pane used by settings view |
250 iNaviContainer = NULL; // iNaviContainer is not owned |
254 iNaviContainer = NULL; // iNaviContainer is not owned |
251 } |
255 } |
252 |
256 |
253 delete iBgContext; |
257 delete iBgContext; |
|
258 iBgContext = NULL; |
254 |
259 |
255 iListBox->Reset(); |
260 iListBox->Reset(); |
256 delete iListBox; |
261 delete iListBox; |
|
262 iListBox = NULL; |
257 |
263 |
258 delete iDesArray; |
264 delete iDesArray; |
|
265 iDesArray = NULL; |
259 |
266 |
260 iColorUidArray.Close(); |
267 iColorUidArray.Close(); |
261 |
268 |
262 iIconIndices.Reset(); |
269 iIconIndices.Reset(); |
263 iIconIndices.Close(); |
270 iIconIndices.Close(); |
264 |
271 |
265 iAsyncExit->Cancel(); |
272 iAsyncExit->Cancel(); |
266 delete iAsyncExit; |
273 delete iAsyncExit; |
|
274 iAsyncExit = NULL; |
|
275 |
|
276 iAsyncDeletequery->Cancel(); |
|
277 delete iAsyncDeletequery; |
|
278 iAsyncDeletequery = NULL; |
|
279 |
|
280 if(iCalendarInfoNew) |
|
281 { |
|
282 delete iCalendarInfoNew; |
|
283 iCalendarInfoNew = NULL; |
|
284 } |
|
285 |
|
286 if(iCalendarInfoOriginal) |
|
287 { |
|
288 delete iCalendarInfoOriginal; |
|
289 iCalendarInfoOriginal = NULL; |
|
290 } |
267 |
291 |
268 TRACE_EXIT_POINT; |
292 TRACE_EXIT_POINT; |
269 } |
293 } |
270 |
294 |
271 // ---------------------------------------------------------------------------- |
295 // ---------------------------------------------------------------------------- |
441 iNaviContainer->PushDefaultL(); |
469 iNaviContainer->PushDefaultL(); |
442 |
470 |
443 // Set title text |
471 // Set title text |
444 CAknTitlePane* tp = static_cast<CAknTitlePane*>( |
472 CAknTitlePane* tp = static_cast<CAknTitlePane*>( |
445 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
473 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
446 |
474 HBufC* titleText; |
447 HBufC* titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDARS , iCoeEnv ); |
475 if(iIsDbEditorOpen) |
|
476 { |
|
477 titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDAR , iCoeEnv ); |
|
478 } |
|
479 else |
|
480 { |
|
481 titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDARS , iCoeEnv ); |
|
482 } |
448 tp->SetTextL( *titleText ); // r_qtn_cale_title_calendars |
483 tp->SetTextL( *titleText ); // r_qtn_cale_title_calendars |
449 CleanupStack::PopAndDestroy( titleText ); |
484 CleanupStack::PopAndDestroy( titleText ); |
450 |
485 |
451 TRACE_EXIT_POINT; |
486 TRACE_EXIT_POINT; |
452 } |
487 } |
|
488 |
|
489 |
453 |
490 |
454 |
491 |
455 // ---------------------------------------------------------------------------- |
492 // ---------------------------------------------------------------------------- |
456 // CCalenMultipleDbUi::DynInitMenuPaneL |
493 // CCalenMultipleDbUi::DynInitMenuPaneL |
457 // Do functionalites before options menu execs |
494 // Do functionalites before options menu execs |
604 // ---------------------------------------------------------------------------- |
631 // ---------------------------------------------------------------------------- |
605 // |
632 // |
606 TInt CCalenMultipleDbUi::AddItemL() |
633 TInt CCalenMultipleDbUi::AddItemL() |
607 { |
634 { |
608 TRACE_ENTRY_POINT |
635 TRACE_ENTRY_POINT |
609 TInt retValue = KErrNotFound; |
636 TInt retValue = 0; |
610 |
637 |
611 CCalCalendarInfo* calendarInfo = CCalCalendarInfo::NewL(); |
638 if(iCalendarInfoNew) |
612 calendarInfo->SetNameL(KNullDesC16); |
639 { |
613 calendarInfo->SetColor(255); |
640 delete iCalendarInfoNew; |
614 calendarInfo->SetEnabled(ETrue); |
641 iCalendarInfoNew = NULL; |
615 iDbEditor = CCalenMultiDBEditor::NewL( *calendarInfo, iController, EFalse ); |
642 } |
|
643 |
|
644 iCalendarInfoNew = CCalCalendarInfo::NewL(); |
|
645 iCalendarInfoNew->SetNameL(KNullDesC16); |
|
646 iCalendarInfoNew->SetColor(255); |
|
647 iCalendarInfoNew->SetEnabled(ETrue); |
|
648 iDbEditor = CCalenMultiDBEditor::NewL(*this,*iCalendarInfoNew, iController, EFalse ); |
616 |
649 |
617 iDialogLaunched = ETrue; |
650 //Async dialog |
618 retValue = iDbEditor->ExecuteLD(); |
651 retValue = iDbEditor->ExecuteLD(); |
619 iDbEditor = NULL; |
652 iDbEditor = NULL; |
620 iDialogLaunched = EFalse; |
653 |
621 |
|
622 if(EAknCmdExit == retValue ) |
654 if(EAknCmdExit == retValue ) |
623 { |
655 { |
624 iController.BroadcastNotification(ECalenNotifyRealExit); |
656 iController.BroadcastNotification(ECalenNotifyRealExit); |
625 } |
657 } |
626 |
658 |
627 HBufC* calendarName = calendarInfo->NameL().AllocLC(); |
659 TRACE_EXIT_POINT |
628 calendarName->Des().Trim(); |
660 return retValue; |
629 if(calendarName->Length() > 0) |
661 } |
630 { |
662 |
631 |
663 |
|
664 // ---------------------------------------------------------------------------- |
|
665 // CCalenMultipleDbUi::UpdateAddOrEditL |
|
666 // ---------------------------------------------------------------------------- |
|
667 // |
|
668 void CCalenMultipleDbUi::UpdateOnAddOrEditL(TBool aItemAdded) |
|
669 { |
|
670 TRACE_ENTRY_POINT |
|
671 |
|
672 if(aItemAdded) |
|
673 { |
632 // Set calendar properties for new calendar being created. |
674 // Set calendar properties for new calendar being created. |
633 SetCalendarAddPropertiesL(*calendarInfo); |
675 SetCalendarAddPropertiesL(*iCalendarInfoNew); |
634 |
676 |
635 iController.AddCalendarL(calendarInfo); |
677 iController.AddCalendarL(iCalendarInfoNew); |
636 |
678 iCalendarInfoNew = NULL; |
637 UpdateListboxL(); |
679 |
638 |
|
639 //Highlight the newly created list item |
680 //Highlight the newly created list item |
640 iListBox->ScrollToMakeItemVisible(iListBox->BottomItemIndex()); |
681 iListBox->ScrollToMakeItemVisible(iListBox->BottomItemIndex()); |
641 iListBox->SetCurrentItemIndexAndDraw(iDesArray->Count()-1); |
682 iListBox->SetCurrentItemIndexAndDraw(iDesArray->Count()-1); |
642 } |
683 } |
643 else |
684 else |
644 { |
685 { |
645 delete calendarInfo; |
686 //Before checking for changes , check if any conflict occured i.e calendar updated / deleted. |
646 } |
687 //if there is conflict iConflictOccured = true then skip below condition. |
647 |
688 if (!iConflictOccured && iCalendarInfoOriginal && |
648 CleanupStack::PopAndDestroy(calendarName); |
689 CheckForChangesL(*iCalendarInfoOriginal, |
|
690 *iCalendarInfoEdited)) |
|
691 { |
|
692 // update the calendar properties such as modification time, sync status. |
|
693 SetCalendarUpdatePropertiesL(*iCalendarInfoEdited); |
|
694 |
|
695 iController.UpdateCalendarL(iCalendarInfoEdited); |
|
696 } |
|
697 |
|
698 iConflictOccured = EFalse; |
|
699 delete iCalendarInfoOriginal,iCalendarInfoOriginal = NULL; |
|
700 } |
|
701 iIsDbEditorOpen = EFalse ; //iIsDbEditorOpen should be set before calling UpdateListboxL() |
|
702 UpdateListboxL(); |
649 |
703 |
650 TRACE_EXIT_POINT |
704 TRACE_EXIT_POINT |
651 return retValue; |
705 } |
|
706 |
|
707 // ---------------------------------------------------------------------------- |
|
708 // CCalenMultipleDbUi::ExitDialogL |
|
709 // Edit item from listbox |
|
710 // ---------------------------------------------------------------------------- |
|
711 // |
|
712 void CCalenMultipleDbUi::ExitDialogL() |
|
713 { |
|
714 TRACE_ENTRY_POINT |
|
715 iAsyncExitCmd = EAknSoftkeyExit; |
|
716 iAsyncExit->CallBack(); |
|
717 TRACE_EXIT_POINT |
652 } |
718 } |
653 |
719 |
654 // ---------------------------------------------------------------------------- |
720 // ---------------------------------------------------------------------------- |
655 // CCalenMultipleDbUi::EditItemL |
721 // CCalenMultipleDbUi::EditItemL |
656 // Edit item from listbox |
722 // Edit item from listbox |
659 TInt CCalenMultipleDbUi::EditItemL() |
725 TInt CCalenMultipleDbUi::EditItemL() |
660 { |
726 { |
661 TRACE_ENTRY_POINT |
727 TRACE_ENTRY_POINT |
662 TInt retValue = KErrNotFound; |
728 TInt retValue = KErrNotFound; |
663 TInt currentIndex = iListBox->CurrentItemIndex(); |
729 TInt currentIndex = iListBox->CurrentItemIndex(); |
664 TInt listCount = iListBox->Model()->ItemTextArray()->MdcaCount(); |
730 |
665 |
|
666 RPointerArray<CCalCalendarInfo> calendarInfoList; |
731 RPointerArray<CCalCalendarInfo> calendarInfoList; |
667 iController.GetAllCalendarInfoL(calendarInfoList); |
732 iController.GetAllCalendarInfoL(calendarInfoList); |
668 CleanupClosePushL(calendarInfoList); |
733 CleanupClosePushL(calendarInfoList); |
669 |
734 |
670 CCalCalendarInfo* calendarInfoedited = calendarInfoList[currentIndex]; |
735 iCalendarInfoEdited = calendarInfoList[currentIndex]; |
|
736 |
|
737 CleanupStack::PopAndDestroy(&calendarInfoList); |
671 |
738 |
672 //Take a copy of original before editing |
739 //Take a copy of original before editing |
673 CCalCalendarInfo* calendarInfoOriginal = CCalCalendarInfo::NewL(); |
740 if(iCalendarInfoOriginal) |
674 CleanupStack::PushL(calendarInfoOriginal); |
741 { |
675 calendarInfoOriginal->SetNameL(calendarInfoedited->NameL()); |
742 delete iCalendarInfoOriginal; |
676 calendarInfoOriginal->SetColor(calendarInfoedited->Color()); |
743 iCalendarInfoOriginal = NULL; |
677 calendarInfoOriginal->SetEnabled(calendarInfoedited->Enabled()); |
744 } |
|
745 iCalendarInfoOriginal = CCalCalendarInfo::NewL(); |
|
746 |
|
747 iCalendarInfoOriginal->SetNameL(iCalendarInfoEdited->NameL()); |
|
748 iCalendarInfoOriginal->SetColor(iCalendarInfoEdited->Color()); |
|
749 iCalendarInfoOriginal->SetEnabled(iCalendarInfoEdited->Enabled()); |
678 TBuf8<KBuffLength> keyBuff; |
750 TBuf8<KBuffLength> keyBuff; |
679 TBool syncstatus = EFalse; |
751 TBool syncstatus = EFalse; |
680 keyBuff.Zero(); |
752 keyBuff.Zero(); |
681 keyBuff.AppendNum( ESyncStatus ); |
753 keyBuff.AppendNum( ESyncStatus ); |
682 TPckgC<TBool> pckgSyncStatusValue(syncstatus); |
754 TPckgC<TBool> pckgSyncStatusValue(syncstatus); |
683 pckgSyncStatusValue.Set(calendarInfoedited->PropertyValueL( keyBuff )); |
755 pckgSyncStatusValue.Set(iCalendarInfoEdited->PropertyValueL( keyBuff )); |
684 calendarInfoOriginal->SetPropertyL( keyBuff, pckgSyncStatusValue ); |
756 iCalendarInfoOriginal->SetPropertyL( keyBuff, pckgSyncStatusValue ); |
685 |
757 |
686 iDbEditor = CCalenMultiDBEditor::NewL(*calendarInfoedited, iController, |
758 iDbEditor = CCalenMultiDBEditor::NewL(*this,*iCalendarInfoEdited, iController, |
687 ETrue); |
759 ETrue); |
688 |
760 |
689 iDialogLaunched = ETrue; |
761 //Async dialog |
690 retValue = iDbEditor->ExecuteLD(); |
762 retValue = iDbEditor->ExecuteLD(); |
691 iDbEditor = NULL; |
763 iDbEditor = NULL; |
692 iDialogLaunched = EFalse; |
764 |
693 |
|
694 //Before checking for changes , check if any conflict occured i.e calendar updated / deleted. |
|
695 //if there is conflict iConflictOccured = true then skip below condition. |
|
696 if (!iConflictOccured && CheckForChangesL(*calendarInfoOriginal, |
|
697 *calendarInfoedited)) |
|
698 { |
|
699 // update the calendar properties such as modification time, sync status. |
|
700 SetCalendarUpdatePropertiesL(*calendarInfoedited); |
|
701 |
|
702 iController.UpdateCalendarL(calendarInfoedited); |
|
703 } |
|
704 |
|
705 iConflictOccured = EFalse; |
|
706 |
|
707 UpdateListboxL(); |
|
708 |
|
709 //If conflict occured i.e calendar deleted check for list count before and after |
|
710 //and update focus accordingly |
|
711 if (listCount != iListBox->Model()->ItemTextArray()->MdcaCount()) |
|
712 { |
|
713 ReAdjustListItemFocusL(currentIndex); |
|
714 } |
|
715 |
|
716 CleanupStack::PopAndDestroy(calendarInfoOriginal); |
|
717 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
718 return retValue; |
765 return retValue; |
719 TRACE_EXIT_POINT |
766 TRACE_EXIT_POINT |
720 } |
767 } |
721 |
768 |
722 // ---------------------------------------------------------------------------- |
769 // ---------------------------------------------------------------------------- |
1124 CCalenMultipleDbUi* self = static_cast<CCalenMultipleDbUi*>(aPtr); |
1167 CCalenMultipleDbUi* self = static_cast<CCalenMultipleDbUi*>(aPtr); |
1125 self->TryExitL(self->iAsyncExitCmd); |
1168 self->TryExitL(self->iAsyncExitCmd); |
1126 TRACE_EXIT_POINT |
1169 TRACE_EXIT_POINT |
1127 return 0; |
1170 return 0; |
1128 } |
1171 } |
|
1172 // ---------------------------------------------------------------------------- |
|
1173 // CCalenMultipleDbUi::CallBackForDeleteItemL |
|
1174 // (other items were commented in a header). |
|
1175 // ---------------------------------------------------------------------------- |
|
1176 // |
|
1177 TInt CCalenMultipleDbUi::DoAsyncDeleteTemL(TAny* aPtr) |
|
1178 { |
|
1179 TRACE_ENTRY_POINT |
|
1180 CCalenMultipleDbUi* self = static_cast<CCalenMultipleDbUi*>(aPtr); |
|
1181 self->DeleteItemL(); |
|
1182 TRACE_EXIT_POINT |
|
1183 return 0; |
|
1184 } |
1129 |
1185 |
1130 // ---------------------------------------------------------------------------- |
1186 // ---------------------------------------------------------------------------- |
1131 // CCalenMultipleDbUi::CreateButtonL |
1187 // CCalenMultipleDbUi::CreateButtonL |
1132 // (other items were commented in a header). |
1188 // (other items were commented in a header). |
1133 // ---------------------------------------------------------------------------- |
1189 // ---------------------------------------------------------------------------- |