636 // |
636 // |
637 void CCalenController::handleServiceManagerSlot(int view, const QDateTime& dateTime) |
637 void CCalenController::handleServiceManagerSlot(int view, const QDateTime& dateTime) |
638 { |
638 { |
639 OstTraceFunctionEntry0( CCALENCONTROLLER_HANDLESERVICEMANAGERSLOT_ENTRY ); |
639 OstTraceFunctionEntry0( CCALENCONTROLLER_HANDLESERVICEMANAGERSLOT_ENTRY ); |
640 |
640 |
|
641 // Broadcast the notification ECalenNotifyCloseDialogs |
|
642 // to close the opened dialogs if any |
|
643 BroadcastNotification(ECalenNotifyCloseDialogs); |
|
644 |
641 if (iIsFromServiceFrmWrk) { |
645 if (iIsFromServiceFrmWrk) { |
642 // Set the context properly |
646 // Set the context properly |
643 mContext->setFocusDateAndTime(dateTime); |
647 mContext->setFocusDateAndTime(dateTime); |
644 // launch the appropriate view |
648 // launch the appropriate view |
645 iViewManager->constructAndActivateView(view); |
649 iViewManager->constructAndActivateView(view); |
646 |
650 |
647 iIsFromServiceFrmWrk = false; |
651 iIsFromServiceFrmWrk = false; |
648 |
652 |
649 } else { // Calendar was in backgroung but now its being brought to foreground |
653 } else { |
|
654 // Calendar was in backgroung but now its being brought to foreground |
|
655 |
|
656 // Remove the previous view to avoid flicker |
|
657 iViewManager->removePreviousView(); |
|
658 |
650 // If current state is editing state or printing state |
659 // If current state is editing state or printing state |
651 // or deleting state or sending state, then dont do anything as |
660 // or deleting state or sending state, then dont do anything as |
652 // user might loose the data |
661 // user might loose the data |
653 CCalenStateMachine::TCalenStateIndex currentState = iStateMachine->CurrentState(); |
662 |
|
663 CCalenStateMachine::TCalenStateIndex currentState = |
|
664 iStateMachine->CurrentState(); |
|
665 |
654 if ((currentState == CCalenStateMachine::ECalenDeletingState) || |
666 if ((currentState == CCalenStateMachine::ECalenDeletingState) || |
655 (currentState == CCalenStateMachine::ECalenPrintingState) || |
667 (currentState == CCalenStateMachine::ECalenPrintingState) || |
656 (currentState == CCalenStateMachine::ECalenSendingState)) { |
668 (currentState == CCalenStateMachine::ECalenSendingState)) { |
657 // simply return - we dont have anything to do |
669 // simply return - we dont have anything to do |
658 } |
670 } else if (currentState == CCalenStateMachine::ECalenViewingState) { |
659 |
671 if(iViewManager->isEventViewerActive()) { |
660 else if (currentState == CCalenStateMachine::ECalenViewingState) { |
672 iViewManager->closeAgendaEventView(); |
661 if(iViewManager->isEventViewerActive()){ |
673 } |
662 iViewManager->closeAgendaEventView(); |
674 } else if (currentState == CCalenStateMachine::ECalenEditingState) { |
663 } |
675 // close the editor and save the entry if application is |
|
676 // in background and launch the desired view |
|
677 if(iViewManager->isEventViewerActive()) { |
|
678 // First close editor and then viewer |
|
679 iViewManager->saveAndCloseEditor(); |
|
680 iViewManager->closeAgendaEventView(); |
|
681 } else { |
|
682 // If viewer is not active, just close the editor |
|
683 iActionUi->saveAndCloseEditor(); |
|
684 } |
|
685 } else if (currentState == CCalenStateMachine::ECalenSettingsState) { |
|
686 iViewManager->removeSettingsView(); |
664 } |
687 } |
665 else if (currentState == CCalenStateMachine::ECalenEditingState) { |
|
666 // close the editor and save the entry if application is in background |
|
667 //and launch the desired view |
|
668 if(iViewManager->isEventViewerActive()){ |
|
669 iViewManager->saveAndCloseEditor(); |
|
670 iViewManager->closeAgendaEventView(); |
|
671 } |
|
672 else{ |
|
673 iActionUi->saveAndCloseEditor(); |
|
674 } |
|
675 } |
|
676 |
|
677 else if (currentState == CCalenStateMachine::ECalenSettingsState){ |
|
678 iViewManager->removeSettingsView(); |
|
679 } |
|
680 |
688 |
681 // Set the context properly |
689 // Set the context properly |
682 mContext->setFocusDateAndTime(dateTime); |
690 mContext->setFocusDateAndTime(dateTime); |
683 IssueCommandL(view); |
691 IssueCommandL(view); |
684 |
692 |
685 // connect to raise the window to foreground once the view is ready |
693 // connect to raise the window to foreground once the view is ready |
686 connect(&MainWindow(), SIGNAL(viewReady()), |
694 connect(&MainWindow(), SIGNAL(viewReady()), this, SLOT(raiseWindow())); |
687 this, SLOT(raiseWindow())); |
695 |
|
696 // Dispatches all posted events of type DeferredDelete, |
|
697 // i.e. empties the event queue in case any deletion is pending |
|
698 qApp->sendPostedEvents(0, QEvent::DeferredDelete); |
688 } |
699 } |
689 |
700 |
|
701 OstTraceFunctionExit0( CCALENCONTROLLER_HANDLESERVICEMANAGERSLOT_EXIT ); |
690 } |
702 } |
|
703 |
691 void CCalenController::raiseWindow() |
704 void CCalenController::raiseWindow() |
692 { |
705 { |
693 MainWindow().raise(); |
706 MainWindow().raise(); |
694 disconnect(&MainWindow(), SIGNAL(viewReady()), |
707 disconnect(&MainWindow(), SIGNAL(viewReady()), |
695 this, SLOT(raiseWindow())); |
708 this, SLOT(raiseWindow())); |