46 |
66 |
47 \sa HsMenuView |
67 \sa HsMenuView |
48 */ |
68 */ |
49 |
69 |
50 |
70 |
51 /*! |
71 |
52 Cleanup search text on showing search panel. Ensures vkb host instance |
72 |
53 is appears on show and disappears on hide search panel. |
73 /*! |
54 |
74 \return Pointer to the view resulting from last \a build call or NULL if |
55 \param visible When true search panel is to show up, |
|
56 hide otherwise. |
|
57 */ |
|
58 void HsMenuViewBuilder::searchPanelVisibilityChange(bool visible) |
|
59 { |
|
60 if (visible) { |
|
61 |
|
62 HbLineEdit *const lineEdit(searchPanelLineEdit()); |
|
63 |
|
64 lineEdit->setText(""); |
|
65 lineEdit->setFocus(); |
|
66 lineEdit->setInputMethodHints(Qt::ImhNoPredictiveText | |
|
67 Qt::ImhNoAutoUppercase); |
|
68 } |
|
69 |
|
70 } |
|
71 |
|
72 /*! |
|
73 \return pointer to the view resulting from last \a build call or NULL if |
|
74 the \a build has not yet been called. |
75 the \a build has not yet been called. |
75 Memory ownership is not changed. |
76 Memory ownership is not changed. |
76 */ |
77 */ |
77 HbView *HsMenuViewBuilder::currentView() const |
78 HbView *HsMenuViewBuilder::currentView() |
78 { |
79 { |
79 const QString VIEW_NAME = |
|
80 mViewContextToStringMap[mViewContext] |
|
81 + "View"; |
|
82 |
|
83 HbView *const view = |
80 HbView *const view = |
84 qobject_cast<HbView *>(mDocumentLoader.findWidget(VIEW_NAME)); |
81 qobject_cast<HbView *>(currentLoader()->findWidget(VIEW_NAME)); |
85 |
82 |
86 if (view != NULL && mViewContext != HsInstalledAppsContext) { |
83 if (view != NULL && mStateContext != HsInstalledAppsContext) { |
87 view->setToolBar(mToolBar); |
84 view->setToolBar(mToolBar); |
88 } |
85 } |
89 return view; |
86 return view; |
90 } |
87 } |
91 |
88 |
92 /*! |
89 /*! |
93 \return pointer to list view resulting from last \a build call or NULL if |
90 \return Pointer to list view resulting from last \a build call or NULL if |
94 the \a build has not yet been called. |
91 the \a build has not yet been called. |
95 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
92 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
96 Memory ownership is not changed. |
93 Memory ownership is not changed. |
97 */ |
94 */ |
98 HbListView *HsMenuViewBuilder::currentListView() const |
95 HbListView *HsMenuViewBuilder::currentListView() |
99 { |
96 { |
100 QString LIST_VIEW_NAME = mViewContextToStringMap[mViewContext]; |
97 HbListView *const listView = |
101 if (mOperationalContext == HsSearchContext) { |
98 qobject_cast<HbListView *>( |
102 LIST_VIEW_NAME.append(mOperationalContextToStringMap[mOperationalContext]); |
99 currentLoader()->findWidget(LIST_VIEW_NAME)); |
103 } |
100 |
104 LIST_VIEW_NAME.append("ListView"); |
101 return listView; |
105 |
102 } |
106 return qobject_cast<HbListView *>( |
103 |
107 mDocumentLoader.findWidget(LIST_VIEW_NAME)); |
104 /*! |
108 } |
105 \return Pointer to the view label resulting from last \a build call. It is |
109 |
|
110 /*! |
|
111 \return pointer to the view label resulting from last \a build call. It is |
|
112 guaranteed to be not NULL if the \a build was called for the context |
106 guaranteed to be not NULL if the \a build was called for the context |
113 related to view including label. |
107 related to view including label. |
114 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
108 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
115 Memory ownership is not changed. |
109 Memory ownership is not changed. |
116 */ |
110 */ |
117 HbGroupBox *HsMenuViewBuilder::currentViewLabel() const |
111 HbGroupBox *HsMenuViewBuilder::currentViewLabel() |
118 { |
112 { |
119 const QString LABEL_NAME = mViewContextToStringMap[mViewContext] |
113 HbGroupBox *viewLabel = |
120 + "Label"; |
114 qobject_cast<HbGroupBox *>( |
121 |
115 currentLoader()->findWidget(VIEW_LABEL_NAME)); |
122 return qobject_cast<HbGroupBox *>( |
116 |
123 mDocumentLoader.findWidget(LABEL_NAME)); |
117 return viewLabel; |
124 } |
118 } |
125 |
119 |
126 /*! |
120 /*! |
127 \return pointer to search panel. |
121 \return Pointer to the search panel resulting from last \a build call. It is |
128 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
122 guaranteed to be not NULL if the \a build was called for the context |
129 Memory ownership is not changed. |
123 related to view including label. |
130 */ |
124 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
131 HbSearchPanel *HsMenuViewBuilder::currentSearchPanel() const |
125 Memory ownership is not changed. |
132 { |
126 */ |
133 return qobject_cast<HbSearchPanel *>(mDocumentLoader.findWidget( |
127 HbSearchPanel *HsMenuViewBuilder::currentSearchPanel() |
134 SEARCH_PANEL_NAME)); |
128 { |
135 } |
129 HbSearchPanel *searchPanel = |
136 |
130 qobject_cast<HbSearchPanel *>(currentLoader()->findWidget( |
137 /*! |
131 SEARCH_PANEL_NAME)); |
138 \return pointer to a button |
132 return searchPanel; |
139 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
133 |
140 Memory ownership is not changed. |
134 } |
141 */ |
135 |
142 HbPushButton *HsMenuViewBuilder::collectionButton() const |
136 /*! |
143 { |
137 \return Pointer to the 'Add content' button resulting from last |
144 return qobject_cast<HbPushButton *>(mDocumentLoader.findWidget( |
138 \a build call. It is |
145 BUTTON_NAME)); |
139 guaranteed to be not NULL if the \a build was called for the context |
146 } |
140 related to view including label. |
147 |
141 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
148 /*! |
142 Memory ownership is not changed. |
149 \return pointer to All Applications Action. Guaranteed to be not NULL. |
143 */ |
|
144 HbPushButton *HsMenuViewBuilder::currentAddContentButton() |
|
145 { |
|
146 HbPushButton *pushButton = |
|
147 qobject_cast<HbPushButton *>(currentLoader()->findWidget( |
|
148 ADD_CONTENT_BUTTON_NAME)); |
|
149 return pushButton; |
|
150 } |
|
151 |
|
152 /*! |
|
153 \return Pointer to All Applications Action. Guaranteed to be not NULL. |
150 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
154 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
151 Memory ownership is not changed. |
155 Memory ownership is not changed. |
152 */ |
156 */ |
153 HbAction *HsMenuViewBuilder::allAppsAction() const |
157 HbAction *HsMenuViewBuilder::allAppsAction() const |
154 { |
158 { |
155 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
159 return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject( |
156 ALL_APPS_ACTION_NAME)); |
160 ALL_APPS_ACTION_NAME)); |
157 } |
161 } |
158 |
162 |
159 /*! |
163 /*! |
160 \return pointer to All Collections Action. Guaranteed to be not NULL. |
164 \return Pointer to All Collections Action. Guaranteed to be not NULL. |
161 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
165 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
162 Memory ownership is not changed. |
166 Memory ownership is not changed. |
163 */ |
167 */ |
164 HbAction *HsMenuViewBuilder::allCollectionsAction() const |
168 HbAction *HsMenuViewBuilder::allCollectionsAction() const |
165 { |
169 { |
166 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
170 return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject( |
167 ALL_COLLECTIONS_ACTION_NAME)); |
171 ALL_COLLECTIONS_ACTION_NAME)); |
168 } |
172 } |
169 |
173 |
170 /*! |
174 /*! |
171 \return pointer to Search Action. Guaranteed to be not NULL. |
175 \return Pointer to Search Action. Guaranteed to be not NULL. |
172 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
176 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
173 Memory ownership is not changed. |
177 Memory ownership is not changed. |
174 */ |
178 */ |
175 HbAction *HsMenuViewBuilder::searchAction() const |
179 HbAction *HsMenuViewBuilder::searchAction() const |
176 { |
180 { |
177 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
181 return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject( |
178 SEARCH_ACTION_NAME)); |
182 SEARCH_ACTION_NAME)); |
179 } |
183 } |
180 |
184 |
181 /*! |
185 /*! |
182 \return pointer to Ovi Store Action. Guaranteed to be not NULL. |
186 \return Pointer to Ovi Store Action. Guaranteed to be not NULL. |
183 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
187 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
184 Memory ownership is not changed. |
188 Memory ownership is not changed. |
185 */ |
189 */ |
186 HbAction *HsMenuViewBuilder::oviStoreAction() const |
190 HbAction *HsMenuViewBuilder::oviStoreAction() const |
187 { |
191 { |
188 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
192 return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject( |
189 OVI_STORE_ACTION_NAME)); |
193 OVI_STORE_ACTION_NAME)); |
190 } |
194 } |
191 |
195 |
192 /*! |
196 /*! |
193 \return pointer to Operator Action. Guaranteed to be not NULL. |
197 \return Pointer to Operator Action. Guaranteed to be not NULL. |
194 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
198 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
195 Memory ownership is not changed. |
199 Memory ownership is not changed. |
196 */ |
200 */ |
197 HbAction *HsMenuViewBuilder::operatorAction() const |
201 HbAction *HsMenuViewBuilder::operatorAction() const |
198 { |
202 { |
199 return qobject_cast<HbAction *>(mDocumentLoader.findObject( |
203 return qobject_cast<HbAction *>(mCommonObjectsLoader->findObject( |
200 OPERATOR_ACTION_NAME)); |
204 OPERATOR_ACTION_NAME)); |
201 } |
205 } |
202 |
206 |
203 /*! |
207 /*! |
204 \return pointer to the main view toolbar. |
208 \return Pointer to the main view toolbar. |
205 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
209 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
206 Memory ownership is not changed. |
210 Memory ownership is not changed. |
207 */ |
211 */ |
208 HbToolBar *HsMenuViewBuilder::toolBar() const |
212 HbToolBar *HsMenuViewBuilder::toolBar() const |
209 { |
213 { |
210 return mToolBar; |
214 return mToolBar; |
211 } |
215 } |
212 |
216 |
213 /*! |
217 /*! |
214 \return pointer to the toolbar extension. |
218 \return Pointer to the toolbar extension. |
215 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
219 The pointer is valid until the HsMenuViewBuilder instance is destroyed. |
216 Memory ownership is not changed. |
220 Memory ownership is not changed. |
217 */ |
221 */ |
218 HbToolBarExtension *HsMenuViewBuilder::toolBarExtension() const |
222 HbToolBarExtension *HsMenuViewBuilder::toolBarExtension() const |
219 { |
223 { |
220 return mToolBarExtension; |
224 return mToolBarExtension; |
221 } |
225 } |
222 |
226 |
223 /*! |
227 /*! |
224 \return action group for \a allAppsState and \a allCollectionsState action. |
228 \return Action group for \a allAppsState and \a allCollectionsState action. |
225 */ |
229 */ |
226 QActionGroup *HsMenuViewBuilder::toolBarActionGroup() const |
230 QActionGroup *HsMenuViewBuilder::toolBarActionGroup() const |
227 { |
231 { |
228 return mToolBarActionGroup; |
232 return mToolBarActionGroup; |
229 } |
233 } |
230 |
234 |
231 /*! |
235 /*! |
232 Reads docml configuration corresponding to current context. |
236 Reads docml configuration corresponding to current context. |
233 */ |
237 \return Shared pointer to loader serving current context. |
234 bool HsMenuViewBuilder::build() |
238 */ |
235 { |
239 QSharedPointer<HbDocumentLoader> HsMenuViewBuilder::currentLoader() |
236 return readContextConfiguration(mViewContext, mOperationalContext); |
240 { |
237 } |
241 if (!mLoaderMap.contains(context())) { |
238 |
242 QSharedPointer<HbDocumentLoader> loader = |
239 |
243 readContextConfiguration(); |
240 |
244 mLoaderMap.insert(context(), loader); |
241 /*! |
245 } |
242 Constructor. |
246 |
243 Makes object be initialized with with hidden but existing |
247 return mLoaderMap[context()]; |
244 search panel and view label. |
248 } |
|
249 |
|
250 |
|
251 /*! |
|
252 Loads non-context sensitive objects. |
245 */ |
253 */ |
246 HsMenuViewBuilder::HsMenuViewBuilder(): |
254 HsMenuViewBuilder::HsMenuViewBuilder(): |
247 DOCUMENT_FILE_NAME(":/xml/applibrary.docml"), |
255 DOCUMENT_FILE_NAME(":/xml/applibrary.docml"), |
248 ALL_APPS_ACTION_NAME("allAppsAction"), |
256 ALL_APPS_ACTION_NAME("allAppsAction"), |
249 ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"), |
257 ALL_COLLECTIONS_ACTION_NAME("allCollectionsAction"), |
289 } |
289 } |
290 |
290 |
291 /*! |
291 /*! |
292 Parses requested docml file section and reflects its contents in the |
292 Parses requested docml file section and reflects its contents in the |
293 object state. |
293 object state. |
294 \param sectionName Name of the section to parse. |
294 \param documentName Identifies document to parse. |
295 \retval \a true on success, \a false otherwise. |
295 \return Document loader instance containing parsed |
296 */ |
296 objects for requested \documentName. |
297 bool HsMenuViewBuilder::parseSection(const QString §ionName) |
297 */ |
298 { |
298 QSharedPointer<HbDocumentLoader> HsMenuViewBuilder::parseDocument( |
299 HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseSection"); |
299 const QString &documentBaseName) |
|
300 { |
|
301 HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::parseDocument"); |
300 |
302 |
301 bool loadStatusOk = false; |
303 bool loadStatusOk = false; |
|
304 |
|
305 QSharedPointer<HbDocumentLoader> loader(new HbDocumentLoader()); |
|
306 |
|
307 const QString documentFullName = DOCUMENT_NAME_PREFIX + |
|
308 documentBaseName + |
|
309 DOCUMENT_NAME_EXT; |
302 const QObjectList loadedObjects = |
310 const QObjectList loadedObjects = |
303 mDocumentLoader.load(DOCUMENT_FILE_NAME, |
311 loader->load(documentFullName, &loadStatusOk); |
304 sectionName, |
312 |
305 &loadStatusOk); |
|
306 mLoadedObjects |= loadedObjects.toSet(); |
313 mLoadedObjects |= loadedObjects.toSet(); |
307 |
314 |
308 Q_ASSERT_X(loadStatusOk, |
315 Q_ASSERT_X(loadStatusOk, |
309 DOCUMENT_FILE_NAME.toLatin1().data(), |
316 documentFullName.toLatin1().data(), |
310 "Error while loading docml file."); |
317 "Error while loading docml file."); |
311 |
318 |
312 HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::parseSection"); |
319 HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::parseDocument"); |
313 |
320 |
314 return loadStatusOk; |
321 return loader; |
315 } |
|
316 |
|
317 |
|
318 /*! |
|
319 \return Line edit of the searchPanel on success, NULL otherwise. |
|
320 */ |
|
321 HbLineEdit *HsMenuViewBuilder::searchPanelLineEdit() const |
|
322 { |
|
323 HSMENUTEST_FUNC_ENTRY("HsMenuViewBuilder::searchPanelLineEdit"); |
|
324 |
|
325 HbLineEdit *result(0); |
|
326 |
|
327 foreach(QGraphicsItem *obj, currentSearchPanel()->childItems()) { |
|
328 |
|
329 QGraphicsWidget *const widget = static_cast<QGraphicsWidget *>(obj); |
|
330 |
|
331 if (widget != NULL) { |
|
332 |
|
333 HbLineEdit *const lineEdit = qobject_cast<HbLineEdit *>(widget); |
|
334 |
|
335 if (lineEdit != NULL) { |
|
336 result = lineEdit; |
|
337 break; |
|
338 } |
|
339 } |
|
340 } |
|
341 HSMENUTEST_FUNC_EXIT("HsMenuViewBuilder::searchPanelLineEdit"); |
|
342 |
|
343 return result; |
|
344 } |
|
345 |
|
346 /*! |
|
347 Builds mapping between context and docml name buidling blocks. |
|
348 */ |
|
349 void HsMenuViewBuilder::init() |
|
350 { |
|
351 mViewContextToStringMap[HsAllAppsContext] = "allApps"; |
|
352 mViewContextToStringMap[HsAllCollectionsContext] = "allCollections"; |
|
353 mViewContextToStringMap[HsInstalledAppsContext] = "installedApps"; |
|
354 mViewContextToStringMap[HsCollectionContext] = "collection"; |
|
355 mOperationalContextToStringMap[HsItemViewContext] = ""; |
|
356 mOperationalContextToStringMap[HsSearchContext] = "Search"; |
|
357 mOperationalContextToStringMap[HsButtonContext] = "Button"; |
|
358 mOperationalContextToStringMap[HsEmptyLabelContext] = "EmptyLabel"; |
|
359 |
|
360 } |
322 } |
361 |
323 |
362 /*! |
324 /*! |
363 Sets view context. Not reflected in widgets returned by the builder |
325 Sets view context. Not reflected in widgets returned by the builder |
364 until \a build is not run. |
326 until \a build is not run. |
365 */ |
327 */ |
366 void HsMenuViewBuilder::setViewContext(HsViewContext viewContext) |
328 void HsMenuViewBuilder::setStateContext(HsStateContext stateContext) |
367 { |
329 { |
368 mViewContext = viewContext; |
330 mStateContext = stateContext; |
369 } |
331 } |
370 |
332 |
371 /*! |
333 /*! |
372 Sets operational context. Not reflected in widgets returned by the builder |
334 Sets operational context. Not reflected in widgets returned by the builder |
373 until \a build is not run. |
335 until \a build is not run. |