diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-11-02 15:20:43 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-01-10 09:13:36 +0000 |
commit | 8c47c2a08ec69fe45a14f6c2334befcb2e074790 (patch) | |
tree | c1f35c262c9c88f5c113ccdafb48ff41e8a89e1a /src/tools/uic/uic.cpp | |
parent | f370410097f8cb8d8fdf6174b799497fe7fe0adf (diff) |
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 <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/tools/uic/uic.cpp')
-rw-r--r-- | src/tools/uic/uic.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
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 |