From effe9bd026ef6b2493bd10883a395bea37a2385e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 19 Oct 2023 15:37:56 +0200 Subject: uic: Write fully qualified enum values for QMainWindow enumerations Task-number: PYSIDE-2492 Task-number: PYSIDE-1735 Task-number: QTBUG-118473 Change-Id: Ief50914bae3cc8e55f61113e8c8b6d6d24fe2c0f Reviewed-by: Jarek Kobus --- src/tools/uic/cpp/cppwriteinitialization.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/tools/uic/cpp/cppwriteinitialization.cpp') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 7d7864330ef..7f1b63d175c 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -42,6 +42,16 @@ namespace { return expandEnum(value, "QSizePolicy::Policy"_L1); } + inline QString expandToolBarArea(const QString &value) + { + return expandEnum(value, "Qt::ToolBarArea"_L1); + } + + inline QString expandDockWidgetArea(const QString &value) + { + return expandEnum(value, "Qt::DockWidgetArea"_L1); + } + // figure out the toolbar area of a DOM attrib list. // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value. QString toolBarAreaStringFromDOMAttributes(const CPP::WriteInitialization::DomPropertyMap &attributes) { @@ -59,9 +69,7 @@ namespace { default: break; } - if (!result.startsWith("Qt::"_L1)) - result.prepend("Qt::"_L1); - return result + ", "_L1; + return expandToolBarArea(result) + ", "_L1; } // Write a statement to create a spacer item. @@ -709,8 +717,8 @@ void WriteInitialization::acceptWidget(DomWidget *node) } else if (cwi->extends(className, "QDockWidget")) { m_output << m_indent << parentWidget << language::derefPointer << "addDockWidget("; if (DomProperty *pstyle = attributes.value("dockWidgetArea"_L1)) { - m_output << "Qt" << language::qualifier - << language::dockWidgetArea(pstyle->elementNumber()) << ", "; + QString a = expandDockWidgetArea(language::dockWidgetArea(pstyle->elementNumber())); + m_output << language::enumValue(a) << ", "; } m_output << varName << ")" << language::eol; } else if (m_uic->customWidgetsInfo()->extends(className, "QStatusBar")) { -- cgit v1.2.3