calendarui/controller/src/calenactionui.cpp
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 45 b6db4fd4947b
--- a/calendarui/controller/src/calenactionui.cpp	Tue Feb 02 10:12:19 2010 +0200
+++ b/calendarui/controller/src/calenactionui.cpp	Fri Apr 16 14:57:40 2010 +0300
@@ -17,26 +17,16 @@
 
 
 // INCLUDES
-#include <aknViewAppUi.h>
-#include <avkon.hrh>
-#include <aknnavi.h>
-#include <akntitle.h>
-#include <eikspane.h>
-#include <Calendar.rsg>
-#include <calencommonui.rsg>
-#include <calenservices.h>
-#include <calentoolbar.h>
-
 #include "calendarui_debug.h"
 #include "calenactionui.h"
 #include "calencontroller.h"
 #include "calendeleteui.h"
 #include "caleneditui.h"
-#include "calenlocationui.h"
-#include "calensettingsui.h"
 #include "calennotifier.h"
-#include "calenmultipledbui.h"
-#include "calenattachmentui.h"
+#include "calenservices.h"
+#include "calensettingsview.h"
+#include "calenviewmanager.h"
+#include <hbmainwindow.h>
 
 // ----------------------------------------------------------------------------
 // CCalenActionUi::NewL
@@ -93,10 +83,8 @@
     TRACE_ENTRY_POINT;
 
     delete iDeleteUi;
-    delete iEditUi;
-    delete iLocationUi;
-    delete iAttachmentUi;
-    
+    delete iEditUi;   
+
     TRACE_EXIT_POINT;
     }
 
@@ -109,94 +97,37 @@
     {
     MCalenCommandHandler* handler = NULL;
 
-    if( aCommand >= ECalenEditCommandBase &&
-        aCommand < ECalenDeleteCommandBase )
-        {
-        if(!iEditUi)
-            {
-            iEditUi = CCalenEditUi::NewL(iController);
-            }
-        handler = iEditUi;
-        }
-    else if( aCommand >= ECalenDeleteCommandBase &&
-             aCommand < ECalenSettingsCommandBase )
-        {
-        if(!iDeleteUi)
-            {
-            iDeleteUi = CCalenDeleteUi::NewL( iController );
-            }
-        handler = iDeleteUi;
-        }
-    else if( aCommand >= ECalenSettingsCommandBase &&
-             aCommand < ECalenMapCommandBase )
-        {
-        handler = this;
-        }
-    else if( aCommand >= ECalenMapCommandBase &&
-             aCommand < ECalenAttachmentCommandBase )
-        {
-        if(!iLocationUi)
-            {
-            iLocationUi = CCalenLocationUi::NewL( iController );
-            }
-        handler = iLocationUi;
-        }
-    else if( aCommand >= ECalenAttachmentCommandBase && 
-             aCommand < ECalenLastCommand )
-        {
-        if(!iAttachmentUi)
-            {
-            iAttachmentUi = CCalenAttachmentUi::NewL(iController);
-            }
-        handler = iAttachmentUi;
-        }
-
-    TRACE_EXIT_POINT;
-    return handler;
-    }
-
-// ----------------------------------------------------------------------------
-// CCalenActionUi::HandleCommmandL
-// Handles Calendar commands. Delegates to appropriate action ui.
-// (other items were commented in a header).
-// ----------------------------------------------------------------------------
-//
-/*TBool CCalenActionUi::HandleActionUiCommandL( TInt aCommand )
-    {
-    TRACE_ENTRY_POINT;
-
-    // Lazy initialisation for action uis.
-    TBool handled( EFalse );
-
-    if( aCommand >= ECalenEditCommandBase && aCommand < ECalenLastCommand )
+    if ( aCommand >= ECalenEditCommandBase
+      && aCommand < ECalenDeleteCommandBase )
         {
         if( !iEditUi )
             {
             iEditUi = CCalenEditUi::NewL( iController );
             }
-        handled = iEditUi->HandleActionUiCommandL( aCommand );
-
-        if( !handled )
+        handler = iEditUi;
+        }
+    else if ( aCommand >= ECalenDeleteCommandBase
+      && aCommand < ECalenSettingsCommandBase )
+        {
+        if( !iDeleteUi )
             {
-            if( !iDeleteUi )
-                {
-                iDeleteUi = CCalenDeleteUi::NewL( iController );
-                }
-            handled = iDeleteUi->HandleActionUiCommandL( aCommand );
+            iDeleteUi = CalenDeleteUi::NewL( iController );
             }
-
-        if( !handled && aCommand == ECalenShowSettings )
-            {
-            handled = ETrue;
-
-            ShowSettingsL();
-            }
+        handler = iDeleteUi;
+        }
+    else if ( aCommand >= ECalenSettingsCommandBase
+      && aCommand < ECalenMapCommandBase )
+        {
+        handler = this;
         }
-
+    else if ( aCommand >= ECalenMapCommandBase
+      && aCommand < ECalenLastCommand )
+        {
+        }
+        
     TRACE_EXIT_POINT;
-    return handled;
-    }*/
-
+    return handler;
+    }
 
 // ----------------------------------------------------------------------------
 // CCalenActionUi::HandleCommandL
