39 #include <hbdocumentloader.h> |
39 #include <hbdocumentloader.h> |
40 |
40 |
41 #include "hbdocumentloader_p.h" |
41 #include "hbdocumentloader_p.h" |
42 #include <hbwidget_p.h> |
42 #include <hbwidget_p.h> |
43 #include <hbwidgetbase_p.h> |
43 #include <hbwidgetbase_p.h> |
44 |
44 #include <hbview.h> |
|
45 #include <hbview_p.h> |
|
46 #include <hbmenu.h> |
|
47 #include <hbtoolbar.h> |
|
48 #include <hbaction.h> |
|
49 #include <hbframeitem.h> |
|
50 #include <hbinstance.h> |
45 |
51 |
46 class AccessToMetadata : public QObject |
52 class AccessToMetadata : public QObject |
47 { |
53 { |
48 public: |
54 public: |
49 int getEnumValue( const char *enumeration, const char *str ) |
55 int getEnumValue( const char *enumeration, const char *str ) |
62 |
68 |
63 HbDocumentLoaderActions::HbDocumentLoaderActions( HbDocumentLoaderPrivate *ref, const HbMainWindow *window ) : |
69 HbDocumentLoaderActions::HbDocumentLoaderActions( HbDocumentLoaderPrivate *ref, const HbMainWindow *window ) : |
64 HbXmlLoaderBaseActions(), |
70 HbXmlLoaderBaseActions(), |
65 d( ref ) |
71 d( ref ) |
66 { |
72 { |
67 if ( window ) { |
73 if (window) { |
68 mCurrentProfile = HbDeviceProfile::profile(window); |
74 mMainWindow = window; |
69 } else { |
75 } else { |
70 mCurrentProfile = HbDeviceProfile::current(); |
76 qWarning() << "HbDocumentLoaderActions: Using default main window"; |
|
77 QList<HbMainWindow*> mainWindows = hbInstance->allMainWindows(); |
|
78 if (mainWindows.isEmpty()) { |
|
79 qWarning() << "HbDocumentLoaderActions: Default main window not found"; |
|
80 } else { |
|
81 mMainWindow = mainWindows.at(0); |
|
82 } |
71 } |
83 } |
72 } |
84 } |
73 |
85 |
74 HbDocumentLoaderActions::~HbDocumentLoaderActions() |
86 HbDocumentLoaderActions::~HbDocumentLoaderActions() |
75 { |
87 { |
307 } |
319 } |
308 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
320 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
309 |
321 |
310 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
322 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
311 bool ok = true; |
323 bool ok = true; |
312 if (left.mType != HbXmlLengthValue::None) { |
324 if (left.mValues.count()) { |
313 ok &= toPixels(left, leftVal); |
325 ok &= toPixels(left, leftVal); |
314 } |
326 } |
315 if (top.mType != HbXmlLengthValue::None) { |
327 if (top.mValues.count()) { |
316 ok &= toPixels(top, topVal); |
328 ok &= toPixels(top, topVal); |
317 } |
329 } |
318 if (right.mType != HbXmlLengthValue::None) { |
330 if (right.mValues.count()) { |
319 ok &= toPixels(right, rightVal); |
331 ok &= toPixels(right, rightVal); |
320 } |
332 } |
321 if (bottom.mType != HbXmlLengthValue::None) { |
333 if (bottom.mValues.count()) { |
322 ok &= toPixels(bottom, bottomVal); |
334 ok &= toPixels(bottom, bottomVal); |
323 } |
335 } |
324 if ( ok ) { |
336 if ( ok ) { |
325 widget->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
337 widget->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
326 } |
338 } |
339 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
351 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(obj); |
340 |
352 |
341 qreal hintWidthVal, hintHeightVal; |
353 qreal hintWidthVal, hintHeightVal; |
342 |
354 |
343 bool ok = true; |
355 bool ok = true; |
344 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
356 if ( hintWidth.mValues.count() ) { |
345 ok &= toPixels(hintWidth, hintWidthVal); |
357 ok &= toPixels(hintWidth, hintWidthVal); |
346 } |
358 } |
347 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
359 if ( hintHeight.mValues.count() ) { |
348 ok &= toPixels(hintHeight, hintHeightVal); |
360 ok &= toPixels(hintHeight, hintHeightVal); |
349 } |
361 } |
350 if (!ok) { |
362 if (!ok) { |
351 return false; |
363 return false; |
352 } |
364 } |
353 |
365 |
354 // TODO: Use set <Min/Pref/Max> Size if both declared. It's more efficient. |
366 // TODO: Use set <Min/Pref/Max> Size if both declared. It's more efficient. |
355 switch (hint) { |
367 switch (hint) { |
356 case Qt::MinimumSize: |
368 case Qt::MinimumSize: |
357 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
369 if ( hintWidth.mValues.count() ) { |
358 |
370 |
359 widget->setMinimumWidth(hintWidthVal); |
371 widget->setMinimumWidth(hintWidthVal); |
360 } |
372 } |
361 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
373 if ( hintHeight.mValues.count() ) { |
362 widget->setMinimumHeight(hintHeightVal); |
374 widget->setMinimumHeight(hintHeightVal); |
363 } |
375 } |
364 break; |
376 break; |
365 |
377 |
366 case Qt::PreferredSize: |
378 case Qt::PreferredSize: |
367 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
379 if ( hintWidth.mValues.count() ) { |
368 widget->setPreferredWidth(hintWidthVal); |
380 widget->setPreferredWidth(hintWidthVal); |
369 } |
381 } |
370 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
382 if ( hintHeight.mValues.count() ) { |
371 widget->setPreferredHeight(hintHeightVal); |
383 widget->setPreferredHeight(hintHeightVal); |
372 } |
384 } |
373 break; |
385 break; |
374 |
386 |
375 case Qt::MaximumSize: |
387 case Qt::MaximumSize: |
376 if ( hintWidth.mType != HbXmlLengthValue::None ) { |
388 if ( hintWidth.mValues.count() ) { |
377 widget->setMaximumWidth(hintWidthVal); |
389 widget->setMaximumWidth(hintWidthVal); |
378 } |
390 } |
379 if ( hintHeight.mType != HbXmlLengthValue::None ) { |
391 if ( hintHeight.mValues.count() ) { |
380 widget->setMaximumHeight(hintHeightVal); |
392 widget->setMaximumHeight(hintHeightVal); |
381 } |
393 } |
382 break; |
394 break; |
383 |
395 |
384 default: |
396 default: |
385 break; |
397 break; |
386 } |
398 } |
387 |
399 |
388 if (fixed) { |
400 if (fixed) { |
389 QSizePolicy policy = widget->sizePolicy(); |
401 QSizePolicy policy = widget->sizePolicy(); |
390 if ( hintWidth.mType != HbXmlLengthValue::None && hintWidthVal >= 0) { |
402 if ( hintWidth.mValues.count() && hintWidthVal >= 0) { |
391 policy.setHorizontalPolicy(QSizePolicy::Fixed); |
403 policy.setHorizontalPolicy(QSizePolicy::Fixed); |
392 } |
404 } |
393 if ( hintHeight.mType != HbXmlLengthValue::None && hintHeightVal >= 0) { |
405 if ( hintHeight.mValues.count() && hintHeightVal >= 0) { |
394 policy.setVerticalPolicy(QSizePolicy::Fixed); |
406 policy.setVerticalPolicy(QSizePolicy::Fixed); |
395 } |
407 } |
396 widget->setSizePolicy(policy); |
408 widget->setSizePolicy(policy); |
397 } |
409 } |
398 |
410 |
413 bool result = variableToQVariant( tooltip, variant ); |
425 bool result = variableToQVariant( tooltip, variant ); |
414 if ( result ) { |
426 if ( result ) { |
415 widget->setToolTip( variant.toString() ); |
427 widget->setToolTip( variant.toString() ); |
416 } |
428 } |
417 return result; |
429 return result; |
|
430 } |
|
431 |
|
432 bool HbDocumentLoaderActions::setBackground( const QString &name, HbFrameDrawer::FrameType type ) |
|
433 { |
|
434 HbWidget *widget = qobject_cast<HbWidget*>(findFromStack()); |
|
435 if (!widget) { |
|
436 HB_DOCUMENTLOADER_PRINT( QString( "Cannot set background for non-HbWidget" ) ); |
|
437 return false; |
|
438 } |
|
439 HbFrameItem *frame = new HbFrameItem(name, type, widget); |
|
440 widget->setBackgroundItem(frame); |
|
441 |
|
442 return true; |
418 } |
443 } |
419 |
444 |
420 bool HbDocumentLoaderActions::setSizePolicy( |
445 bool HbDocumentLoaderActions::setSizePolicy( |
421 QSizePolicy::Policy *horizontalPolicy, |
446 QSizePolicy::Policy *horizontalPolicy, |
422 QSizePolicy::Policy *verticalPolicy, |
447 QSizePolicy::Policy *verticalPolicy, |
539 anchor = new HbAnchor( srcId, srcEdge, item2, dstEdge ); |
564 anchor = new HbAnchor( srcId, srcEdge, item2, dstEdge ); |
540 } else { |
565 } else { |
541 anchor = new HbAnchor( srcId, srcEdge, dstId, dstEdge ); |
566 anchor = new HbAnchor( srcId, srcEdge, dstId, dstEdge ); |
542 } |
567 } |
543 |
568 |
544 if ( minLength.mType != HbXmlLengthValue::None ) { |
569 if ( minLength.mValues.count() ) { |
545 qreal minVal(0); |
570 qreal minVal(0); |
546 if ( !toPixels(minLength, minVal) ) { |
571 if ( !toPixels(minLength, minVal) ) { |
547 delete anchor; |
572 delete anchor; |
548 return false; |
573 return false; |
549 } else { |
574 } else { |
550 anchor->setMinimumLength( minVal ); |
575 anchor->setMinimumLength( minVal ); |
551 } |
576 } |
552 } |
577 } |
553 |
578 |
554 if ( prefLength.mType != HbXmlLengthValue::None ) { |
579 if ( prefLength.mValues.count() ) { |
555 qreal prefVal(0); |
580 qreal prefVal(0); |
556 if ( !toPixels(prefLength, prefVal) ) { |
581 if ( !toPixels(prefLength, prefVal) ) { |
557 delete anchor; |
582 delete anchor; |
558 return false; |
583 return false; |
559 } else { |
584 } else { |
560 anchor->setPreferredLength( prefVal ); |
585 // if the expression resulted a negative result, we must reverse the direction |
561 } |
586 if ( prefVal < 0 && dir ) { |
562 } |
587 *dir = (*dir==HbAnchor::Positive) ? HbAnchor::Negative : HbAnchor::Positive; |
563 |
588 } |
564 if ( maxLength.mType != HbXmlLengthValue::None ) { |
589 anchor->setPreferredLength( qAbs(prefVal) ); |
|
590 } |
|
591 } |
|
592 |
|
593 if ( maxLength.mValues.count() ) { |
565 qreal maxVal(0); |
594 qreal maxVal(0); |
566 if ( !toPixels(maxLength, maxVal) ) { |
595 if ( !toPixels(maxLength, maxVal) ) { |
567 delete anchor; |
596 delete anchor; |
568 return false; |
597 return false; |
569 } else { |
598 } else { |
760 if( !layout ) { |
789 if( !layout ) { |
761 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
790 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
762 return false; |
791 return false; |
763 } |
792 } |
764 |
793 |
765 if ( minHeight.mType != HbXmlLengthValue::None ) { |
794 if ( minHeight.mValues.count() ) { |
766 qreal minHeightVal; |
795 qreal minHeightVal; |
767 if ( !toPixels(minHeight, minHeightVal) ) { |
796 if ( !toPixels(minHeight, minHeightVal) ) { |
768 return false; |
797 return false; |
769 } |
798 } |
770 layout->setRowMinimumHeight( row, minHeightVal ); |
799 layout->setRowMinimumHeight( row, minHeightVal ); |
771 } |
800 } |
772 |
801 |
773 if ( maxHeight.mType != HbXmlLengthValue::None ) { |
802 if ( maxHeight.mValues.count() ) { |
774 qreal maxHeightVal; |
803 qreal maxHeightVal; |
775 if ( !toPixels(maxHeight, maxHeightVal) ) { |
804 if ( !toPixels(maxHeight, maxHeightVal) ) { |
776 return false; |
805 return false; |
777 } |
806 } |
778 layout->setRowMaximumHeight( row, maxHeightVal ); |
807 layout->setRowMaximumHeight( row, maxHeightVal ); |
779 } |
808 } |
780 |
809 |
781 if ( prefHeight.mType != HbXmlLengthValue::None ) { |
810 if ( prefHeight.mValues.count() ) { |
782 qreal prefHeightVal; |
811 qreal prefHeightVal; |
783 if ( !toPixels(prefHeight, prefHeightVal) ) { |
812 if ( !toPixels(prefHeight, prefHeightVal) ) { |
784 return false; |
813 return false; |
785 } |
814 } |
786 layout->setRowPreferredHeight( row, prefHeightVal ); |
815 layout->setRowPreferredHeight( row, prefHeightVal ); |
787 } |
816 } |
788 |
817 |
789 if ( fixedHeight.mType != HbXmlLengthValue::None ) { |
818 if ( fixedHeight.mValues.count() ) { |
790 qreal fixedHeightVal; |
819 qreal fixedHeightVal; |
791 if ( !toPixels(fixedHeight, fixedHeightVal) ) { |
820 if ( !toPixels(fixedHeight, fixedHeightVal) ) { |
792 return false; |
821 return false; |
793 } |
822 } |
794 layout->setRowFixedHeight( row, fixedHeightVal ); |
823 layout->setRowFixedHeight( row, fixedHeightVal ); |
795 } |
824 } |
796 |
825 |
797 if ( rowSpacing.mType != HbXmlLengthValue::None ) { |
826 if ( rowSpacing.mValues.count() ) { |
798 qreal rowSpacingVal; |
827 qreal rowSpacingVal; |
799 if ( !toPixels(rowSpacing, rowSpacingVal) ) { |
828 if ( !toPixels(rowSpacing, rowSpacingVal) ) { |
800 return false; |
829 return false; |
801 } |
830 } |
802 layout->setRowSpacing( row, rowSpacingVal ); |
831 layout->setRowSpacing( row, rowSpacingVal ); |
818 if( !layout ) { |
847 if( !layout ) { |
819 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
848 HB_DOCUMENTLOADER_PRINT( QString( "GRIDLAYOUT: INTERNAL ERROR " ) ); |
820 return false; |
849 return false; |
821 } |
850 } |
822 |
851 |
823 if ( minWidth.mType != HbXmlLengthValue::None ) { |
852 if ( minWidth.mValues.count() ) { |
824 qreal minWidthVal; |
853 qreal minWidthVal; |
825 if ( !toPixels(minWidth, minWidthVal) ) { |
854 if ( !toPixels(minWidth, minWidthVal) ) { |
826 return false; |
855 return false; |
827 } |
856 } |
828 layout->setColumnMinimumWidth( column, minWidthVal ); |
857 layout->setColumnMinimumWidth( column, minWidthVal ); |
829 } |
858 } |
830 |
859 |
831 if ( maxWidth.mType != HbXmlLengthValue::None ) { |
860 if ( maxWidth.mValues.count() ) { |
832 qreal maxWidthVal; |
861 qreal maxWidthVal; |
833 if ( !toPixels(maxWidth, maxWidthVal) ) { |
862 if ( !toPixels(maxWidth, maxWidthVal) ) { |
834 return false; |
863 return false; |
835 } |
864 } |
836 layout->setColumnMaximumWidth( column, maxWidthVal ); |
865 layout->setColumnMaximumWidth( column, maxWidthVal ); |
837 } |
866 } |
838 |
867 |
839 if ( prefWidth.mType != HbXmlLengthValue::None ) { |
868 if ( prefWidth.mValues.count() ) { |
840 qreal prefWidthVal; |
869 qreal prefWidthVal; |
841 if ( !toPixels(prefWidth, prefWidthVal) ) { |
870 if ( !toPixels(prefWidth, prefWidthVal) ) { |
842 return false; |
871 return false; |
843 } |
872 } |
844 layout->setColumnPreferredWidth( column, prefWidthVal ); |
873 layout->setColumnPreferredWidth( column, prefWidthVal ); |
845 } |
874 } |
846 |
875 |
847 if ( fixedWidth.mType != HbXmlLengthValue::None ) { |
876 if ( fixedWidth.mValues.count() ) { |
848 qreal fixedWidthVal; |
877 qreal fixedWidthVal; |
849 if ( !toPixels(fixedWidth, fixedWidthVal) ) { |
878 if ( !toPixels(fixedWidth, fixedWidthVal) ) { |
850 return false; |
879 return false; |
851 } |
880 } |
852 layout->setColumnFixedWidth( column, fixedWidthVal ); |
881 layout->setColumnFixedWidth( column, fixedWidthVal ); |
853 } |
882 } |
854 |
883 |
855 if ( columnSpacing.mType != HbXmlLengthValue::None ) { |
884 if ( columnSpacing.mValues.count() ) { |
856 qreal columnSpacingVal; |
885 qreal columnSpacingVal; |
857 if ( !toPixels(columnSpacing, columnSpacingVal) ) { |
886 if ( !toPixels(columnSpacing, columnSpacingVal) ) { |
858 return false; |
887 return false; |
859 } |
888 } |
860 layout->setColumnSpacing( column, columnSpacingVal ); |
889 layout->setColumnSpacing( column, columnSpacingVal ); |
1005 return false; |
1034 return false; |
1006 } |
1035 } |
1007 |
1036 |
1008 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
1037 qreal leftVal=0, topVal=0, rightVal=0, bottomVal=0; |
1009 bool ok = true; |
1038 bool ok = true; |
1010 if (left.mType != HbXmlLengthValue::None) { |
1039 if (left.mValues.count()) { |
1011 ok &= toPixels(left, leftVal); |
1040 ok &= toPixels(left, leftVal); |
1012 } |
1041 } |
1013 if (top.mType != HbXmlLengthValue::None) { |
1042 if (top.mValues.count()) { |
1014 ok &= toPixels(top, topVal); |
1043 ok &= toPixels(top, topVal); |
1015 } |
1044 } |
1016 if (right.mType != HbXmlLengthValue::None) { |
1045 if (right.mValues.count()) { |
1017 ok &= toPixels(right, rightVal); |
1046 ok &= toPixels(right, rightVal); |
1018 } |
1047 } |
1019 if (bottom.mType != HbXmlLengthValue::None) { |
1048 if (bottom.mValues.count()) { |
1020 ok &= toPixels(bottom, bottomVal); |
1049 ok &= toPixels(bottom, bottomVal); |
1021 } |
1050 } |
1022 if ( ok ) { |
1051 if ( ok ) { |
1023 mCurrentLayout->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
1052 mCurrentLayout->setContentsMargins( leftVal, topVal, rightVal, bottomVal ); |
1024 } |
1053 } |
1189 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1218 HbXmlLengthValue* widthVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1190 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(2); |
1219 HbXmlLengthValue* heightVal = (HbXmlLengthValue*)variable.mParameters.at(2); |
1191 |
1220 |
1192 HbIcon icon(*iconName); |
1221 HbIcon icon(*iconName); |
1193 qreal width, height; |
1222 qreal width, height; |
1194 if ( widthVal->mType != HbXmlLengthValue::None ) { |
1223 if ( widthVal->mValues.count() ) { |
1195 result = toPixels(*widthVal, width); |
1224 result = toPixels(*widthVal, width); |
1196 } |
1225 } |
1197 if ( result && heightVal->mType != HbXmlLengthValue::None ) { |
1226 if ( result && heightVal->mValues.count() ) { |
1198 result = toPixels(*heightVal, height); |
1227 result = toPixels(*heightVal, height); |
1199 } |
1228 } |
1200 if ( result ) { |
1229 if ( result ) { |
1201 if ( widthVal->mType != HbXmlLengthValue::None && |
1230 if ( widthVal->mValues.count() && |
1202 heightVal->mType != HbXmlLengthValue::None ) { |
1231 heightVal->mValues.count() ) { |
1203 icon.setSize(QSizeF(width, height)); |
1232 icon.setSize(QSizeF(width, height)); |
1204 } else if ( widthVal->mType != HbXmlLengthValue::None ) { |
1233 } else if ( widthVal->mValues.count() ) { |
1205 icon.setWidth(width); |
1234 icon.setWidth(width); |
1206 } else if ( heightVal->mType != HbXmlLengthValue::None ) { |
1235 } else if ( heightVal->mValues.count() ) { |
1207 icon.setHeight(height); |
1236 icon.setHeight(height); |
1208 } |
1237 } |
1209 variant.setValue( icon ); |
1238 variant.setValue( icon ); |
1210 } |
1239 } |
1211 break; |
1240 break; |
1272 case HbXmlVariable::FONTSPEC: |
1301 case HbXmlVariable::FONTSPEC: |
1273 { |
1302 { |
1274 quint8* role_b = (quint8*)variable.mParameters.at(0); |
1303 quint8* role_b = (quint8*)variable.mParameters.at(0); |
1275 HbXmlLengthValue* textHeightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1304 HbXmlLengthValue* textHeightVal = (HbXmlLengthValue*)variable.mParameters.at(1); |
1276 qreal textHeight; |
1305 qreal textHeight; |
1277 if ( textHeightVal->mType != HbXmlLengthValue::None ) { |
1306 if ( textHeightVal->mValues.count() ) { |
1278 result = toPixels(*textHeightVal, textHeight); |
1307 result = toPixels(*textHeightVal, textHeight); |
1279 } |
1308 } |
1280 if (result) { |
1309 if (result) { |
1281 HbFontSpec fontSpec((HbFontSpec::Role)(*role_b)); |
1310 HbFontSpec fontSpec((HbFontSpec::Role)(*role_b)); |
1282 if ( textHeightVal->mType != HbXmlLengthValue::None ) { |
1311 if ( textHeightVal->mValues.count() ) { |
1283 fontSpec.setTextHeight(textHeight); |
1312 fontSpec.setTextHeight(textHeight); |
1284 } |
1313 } |
1285 variant.setValue(fontSpec); |
1314 variant.setValue(fontSpec); |
1286 } |
1315 } |
1287 break; |
1316 break; |
1296 |
1325 |
1297 return result; |
1326 return result; |
1298 } |
1327 } |
1299 |
1328 |
1300 |
1329 |
|
1330 bool HbDocumentLoaderActions::setObjectTree( QList<QObject *> roots ) |
|
1331 { |
|
1332 reset(); |
|
1333 addToObjectMap( roots ); |
|
1334 return true; |
|
1335 } |
|
1336 |
|
1337 void HbDocumentLoaderActions::addToObjectMap( QList<QObject *> objects ) |
|
1338 { |
|
1339 for ( int i = 0; i < objects.size(); i++ ) { |
|
1340 QObject *obj = objects.at(i); |
|
1341 QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(obj); |
|
1342 |
|
1343 ObjectMapItem item; |
|
1344 item.mObject = obj; |
|
1345 item.mType = widget ? HbXml::WIDGET : HbXml::OBJECT; |
|
1346 item.mOwned = false; |
|
1347 mObjectMap.insert( obj->objectName(), item ); |
|
1348 |
|
1349 if ( widget ) { |
|
1350 widgetAddedToMap( widget ); |
|
1351 addToObjectMap( widget->childItems() ); |
|
1352 } else { |
|
1353 addToObjectMap( obj->children() ); |
|
1354 } |
|
1355 } |
|
1356 } |
|
1357 |
|
1358 void HbDocumentLoaderActions::addToObjectMap( QList<QGraphicsItem *> objects ) |
|
1359 { |
|
1360 for ( int i = 0; i < objects.size(); i++ ) { |
|
1361 if ( objects.at(i)->isWidget() ) { |
|
1362 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>( objects.at(i) ); |
|
1363 ObjectMapItem item; |
|
1364 item.mObject = widget; |
|
1365 item.mType = HbXml::WIDGET; |
|
1366 item.mOwned = false; |
|
1367 mObjectMap.insert( widget->objectName(), item ); |
|
1368 addToObjectMap( widget->childItems() ); |
|
1369 } |
|
1370 } |
|
1371 } |
|
1372 |
|
1373 void HbDocumentLoaderActions::widgetAddedToMap(QGraphicsWidget *widget) |
|
1374 { |
|
1375 // check the menu/toolbar from view |
|
1376 if ( widget->type() == Hb::ItemType_View ) { |
|
1377 HbView *view = qobject_cast<HbView*>(widget); |
|
1378 HbViewPrivate *viewPrivate = HbViewPrivate::d_ptr( view ); |
|
1379 if ( viewPrivate->menu ) { |
|
1380 QList<QObject *> newObjects; |
|
1381 newObjects << viewPrivate->menu.data(); |
|
1382 addToObjectMap( newObjects ); |
|
1383 } |
|
1384 if ( viewPrivate->toolBar ) { |
|
1385 QList<QObject *> newObjects; |
|
1386 newObjects << viewPrivate->toolBar.data(); |
|
1387 addToObjectMap( newObjects ); |
|
1388 } |
|
1389 // check submenu |
|
1390 } else if ( widget->type() == Hb::ItemType_Menu ) { |
|
1391 QList<QAction *> actions = widget->actions(); |
|
1392 for ( int i = 0; i < actions.count(); i++ ) { |
|
1393 HbAction *action = qobject_cast<HbAction *>( actions.at(i) ); |
|
1394 if ( action && action->menu() ) { |
|
1395 QList<QObject *> newObjects; |
|
1396 newObjects << action->menu(); |
|
1397 addToObjectMap( newObjects ); |
|
1398 } |
|
1399 } |
|
1400 } |
|
1401 } |
|
1402 |
|
1403 |
|
1404 |