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/uic.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/tools/uic/uic.cpp') diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index b426d33e5c..225dc6aeb2 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -245,28 +245,32 @@ void Uic::writeHeaderProtectionEnd() bool Uic::isButton(const QString &className) const { - return customWidgetsInfo()->extends(className, QLatin1String("QRadioButton")) - || customWidgetsInfo()->extends(className, QLatin1String("QToolButton")) - || customWidgetsInfo()->extends(className, QLatin1String("QCheckBox")) - || customWidgetsInfo()->extends(className, QLatin1String("QPushButton")) - || customWidgetsInfo()->extends(className, QLatin1String("QCommandLinkButton")); + static const QStringList buttons = { + QLatin1String("QRadioButton"), QLatin1String("QToolButton"), + QLatin1String("QCheckBox"), QLatin1String("QPushButton"), + QLatin1String("QCommandLinkButton") + }; + return customWidgetsInfo()->extendsOneOf(className, buttons); } bool Uic::isContainer(const QString &className) const { - return customWidgetsInfo()->extends(className, QLatin1String("QStackedWidget")) - || customWidgetsInfo()->extends(className, QLatin1String("QToolBox")) - || customWidgetsInfo()->extends(className, QLatin1String("QTabWidget")) - || customWidgetsInfo()->extends(className, QLatin1String("QScrollArea")) - || customWidgetsInfo()->extends(className, QLatin1String("QMdiArea")) - || customWidgetsInfo()->extends(className, QLatin1String("QWizard")) - || customWidgetsInfo()->extends(className, QLatin1String("QDockWidget")); + static const QStringList containers = { + QLatin1String("QStackedWidget"), QLatin1String("QToolBox"), + QLatin1String("QTabWidget"), QLatin1String("QScrollArea"), + QLatin1String("QMdiArea"), QLatin1String("QWizard"), + QLatin1String("QDockWidget") + }; + + return customWidgetsInfo()->extendsOneOf(className, containers); } bool Uic::isMenu(const QString &className) const { - return customWidgetsInfo()->extends(className, QLatin1String("QMenu")) - || customWidgetsInfo()->extends(className, QLatin1String("QPopupMenu")); + static const QStringList menus = { + QLatin1String("QMenu"), QLatin1String("QPopupMenu") + }; + return customWidgetsInfo()->extendsOneOf(className, menus); } QT_END_NAMESPACE -- cgit v1.2.3