@@ -208,269 +139,26 @@
     {
     TRACE_ENTRY_POINT;
     TBool continueCommand(EFalse);
-
-    switch(aCommand.Command())
-        {
-        case ECalenShowSettings:
-            {
-            ShowSettingsL();
-            }
-            break;
-        case ECalenShowCalendars:
-            {
-            ShowCalendarsL();
-            }
-            break;
-        default:
-            break;
+    
+    if(aCommand.Command()==ECalenShowSettings)
+        {  
+        launchSettingsView();
         }
-
+    
     TRACE_EXIT_POINT;
-    return continueCommand;
-    }
+    return continueCommand;    }
 
 // ----------------------------------------------------------------------------
-// CCalenActionUi::CalenCommandHandlerExtensionL
-// Dummy implementation.
-// (other items were commented in a header).
-// ----------------------------------------------------------------------------
-//
-TAny* CCalenActionUi::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ )
-    {
-    TRACE_ENTRY_POINT;
-    TRACE_EXIT_POINT;
-    return NULL;
-    }
-
-// ----------------------------------------------------------------------------
-// CCalenActionUi::ShowCalendarsL
-// Shows the multiple db calendar's dialog
+// CCalenActionUi::launchSettingsView
+// Launches settings view
 // (other items were commented in a header).
 // ----------------------------------------------------------------------------
 //
