--- a/src/hbutils/document/hbdocumentloaderactions_p.cpp Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbutils/document/hbdocumentloaderactions_p.cpp Wed Aug 18 10:05:37 2010 +0300
@@ -41,6 +41,11 @@
#include "hbdocumentloader_p.h"
#include <hbwidget_p.h>
#include <hbwidgetbase_p.h>
+#include <hbview.h>
+#include <hbview_p.h>
+#include <hbmenu.h>
+#include <hbtoolbar.h>
+#include <hbaction.h>
class AccessToMetadata : public QObject
@@ -557,7 +562,11 @@
delete anchor;
return false;
} else {
- anchor->setPreferredLength( prefVal );
+ // if the expression resulted a negative result, we must reverse the direction
+ if ( prefLength.mType == HbXmlLengthValue::Expression && prefVal < 0 && dir ) {
+ *dir = (*dir==HbAnchor::Positive) ? HbAnchor::Negative : HbAnchor::Positive;
+ }
+ anchor->setPreferredLength( qAbs(prefVal) );
}
}
@@ -1298,3 +1307,78 @@
}
+bool HbDocumentLoaderActions::setObjectTree( QList<QObject *> roots )
+{
+ reset();
+ addToObjectMap( roots );
+ return true;
+}
+
+void HbDocumentLoaderActions::addToObjectMap( QList<QObject *> objects )
+{
+ for ( int i = 0; i < objects.size(); i++ ) {
+ QObject *obj = objects.at(i);
+ QGraphicsWidget *widget = qobject_cast<QGraphicsWidget*>(obj);
+
+ ObjectMapItem item;
+ item.mObject = obj;
+ item.mType = widget ? HbXml::WIDGET : HbXml::OBJECT;
+ item.mOwned = false;
+ mObjectMap.insert( obj->objectName(), item );
+
+ if ( widget ) {
+ widgetAddedToMap( widget );
+ addToObjectMap( widget->childItems() );
+ } else {
+ addToObjectMap( obj->children() );
+ }
+ }
+}
+
+void HbDocumentLoaderActions::addToObjectMap( QList<QGraphicsItem *> objects )
+{
+ for ( int i = 0; i < objects.size(); i++ ) {
+ if ( objects.at(i)->isWidget() ) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>( objects.at(i) );
+ ObjectMapItem item;
+ item.mObject = widget;
+ item.mType = HbXml::WIDGET;
+ item.mOwned = false;
+ mObjectMap.insert( widget->objectName(), item );
+ addToObjectMap( widget->childItems() );
+ }
+ }
+}
+
+void HbDocumentLoaderActions::widgetAddedToMap(QGraphicsWidget *widget)
+{
+ // check the menu/toolbar from view
+ if ( widget->type() == Hb::ItemType_View ) {
+ HbView *view = qobject_cast<HbView*>(widget);
+ HbViewPrivate *viewPrivate = HbViewPrivate::d_ptr( view );
+ if ( viewPrivate->menu ) {
+ QList<QObject *> newObjects;
+ newObjects << viewPrivate->menu.data();
+ addToObjectMap( newObjects );
+ }
+ if ( viewPrivate->toolBar ) {
+ QList<QObject *> newObjects;
+ newObjects << viewPrivate->toolBar.data();
+ addToObjectMap( newObjects );
+ }
+ // check submenu
+ } else if ( widget->type() == Hb::ItemType_Menu ) {
+ QList<QAction *> actions = widget->actions();
+ for ( int i = 0; i < actions.count(); i++ ) {
+ HbAction *action = qobject_cast<HbAction *>( actions.at(i) );
+ if ( action && action->menu() ) {
+ QList<QObject *> newObjects;
+ newObjects << action->menu();
+ addToObjectMap( newObjects );
+ }
+ }
+ }
+}
+
+
+