69 Reads UI object from Application Library docml |
72 Reads UI object from Application Library docml |
70 |
73 |
71 \sa HsMenuView |
74 \sa HsMenuView |
72 */ |
75 */ |
73 |
76 |
74 /*! |
77 |
75 Sets view label visible or hidden. |
78 /*! |
76 \param visible When true label is set visible, invisible otherwise. |
79 Cleanup search text on showing search panel. Ensures vkb host instance |
77 \return \a true on success, \a false otherwise. |
80 is appears on show and disappears on hide search panel. |
78 */ |
81 |
79 bool HsMenuViewBuilder::setLabelVisible(bool visible) |
82 \param visible When true search panel is to show up, |
80 { |
83 hide otherwise. |
81 bool result(true); |
84 */ |
82 |
85 void HsMenuViewBuilder::searchPanelVisibilityChange(bool visible) |
83 if (visible != mViewOptions.testFlag(Label)) { |
86 { |
84 mViewOptions ^= ViewOptions(Label); |
87 if (visible) { |
85 result = parseSection(mSections[mViewOptions]); |
88 // TODO this is temprary solution, proper solution should come from Orbit |
86 } |
89 if (!HbVkbHost::getVkbHost(currentSearchPanel())) { |
87 return result; |
90 new HsVkbHost(currentSearchPanel()); |
88 } |
|
89 |
|
90 |
|
91 /*! |
|
92 Sets search panel visible or hidden. |
|
93 \param visible When true search panel is set visible, |
|
94 invisible otherwise. |
|
95 \return \a true on success, \a false otherwise. |
|
96 */ |
|
97 bool HsMenuViewBuilder::setSearchPanelVisible(bool visible) |
|
98 { |
|
99 bool result(true); |
|
100 |
|
101 if (visible != mViewOptions.testFlag(Search)) { |
|
102 mViewOptions ^= ViewOptions(Search); |
|
103 result = parseSection(mSections[mViewOptions]); |
|
104 |
|
105 if (visible) { |
|
106 // TODO this is temprary solution, proper solution should come from Orbit |
|
107 if (!HbVkbHost::getVkbHost(searchPanel())) |
|
108 { |
|
109 new HsVkbHost(searchPanel()); |
|
110 } |
|
111 HbLineEdit *const lineEdit(searchPanelLineEdit()); |
|
112 |
|
113 lineEdit->setText(""); |
|
114 } |
91 } |
115 else { |
92 HbLineEdit *const lineEdit(searchPanelLineEdit()); |
116 if (static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(searchPanel()))) { |
93 |
117 static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(searchPanel()))-> |
94 lineEdit->setText(""); |
118 updateViewHeight(-1); |
95 } else { |
119 } |
96 if (static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(currentSearchPanel()))) { |
120 } |
97 static_cast<HsVkbHost *>(HbVkbHost::getVkbHost(currentSearchPanel()))-> |
121 } |
98 updateViewHeight(-1); |
122 return result; |
99 } |
123 } |
100 } |
124 |
101 |
125 /*! |
102 } |
126 \return \a true when label is visible, \a false otherwise. |
103 |
127 */ |
104 /*! |
128 bool HsMenuViewBuilder::isLabelVisible() const |
105 \return pointer to the view resulting from last \a build call or NULL if |
129 { |
106 the \a build has not yet been called. |
130 return mViewOptions.testFlag(Label); |
107 Memory ownership is not changed. |
131 } |
108 */ |
132 |
109 HbView *HsMenuViewBuilder::currentView() const |
133 /*! |
110 { |
134 \return \a true when search panel is visible, \a false otherwise. |
111 const QString VIEW_NAME = |
135 */ |
112 mViewContextToStringMap[mViewContext] |
136 bool HsMenuViewBuilder::isSearchPanelVisible() const |
113 + "View"; |
137 { |
114 |
138 return mViewOptions.testFlag(Search); |
115 HbView *const view = |
139 } |
116 qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME)); |
140 |
117 |
141 /*! |
118 if (view != NULL && mViewContext != HsInstalledAppsContext) { |
142 \return pointer to the main view. |
119 view->setToolBar(mToolBar); |
143 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
120 } |
144 Memory ownership is not changed. |
121 |
145 */ |
122 return view; |
146 HbView *HsMenuViewBuilder::view() const |
123 } |
147 { |
124 |
148 return qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME)); |
125 /*! |
149 } |
126 \return pointer to list view resulting from last \a build call or NULL if |
150 |
127 the \a build has not yet been called. |
151 /*! |
128 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
152 \return pointer to the list item view. |
129 Memory ownership is not changed. |
153 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
130 */ |
154 Memory ownership is not changed. |
131 HbListView *HsMenuViewBuilder::currentListView() const |
155 */ |
132 { |
156 HbListView *HsMenuViewBuilder::listView() const |
133 const QString LIST_VIEW_NAME = mViewContextToStringMap[mViewContext] |
157 { |
134 + mOperationalContextToStringMap[mOperationalContext] |
|
135 + "ListView"; |
|
136 |
158 return qobject_cast<HbListView *>( |
137 return qobject_cast<HbListView *>( |
159 mDocumentLoader.findWidget(LIST_VIEW_NAME)); |
138 mDocumentLoader.findWidget(LIST_VIEW_NAME)); |
160 } |
139 } |
161 |
140 |
162 /*! |
141 /*! |
163 \return pointer to the label. |
142 \return pointer to the view label resulting from last \a build call. It is |
164 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
143 guaranteed to be not NULL if the \a build was called for the context |
165 Memory ownership is not changed. |
144 related to view including label. |
166 */ |
145 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
167 HbGroupBox *HsMenuViewBuilder::label() const |
146 Memory ownership is not changed. |
168 { |
147 */ |
|
148 HbGroupBox *HsMenuViewBuilder::currentViewLabel() const |
|
149 { |
|
150 const QString LABEL_NAME = mViewContextToStringMap[mViewContext] |
|
151 + "Label"; |
|
152 |
169 return qobject_cast<HbGroupBox *>( |
153 return qobject_cast<HbGroupBox *>( |
170 mDocumentLoader.findWidget(LABEL_NAME)); |
154 mDocumentLoader.findWidget(LABEL_NAME)); |
171 } |
155 } |
172 |
156 |
173 /*! |
157 /*! |
174 \return pointer to the searchPanel. |
158 \return pointer to search panel. |
175 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
159 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
176 Memory ownership is not changed. |
160 Memory ownership is not changed. |
177 */ |
161 */ |
178 HbSearchPanel *HsMenuViewBuilder::searchPanel() const |
162 HbSearchPanel *HsMenuViewBuilder::currentSearchPanel() const |
179 { |
163 { |
180 return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget( |
164 return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget( |
181 SEARCH_PANEL_NAME)); |
165 SEARCH_PANEL_NAME)); |
182 } |
166 } |
183 |
167 |
184 /*! |
168 /*! |
185 \return pointer to All Applications Action. |
169 \return pointer to All Applications Action. Guaranteed to be not NULL. |
186 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
170 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
187 Memory ownership is not changed. |
171 Memory ownership is not changed. |
188 */ |
172 */ |
189 HbAction *HsMenuViewBuilder::allAppsAction() const |
173 HbAction *HsMenuViewBuilder::allAppsAction() const |
190 { |
174 { |
191 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
175 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
192 ALL_APPS_ACTION_NAME)); |
176 ALL_APPS_ACTION_NAME)); |
193 } |
177 } |
194 |
178 |
195 /*! |
179 /*! |
196 \return pointer to All Collections Action. |
180 \return pointer to All Collections Action. Guaranteed to be not NULL. |
197 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
181 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
198 Memory ownership is not changed. |
182 Memory ownership is not changed. |
199 */ |
183 */ |
200 HbAction *HsMenuViewBuilder::allCollectionsAction() const |
184 HbAction *HsMenuViewBuilder::allCollectionsAction() const |
201 { |
185 { |
202 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
186 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
203 ALL_COLLECTIONS_ACTION_NAME)); |
187 ALL_COLLECTIONS_ACTION_NAME)); |
204 } |
188 } |
205 |
189 |
206 /*! |
190 /*! |
207 \return pointer to Search Action. |
191 \return pointer to Search Action. Guaranteed to be not NULL. |
208 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
192 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
209 Memory ownership is not changed. |
193 Memory ownership is not changed. |
210 */ |
194 */ |
211 HbAction *HsMenuViewBuilder::searchAction() const |
195 HbAction *HsMenuViewBuilder::searchAction() const |
212 { |
196 { |
213 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
197 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
214 SEARCH_ACTION_NAME)); |
198 SEARCH_ACTION_NAME)); |
215 } |
199 } |
216 |
200 |
217 /*! |
201 /*! |
218 \return pointer to Ovi Store Action. |
202 \return pointer to Ovi Store Action. Guaranteed to be not NULL. |
219 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
203 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
220 Memory ownership is not changed. |
204 Memory ownership is not changed. |
221 */ |
205 */ |
222 HbAction *HsMenuViewBuilder::oviStoreAction() const |
206 HbAction *HsMenuViewBuilder::oviStoreAction() const |
223 { |
207 { |
224 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
208 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
225 OVI_STORE_ACTION_NAME)); |
209 OVI_STORE_ACTION_NAME)); |
226 } |
210 } |
227 |
211 |
228 /*! |
212 /*! |
|
213 \return pointer to Operator Action. Guaranteed to be not NULL. |
|
214 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
|
215 Memory ownership is not changed. |
|
216 */ |
|
217 HbAction *HsMenuViewBuilder::operatorAction() const |
|
218 { |
|
219 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
|
220 OPERATOR_ACTION_NAME)); |
|
221 } |
|
222 |
|
223 /*! |
229 \return pointer to the main view toolbar. |
224 \return pointer to the main view toolbar. |
230 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
225 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
231 Memory ownership is not changed. |
226 Memory ownership is not changed. |
232 */ |
227 */ |
233 HbToolBar *HsMenuViewBuilder::toolBar() const |
228 HbToolBar *HsMenuViewBuilder::toolBar() const |
234 { |
229 { |
235 return qobject_cast<HbToolBar *>( |
230 return mToolBar; |
236 mDocumentLoader.findWidget(TOOL_BAR_NAME)); |
231 } |
237 } |
232 |
|
233 /*! |
|
234 \return pointer to the toolbar extension. |
|
235 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
|
236 Memory ownership is not changed. |
|
237 */ |
|
238 HbToolBarExtension *HsMenuViewBuilder::toolBarExtension() const |
|
239 { |
|
240 return mToolBarExtension; |
|
241 } |
|
242 |
|
243 /*! |
|
244 \return action group for \a allAppsState and \a allCollectionsState action. |
|
245 */ |
|
246 QActionGroup *HsMenuViewBuilder::toolBarActionGroup() const |
|
247 { |
|
248 return mToolBarActionGroup; |
|
249 } |
|
250 |
|
251 /*! |
|
252 Reads docml configuration corresponding to current context. |
|
253 */ |
|
254 bool HsMenuViewBuilder::build() |
|
255 { |
|
256 return readContextConfiguration(mViewContext, mOperationalContext); |
|
257 } |
|
258 |
|
259 |
238 |
260 |
239 /*! |
261 /*! |
240 Constructor. |
262 Constructor. |
241 Makes object be initialized with with hidden but existing |
263 Makes object be initialized with with hidden but existing |
242 search panel and view label. |
264 search panel and view label. |
243 */ |
265 */ |
244 HsMenuViewBuilder::HsMenuViewBuilder(): |
266 HsMenuViewBuilder::HsMenuViewBuilder(): |
245 mViewOptions(0), |
|
246 DOCUMENT_FILE_NAME(":/xml/applibrary.docml"), |
267 DOCUMENT_FILE_NAME(":/xml/applibrary.docml"), |
|
268 COMMON_SECTION_NAME("commonDefinitions"), |
247 ALL_APPS_ACTION_NAME("allAppsAction"), |
269 ALL_APPS_ACTION_NAME("allAppsAction"), |
248 ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"), |
270 ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"), |
249 SEARCH_ACTION_NAME("searchAction"), |
271 SEARCH_ACTION_NAME("searchAction"), |
250 OVI_STORE_ACTION_NAME("oviStoreAction"), |
272 OVI_STORE_ACTION_NAME("oviStoreAction"), |
251 VIEW_NAME("view"), |
273 OPERATOR_ACTION_NAME("operatorAction"), |
252 CONTAINER_NAME("container"), |
274 SEARCH_PANEL_NAME("searchPanel"), |
253 LIST_VIEW_NAME("listView"), |
|
254 TOOL_BAR_NAME("toolBar"), |
275 TOOL_BAR_NAME("toolBar"), |
255 SEARCH_PANEL_NAME("searchPanel"), |
276 mToolBar(new HbToolBar), |
256 LABEL_NAME("label"), |
277 mToolBarExtension(new HbToolBarExtension), |
257 LIST_VIEW_SECTION_NAME("list_view"), |
278 mViewContext(HsAllAppsContext), |
258 LIST_LABELED_VIEW_SECTION_NAME("list_labeled_view"), |
279 mOperationalContext(HsItemViewContext) |
259 LIST_SEARCH_VIEW_SECTION_NAME("list_search_view"), |
280 { |
260 LIST_SEARCH_LABELED_VIEW_SECTION_NAME("list_search_labeled_view") |
281 init(); |
261 { |
|
262 buildSectionKeyMap(); |
|
263 |
282 |
264 // parse common section and the one specified by view options |
283 // parse common section and the one specified by view options |
265 bool result = parseSection("") && parseSection(mSections[mViewOptions]); |
284 const bool result = parseSection(COMMON_SECTION_NAME); |
266 |
285 |
267 Q_ASSERT_X(result, |
286 Q_ASSERT_X(result, |
268 "HsMenuViewBuilder::HsMenuViewBuilder()", |
287 "HsMenuViewBuilder::HsMenuViewBuilder()", |
269 "construction failed"); |
288 "construction failed"); |
|
289 |
|
290 mToolBar->addAction(allAppsAction()); |
|
291 mToolBar->addAction(allCollectionsAction()); |
|
292 mToolBar->addAction(searchAction()); |
|
293 |
|
294 mToolBarActionGroup = new QActionGroup(allAppsAction()); |
|
295 |
|
296 allAppsAction()->setActionGroup(mToolBarActionGroup); |
|
297 allCollectionsAction()->setActionGroup(mToolBarActionGroup); |
270 } |
298 } |
271 |
299 |
272 /*! |
300 /*! |
273 Destructor. |
301 Destructor. |
274 Deletes list view, search panel, view label, All Applications |
302 Deletes widgets owned by the Menu View Builder. |
275 Action, All Collections Action, Search Action, Ovi Store Action, container |
|
276 widget, main view toolbar and the main view. |
|
277 |
|
278 The destructor needs to be checked agains any change in related docml file. |
|
279 */ |
303 */ |
280 HsMenuViewBuilder::~HsMenuViewBuilder() |
304 HsMenuViewBuilder::~HsMenuViewBuilder() |
281 { |
305 { |
282 QObjectList objectList; |
306 delete mToolBarExtension; |
283 |
307 delete mToolBar; |
284 objectList << listView(); |
308 qDeleteAll(mLoadedObjects); |
285 |
|
286 objectList << searchPanel(); |
|
287 |
|
288 objectList << label(); |
|
289 |
|
290 objectList << allAppsAction(); |
|
291 objectList << allCollectionsAction(); |
|
292 objectList << searchAction(); |
|
293 objectList << mDocumentLoader.findWidget(CONTAINER_NAME); |
|
294 objectList << toolBar(); |
|
295 objectList << view(); |
|
296 |
|
297 foreach(QObject *obj, objectList) { |
|
298 obj->deleteLater(); |
|
299 } |
|
300 } |
309 } |
301 |
310 |
302 /*! |
311 /*! |
303 Parses requested docml file section and reflects its contents in the |
312 Parses requested docml file section and reflects its contents in the |
304 object state. |
313 object state. |