diff options
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 46 | ||||
-rw-r--r-- | src/tools/uic/customwidgetsinfo.cpp | 24 | ||||
-rw-r--r-- | src/tools/uic/customwidgetsinfo.h | 2 | ||||
-rw-r--r-- | src/tools/uic/python/pythonwriteimports.cpp | 6 | ||||
-rw-r--r-- | src/tools/uic/shared/writeincludesbase.cpp | 4 |
5 files changed, 41 insertions, 41 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 9471fd22d9..4c073987dc 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -143,7 +143,7 @@ namespace { // ### fixme Qt 7 remove this: Exclude deprecated properties of Qt 5. case DomProperty::Set: if (p->attributeName() == u"features" - && customWidgetsInfo->extends(className, QLatin1String("QDockWidget")) + && customWidgetsInfo->extends(className, "QDockWidget") && p->elementSet() == u"QDockWidget::AllDockWidgetFeatures") { const QString msg = fileName + QLatin1String(": Warning: Deprecated enum value QDockWidget::AllDockWidgetFeatures was encountered."); qWarning("%s", qPrintable(msg)); @@ -152,7 +152,7 @@ namespace { break; case DomProperty::Enum: if (p->attributeName() == u"sizeAdjustPolicy" - && customWidgetsInfo->extends(className, QLatin1String("QComboBox")) + && customWidgetsInfo->extends(className, "QComboBox") && p->elementEnum() == u"QComboBox::AdjustToMinimumContentsLength") { const QString msg = fileName + QLatin1String(": Warning: Deprecated enum value QComboBox::AdjustToMinimumContentsLength was encountered."); qWarning("%s", qPrintable(msg)); @@ -649,13 +649,13 @@ void WriteInitialization::acceptWidget(DomWidget *node) parentWidget = savedParentWidget; - if (cwi->extends(className, QLatin1String("QComboBox"))) { + if (cwi->extends(className, "QComboBox")) { initializeComboBox(node); - } else if (cwi->extends(className, QLatin1String("QListWidget"))) { + } else if (cwi->extends(className, "QListWidget")) { initializeListWidget(node); - } else if (cwi->extends(className, QLatin1String("QTreeWidget"))) { + } else if (cwi->extends(className, "QTreeWidget")) { initializeTreeWidget(node); - } else if (cwi->extends(className, QLatin1String("QTableWidget"))) { + } else if (cwi->extends(className, "QTableWidget")) { initializeTableWidget(node); } @@ -665,7 +665,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) writeProperties(varName, className, node->elementProperty()); if (!parentWidget.isEmpty() - && cwi->extends(className, QLatin1String("QMenu"))) { + && cwi->extends(className, "QMenu")) { initializeMenu(node, parentWidget); } @@ -693,11 +693,11 @@ void WriteInitialization::acceptWidget(DomWidget *node) const QString pageDefaultString = QLatin1String("Page"); - if (cwi->extends(parentClass, QLatin1String("QMainWindow"))) { - if (cwi->extends(className, QLatin1String("QMenuBar"))) { + if (cwi->extends(parentClass, "QMainWindow")) { + if (cwi->extends(className, "QMenuBar")) { m_output << m_indent << parentWidget << language::derefPointer << "setMenuBar(" << varName << ')' << language::eol; - } else if (cwi->extends(className, QLatin1String("QToolBar"))) { + } else if (cwi->extends(className, "QToolBar")) { m_output << m_indent << parentWidget << language::derefPointer << "addToolBar(" << language::enumValue(toolBarAreaStringFromDOMAttributes(attributes)) << varName << ')' << language::eol; @@ -709,14 +709,14 @@ void WriteInitialization::acceptWidget(DomWidget *node) } } - } else if (cwi->extends(className, QLatin1String("QDockWidget"))) { + } else if (cwi->extends(className, "QDockWidget")) { m_output << m_indent << parentWidget << language::derefPointer << "addDockWidget("; if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) { m_output << "Qt" << language::qualifier << language::dockWidgetArea(pstyle->elementNumber()) << ", "; } m_output << varName << ")" << language::eol; - } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"))) { + } else if (m_uic->customWidgetsInfo()->extends(className, "QStatusBar")) { m_output << m_indent << parentWidget << language::derefPointer << "setStatusBar(" << varName << ')' << language::eol; } else { @@ -732,9 +732,9 @@ void WriteInitialization::acceptWidget(DomWidget *node) if (!addPageMethod.isEmpty()) { m_output << m_indent << parentWidget << language::derefPointer << addPageMethod << '(' << varName << ')' << language::eol; - } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QWizard"))) { + } else if (m_uic->customWidgetsInfo()->extends(parentClass, "QWizard")) { addWizardPage(varName, node, parentWidget); - } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QToolBox"))) { + } else if (m_uic->customWidgetsInfo()->extends(parentClass, "QToolBox")) { const DomProperty *plabel = attributes.value(QLatin1String("label")); DomString *plabelString = plabel ? plabel->elementString() : nullptr; QString icon; @@ -757,7 +757,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) << autoTrCall(ptoolTip->elementString()) << ')' << language::eol << language::closeQtConfig(toolTipConfigKey()); } - } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QTabWidget"))) { + } else if (m_uic->customWidgetsInfo()->extends(parentClass, "QTabWidget")) { const DomProperty *ptitle = attributes.value(QLatin1String("title")); DomString *ptitleString = ptitle ? ptitle->elementString() : nullptr; QString icon; @@ -1190,7 +1190,7 @@ void WriteInitialization::writeProperties(const QString &varName, { const bool isTopLevel = m_widgetChain.count() == 1; - if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { + if (m_uic->customWidgetsInfo()->extends(className, "QAxWidget")) { DomPropertyMap properties = propertyMap(lst); if (DomProperty *p = properties.value(QLatin1String("control"))) { m_output << m_indent << varName << language::derefPointer << "setControl(" @@ -1239,7 +1239,7 @@ void WriteInitialization::writeProperties(const QString &varName, continue; } if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) { + && m_uic->customWidgetsInfo()->extends(className, "QListWidget")) { m_delayedOut << m_indent << varName << language::derefPointer << "setCurrentRow(" << p->elementNumber() << ')' << language::eol; continue; @@ -1255,19 +1255,19 @@ void WriteInitialization::writeProperties(const QString &varName, continue; } if (propertyName == QLatin1String("tabSpacing") - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) { + && m_uic->customWidgetsInfo()->extends(className, "QToolBox")) { m_delayedOut << m_indent << varName << language::derefPointer << "layout()" << language::derefPointer << "setSpacing(" << p->elementNumber() << ')' << language::eol; continue; } if (propertyName == QLatin1String("control") // ActiveQt support - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { + && m_uic->customWidgetsInfo()->extends(className, "QAxWidget")) { // already done ;) continue; } if (propertyName == QLatin1String("default") - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))) { + && m_uic->customWidgetsInfo()->extends(className, "QPushButton")) { // QTBUG-44406: Setting of QPushButton::default needs to be delayed until the parent is set delayProperty = true; } else if (propertyName == QLatin1String("database") @@ -1279,7 +1279,7 @@ void WriteInitialization::writeProperties(const QString &varName, // Sql support continue; } else if (propertyName == QLatin1String("orientation") - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("Line"))) { + && m_uic->customWidgetsInfo()->extends(className, "Line")) { // Line support QString shape = QLatin1String("QFrame::HLine"); if (p->elementEnum() == QLatin1String("Qt::Vertical")) @@ -1312,7 +1312,7 @@ void WriteInitialization::writeProperties(const QString &varName, bottomMargin = p->elementNumber(); continue; } else if (propertyName == QLatin1String("numDigits") // Deprecated in Qt 4, removed in Qt 5. - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QLCDNumber"))) { + && m_uic->customWidgetsInfo()->extends(className, "QLCDNumber")) { qWarning("Widget '%s': Deprecated property QLCDNumber::numDigits encountered. It has been replaced by QLCDNumber::digitCount.", qPrintable(varName)); propertyName = QLatin1String("digitCount"); @@ -1354,7 +1354,7 @@ void WriteInitialization::writeProperties(const QString &varName, propertyValue = domColor2QString(p->elementColor()); break; case DomProperty::Cstring: - if (propertyName == QLatin1String("buddy") && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QLabel"))) { + if (propertyName == QLatin1String("buddy") && m_uic->customWidgetsInfo()->extends(className, "QLabel")) { Buddy buddy = { varName, p->elementCstring() }; m_buddies.append(std::move(buddy)); } else { diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp index c838feaf73..347c647acb 100644 --- a/src/tools/uic/customwidgetsinfo.cpp +++ b/src/tools/uic/customwidgetsinfo.cpp @@ -58,7 +58,7 @@ void CustomWidgetsInfo::acceptCustomWidget(DomCustomWidget *node) m_customWidgets.insert(node->elementClass(), node); } -bool CustomWidgetsInfo::extends(const QString &classNameIn, QLatin1String baseClassName) const +bool CustomWidgetsInfo::extends(const QString &classNameIn, QAnyStringView baseClassName) const { if (classNameIn == baseClassName) return true; @@ -119,19 +119,19 @@ QString CustomWidgetsInfo::customWidgetAddPageMethod(const QString &name) const // add page methods for simple containers taking only the widget parameter QString CustomWidgetsInfo::simpleContainerAddPageMethod(const QString &name) const { - using AddPageMethod = std::pair<const char *, const char *>; - - static AddPageMethod addPageMethods[] = { - {"QStackedWidget", "addWidget"}, - {"QToolBar", "addWidget"}, - {"QDockWidget", "setWidget"}, - {"QScrollArea", "setWidget"}, - {"QSplitter", "addWidget"}, - {"QMdiArea", "addSubWindow"} + using AddPageMethod = std::pair<QString, QString>; + + static const AddPageMethod addPageMethods[] = { + {u"QStackedWidget"_qs, u"addWidget"_qs}, + {u"QToolBar"_qs, u"addWidget"_qs}, + {u"QDockWidget"_qs, u"setWidget"_qs}, + {u"QScrollArea"_qs, u"setWidget"_qs}, + {u"QSplitter"_qs, u"addWidget"_qs}, + {u"QMdiArea"_qs, u"addSubWindow"_qs} }; for (const auto &m : addPageMethods) { - if (extends(name, QLatin1String(m.first))) - return QLatin1String(m.second); + if (extends(name, m.first)) + return m.second; } return QString(); } diff --git a/src/tools/uic/customwidgetsinfo.h b/src/tools/uic/customwidgetsinfo.h index a1b24ab042..82b9882bef 100644 --- a/src/tools/uic/customwidgetsinfo.h +++ b/src/tools/uic/customwidgetsinfo.h @@ -56,7 +56,7 @@ public: QString realClassName(const QString &className) const; - bool extends(const QString &className, QLatin1String baseClassName) const; + bool extends(const QString &className, QAnyStringView baseClassName) const; bool extendsOneOf(const QString &className, const QStringList &baseClassNames) const; bool isCustomWidgetContainer(const QString &className) const; diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp index afa5c55da7..ec4968da2f 100644 --- a/src/tools/uic/python/pythonwriteimports.cpp +++ b/src/tools/uic/python/pythonwriteimports.cpp @@ -179,11 +179,11 @@ void WriteImports::writeImport(const QString &module) void WriteImports::doAdd(const QString &className, const DomCustomWidget *dcw) { const CustomWidgetsInfo *cwi = uic()->customWidgetsInfo(); - if (cwi->extends(className, QLatin1String("QListWidget"))) + if (cwi->extends(className, "QListWidget")) add(QStringLiteral("QListWidgetItem")); - else if (cwi->extends(className, QLatin1String("QTreeWidget"))) + else if (cwi->extends(className, "QTreeWidget")) add(QStringLiteral("QTreeWidgetItem")); - else if (cwi->extends(className, QLatin1String("QTableWidget"))) + else if (cwi->extends(className, "QTableWidget")) add(QStringLiteral("QTableWidgetItem")); if (dcw != nullptr) { diff --git a/src/tools/uic/shared/writeincludesbase.cpp b/src/tools/uic/shared/writeincludesbase.cpp index 128200ed68..6035e8694b 100644 --- a/src/tools/uic/shared/writeincludesbase.cpp +++ b/src/tools/uic/shared/writeincludesbase.cpp @@ -118,7 +118,7 @@ void WriteIncludesBase::add(const QString &className, const DomCustomWidget *dcw if (cwi->extendsOneOf(className, treeViewsWithHeaders)) add(QStringLiteral("QHeaderView")); - if (!m_laidOut && cwi->extends(className, QLatin1String("QToolBox"))) + if (!m_laidOut && cwi->extends(className, "QToolBox")) add(QStringLiteral("QLayout")); // spacing property of QToolBox) if (className == QStringLiteral("Line")) { // ### hmm, deprecate me! @@ -126,7 +126,7 @@ void WriteIncludesBase::add(const QString &className, const DomCustomWidget *dcw return; } - if (cwi->extends(className, QLatin1String("QDialogButtonBox"))) + if (cwi->extends(className, "QDialogButtonBox")) add(QStringLiteral("QAbstractButton")); // for signal "clicked(QAbstractButton*)" doAdd(className, dcw); |