diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-05-29 12:52:44 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-05-29 12:52:44 (GMT) |
commit | 4b00e265388ed09017702489437c79e0b1a19a44 (patch) | |
tree | e9349498caa5d11ee32d3f250f06ab5ffb026eae /tools | |
parent | 7fc1d12ebd103539168be590b1cde91d49a3d75b (diff) | |
download | Qt-4b00e265388ed09017702489437c79e0b1a19a44.zip Qt-4b00e265388ed09017702489437c79e0b1a19a44.tar.gz Qt-4b00e265388ed09017702489437c79e0b1a19a44.tar.bz2 |
Enable overriding of the factory functions of QUiLoader.
Move initialization of QAction/QActionGroups elsewhere.
Detect the root widget by checking its parent against
the parent widget passed in and apply only
the size part of the geometry property to it.
Task-number: 254824
Initial-patch-by: joao <joao@abecasis.name>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/designer/src/lib/uilib/abstractformbuilder.cpp | 7 | ||||
-rw-r--r-- | tools/designer/src/lib/uilib/formbuilder.cpp | 15 | ||||
-rw-r--r-- | tools/designer/src/lib/uilib/formbuilderextra.cpp | 18 | ||||
-rw-r--r-- | tools/designer/src/lib/uilib/formbuilderextra_p.h | 8 |
4 files changed, 28 insertions, 20 deletions
diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 4dae28e..c5aefb1 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -403,6 +403,7 @@ QAction *QAbstractFormBuilder::create(DomAction *ui_action, QObject *parent) if (!a) return 0; + m_actions.insert(ui_action->attributeName(), a); applyProperties(a, ui_action->elementProperty()); return a; } @@ -415,7 +416,7 @@ QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObj QActionGroup *a = createActionGroup(parent, ui_action_group->attributeName()); if (!a) return 0; - + m_actionGroups.insert(ui_action_group->attributeName(), a); applyProperties(a, ui_action_group->elementProperty()); foreach (DomAction *ui_action, ui_action_group->elementAction()) { @@ -1184,8 +1185,6 @@ QAction *QAbstractFormBuilder::createAction(QObject *parent, const QString &name { QAction *action = new QAction(parent); action->setObjectName(name); - m_actions.insert(name, action); - return action; } @@ -1196,8 +1195,6 @@ QActionGroup *QAbstractFormBuilder::createActionGroup(QObject *parent, const QSt { QActionGroup *g = new QActionGroup(parent); g->setObjectName(name); - m_actionGroups.insert(name, g); - return g; } diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index 5a771b7..53d1e9d 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -121,6 +121,8 @@ QFormBuilder::~QFormBuilder() QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget) { QFormBuilderExtra *fb = QFormBuilderExtra::instance(this); + if (!fb->parentWidgetIsSet()) + fb->setParentWidget(parentWidget); fb->setProcessingLayoutWidget(false); if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative() && parentWidget @@ -229,9 +231,6 @@ QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWi if (qobject_cast<QDialog *>(w)) w->setParent(parentWidget); - if (!fb->rootWidget()) - fb->setRootWidget(w); - return w; } @@ -527,6 +526,7 @@ QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const /*! \internal */ + void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { typedef QList<DomProperty*> DomPropertyList; @@ -544,11 +544,12 @@ void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &proper continue; const QString attributeName = (*it)->attributeName(); - if (o == fb->rootWidget() && attributeName == strings.geometryProperty) { - // apply only the size for the rootWidget - fb->rootWidget()->resize(qvariant_cast<QRect>(v).size()); + const bool isWidget = o->isWidgetType(); + if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) { + // apply only the size part of a geometry for the root widget + static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size()); } else if (fb->applyPropertyInternally(o, attributeName, v)) { - } else if (!qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { + } else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) { // ### special-casing for Line (QFrame) -- try to fix me o->setProperty("frameShape", v); // v is of QFrame::Shape enum } else { diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp index cb82967..38fe2ae 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra.cpp +++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp @@ -81,7 +81,8 @@ QFormBuilderExtra::~QFormBuilderExtra() void QFormBuilderExtra::clear() { m_buddies.clear(); - m_rootWidget = 0; + m_parentWidget = 0; + m_parentWidgetIsSet = false; #ifndef QT_FORMBUILDER_NO_SCRIPT m_FormScriptRunner.clearErrors(); m_customWidgetScriptHash.clear(); @@ -136,14 +137,21 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode return false; } -const QPointer<QWidget> &QFormBuilderExtra::rootWidget() const +const QPointer<QWidget> &QFormBuilderExtra::parentWidget() const { - return m_rootWidget; + return m_parentWidget; } -void QFormBuilderExtra::setRootWidget(const QPointer<QWidget> &w) +bool QFormBuilderExtra::parentWidgetIsSet() const { - m_rootWidget = w; + return m_parentWidgetIsSet; +} + +void QFormBuilderExtra::setParentWidget(const QPointer<QWidget> &w) +{ + // Parent widget requires special handling of the geometry property. + m_parentWidget = w; + m_parentWidgetIsSet = true; } #ifndef QT_FORMBUILDER_NO_SCRIPT diff --git a/tools/designer/src/lib/uilib/formbuilderextra_p.h b/tools/designer/src/lib/uilib/formbuilderextra_p.h index f357239..9166c48 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra_p.h +++ b/tools/designer/src/lib/uilib/formbuilderextra_p.h @@ -101,8 +101,9 @@ public: void applyInternalProperties() const; static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label); - const QPointer<QWidget> &rootWidget() const; - void setRootWidget(const QPointer<QWidget> &w); + const QPointer<QWidget> &parentWidget() const; + bool parentWidgetIsSet() const; + void setParentWidget(const QPointer<QWidget> &w); #ifndef QT_FORMBUILDER_NO_SCRIPT QFormScriptRunner &formScriptRunner(); @@ -182,7 +183,8 @@ private: QResourceBuilder *m_resourceBuilder; QTextBuilder *m_textBuilder; - QPointer<QWidget> m_rootWidget; + QPointer<QWidget> m_parentWidget; + bool m_parentWidgetIsSet; }; void uiLibWarning(const QString &message); |