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 /src/tools/uic | |
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 'src/tools/uic')
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 9 | ||||
-rw-r--r-- | src/tools/uic/customwidgetsinfo.cpp | 8 | ||||
-rw-r--r-- | src/tools/uic/customwidgetsinfo.h | 2 | ||||
-rw-r--r-- | src/tools/uic/uic.cpp | 5 | ||||
-rw-r--r-- | src/tools/uic/uic.h | 1 |
5 files changed, 22 insertions, 3 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 1690c2e..74a4b9d 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -670,10 +670,13 @@ void WriteInitialization::acceptWidget(DomWidget *node) m_layoutWidget = false; if (className == QLatin1String("QWidget") && !node->hasAttributeNative()) { - if (m_widgetChain.top() - && m_widgetChain.top()->attributeClass() != QLatin1String("QMainWindow") - && !m_uic->isContainer(m_widgetChain.top()->attributeClass())) + if (const DomWidget* parentWidget = m_widgetChain.top()) { + const QString parentClass = parentWidget->attributeClass(); + if (parentClass != QLatin1String("QMainWindow") + && !m_uic->isCustomWidgetContainer(parentClass) + && !m_uic->isContainer(parentClass)) m_layoutWidget = true; + } } m_widgetChain.push(node); m_layoutChain.push(0); diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp index 70adba2..ca3fd19 100644 --- a/src/tools/uic/customwidgetsinfo.cpp +++ b/src/tools/uic/customwidgetsinfo.cpp @@ -88,6 +88,14 @@ bool CustomWidgetsInfo::extends(const QString &classNameIn, const QLatin1String return false; } +bool CustomWidgetsInfo::isCustomWidgetContainer(const QString &className) const +{ + if (const DomCustomWidget *dcw = m_customWidgets.value(className, 0)) + if (dcw->hasElementContainer()) + return dcw->elementContainer() != 0; + return false; +} + QString CustomWidgetsInfo::realClassName(const QString &className) const { if (className == QLatin1String("Line")) diff --git a/src/tools/uic/customwidgetsinfo.h b/src/tools/uic/customwidgetsinfo.h index 1471118..d5be5a2 100644 --- a/src/tools/uic/customwidgetsinfo.h +++ b/src/tools/uic/customwidgetsinfo.h @@ -78,6 +78,8 @@ public: bool extends(const QString &className, const QLatin1String &baseClassName) const; + bool isCustomWidgetContainer(const QString &className) const; + private: typedef QMap<QString, DomCustomWidget*> NameCustomWidgetMap; NameCustomWidgetMap m_customWidgets; diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index 32e5e3d..71b6ac1 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -363,6 +363,11 @@ bool Uic::isContainer(const QString &className) const || customWidgetsInfo()->extends(className, QLatin1String("QDockWidget")); } +bool Uic::isCustomWidgetContainer(const QString &className) const +{ + return customWidgetsInfo()->isCustomWidgetContainer(className); +} + bool Uic::isStatusBar(const QString &className) const { return customWidgetsInfo()->extends(className, QLatin1String("QStatusBar")); diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h index 3e072a4..5175ea9 100644 --- a/src/tools/uic/uic.h +++ b/src/tools/uic/uic.h @@ -115,6 +115,7 @@ public: bool isStatusBar(const QString &className) const; bool isButton(const QString &className) const; bool isContainer(const QString &className) const; + bool isCustomWidgetContainer(const QString &className) const; bool isMenuBar(const QString &className) const; bool isMenu(const QString &className) const; |