74 #include <hblistviewitem.h> |
74 #include <hblistviewitem.h> |
75 #include <hbdatetimepicker.h> |
75 #include <hbdatetimepicker.h> |
76 #include <hbgridviewitem.h> |
76 #include <hbgridviewitem.h> |
77 #include <hbtreeviewitem.h> |
77 #include <hbtreeviewitem.h> |
78 #include <hbdataformviewitem.h> |
78 #include <hbdataformviewitem.h> |
|
79 #include <hbtumbleview.h> |
|
80 #include <hbtumbleviewitem.h> |
79 |
81 |
80 enum HbDocumentLoaderFactoryWidgetRoles { |
82 enum HbDocumentLoaderFactoryWidgetRoles { |
81 HbWidgetRoleUnknown, // needs to be the first one = 0 |
83 HbWidgetRoleUnknown, // needs to be the first one = 0 |
82 HbWidgetRoleViewWidget, |
84 HbWidgetRoleViewWidget, |
83 HbWidgetRoleViewToolBar, |
85 HbWidgetRoleViewToolBar, |
236 CHECK_OBJECT_0(HbListViewItem) |
238 CHECK_OBJECT_0(HbListViewItem) |
237 CHECK_OBJECT_0(HbDateTimePicker) |
239 CHECK_OBJECT_0(HbDateTimePicker) |
238 CHECK_OBJECT_0(HbGridViewItem) |
240 CHECK_OBJECT_0(HbGridViewItem) |
239 CHECK_OBJECT_0(HbDataFormViewItem) |
241 CHECK_OBJECT_0(HbDataFormViewItem) |
240 CHECK_OBJECT_0(HbTreeViewItem) |
242 CHECK_OBJECT_0(HbTreeViewItem) |
|
243 CHECK_OBJECT_0(HbTumbleView) |
|
244 CHECK_OBJECT_0(HbTumbleViewItem) |
241 #if QT_VERSION >= 0x040600 && defined(HBUTILS_WEBKIT) |
245 #if QT_VERSION >= 0x040600 && defined(HBUTILS_WEBKIT) |
242 CHECK_OBJECT_0(QGraphicsWebView) |
246 CHECK_OBJECT_0(QGraphicsWebView) |
243 #endif |
247 #endif |
244 else { |
248 else { |
245 } |
249 } |
255 If role is not specified, then basic parent-child relationship is created. |
259 If role is not specified, then basic parent-child relationship is created. |
256 |
260 |
257 \param parent parent widget. |
261 \param parent parent widget. |
258 \param child child widget. |
262 \param child child widget. |
259 \param role desired role for child widget. |
263 \param role desired role for child widget. |
|
264 \param roleTransfersOwnership Must be updated to 'true' if owership of the child is |
|
265 moved to the parent, but the graphicsitem parent is not |
260 \return true upon success, false on failure. |
266 \return true upon success, false on failure. |
261 */ |
267 */ |
262 bool HbDocumentLoaderFactory::setWidgetRole( |
268 bool HbDocumentLoaderFactory::setWidgetRole( |
263 QGraphicsWidget *parent, QGraphicsWidget *child, const QString &role) |
269 QGraphicsWidget *parent, |
264 { |
270 QGraphicsWidget *child, |
|
271 const QString &role, |
|
272 bool &roleTransfersOwnership ) |
|
273 { |
|
274 roleTransfersOwnership = false; |
|
275 |
265 if (role.isEmpty()) { |
276 if (role.isEmpty()) { |
266 child->setParentItem(parent); |
277 child->setParentItem(parent); |
267 return true; |
278 return true; |
268 } |
279 } |
269 |
280 |
314 HbView *view = qobject_cast<HbView *>(parent); |
325 HbView *view = qobject_cast<HbView *>(parent); |
315 success = (view != 0); |
326 success = (view != 0); |
316 if (view) { |
327 if (view) { |
317 child->setParentItem(parent); |
328 child->setParentItem(parent); |
318 view->setToolBar(qobject_cast<HbToolBar *>(child)); |
329 view->setToolBar(qobject_cast<HbToolBar *>(child)); |
|
330 roleTransfersOwnership = true; |
319 } |
331 } |
320 } |
332 } |
321 break; |
333 break; |
322 |
334 |
323 case HbWidgetRoleViewMenu: |
335 case HbWidgetRoleViewMenu: |
324 { |
336 { |
325 HbView *view = qobject_cast<HbView *>(parent); |
337 HbView *view = qobject_cast<HbView *>(parent); |
326 success = (view != 0); |
338 success = (view != 0); |
327 if (view) { |
339 if (view) { |
328 view->setMenu(qobject_cast<HbMenu *>(child)); |
340 view->setMenu(qobject_cast<HbMenu *>(child)); |
|
341 roleTransfersOwnership = true; |
329 } |
342 } |
330 } |
343 } |
331 break; |
344 break; |
332 |
345 |
333 case HbWidgetRoleMenuSubmenu: |
346 case HbWidgetRoleMenuSubmenu: |
334 { |
347 { |
335 HbMenu *menu = qobject_cast<HbMenu *>(parent); |
348 HbMenu *menu = qobject_cast<HbMenu *>(parent); |
336 success = (menu != 0); |
349 success = (menu != 0); |
337 if (menu) { |
350 if (menu) { |
338 menu->addMenu(qobject_cast<HbMenu *>(child)); |
351 menu->addMenu(qobject_cast<HbMenu *>(child)); |
|
352 roleTransfersOwnership = true; |
339 } |
353 } |
340 } |
354 } |
341 break; |
355 break; |
342 |
356 |
343 case HbWidgetRoleScrollAreaContents: |
357 case HbWidgetRoleScrollAreaContents: |