21 #include "cntmainwindow.h" |
21 #include "cntmainwindow.h" |
22 #include <hbview.h> |
22 #include <hbview.h> |
23 #include <hbmainwindow.h> |
23 #include <hbmainwindow.h> |
24 #include <qtcontacts.h> |
24 #include <qtcontacts.h> |
25 #include "cntviewnavigator.h" |
25 #include "cntviewnavigator.h" |
26 #include <simutility.h> |
26 #include "simutility.h" |
27 |
27 |
28 CntDefaultViewManager::CntDefaultViewManager( HbMainWindow* aWindow ) : QObject(), |
28 CntDefaultViewManager::CntDefaultViewManager( HbMainWindow* aWindow ) : QObject(), |
29 mFactory(NULL), |
29 mFactory(NULL), |
30 mCurrent(NULL), |
30 mCurrent(NULL), |
31 mOldView(NULL), |
31 mOldView(NULL), |
32 mNavigator(NULL), |
32 mNavigator(NULL), |
33 mMainWindow( aWindow ) |
33 mMainWindow( aWindow ), |
|
34 mSimUtility(NULL) |
34 |
35 |
35 { |
36 { |
36 setViewFactory(new CntDefaultViewFactory()); |
37 setViewFactory(new CntDefaultViewFactory()); |
37 setViewNavigator(new CntViewNavigator(this)); |
38 setViewNavigator(new CntViewNavigator(this)); |
38 |
39 |
39 #ifndef __WINS__ |
|
40 int error = -1; |
40 int error = -1; |
41 SimUtility simUtility = SimUtility(SimUtility::AdnStore, error); |
41 mSimUtility = new SimUtility(SimUtility::AdnStore, error); |
42 if (error == 0) |
42 if (error != 0) |
43 { |
43 { |
44 SimUtility::AvailableStores store = simUtility.getAvailableStores(error); |
44 delete mSimUtility; |
45 if (error == 0 && store.AdnStorePresent) |
45 mSimUtility = 0; |
46 { |
|
47 QContactManager* manager = QContactManager::fromUri(SIM_BACKEND_ADN); |
|
48 mBackends.append( manager ); |
|
49 } |
|
50 } |
46 } |
51 #endif |
|
52 } |
47 } |
53 |
48 |
54 CntDefaultViewManager::~CntDefaultViewManager() |
49 CntDefaultViewManager::~CntDefaultViewManager() |
55 { |
50 { |
56 qDeleteAll(mDefaults.values()); |
51 qDeleteAll(mDefaults.values()); |
57 delete mFactory; |
52 delete mFactory; |
|
53 delete mSimUtility; |
58 } |
54 } |
59 |
55 |
60 void CntDefaultViewManager::setViewFactory( CntAbstractViewFactory* aFactory ) |
56 void CntDefaultViewManager::setViewFactory( CntAbstractViewFactory* aFactory ) |
61 { |
57 { |
62 if ( aFactory ) |
58 if ( aFactory ) |
77 { |
73 { |
78 mArgs.clear(); |
74 mArgs.clear(); |
79 |
75 |
80 QFlags<Hb::ViewSwitchFlag> flags; |
76 QFlags<Hb::ViewSwitchFlag> flags; |
81 int back = mNavigator->back( flags ); |
77 int back = mNavigator->back( flags ); |
82 |
78 |
|
79 foreach( int k, aArgs.keys() ) |
|
80 { |
|
81 mArgs.insert( k, aArgs.value(k) ); |
|
82 } |
83 mArgs.insert(EViewId, back ); |
83 mArgs.insert(EViewId, back ); |
84 mArgs.insert(ESelectedAction, aArgs.value(ESelectedAction)); |
84 // mArgs.insert(ESelectedAction, aArgs.value(ESelectedAction)); |
85 mArgs.insert(ESelectedContact, aArgs.value(ESelectedContact)); |
85 // mArgs.insert(ESelectedContact, aArgs.value(ESelectedContact)); |
86 mArgs.insert(ESelectedGroupContact, aArgs.value(ESelectedGroupContact)); |
86 // mArgs.insert(ESelectedGroupContact, aArgs.value(ESelectedGroupContact)); |
87 mArgs.insert(ESelectedDetail, aArgs.value(ESelectedDetail)); |
87 // mArgs.insert(ESelectedDetail, aArgs.value(ESelectedDetail)); |
88 |
88 |
89 if (mArgs.value(EViewId).toInt() != noView) |
89 if (mArgs.value(EViewId).toInt() != noView) |
90 { |
90 { |
91 switchView( mArgs, flags ); |
91 switchView( mArgs, flags ); |
92 } |
92 } |
141 if (!mOldView->isDefault()) |
142 if (!mOldView->isDefault()) |
142 { |
143 { |
143 delete mOldView; |
144 delete mOldView; |
144 mOldView = NULL; |
145 mOldView = NULL; |
145 } |
146 } |
|
147 // If view id is not in defaults list, it means that view has changed |
|
148 // its opinnion about preserving state to true. |
|
149 else if ( !mDefaults.contains(mOldView->viewId()) ) |
|
150 { |
|
151 mDefaults.insert( mOldView->viewId(), mOldView ); |
|
152 } |
|
153 |
146 mMainWindow->setInteractive(true); |
154 mMainWindow->setInteractive(true); |
147 } |
155 } |
148 } |
156 } |
149 |
157 |
150 void CntDefaultViewManager::switchView(const CntViewParameters aArgs, QFlags<Hb::ViewSwitchFlag> flags) |
158 void CntDefaultViewManager::switchView(const CntViewParameters aArgs, QFlags<Hb::ViewSwitchFlag> flags) |