42 \param controller A reference to the object of ClockAppController. |
41 \param controller A reference to the object of ClockAppController. |
43 */ |
42 */ |
44 ClockViewManager::ClockViewManager( |
43 ClockViewManager::ClockViewManager( |
45 ClockAppControllerIf &controllerIf, QObject *parent) |
44 ClockAppControllerIf &controllerIf, QObject *parent) |
46 :QObject(parent), |
45 :QObject(parent), |
47 mAppControllerIf(controllerIf) |
46 mAppControllerIf(controllerIf), |
|
47 mWorldClockView(0) |
48 { |
48 { |
49 qDebug("clock: ClockViewManager::ClockViewManager() -->"); |
49 // Load the main view at the start up. |
|
50 loadMainView(); |
50 |
51 |
51 // Load the document and the views. |
52 // Delay loading of other views till main view is loaded. |
52 loadViews(); |
53 HbMainWindow *window = hbInstance->allMainWindows().first(); |
53 |
54 connect( |
54 qDebug("clock: ClockViewManager::ClockViewManager() <--"); |
55 window, SIGNAL(viewReady()), |
|
56 this, SLOT(loadOtherViews())); |
55 } |
57 } |
56 |
58 |
57 /*! |
59 /*! |
58 Destructor. |
60 Destructor. |
59 */ |
61 */ |
88 break; |
90 break; |
89 } |
91 } |
90 } |
92 } |
91 |
93 |
92 /*! |
94 /*! |
93 Loads the views from the docml file. |
|
94 */ |
|
95 void ClockViewManager::loadViews() |
|
96 { |
|
97 qDebug() << "clock: ClockViewManager::loadViews -->"; |
|
98 |
|
99 // Load the main view. |
|
100 loadMainView(); |
|
101 // Load the world clock view. |
|
102 loadWorldClockView(); |
|
103 |
|
104 // Set the main view to the window |
|
105 hbInstance->allMainWindows().first()->addView(mMainView); |
|
106 |
|
107 qDebug() << "clock: ClockViewManager::loadViews <--"; |
|
108 } |
|
109 |
|
110 /*! |
|
111 Loads the clock main view. |
95 Loads the clock main view. |
112 */ |
96 */ |
113 void ClockViewManager::loadMainView() |
97 void ClockViewManager::loadMainView() |
114 { |
98 { |
115 qDebug() << "clock: ClockViewManager::loadMainView -->"; |
|
116 |
|
117 bool loadSuccess; |
99 bool loadSuccess; |
118 |
100 |
119 // Construct the document loader instance |
101 // Construct the document loader instance |
120 ClockDocLoader *docLoader = new ClockDocLoader(); |
102 ClockDocLoader *docLoader = new ClockDocLoader(); |
121 |
103 |
122 // Load the application xml. |
104 // Load the application xml. |
123 docLoader->load(CLOCK_MAIN_VIEW_DOCML, &loadSuccess); |
105 docLoader->load(CLOCK_MAIN_VIEW_DOCML, &loadSuccess); |
124 Q_ASSERT_X( |
|
125 loadSuccess, |
|
126 "viewmanager.cpp", |
|
127 "Unable to load the main view app xml"); |
|
128 |
106 |
129 // Find the main view. |
107 // Find the main view. |
130 mMainView = static_cast<ClockMainView *> ( |
108 mMainView = static_cast<ClockMainView *> ( |
131 docLoader->findWidget(CLOCK_MAIN_VIEW)); |
109 docLoader->findWidget(CLOCK_MAIN_VIEW)); |
132 |
110 |
133 // Setup the view. |
111 // Setup the view. |
134 mMainView->setupView(mAppControllerIf, docLoader); |
112 mMainView->setupView(mAppControllerIf, docLoader); |
135 |
113 |
136 qDebug() << "clock: ClockViewManager::loadMainView <--"; |
114 // Set the main view to the window |
|
115 hbInstance->allMainWindows().first()->addView(mMainView); |
137 } |
116 } |
138 |
117 |
139 /*! |
118 /*! |
140 Loads the world clock view. |
119 Loads the world clock view. |
141 */ |
120 */ |
145 ClockDocLoader *docLoader = new ClockDocLoader(); |
124 ClockDocLoader *docLoader = new ClockDocLoader(); |
146 |
125 |
147 bool loadSuccess; |
126 bool loadSuccess; |
148 |
127 |
149 // Construct the world list view from doc loader. |
128 // Construct the world list view from doc loader. |
150 docLoader->load(":/xml/worldclockview.docml", &loadSuccess); |
129 docLoader->load(CLOCK_WORLD_VIEW_DOCML, &loadSuccess); |
151 |
130 |
152 // Get the world list view. |
131 // Get the world list view. |
153 mWorldClockView = |
132 mWorldClockView = static_cast<ClockWorldView *> ( |
154 static_cast<ClockWorldView *> (docLoader->findWidget("worldClockView")); |
133 docLoader->findWidget(CLOCK_WORLD_VIEW)); |
155 |
134 |
156 mWorldClockView->setupView(mAppControllerIf, docLoader); |
135 mWorldClockView->setupView(mAppControllerIf, docLoader); |
|
136 } |
157 |
137 |
158 /* // Get the world list widget. |
138 /*! |
159 WorldListWidget *listWidget = |
139 Load other views |
160 qobject_cast<WorldListWidget *> (docLoader->findWidget("worldListWidget")); |
140 */ |
161 Q_ASSERT_X(listWidget, |
141 void ClockViewManager::loadOtherViews() |
162 "viewmanager.cpp", "Unable to load the world list widget"); |
142 { |
163 listWidget->setupWidget(mWorldListView, docLoader);*/ |
143 mMainView->setupAfterViewReady(); |
|
144 |
|
145 // Load world clock view |
|
146 loadWorldClockView(); |
|
147 |
|
148 // Disconnect the signal viewReady as all the views are loaded. |
|
149 HbMainWindow *window = hbInstance->allMainWindows().first(); |
|
150 disconnect( |
|
151 window, SIGNAL(viewReady()), |
|
152 this, SLOT(loadOtherViews())); |
164 } |
153 } |
165 |
154 |
166 // End of file --Don't remove this. |
155 // End of file --Don't remove this. |