phonebookui/pbkcommonui/src/cntdefaultviewmanager.cpp
changeset 61 d30183af6ca6
parent 54 47627ab5d7a4
child 66 554fe4dbbb59
equal deleted inserted replaced
56:d508aa856878 61:d30183af6ca6
    24 #include <qtcontacts.h>
    24 #include <qtcontacts.h>
    25 #include "cntviewnavigator.h"
    25 #include "cntviewnavigator.h"
    26 #include "cntsimutility.h"
    26 #include "cntsimutility.h"
    27 #include "cntdebug.h"
    27 #include "cntdebug.h"
    28 #include <QApplication>
    28 #include <QApplication>
       
    29 #include "cntdefaultengine.h"
    29 
    30 
    30 CntDefaultViewManager::CntDefaultViewManager( HbMainWindow* aWindow ) : QObject(),
    31 CntDefaultViewManager::CntDefaultViewManager( HbMainWindow* aWindow ) : QObject(),
    31     mFactory(NULL),
    32     mFactory(NULL),
    32     mCurrent(NULL),
    33     mCurrent(NULL),
    33     mOldView(NULL),
    34     mOldView(NULL),
    34     mNavigator(NULL),
    35     mNavigator(NULL),
    35     mMainWindow( aWindow ),
    36     mMainWindow( aWindow ),
    36     mSimUtility(NULL)
    37     mSimUtility(NULL),
    37 {
    38     mEngine(NULL)
    38     CNT_ENTRY
    39 {
    39     
    40     CNT_ENTRY
    40     setViewFactory(new CntDefaultViewFactory());
    41     
    41     setViewNavigator(new CntViewNavigator(this));
    42     mEngine = new CntDefaultEngine( *this );
       
    43     setViewFactory( new CntDefaultViewFactory( mEngine->extensionManager()) );
       
    44     setViewNavigator( new CntViewNavigator(this) );
    42 
    45 
    43     int error = -1;
    46     int error = -1;
    44     mSimUtility = new CntSimUtility(CntSimUtility::AdnStore, error);
    47     mSimUtility = new CntSimUtility(CntSimUtility::AdnStore, error);
    45     if (error != 0) 
    48     if (error != 0) 
    46     {
    49     {
    49     }
    52     }
    50     
    53     
    51     CNT_EXIT
    54     CNT_EXIT
    52 }
    55 }
    53 
    56 
       
    57 CntAbstractEngine& CntDefaultViewManager::engine()
       
    58 {
       
    59     return *mEngine;
       
    60 }
       
    61 
    54 CntDefaultViewManager::~CntDefaultViewManager()
    62 CntDefaultViewManager::~CntDefaultViewManager()
    55 {
    63 {
    56     CNT_ENTRY
    64     CNT_ENTRY
    57     
    65     
    58     cleanup();
    66     cleanup();
    59 
    67 
       
    68     delete mEngine;
    60     CNT_EXIT
    69     CNT_EXIT
    61 }
    70 }
    62 
    71 
    63 void CntDefaultViewManager::cleanup()
    72 void CntDefaultViewManager::cleanup()
    64 {
    73 {
   159     mNavigator->next(aArgs.value(EViewId).toInt(), flags);
   168     mNavigator->next(aArgs.value(EViewId).toInt(), flags);
   160     switchView(aArgs, flags);
   169     switchView(aArgs, flags);
   161     
   170     
   162     CNT_EXIT
   171     CNT_EXIT
   163 }
   172 }
   164 
   173 /*
   165 QContactManager* CntDefaultViewManager::contactManager( const QString& aType )
   174 QContactManager* CntDefaultViewManager::contactManager( const QString& aType )
   166 {
   175 {
   167     CNT_ENTRY
   176     CNT_ENTRY
   168     
   177     
   169     foreach ( QContactManager* mgr, mBackends ) 
   178     foreach ( QContactManager* mgr, mBackends ) 
   182     }
   191     }
   183     
   192     
   184     CNT_EXIT
   193     CNT_EXIT
   185     return manager;
   194     return manager;
   186 }
   195 }
       
   196 */
   187 
   197 
   188 void CntDefaultViewManager::removeCurrentView()
   198 void CntDefaultViewManager::removeCurrentView()
   189 {
   199 {
   190     CNT_ENTRY
   200     CNT_ENTRY
   191     
   201     
   239             nextView = mDefaults.value(id);
   249             nextView = mDefaults.value(id);
   240         }
   250         }
   241         else
   251         else
   242         {
   252         {
   243             nextView = mFactory->createView( id );
   253             nextView = mFactory->createView( id );
       
   254             nextView->setEngine( *mEngine );
       
   255             
   244             if (nextView->isDefault())
   256             if (nextView->isDefault())
   245             {
   257             {
   246                 mDefaults.insert(id, nextView);
   258                 mDefaults.insert(id, nextView);
   247             }
   259             }
   248         }
   260         }
   249         
   261         
   250         mOldView = mCurrent;
   262         mOldView = mCurrent;
   251         mCurrent = nextView;
   263         mCurrent = nextView;
   252         mMainWindow->addView(mCurrent->view());
   264         mMainWindow->addView(mCurrent->view());
   253         mMainWindow->setCurrentView(mCurrent->view(), true, flags);
   265         mMainWindow->setCurrentView(mCurrent->view(), true, flags);
   254         mCurrent->activate(this, aArgs);
   266         mCurrent->activate(aArgs);
   255         
   267         
   256         removeCurrentView();
   268         removeCurrentView();
   257     }
   269     }
   258     
   270     
   259     CNT_EXIT
   271     CNT_EXIT