diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-11-10 12:52:03 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-11-10 13:02:11 (GMT) |
commit | d1c5585faa066a6693c24600cf8a1c42a285fe3b (patch) | |
tree | 089ec414e6181c12d44d0f417ec33ee5541e8018 /tools/designer/src/lib/uilib/formbuilderextra.cpp | |
parent | 5067c64c2356196f2086a97304f1a99309c09d69 (diff) | |
download | Qt-d1c5585faa066a6693c24600cf8a1c42a285fe3b.zip Qt-d1c5585faa066a6693c24600cf8a1c42a285fe3b.tar.gz Qt-d1c5585faa066a6693c24600cf8a1c42a285fe3b.tar.bz2 |
uic/Designer: Use correct margin defaults for custom page-based containers.
Designer-formbuilder/uic incorrectly considered custom containers that
do not inherit a known page-based container (say QTabWidget) as
instances of QLayoutWidget, giving them a default margin of 0.
Add a check for the custom widget <container>-element to the checks
for QLayoutWidget in uic/formbuilder.
In the formbuilder, introduce a new data structure to store
custom widget information instead of using 3 separate hashes.
Adapt one autotest baseline (Qt 3).
Reviewed-by: Jarek Kobus <jkobus@trolltech.com>
Task-number: QTBUG-5335
Diffstat (limited to 'tools/designer/src/lib/uilib/formbuilderextra.cpp')
-rw-r--r-- | tools/designer/src/lib/uilib/formbuilderextra.cpp | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp index 0e803fb..ce71d59 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra.cpp +++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp @@ -65,6 +65,23 @@ void uiLibWarning(const QString &message) { qWarning("Designer: %s", qPrintable(message)); } + +QFormBuilderExtra::CustomWidgetData::CustomWidgetData() : + isContainer(false) +{ +} + +QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw) : + addPageMethod(dcw->elementAddPageMethod()), + baseClass(dcw->elementExtends()), + isContainer(dcw->hasElementContainer() && dcw->elementContainer() != 0) +{ +#ifndef QT_FORMBUILDER_NO_SCRIPT + if (const DomScript *domScript = dcw->elementScript()) + script = domScript->text(); +#endif +} + QFormBuilderExtra::QFormBuilderExtra() : m_layoutWidget(false), m_resourceBuilder(0), @@ -85,8 +102,8 @@ void QFormBuilderExtra::clear() m_parentWidgetIsSet = false; #ifndef QT_FORMBUILDER_NO_SCRIPT m_FormScriptRunner.clearErrors(); - m_customWidgetScriptHash.clear(); #endif + m_customWidgetDataHash.clear(); m_buttonGroups.clear(); } @@ -160,45 +177,44 @@ QFormScriptRunner &QFormBuilderExtra::formScriptRunner() return m_FormScriptRunner; } -void QFormBuilderExtra::storeCustomWidgetScript(const QString &className, const QString &script) -{ - m_customWidgetScriptHash.insert(className, script); -} - QString QFormBuilderExtra::customWidgetScript(const QString &className) const { - const CustomWidgetScriptHash::const_iterator it = m_customWidgetScriptHash.constFind(className); - if ( it == m_customWidgetScriptHash.constEnd()) - return QString(); - return it.value(); + const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + if (it != m_customWidgetDataHash.constEnd()) + return it.value().script; + return QString(); } #endif -void QFormBuilderExtra::storeCustomWidgetBaseClass(const QString &className, const QString &baseClassName) +void QFormBuilderExtra::storeCustomWidgetData(const QString &className, const DomCustomWidget *d) { - m_customWidgetBaseClassHash.insert(className, baseClassName); + if (d) + m_customWidgetDataHash.insert(className, CustomWidgetData(d)); } QString QFormBuilderExtra::customWidgetBaseClass(const QString &className) const { - const QHash<QString, QString>::const_iterator it = m_customWidgetBaseClassHash.constFind(className); - if (it == m_customWidgetBaseClassHash.constEnd()) - return QString(); - return it.value(); + const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + if (it != m_customWidgetDataHash.constEnd()) + return it.value().baseClass; + return QString(); } -void QFormBuilderExtra::storeCustomWidgetAddPageMethod(const QString &className, const QString &ct) +QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) const { - m_customWidgetAddPageMethodHash.insert(className, ct); + const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + if (it != m_customWidgetDataHash.constEnd()) + return it.value().addPageMethod; + return QString(); } -QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) const +bool QFormBuilderExtra::isCustomWidgetContainer(const QString &className) const { - const QHash<QString, QString>::const_iterator it = m_customWidgetAddPageMethodHash.constFind(className); - if (it == m_customWidgetAddPageMethodHash.constEnd()) - return QString(); - return it.value(); + const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className); + if (it != m_customWidgetDataHash.constEnd()) + return it.value().isContainer; + return false; } namespace { |