-void CCalenActionUi::ShowCalendarsL()
-    {
-    TRACE_ENTRY_POINT;
-    // Create settings own titlepane and navipane, and swap with existing ones
-    CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane();
-    
-    // Titlepane
-    CAknTitlePane* newtp = new( ELeave ) CAknTitlePane();
-    CleanupStack::PushL( newtp );
-    CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp );
-    CleanupStack::Pop( newtp ); // ownership is passed to statuspane
-    TRect oldRect( 0, 0, 0, 0 );
-    if( oldtp )
-        {
-        CleanupStack::PushL( oldtp );
-        oldRect = oldtp->Rect();
-        CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle ));
-        newtp->SetContainerWindowL( *ctrl );
-        newtp->ConstructL();
-        newtp->SetRect(oldRect);
-        newtp->ActivateL();
-        }        
-    // NaviPane
-    CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer();
-    CleanupStack::PushL( newnp );
-    CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp );
-    CleanupStack::Pop( newnp ); // ownership is passed to statuspane
-    if( oldnp )
-        {
-        CleanupStack::PushL( oldnp );
-        oldRect = oldnp->Rect();
-        CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
-        newnp->SetContainerWindowL( *ctrl );
-        newnp->ConstructL();
-        newnp->SetRect( oldRect );
-        newnp->PushDefaultL();
-        newnp->ActivateL();
-        }
-            
-        // Hide the toolbar before we display settings menu
-        MCalenToolbar* toolbar = iController.Services().ToolbarOrNull();
-        if(toolbar)
-            {
-            toolbar->SetToolbarVisibilityL(EFalse);  
-            }
-        
-        // defer settings notifications before launching the settings  
-        CCalenNotifier& notifier = iController.Notifier();
-        notifier.DeferSettingsNotifications();
-        
-        CCalenMultipleDbUi* dlg = CCalenMultipleDbUi::NewL(iController);
-        TInt retValue = KErrNone;
-        // Trap showing settings so settings watcher is always resumed.
-        PIM_TRAPD_HANDLE( retValue = dlg->ExecuteLD( R_CALEN_MULTIPLEDB_DIALOG ) );
-        notifier.ResumeSettingsNotifications();
-        
-        // Unhide the toolbar when settings is closed
-        if(toolbar)
-            {
-            toolbar->SetToolbarVisibilityL(ETrue); 
-            }
-        
-    // When setting is closed, swap back old titlepane and navipane
-    if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) )
-        {
-        CleanupStack::Pop( oldnp );
-        delete newnp;
-        oldnp->ActivateL();
-        }
-    if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) )
-        {
-        CleanupStack::Pop( oldtp );
-        delete newtp;
-        oldtp->ActivateL();
-        }
-    
-    iController.BroadcastNotification( ECalenNotifyCalendarFieldChanged );
-
-    if( retValue == EAknCmdExit ||
-        retValue == EKeyEscape )
-        {
-        // iController.IssueCommandL( EAknCmdExit );
-        // FIX ME ::
-        // Issuing the command from here will not exit the application properly
-        // because aknviewappui is not exited
-        // Calling ProcessCommandL of aknviewappui will exits the application
-        iController.AppUi().ProcessCommandL(EAknCmdExit);
-        }
-    else if(retValue == EAknSoftkeyExit)
-        {
-        // iController.IssueCommandL( EAknCmdExit );
-        // FIX ME ::
-        // Issuing the command from here will not exit the application properly
-        // because aknviewappui is not exited
-        // Calling ProcessCommandL of aknviewappui will exits the application
-        iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
-        }
-
-    TRACE_EXIT_POINT;
-    }
-
-// ----------------------------------------------------------------------------
-// CCalenActionUi::ShowSettingsL
-// Shows the settings dialog
-// (other items were commented in a header).
-// ----------------------------------------------------------------------------
-//
-void CCalenActionUi::ShowSettingsL()
+void CCalenActionUi::launchSettingsView()
     {
-    TRACE_ENTRY_POINT;
-    
-    // Create settings own titlepane and navipane, and swap with existing ones
-    CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane();
-    
-    // Titlepane
-    CAknTitlePane* newtp = new( ELeave ) CAknTitlePane();
-    CleanupStack::PushL( newtp );
-    CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp );
-    CleanupStack::Pop( newtp ); // ownership is passed to statuspane
-    TRect oldRect( 0, 0, 0, 0 );
-    if( oldtp )
-        {
-        CleanupStack::PushL( oldtp );
-        oldRect = oldtp->Rect();
-        CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle ));
-        newtp->SetContainerWindowL( *ctrl );
-        newtp->ConstructL();
-        newtp->SetRect(oldRect);
-        newtp->ActivateL();
-        }        
-    
-    // NaviPane
-    CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer();
-    CleanupStack::PushL( newnp );
-    CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp );
-    CleanupStack::Pop( newnp ); // ownership is passed to statuspane
-    if( oldnp )
-        {
-        CleanupStack::PushL( oldnp );
-        oldRect = oldnp->Rect();
-        CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) );
-        newnp->SetContainerWindowL( *ctrl );
-        newnp->ConstructL();
-        newnp->SetRect( oldRect );
-        newnp->PushDefaultL();
-        newnp->ActivateL();
-        }
-        
-    // Hide the toolbar before we display settings menu
-    MCalenToolbar* toolbar = iController.Services().ToolbarOrNull();
-    if(toolbar)
-        {
-        toolbar->SetToolbarVisibilityL(EFalse);  
-        }
-    
-    // defer settings notifications before launching the settings  
-    CCalenNotifier& notifier = iController.Notifier();
-    notifier.DeferSettingsNotifications();
-    
-    CCalenSettingsUi* dlg = CCalenSettingsUi::NewL(iController.CustomisationManager());
-    TInt retValue = KErrNone;
-    // Trap showing settings so settings watcher is always resumed.
-    PIM_TRAPD_HANDLE( retValue = dlg->ExecuteLD( R_CALEN_SETTING_DIALOG ) );
-    notifier.ResumeSettingsNotifications();
-    
-    // Unhide the toolbar when settings is closed
-    if(toolbar)
-        {
-        toolbar->SetToolbarVisibilityL(ETrue); 
-        }
-    
-    // When setting is closed, swap back old titlepane and navipane
-    if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) )
-        {
-        CleanupStack::Pop( oldnp );
-        delete newnp;
-        oldnp->ActivateL();
-        }
-    if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) )
-        {
-        CleanupStack::Pop( oldtp );
-        delete newtp;
-        oldtp->ActivateL();
-        }
-    
-    iController.BroadcastNotification( ECalenNotifySettingsClosed );
-
-      if( retValue == EAknCmdExit ||
-        retValue == EKeyEscape )
-        {
-        // iController.IssueCommandL( EAknCmdExit );
-        // FIX ME ::
-        // Issuing the command from here will not exit the application properly
-        // because aknviewappui is not exited
-        // Calling ProcessCommandL of aknviewappui will exits the application
-        iController.AppUi().ProcessCommandL(EAknCmdExit);
-        }
-    else if(retValue == EAknSoftkeyExit)
-        {
-        // iController.IssueCommandL( EAknCmdExit );
-        // FIX ME ::
-        // Issuing the command from here will not exit the application properly
-        // because aknviewappui is not exited
-        // Calling ProcessCommandL of aknviewappui will exits the application
-        iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
-        }
-    
-    TRACE_EXIT_POINT;
-    }
-
-// -----------------------------------------------------------------------------
-// CCalenActionUi::IsEditorActive
-// Tells framework whether editor is active or not
-// -----------------------------------------------------------------------------
-//
-TBool CCalenActionUi::IsEditorActive()
-    {
-    if(iEditUi)
-        {
-        return(iEditUi->IsEditorActive());
-        }
-    else
-        return EFalse;
+    CalenSettingsView* settingsView = iController.ViewManager().settingsView();
+    settingsView->initializeForm();
+    iController.Services().MainWindow().setCurrentView(settingsView);
     }
 
 // End of file