From 8c47c2a08ec69fe45a14f6c2334befcb2e074790 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 2 Nov 2018 15:20:43 +0100 Subject: uic: Refactor CustomWidgetsInfo::extends() Add a extendsOneOf() helper that takes a QStringList to be searched and simplify the code accordingly. In WriteInitialization::acceptWidget(), move the variable CustomWidgetsInfo *cwi up and reuse everywhere to shorten code. Task-number: PYSIDE-797 Change-Id: I331e135b6aa58dbbd413ca151eb67b3eb92f09c6 Reviewed-by: Jarek Kobus --- src/tools/uic/cpp/cppwriteincludes.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/tools/uic/cpp/cppwriteincludes.cpp') diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 74546bb01d3..0ba49627c0f 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -214,14 +214,14 @@ void WriteIncludes::add(const QString &className, bool determineHeader, const QS m_knownClasses.insert(className); const CustomWidgetsInfo *cwi = m_uic->customWidgetsInfo(); - if (cwi->extends(className, QLatin1String("QTreeView")) - || cwi->extends(className, QLatin1String("QTreeWidget")) - || cwi->extends(className, QLatin1String("QTableView")) - || cwi->extends(className, QLatin1String("QTableWidget"))) { + static const QStringList treeViewsWithHeaders = { + QLatin1String("QTreeView"), QLatin1String("QTreeWidget"), + QLatin1String("QTableView"), QLatin1String("QTableWidget") + }; + if (cwi->extendsOneOf(className, treeViewsWithHeaders)) add(QLatin1String("QHeaderView")); - } - if (!m_laidOut && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) + if (!m_laidOut && cwi->extends(className, QLatin1String("QToolBox"))) add(QLatin1String("QLayout")); // spacing property of QToolBox) if (className == QLatin1String("Line")) { // ### hmm, deprecate me! -- cgit v1.2.3