summaryrefslogtreecommitdiffstats
path: root/src/tools/uic
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/uic')
-rw-r--r--src/tools/uic/.prev_CMakeLists.txt46
-rw-r--r--src/tools/uic/CMakeLists.txt19
-rw-r--r--src/tools/uic/cpp/cpp.pri10
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.cpp55
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.h29
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.cpp208
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.h74
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp786
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.h36
-rw-r--r--src/tools/uic/customwidgetsinfo.cpp144
-rw-r--r--src/tools/uic/customwidgetsinfo.h39
-rw-r--r--src/tools/uic/databaseinfo.cpp35
-rw-r--r--src/tools/uic/databaseinfo.h29
-rw-r--r--src/tools/uic/driver.cpp57
-rw-r--r--src/tools/uic/driver.h29
-rw-r--r--src/tools/uic/main.cpp185
-rw-r--r--src/tools/uic/option.h52
-rw-r--r--src/tools/uic/python/python.pri8
-rw-r--r--src/tools/uic/python/pythonwritedeclaration.cpp33
-rw-r--r--src/tools/uic/python/pythonwritedeclaration.h29
-rw-r--r--src/tools/uic/python/pythonwriteimports.cpp311
-rw-r--r--src/tools/uic/python/pythonwriteimports.h62
-rw-r--r--src/tools/uic/qclass_lib_map.h171
-rw-r--r--src/tools/uic/shared/language.cpp265
-rw-r--r--src/tools/uic/shared/language.h47
-rw-r--r--src/tools/uic/shared/shared.pri5
-rw-r--r--src/tools/uic/shared/writeincludesbase.cpp135
-rw-r--r--src/tools/uic/shared/writeincludesbase.h74
-rw-r--r--src/tools/uic/treewalker.cpp29
-rw-r--r--src/tools/uic/treewalker.h29
-rw-r--r--src/tools/uic/ui4.cpp1292
-rw-r--r--src/tools/uic/ui4.h45
-rw-r--r--src/tools/uic/uic.cpp71
-rw-r--r--src/tools/uic/uic.h29
-rw-r--r--src/tools/uic/uic.pri20
-rw-r--r--src/tools/uic/uic.pro18
-rw-r--r--src/tools/uic/utils.h31
-rw-r--r--src/tools/uic/validator.cpp29
-rw-r--r--src/tools/uic/validator.h29
39 files changed, 2155 insertions, 2440 deletions
diff --git a/src/tools/uic/.prev_CMakeLists.txt b/src/tools/uic/.prev_CMakeLists.txt
deleted file mode 100644
index 20c5e1a7c6..0000000000
--- a/src/tools/uic/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-# Generated from uic.pro.
-
-#####################################################################
-## uic Tool:
-#####################################################################
-
-qt_get_tool_target_name(target_name uic)
-qt_internal_add_tool(${target_name}
- TARGET_DESCRIPTION "Qt User Interface Compiler"
- SOURCES
- cpp/cppwritedeclaration.cpp cpp/cppwritedeclaration.h
- cpp/cppwriteincludes.cpp cpp/cppwriteincludes.h
- cpp/cppwriteinitialization.cpp cpp/cppwriteinitialization.h
- customwidgetsinfo.cpp customwidgetsinfo.h
- databaseinfo.cpp databaseinfo.h
- driver.cpp driver.h
- main.cpp
- option.h
- python/pythonwritedeclaration.cpp python/pythonwritedeclaration.h
- python/pythonwriteimports.cpp python/pythonwriteimports.h
- shared/language.cpp shared/language.h
- treewalker.cpp treewalker.h
- ui4.cpp ui4.h
- uic.cpp uic.h
- utils.h
- validator.cpp validator.h
- DEFINES
- QT_NO_CAST_FROM_ASCII
- QT_NO_FOREACH
- QT_UIC
- INCLUDE_DIRECTORIES
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${PROJECT_BINARY_DIR}/src/tools/uic
- cpp
- python
- shared
- PUBLIC_LIBRARIES
- Qt::Gui
-)
-
-#### Keys ignored in scope 1:.:.:uic.pro:<TRUE>:
-# QMAKE_TARGET_DESCRIPTION = "Qt User Interface Compiler"
-# _OPTION = "host_build"
-
-## Scopes:
-#####################################################################
diff --git a/src/tools/uic/CMakeLists.txt b/src/tools/uic/CMakeLists.txt
index afda54d179..9f47ec8b4b 100644
--- a/src/tools/uic/CMakeLists.txt
+++ b/src/tools/uic/CMakeLists.txt
@@ -1,4 +1,5 @@
-# Generated from uic.pro.
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## uic Tool:
@@ -6,8 +7,10 @@
qt_get_tool_target_name(target_name uic)
qt_internal_add_tool(${target_name}
+ TRY_RUN
TARGET_DESCRIPTION "Qt User Interface Compiler"
- TOOLS_TARGET Widgets # special case
+ INSTALL_DIR "${INSTALL_LIBEXECDIR}"
+ TOOLS_TARGET Widgets
SOURCES
cpp/cppwritedeclaration.cpp cpp/cppwritedeclaration.h
cpp/cppwriteincludes.cpp cpp/cppwriteincludes.h
@@ -20,6 +23,7 @@ qt_internal_add_tool(${target_name}
python/pythonwritedeclaration.cpp python/pythonwritedeclaration.h
python/pythonwriteimports.cpp python/pythonwriteimports.h
shared/language.cpp shared/language.h
+ shared/writeincludesbase.cpp shared/writeincludesbase.h
treewalker.cpp treewalker.h
ui4.cpp ui4.h
uic.cpp uic.h
@@ -28,6 +32,7 @@ qt_internal_add_tool(${target_name}
DEFINES
QT_NO_CAST_FROM_ASCII
QT_NO_FOREACH
+ QT_USE_NODISCARD_FILE_OPEN
QT_UIC
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
@@ -35,13 +40,5 @@ qt_internal_add_tool(${target_name}
cpp
python
shared
- #PUBLIC_LIBRARIES # special case remove
- #Qt::Gui # special case remove
)
-
-#### Keys ignored in scope 1:.:.:uic.pro:<TRUE>:
-# QMAKE_TARGET_DESCRIPTION = "Qt User Interface Compiler"
-# _OPTION = "host_build"
-
-## Scopes:
-#####################################################################
+qt_internal_return_unless_building_tools()
diff --git a/src/tools/uic/cpp/cpp.pri b/src/tools/uic/cpp/cpp.pri
deleted file mode 100644
index 786b0e97a5..0000000000
--- a/src/tools/uic/cpp/cpp.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-INCLUDEPATH += $$PWD $$QT_BUILD_TREE/src/tools/uic
-
-# Input
-HEADERS += $$PWD/cppwritedeclaration.h \
- $$PWD/cppwriteincludes.h \
- $$PWD/cppwriteinitialization.h
-
-SOURCES += $$PWD/cppwritedeclaration.cpp \
- $$PWD/cppwriteincludes.cpp \
- $$PWD/cppwriteinitialization.cpp
diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp
index 995b99b692..8261963cfa 100644
--- a/src/tools/uic/cpp/cppwritedeclaration.cpp
+++ b/src/tools/uic/cpp/cppwritedeclaration.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppwritedeclaration.h"
#include "cppwriteinitialization.h"
@@ -39,6 +14,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
void openNameSpaces(const QStringList &namespaceList, QTextStream &output)
{
@@ -75,10 +52,10 @@ void WriteDeclaration::acceptUI(DomUI *node)
QString exportMacro = node->elementExportMacro();
if (!exportMacro.isEmpty())
- exportMacro.append(QLatin1Char(' '));
+ exportMacro.append(u' ');
- QStringList namespaceList = qualifiedClassName.split(QLatin1String("::"));
- if (namespaceList.count()) {
+ QStringList namespaceList = qualifiedClassName.split("::"_L1);
+ if (namespaceList.size()) {
className = namespaceList.last();
namespaceList.removeLast();
}
@@ -88,15 +65,15 @@ void WriteDeclaration::acceptUI(DomUI *node)
// is a User using Qt-in-namespace having his own classes not in a namespace.
// In this case the generated Ui helper classes will also end up in
// the Qt namespace (which is harmless, but not "pretty")
- const bool needsMacro = namespaceList.count() == 0
- || namespaceList[0] == QLatin1String("qdesigner_internal");
+ const bool needsMacro = m_option.qtNamespace &&
+ (namespaceList.size() == 0 || namespaceList[0] == "qdesigner_internal"_L1);
if (needsMacro)
m_output << "QT_BEGIN_NAMESPACE\n\n";
openNameSpaces(namespaceList, m_output);
- if (namespaceList.count())
+ if (namespaceList.size())
m_output << "\n";
m_output << "class " << exportMacro << m_option.prefix << className << "\n"
@@ -105,7 +82,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
const QStringList connections = m_uic->databaseInfo()->connections();
for (const QString &connection : connections) {
- if (connection != QLatin1String("(default)"))
+ if (connection != "(default)"_L1)
m_output << m_option.indent << "QSqlDatabase " << connection << "Connection;\n";
}
@@ -121,11 +98,11 @@ void WriteDeclaration::acceptUI(DomUI *node)
closeNameSpaces(namespaceList, m_output);
- if (namespaceList.count())
+ if (namespaceList.size())
m_output << "\n";
if (m_option.generateNamespace && !m_option.prefix.isEmpty()) {
- namespaceList.append(QLatin1String("Ui"));
+ namespaceList.append("Ui"_L1);
openNameSpaces(namespaceList, m_output);
@@ -133,7 +110,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
closeNameSpaces(namespaceList, m_output);
- if (namespaceList.count())
+ if (namespaceList.size())
m_output << "\n";
}
@@ -143,7 +120,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
void WriteDeclaration::acceptWidget(DomWidget *node)
{
- QString className = QLatin1String("QWidget");
+ QString className = u"QWidget"_s;
if (node->hasAttributeClass())
className = node->attributeClass();
@@ -160,7 +137,7 @@ void WriteDeclaration::acceptSpacer(DomSpacer *node)
void WriteDeclaration::acceptLayout(DomLayout *node)
{
- QString className = QLatin1String("QLayout");
+ QString className = u"QLayout"_s;
if (node->hasAttributeClass())
className = node->attributeClass();
diff --git a/src/tools/uic/cpp/cppwritedeclaration.h b/src/tools/uic/cpp/cppwritedeclaration.h
index f83bfe8f50..2dcb5981e1 100644
--- a/src/tools/uic/cpp/cppwritedeclaration.h
+++ b/src/tools/uic/cpp/cppwritedeclaration.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CPPWRITEDECLARATION_H
#define CPPWRITEDECLARATION_H
diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp
index 9784825c72..7cf7c4e59e 100644
--- a/src/tools/uic/cpp/cppwriteincludes.cpp
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppwriteincludes.h"
#include "driver.h"
@@ -40,46 +15,33 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
enum { debugWriteIncludes = 0 };
enum { warnHeaderGeneration = 0 };
-struct ClassInfoEntry
-{
- const char *klass;
- const char *module;
- const char *header;
-};
-
-static const ClassInfoEntry qclass_lib_map[] = {
-#define QT_CLASS_LIB(klass, module, header) { #klass, #module, #header },
-#include "qclass_lib_map.h"
-
-#undef QT_CLASS_LIB
-};
-
// Format a module header as 'QtCore/QObject'
static inline QString moduleHeader(const QString &module, const QString &header)
{
QString rc = module;
- rc += QLatin1Char('/');
+ rc += u'/';
rc += header;
return rc;
}
namespace CPP {
-WriteIncludes::WriteIncludes(Uic *uic)
- : m_uic(uic), m_output(uic->output())
+WriteIncludes::WriteIncludes(Uic *uic) : WriteIncludesBase(uic),
+ m_output(uic->output())
{
// When possible (no namespace) use the "QtModule/QClass" convention
// and create a re-mapping of the old header "qclass.h" to it. Do not do this
// for the "Phonon::Someclass" classes, however.
- const QString namespaceDelimiter = QLatin1String("::");
- const ClassInfoEntry *classLibEnd = qclass_lib_map + sizeof(qclass_lib_map)/sizeof(ClassInfoEntry);
- for (const ClassInfoEntry *it = qclass_lib_map; it < classLibEnd; ++it) {
- const QString klass = QLatin1String(it->klass);
- const QString module = QLatin1String(it->module);
- QLatin1String header = QLatin1String(it->header);
+ const QLatin1StringView namespaceDelimiter = "::"_L1;
+ for (const auto &e : classInfoEntries()) {
+ const QString klass = QLatin1StringView(e.klass);
+ const QString module = QLatin1StringView(e.module);
+ QLatin1StringView header = QLatin1StringView(e.header);
if (klass.contains(namespaceDelimiter)) {
m_classToHeader.insert(klass, moduleHeader(module, header));
} else {
@@ -92,27 +54,13 @@ WriteIncludes::WriteIncludes(Uic *uic)
void WriteIncludes::acceptUI(DomUI *node)
{
- m_laidOut = false;
m_localIncludes.clear();
m_globalIncludes.clear();
- m_knownClasses.clear();
m_includeBaseNames.clear();
- if (node->elementIncludes())
- acceptIncludes(node->elementIncludes());
-
- if (node->elementCustomWidgets())
- TreeWalker::acceptCustomWidgets(node->elementCustomWidgets());
-
- add(QLatin1String("QApplication"));
- add(QLatin1String("QVariant"));
+ WriteIncludesBase::acceptUI(node);
- if (node->elementButtonGroups())
- add(QLatin1String("QButtonGroup"));
-
- TreeWalker::acceptUI(node);
-
- const auto includeFile = m_uic->option().includeFile;
+ const auto includeFile = uic()->option().includeFile;
if (!includeFile.isEmpty())
m_globalIncludes.insert(includeFile);
@@ -122,39 +70,6 @@ void WriteIncludes::acceptUI(DomUI *node)
m_output << '\n';
}
-void WriteIncludes::acceptWidget(DomWidget *node)
-{
- if (debugWriteIncludes)
- fprintf(stderr, "%s '%s'\n", Q_FUNC_INFO, qPrintable(node->attributeClass()));
-
- add(node->attributeClass());
- TreeWalker::acceptWidget(node);
-}
-
-void WriteIncludes::acceptLayout(DomLayout *node)
-{
- add(node->attributeClass());
- m_laidOut = true;
- TreeWalker::acceptLayout(node);
-}
-
-void WriteIncludes::acceptSpacer(DomSpacer *node)
-{
- add(QLatin1String("QSpacerItem"));
- TreeWalker::acceptSpacer(node);
-}
-
-void WriteIncludes::acceptProperty(DomProperty *node)
-{
- if (node->kind() == DomProperty::Date)
- add(QLatin1String("QDate"));
- if (node->kind() == DomProperty::Locale)
- add(QLatin1String("QLocale"));
- if (node->kind() == DomProperty::IconSet)
- add(QLatin1String("QIcon"));
- TreeWalker::acceptProperty(node);
-}
-
void WriteIncludes::insertIncludeForClass(const QString &className, QString header, bool global)
{
if (debugWriteIncludes)
@@ -175,7 +90,7 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head
// Quick check by class name to detect includehints provided for custom widgets.
// Remove namespaces
QString lowerClassName = className.toLower();
- static const QString namespaceSeparator = QLatin1String("::");
+ static const auto namespaceSeparator = "::"_L1;
const int namespaceIndex = lowerClassName.lastIndexOf(namespaceSeparator);
if (namespaceIndex != -1)
lowerClassName.remove(0, namespaceIndex + namespaceSeparator.size());
@@ -185,13 +100,13 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head
}
// Last resort: Create default header
- if (!m_uic->option().implicitIncludes)
+ if (!uic()->option().implicitIncludes)
break;
header = lowerClassName;
- header += QLatin1String(".h");
+ header += ".h"_L1;
if (warnHeaderGeneration) {
qWarning("%s: Warning: generated header '%s' for class '%s'.",
- qPrintable(m_uic->option().messagePrefix()),
+ qPrintable(uic()->option().messagePrefix()),
qPrintable(header), qPrintable(className));
}
@@ -203,92 +118,35 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head
insertInclude(header, global);
}
-void WriteIncludes::add(const QString &className, bool determineHeader, const QString &header, bool global)
+void WriteIncludes::doAdd(const QString &className, const DomCustomWidget *dcw)
{
- if (debugWriteIncludes)
- fprintf(stderr, "%s %s '%s' %d\n", Q_FUNC_INFO, qPrintable(className), qPrintable(header), global);
-
- if (className.isEmpty() || m_knownClasses.contains(className))
- return;
-
- m_knownClasses.insert(className);
-
- const CustomWidgetsInfo *cwi = m_uic->customWidgetsInfo();
- static const QStringList treeViewsWithHeaders = {
- QLatin1String("QTreeView"), QLatin1String("QTreeWidget"),
- QLatin1String("QTableView"), QLatin1String("QTableWidget")
- };
- if (cwi->extendsOneOf(className, treeViewsWithHeaders))
- add(QLatin1String("QHeaderView"));
-
- if (!m_laidOut && cwi->extends(className, QLatin1String("QToolBox")))
- add(QLatin1String("QLayout")); // spacing property of QToolBox)
-
- if (className == QLatin1String("Line")) { // ### hmm, deprecate me!
- add(QLatin1String("QFrame"));
- return;
- }
-
- if (cwi->extends(className, QLatin1String("QDialogButtonBox")))
- add(QLatin1String("QAbstractButton")); // for signal "clicked(QAbstractButton*)"
-
- if (determineHeader)
- insertIncludeForClass(className, header, global);
+ if (dcw != nullptr)
+ addCppCustomWidget(className, dcw);
+ else
+ insertIncludeForClass(className, {}, false);
}
-void WriteIncludes::acceptCustomWidget(DomCustomWidget *node)
+void WriteIncludes::addCppCustomWidget(const QString &className, const DomCustomWidget *dcw)
{
- const QString className = node->elementClass();
- if (className.isEmpty())
- return;
-
- if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) {
- add(className, false); // no header specified
- } else {
+ const DomHeader *domHeader = dcw->elementHeader();
+ if (domHeader != nullptr && !domHeader->text().isEmpty()) {
// custom header unless it is a built-in qt class
QString header;
bool global = false;
if (!m_classToHeader.contains(className)) {
- global = node->elementHeader()->attributeLocation().toLower() == QLatin1String("global");
- header = node->elementHeader()->text();
+ global = domHeader->attributeLocation().toLower() == "global"_L1;
+ header = domHeader->text();
}
- add(className, true, header, global);
+ insertIncludeForClass(className, header, global);
+ return;
}
}
-void WriteIncludes::acceptActionGroup(DomActionGroup *node)
-{
- add(QLatin1String("QActionGroup"));
- TreeWalker::acceptActionGroup(node);
-}
-
-void WriteIncludes::acceptAction(DomAction *node)
-{
- add(QLatin1String("QAction"));
- TreeWalker::acceptAction(node);
-}
-
-void WriteIncludes::acceptActionRef(DomActionRef *node)
-{
- add(QLatin1String("QAction"));
- TreeWalker::acceptActionRef(node);
-}
-
-void WriteIncludes::acceptCustomWidgets(DomCustomWidgets *node)
-{
- Q_UNUSED(node);
-}
-
-void WriteIncludes::acceptIncludes(DomIncludes *node)
-{
- TreeWalker::acceptIncludes(node);
-}
-
void WriteIncludes::acceptInclude(DomInclude *node)
{
bool global = true;
if (node->hasAttributeLocation())
- global = node->attributeLocation() == QLatin1String("global");
+ global = node->attributeLocation() == "global"_L1;
insertInclude(node->text(), global);
}
@@ -309,8 +167,8 @@ void WriteIncludes::insertInclude(const QString &header, bool global)
void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
{
- const QChar openingQuote = global ? QLatin1Char('<') : QLatin1Char('"');
- const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"');
+ const QChar openingQuote = global ? u'<' : u'"';
+ const QChar closingQuote = global ? u'>' : u'"';
// Check for the old headers 'qslider.h' and replace by 'QtGui/QSlider'
for (const QString &header : headers) {
diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h
index 9b9ac283fe..1ec10f39b2 100644
--- a/src/tools/uic/cpp/cppwriteincludes.h
+++ b/src/tools/uic/cpp/cppwriteincludes.h
@@ -1,107 +1,49 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CPPWRITEINCLUDES_H
#define CPPWRITEINCLUDES_H
-#include "treewalker.h"
+#include <writeincludesbase.h>
-#include <qmap.h>
-#include <qset.h>
-#include <qstring.h>
+#include <QtCore/qmap.h>
#include <set>
QT_BEGIN_NAMESPACE
class QTextStream;
-class CustomWidgetsInfo;
-class Driver;
-class Uic;
namespace CPP {
-struct WriteIncludes : public TreeWalker
+class WriteIncludes : public WriteIncludesBase
{
+public:
WriteIncludes(Uic *uic);
void acceptUI(DomUI *node) override;
- void acceptWidget(DomWidget *node) override;
- void acceptLayout(DomLayout *node) override;
- void acceptSpacer(DomSpacer *node) override;
- void acceptProperty(DomProperty *node) override;
-
-//
-// actions
-//
- void acceptActionGroup(DomActionGroup *node) override;
- void acceptAction(DomAction *node) override;
- void acceptActionRef(DomActionRef *node) override;
-
-//
-// custom widgets
-//
- void acceptCustomWidgets(DomCustomWidgets *node) override;
- void acceptCustomWidget(DomCustomWidget *node) override;
-
-//
-// include hints
-//
- void acceptIncludes(DomIncludes *node) override;
void acceptInclude(DomInclude *node) override;
protected:
QTextStream &output() const { return m_output; }
-
-private:
- void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false);
+ void doAdd(const QString &className, const DomCustomWidget *dcw = nullptr) override;
private:
using OrderedSet = std::set<QString>;
+ void addCppCustomWidget(const QString &className, const DomCustomWidget *dcw);
void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false);
void insertInclude(const QString &header, bool global);
void writeHeaders(const OrderedSet &headers, bool global);
QString headerForClassName(const QString &className) const;
- const Uic *m_uic;
QTextStream &m_output;
OrderedSet m_localIncludes;
OrderedSet m_globalIncludes;
QSet<QString> m_includeBaseNames;
-
- QSet<QString> m_knownClasses;
-
using StringMap = QMap<QString, QString>;
StringMap m_classToHeader;
StringMap m_oldHeaderToNewHeader;
-
- bool m_laidOut = false;
};
} // namespace CPP
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 328fb22c2e..205d6a50a9 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -1,32 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppwriteinitialization.h"
+#include "customwidgetsinfo.h"
#include "driver.h"
#include "ui4.h"
#include "utils.h"
@@ -45,17 +21,47 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
+
+ // Expand "Horizontal", "Qt::Horizontal" to "Qt::Orientation::Horizontal"
+ QString expandEnum(QString value, const QString &prefix)
+ {
+ if (value.startsWith(prefix))
+ return value;
+ const auto pos = value.lastIndexOf("::"_L1);
+ if (pos == -1)
+ return prefix + "::"_L1 + value;
+ value.replace(0, pos, prefix);
+ return value;
+ }
+
+ inline QString expandSizePolicyEnum(const QString &value)
+ {
+ 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) {
- const DomProperty *pstyle = attributes.value(QLatin1String("toolBarArea"));
+ const DomProperty *pstyle = attributes.value("toolBarArea"_L1);
QString result;
if (!pstyle)
return result;
switch (pstyle->kind()) {
case DomProperty::Number:
- result = QLatin1String(language::toolbarArea(pstyle->elementNumber()));
+ result = language::toolbarArea(pstyle->elementNumber());
break;
case DomProperty::Enum:
result = pstyle->elementEnum();
@@ -63,9 +69,7 @@ namespace {
default:
break;
}
- if (!result.startsWith(QLatin1String("Qt::")))
- result.prepend(QLatin1String("Qt::"));
- return result + QLatin1String(", ");
+ return expandToolBarArea(result) + ", "_L1;
}
// Write a statement to create a spacer item.
@@ -75,7 +79,7 @@ namespace {
int w = 0;
int h = 0;
- if (const DomProperty *sh = properties.value(QLatin1String("sizeHint"))) {
+ if (const DomProperty *sh = properties.value("sizeHint"_L1)) {
if (const DomSize *sizeHint = sh->elementSize()) {
w = sizeHint->elementWidth();
h = sizeHint->elementHeight();
@@ -84,27 +88,17 @@ namespace {
output << w << ", " << h << ", ";
// size type
- QString sizeType;
- if (const DomProperty *st = properties.value(QLatin1String("sizeType"))) {
- const QString value = st->elementEnum();
- if (value.startsWith(QLatin1String("QSizePolicy::")))
- sizeType = value;
- else
- sizeType = QLatin1String("QSizePolicy::") + value;
- } else {
- sizeType = QStringLiteral("QSizePolicy::Expanding");
- }
+ const DomProperty *st = properties.value("sizeType"_L1);
+ QString horizType = st != nullptr ? st->elementEnum() : "Expanding"_L1;
+ QString vertType = "Minimum"_L1;
// orientation
- bool isVspacer = false;
- if (const DomProperty *o = properties.value(QLatin1String("orientation"))) {
- const QString orientation = o->elementEnum();
- if (orientation == QLatin1String("Qt::Vertical") || orientation == QLatin1String("Vertical"))
- isVspacer = true;
- }
- const QString horizType = isVspacer ? QLatin1String("QSizePolicy::Minimum") : sizeType;
- const QString vertType = isVspacer ? sizeType : QLatin1String("QSizePolicy::Minimum");
- output << language::enumValue(horizType) << ", " << language::enumValue(vertType) << ')';
+ const DomProperty *o = properties.value("orientation"_L1);
+ if (o != nullptr && o->elementEnum().endsWith("Vertical"_L1))
+ std::swap(horizType, vertType);
+
+ output << language::enumValue(expandSizePolicyEnum(horizType)) << ", "
+ << language::enumValue(expandSizePolicyEnum(vertType)) << ')';
}
@@ -136,8 +130,29 @@ namespace {
// Check on properties. Filter out empty legacy pixmap/icon properties
// as Designer pre 4.4 used to remove missing resource references.
// This can no longer be handled by the code as we have 'setIcon(QIcon())' as well as 'QIcon icon'
- static bool checkProperty(const QString &fileName, const DomProperty *p) {
+ static bool checkProperty(const CustomWidgetsInfo *customWidgetsInfo,
+ const QString &fileName, const QString &className,
+ const DomProperty *p) {
switch (p->kind()) {
+ // ### fixme Qt 7 remove this: Exclude deprecated properties of Qt 5.
+ case DomProperty::Set:
+ if (p->attributeName() == u"features"
+ && customWidgetsInfo->extends(className, "QDockWidget")
+ && p->elementSet() == u"QDockWidget::AllDockWidgetFeatures") {
+ const QString msg = fileName + ": Warning: Deprecated enum value QDockWidget::AllDockWidgetFeatures was encountered."_L1;
+ qWarning("%s", qPrintable(msg));
+ return false;
+ }
+ break;
+ case DomProperty::Enum:
+ if (p->attributeName() == u"sizeAdjustPolicy"
+ && customWidgetsInfo->extends(className, "QComboBox")
+ && p->elementEnum() == u"QComboBox::AdjustToMinimumContentsLength") {
+ const QString msg = fileName + ": Warning: Deprecated enum value QComboBox::AdjustToMinimumContentsLength was encountered."_L1;
+ qWarning("%s", qPrintable(msg));
+ return false;
+ }
+ break;
case DomProperty::IconSet:
if (const DomResourceIcon *dri = p->elementIconSet()) {
if (!isIconFormat44(dri)) {
@@ -181,6 +196,15 @@ FontHandle::FontHandle(const DomFont *domFont) :
{
}
+static QString fontWeight(const DomFont *domFont)
+{
+ if (domFont->hasElementFontWeight())
+ return domFont->elementFontWeight();
+ if (domFont->hasElementBold())
+ return domFont->elementBold() ? u"Bold"_s : u"Normal"_s;
+ return {};
+}
+
int FontHandle::compare(const FontHandle &rhs) const
{
const QString family = m_domFont->hasElementFamily() ? m_domFont->elementFamily() : QString();
@@ -195,10 +219,10 @@ int FontHandle::compare(const FontHandle &rhs) const
if (const int crc = compareInt(pointSize, rhsPointSize))
return crc;
- const int bold = m_domFont->hasElementBold() ? (m_domFont->elementBold() ? 1 : 0) : -1;
- const int rhsBold = rhs.m_domFont->hasElementBold() ? (rhs.m_domFont->elementBold() ? 1 : 0) : -1;
- if (const int crc = compareInt(bold, rhsBold))
- return crc;
+ const QString fontWeight = CPP::fontWeight(m_domFont);
+ const QString rhsFontWeight = CPP::fontWeight(rhs.m_domFont);
+ if (const int wrc = fontWeight.compare(rhsFontWeight))
+ return wrc;
const int italic = m_domFont->hasElementItalic() ? (m_domFont->elementItalic() ? 1 : 0) : -1;
const int rhsItalic = rhs.m_domFont->hasElementItalic() ? (rhs.m_domFont->elementItalic() ? 1 : 0) : -1;
@@ -210,11 +234,6 @@ int FontHandle::compare(const FontHandle &rhs) const
if (const int crc = compareInt(underline, rhsUnderline))
return crc;
- const int weight = m_domFont->hasElementWeight() ? m_domFont->elementWeight() : -1;
- const int rhsWeight = rhs.m_domFont->hasElementWeight() ? rhs.m_domFont->elementWeight() : -1;
- if (const int crc = compareInt(weight, rhsWeight))
- return crc;
-
const int strikeOut = m_domFont->hasElementStrikeOut() ? (m_domFont->elementStrikeOut() ? 1 : 0) : -1;
const int rhsStrikeOut = rhs.m_domFont->hasElementStrikeOut() ? (rhs.m_domFont->elementStrikeOut() ? 1 : 0) : -1;
if (const int crc = compareInt(strikeOut, rhsStrikeOut))
@@ -236,6 +255,13 @@ int FontHandle::compare(const FontHandle &rhs) const
if (const int src = styleStrategy.compare(rhsStyleStrategy))
return src;
+ const QString hintingPreference = m_domFont->hasElementHintingPreference()
+ ? m_domFont->elementHintingPreference() : QString();
+ const QString rhsHintingPreference = rhs.m_domFont->hasElementHintingPreference()
+ ? rhs.m_domFont->elementHintingPreference() : QString();
+ if (const int src = hintingPreference.compare(rhsHintingPreference))
+ return src;
+
return 0;
}
@@ -366,12 +392,12 @@ void WriteInitialization::LayoutDefaultHandler::acceptLayoutFunction(DomLayoutFu
if (node->hasAttributeMargin()) {
m_state[Margin] |= HasDefaultFunction;
m_functions[Margin] = node->attributeMargin();
- m_functions[Margin] += QLatin1String("()");
+ m_functions[Margin] += "()"_L1;
}
if (node->hasAttributeSpacing()) {
m_state[Spacing] |= HasDefaultFunction;
m_functions[Spacing] = node->attributeSpacing();
- m_functions[Spacing] += QLatin1String("()");
+ m_functions[Spacing] += "()"_L1;
}
}
@@ -379,7 +405,7 @@ static inline void writeContentsMargins(const QString &indent, const QString &ob
{
QString contentsMargins;
QTextStream(&contentsMargins) << value << ", " << value << ", " << value << ", " << value;
- writeSetter(indent, objectName, QLatin1String("setContentsMargins"), contentsMargins, str);
+ writeSetter(indent, objectName, "setContentsMargins"_L1, contentsMargins, str);
}
void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QString &indent, const QString &objectName,
@@ -433,11 +459,11 @@ void WriteInitialization::LayoutDefaultHandler::writeProperties(const QString &i
// Write out properties and ignore the ones found in
// subsequent writing of the property list.
int defaultSpacing = marginType == WriteInitialization::Use43UiFile ? -1 : 6;
- writeProperty(Spacing, indent, varName, properties, QLatin1String("spacing"), QLatin1String("setSpacing"),
+ writeProperty(Spacing, indent, varName, properties, "spacing"_L1, "setSpacing"_L1,
defaultSpacing, false, str);
// We use 9 as TopLevelMargin, since Designer seem to always use 9.
static const int layoutmargins[4] = {-1, 9, 9, 0};
- writeProperty(Margin, indent, varName, properties, QLatin1String("margin"), QLatin1String("setMargin"),
+ writeProperty(Margin, indent, varName, properties, "margin"_L1, "setMargin"_L1,
layoutmargins[marginType], suppressMarginDefault, str);
}
@@ -496,16 +522,16 @@ void WriteInitialization::acceptUI(DomUI *node)
const QString widgetClassName = node->elementWidget()->attributeClass();
- const QString parameterType = widgetClassName + QLatin1String(" *");
+ const QString parameterType = widgetClassName + " *"_L1;
m_output << m_option.indent
<< language::startFunctionDefinition1("setupUi", parameterType, varName, m_option.indent);
const QStringList connections = m_uic->databaseInfo()->connections();
for (const auto &connection : connections) {
- if (connection == QLatin1String("(default)"))
+ if (connection == "(default)"_L1)
continue;
- const QString varConn = connection + QLatin1String("Connection");
+ const QString varConn = connection + "Connection"_L1;
m_output << m_indent << varConn << " = QSqlDatabase::database("
<< language::charliteral(connection, m_dindent) << ")" << language::eol;
}
@@ -514,7 +540,7 @@ void WriteInitialization::acceptUI(DomUI *node)
if (!m_buddies.empty())
m_output << language::openQtConfig(shortcutConfigKey());
- for (const Buddy &b : qAsConst(m_buddies)) {
+ for (const Buddy &b : std::as_const(m_buddies)) {
const QString buddyVarName = m_driver->widgetVariableName(b.buddyAttributeName);
if (buddyVarName.isEmpty()) {
fprintf(stderr, "%s: Warning: Buddy assignment: '%s' is not a valid widget.\n",
@@ -555,13 +581,13 @@ void WriteInitialization::acceptUI(DomUI *node)
if (language::language() == Language::Cpp) {
// Mark varName as unused to avoid compiler warnings.
m_refreshInitialization += m_indent;
- m_refreshInitialization += QLatin1String("(void)");
+ m_refreshInitialization += "(void)"_L1;
m_refreshInitialization += varName ;
m_refreshInitialization += language::eol;
} else if (language::language() == Language::Python) {
// output a 'pass' to have an empty function
m_refreshInitialization += m_indent;
- m_refreshInitialization += QLatin1String("pass");
+ m_refreshInitialization += "pass"_L1;
m_refreshInitialization += language::eol;
}
}
@@ -584,7 +610,7 @@ void WriteInitialization::addWizardPage(const QString &pageVarName, const DomWid
const auto &attributes = page->elementAttribute();
if (!attributes.empty()) {
for (const DomProperty *p : attributes) {
- if (p->attributeName() == QLatin1String("pageId")) {
+ if (p->attributeName() == "pageId"_L1) {
if (const DomString *ds = p->elementString())
id = ds->text();
break;
@@ -602,7 +628,7 @@ void WriteInitialization::addWizardPage(const QString &pageVarName, const DomWid
void WriteInitialization::acceptWidget(DomWidget *node)
{
- m_layoutMarginType = m_widgetChain.count() == 1 ? TopLevelMargin : ChildMargin;
+ m_layoutMarginType = m_widgetChain.size() == 1 ? TopLevelMargin : ChildMargin;
const QString className = node->attributeClass();
const QString varName = m_driver->findOrInsertWidget(node);
@@ -628,13 +654,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);
}
@@ -644,7 +670,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);
}
@@ -652,10 +678,10 @@ void WriteInitialization::acceptWidget(DomWidget *node)
m_layoutChain.push(nullptr);
m_layoutWidget = false;
- if (className == QLatin1String("QWidget") && !node->hasAttributeNative()) {
+ if (className == "QWidget"_L1 && !node->hasAttributeNative()) {
if (const DomWidget* parentWidget = m_widgetChain.top()) {
const QString parentClass = parentWidget->attributeClass();
- if (parentClass != QLatin1String("QMainWindow")
+ if (parentClass != "QMainWindow"_L1
&& !m_uic->customWidgetsInfo()->isCustomWidgetContainer(parentClass)
&& !m_uic->isContainer(parentClass))
m_layoutWidget = true;
@@ -670,32 +696,32 @@ void WriteInitialization::acceptWidget(DomWidget *node)
const DomPropertyMap attributes = propertyMap(node->elementAttribute());
- const QString pageDefaultString = QLatin1String("Page");
+ const QString pageDefaultString = u"Page"_s;
- 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;
- if (const DomProperty *pbreak = attributes.value(QLatin1String("toolBarBreak"))) {
- if (pbreak->elementBool() == QLatin1String("true")) {
+ if (const DomProperty *pbreak = attributes.value("toolBarBreak"_L1)) {
+ if (pbreak->elementBool() == "true"_L1) {
m_output << m_indent << parentWidget << language::derefPointer
<< "insertToolBarBreak(" << varName << ')' << language::eol;
}
}
- } 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()) << ", ";
+ if (DomProperty *pstyle = attributes.value("dockWidgetArea"_L1)) {
+ QString a = expandDockWidgetArea(language::dockWidgetArea(pstyle->elementNumber()));
+ m_output << language::enumValue(a) << ", ";
}
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 {
@@ -711,14 +737,14 @@ 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"))) {
- const DomProperty *plabel = attributes.value(QLatin1String("label"));
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, "QToolBox")) {
+ const DomProperty *plabel = attributes.value("label"_L1);
DomString *plabelString = plabel ? plabel->elementString() : nullptr;
QString icon;
- if (const DomProperty *picon = attributes.value(QLatin1String("icon")))
- icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition
+ if (const DomProperty *picon = attributes.value("icon"_L1))
+ icon = ", "_L1 + iconCall(picon); // Side effect: Writes icon definition
m_output << m_indent << parentWidget << language::derefPointer << "addItem("
<< varName << icon << ", " << noTrCall(plabelString, pageDefaultString)
<< ')' << language::eol;
@@ -728,7 +754,7 @@ void WriteInitialization::acceptWidget(DomWidget *node)
<< language::derefPointer << "indexOf(" << varName << "), "
<< autoTrCall(plabelString, pageDefaultString) << ')' << language::eol;
- if (DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) {
+ if (DomProperty *ptoolTip = attributes.value("toolTip"_L1)) {
autoTrOutput(ptoolTip->elementString())
<< language::openQtConfig(toolTipConfigKey())
<< m_indent << parentWidget << language::derefPointer << "setItemToolTip(" << parentWidget
@@ -736,12 +762,12 @@ void WriteInitialization::acceptWidget(DomWidget *node)
<< autoTrCall(ptoolTip->elementString()) << ')' << language::eol
<< language::closeQtConfig(toolTipConfigKey());
}
- } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QTabWidget"))) {
- const DomProperty *ptitle = attributes.value(QLatin1String("title"));
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, "QTabWidget")) {
+ const DomProperty *ptitle = attributes.value("title"_L1);
DomString *ptitleString = ptitle ? ptitle->elementString() : nullptr;
QString icon;
- if (const DomProperty *picon = attributes.value(QLatin1String("icon")))
- icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition
+ if (const DomProperty *picon = attributes.value("icon"_L1))
+ icon = ", "_L1 + iconCall(picon); // Side effect: Writes icon definition
m_output << m_indent << parentWidget << language::derefPointer << "addTab("
<< varName << icon << ", " << language::emptyString << ')' << language::eol;
@@ -750,7 +776,7 @@ void WriteInitialization::acceptWidget(DomWidget *node)
<< language::derefPointer << "indexOf(" << varName << "), "
<< autoTrCall(ptitleString, pageDefaultString) << ')' << language::eol;
- if (const DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) {
+ if (const DomProperty *ptoolTip = attributes.value("toolTip"_L1)) {
autoTrOutput(ptoolTip->elementString())
<< language::openQtConfig(toolTipConfigKey())
<< m_indent << parentWidget << language::derefPointer << "setTabToolTip("
@@ -758,7 +784,7 @@ void WriteInitialization::acceptWidget(DomWidget *node)
<< "), " << autoTrCall(ptoolTip->elementString()) << ')' << language::eol
<< language::closeQtConfig(toolTipConfigKey());
}
- if (const DomProperty *pwhatsThis = attributes.value(QLatin1String("whatsThis"))) {
+ if (const DomProperty *pwhatsThis = attributes.value("whatsThis"_L1)) {
autoTrOutput(pwhatsThis->elementString())
<< language::openQtConfig(whatsThisConfigKey())
<< m_indent << parentWidget << language::derefPointer << "setTabWhatsThis("
@@ -771,41 +797,41 @@ void WriteInitialization::acceptWidget(DomWidget *node)
//
// Special handling for qtableview/qtreeview fake header attributes
//
- static const QLatin1String realPropertyNames[] = {
- QLatin1String("visible"),
- QLatin1String("cascadingSectionResizes"),
- QLatin1String("minimumSectionSize"), // before defaultSectionSize
- QLatin1String("defaultSectionSize"),
- QLatin1String("highlightSections"),
- QLatin1String("showSortIndicator"),
- QLatin1String("stretchLastSection"),
+ static const QLatin1StringView realPropertyNames[] = {
+ "visible"_L1,
+ "cascadingSectionResizes"_L1,
+ "minimumSectionSize"_L1, // before defaultSectionSize
+ "defaultSectionSize"_L1,
+ "highlightSections"_L1,
+ "showSortIndicator"_L1,
+ "stretchLastSection"_L1,
};
static const QStringList trees = {
- QLatin1String("QTreeView"), QLatin1String("QTreeWidget")
+ u"QTreeView"_s, u"QTreeWidget"_s
};
static const QStringList tables = {
- QLatin1String("QTableView"), QLatin1String("QTableWidget")
+ u"QTableView"_s, u"QTableWidget"_s
};
if (cwi->extendsOneOf(className, trees)) {
DomPropertyList headerProperties;
for (auto realPropertyName : realPropertyNames) {
- const QString fakePropertyName = QLatin1String("header")
+ const QString fakePropertyName = "header"_L1
+ QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1);
if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
fakeProperty->setAttributeName(realPropertyName);
headerProperties << fakeProperty;
}
}
- writeProperties(varName + language::derefPointer + QLatin1String("header()"),
- QLatin1String("QHeaderView"), headerProperties,
+ writeProperties(varName + language::derefPointer + "header()"_L1,
+ "QHeaderView"_L1, headerProperties,
WritePropertyIgnoreObjectName);
} else if (cwi->extendsOneOf(className, tables)) {
- static const QLatin1String headerPrefixes[] = {
- QLatin1String("horizontalHeader"),
- QLatin1String("verticalHeader"),
+ static const QLatin1StringView headerPrefixes[] = {
+ "horizontalHeader"_L1,
+ "verticalHeader"_L1,
};
for (auto headerPrefix : headerPrefixes) {
@@ -819,8 +845,8 @@ void WriteInitialization::acceptWidget(DomWidget *node)
}
}
const QString headerVar = varName + language::derefPointer
- + headerPrefix + QLatin1String("()");
- writeProperties(headerVar, QLatin1String("QHeaderView"),
+ + headerPrefix + "()"_L1;
+ writeProperties(headerVar, "QHeaderView"_L1,
headerProperties, WritePropertyIgnoreObjectName);
}
}
@@ -846,7 +872,7 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr
{
const DomPropertyMap attributes = propertyMap(buttonNode->elementAttribute());
// Look up the button group name as specified in the attribute and find the uniquified name
- const DomProperty *prop = attributes.value(QLatin1String("buttonGroup"));
+ const DomProperty *prop = attributes.value("buttonGroup"_L1);
if (!prop)
return;
const QString attributeName = toString(prop->elementString());
@@ -865,7 +891,7 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr
const QString groupName = m_driver->findOrInsertButtonGroup(group);
// Create on demand
if (!m_buttonGroups.contains(groupName)) {
- const QString className = QLatin1String("QButtonGroup");
+ const QString className = u"QButtonGroup"_s;
m_output << m_indent;
if (createGroupOnTheFly)
m_output << className << " *";
@@ -884,7 +910,7 @@ void WriteInitialization::acceptLayout(DomLayout *node)
const QString varName = m_driver->findOrInsertLayout(node);
const DomPropertyMap properties = propertyMap(node->elementProperty());
- const bool oldLayoutProperties = properties.value(QLatin1String("margin")) != nullptr;
+ const bool oldLayoutProperties = properties.value("margin"_L1) != nullptr;
bool isGroupBox = false;
@@ -911,36 +937,36 @@ void WriteInitialization::acceptLayout(DomLayout *node)
left = top = right = bottom = false;
for (const DomProperty *p : propList) {
const QString propertyName = p->attributeName();
- if (propertyName == QLatin1String("leftMargin") && p->kind() == DomProperty::Number)
+ if (propertyName == "leftMargin"_L1 && p->kind() == DomProperty::Number)
left = true;
- else if (propertyName == QLatin1String("topMargin") && p->kind() == DomProperty::Number)
+ else if (propertyName == "topMargin"_L1 && p->kind() == DomProperty::Number)
top = true;
- else if (propertyName == QLatin1String("rightMargin") && p->kind() == DomProperty::Number)
+ else if (propertyName == "rightMargin"_L1 && p->kind() == DomProperty::Number)
right = true;
- else if (propertyName == QLatin1String("bottomMargin") && p->kind() == DomProperty::Number)
+ else if (propertyName == "bottomMargin"_L1 && p->kind() == DomProperty::Number)
bottom = true;
}
if (!left) {
DomProperty *p = new DomProperty();
- p->setAttributeName(QLatin1String("leftMargin"));
+ p->setAttributeName("leftMargin"_L1);
p->setElementNumber(0);
newPropList.append(p);
}
if (!top) {
DomProperty *p = new DomProperty();
- p->setAttributeName(QLatin1String("topMargin"));
+ p->setAttributeName("topMargin"_L1);
p->setElementNumber(0);
newPropList.append(p);
}
if (!right) {
DomProperty *p = new DomProperty();
- p->setAttributeName(QLatin1String("rightMargin"));
+ p->setAttributeName("rightMargin"_L1);
p->setElementNumber(0);
newPropList.append(p);
}
if (!bottom) {
DomProperty *p = new DomProperty();
- p->setAttributeName(QLatin1String("bottomMargin"));
+ p->setAttributeName("bottomMargin"_L1);
p->setElementNumber(0);
newPropList.append(p);
}
@@ -961,12 +987,12 @@ void WriteInitialization::acceptLayout(DomLayout *node)
m_layoutChain.pop();
// Stretch? (Unless we are compiling for UIC3)
- const QString numberNull = QString(QLatin1Char('0'));
- writePropertyList(varName, QLatin1String("setStretch"), node->attributeStretch(), numberNull);
- writePropertyList(varName, QLatin1String("setRowStretch"), node->attributeRowStretch(), numberNull);
- writePropertyList(varName, QLatin1String("setColumnStretch"), node->attributeColumnStretch(), numberNull);
- writePropertyList(varName, QLatin1String("setColumnMinimumWidth"), node->attributeColumnMinimumWidth(), numberNull);
- writePropertyList(varName, QLatin1String("setRowMinimumHeight"), node->attributeRowMinimumHeight(), numberNull);
+ const QString numberNull(u'0');
+ writePropertyList(varName, "setStretch"_L1, node->attributeStretch(), numberNull);
+ writePropertyList(varName, "setRowStretch"_L1, node->attributeRowStretch(), numberNull);
+ writePropertyList(varName, "setColumnStretch"_L1, node->attributeColumnStretch(), numberNull);
+ writePropertyList(varName, "setColumnMinimumWidth"_L1, node->attributeColumnMinimumWidth(), numberNull);
+ writePropertyList(varName, "setRowMinimumHeight"_L1, node->attributeRowMinimumHeight(), numberNull);
}
// Apply a comma-separated list of values using a function "setSomething(int idx, value)"
@@ -977,8 +1003,8 @@ void WriteInitialization::writePropertyList(const QString &varName,
{
if (value.isEmpty())
return;
- const QStringList list = value.split(QLatin1Char(','));
- const int count = list.count();
+ const QStringList list = value.split(u',');
+ const int count = list.size();
for (int i = 0; i < count; i++) {
if (list.at(i) != defaultValue) {
m_output << m_indent << varName << language::derefPointer << setFunction
@@ -997,21 +1023,20 @@ void WriteInitialization::acceptSpacer(DomSpacer *node)
static inline QString formLayoutRole(int column, int colspan)
{
if (colspan > 1)
- return QLatin1String("QFormLayout::SpanningRole");
- return column == 0 ? QLatin1String("QFormLayout::LabelRole") : QLatin1String("QFormLayout::FieldRole");
+ return "QFormLayout::SpanningRole"_L1;
+ return column == 0 ? "QFormLayout::LabelRole"_L1 : "QFormLayout::FieldRole"_L1;
}
static QString layoutAddMethod(DomLayoutItem::Kind kind, const QString &layoutClass)
{
- const QString methodPrefix = layoutClass == QLatin1String("QFormLayout")
- ? QLatin1String("set") : QLatin1String("add");
+ const auto methodPrefix = layoutClass == "QFormLayout"_L1 ? "set"_L1 : "add"_L1;
switch (kind) {
case DomLayoutItem::Widget:
- return methodPrefix + QLatin1String("Widget");
+ return methodPrefix + "Widget"_L1;
case DomLayoutItem::Layout:
- return methodPrefix + QLatin1String("Layout");
+ return methodPrefix + "Layout"_L1;
case DomLayoutItem::Spacer:
- return methodPrefix + QLatin1String("Item");
+ return methodPrefix + "Item"_L1;
case DomLayoutItem::Unknown:
Q_ASSERT( false );
break;
@@ -1034,7 +1059,7 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node)
m_output << "\n" << m_indent << layoutName << language::derefPointer << ""
<< layoutAddMethod(node->kind(), layout->attributeClass()) << '(';
- if (layout->attributeClass() == QLatin1String("QGridLayout")) {
+ if (layout->attributeClass() == "QGridLayout"_L1) {
const int row = node->attributeRow();
const int col = node->attributeColumn();
@@ -1043,14 +1068,14 @@ void WriteInitialization::acceptLayoutItem(DomLayoutItem *node)
m_output << itemName << ", " << row << ", " << col << ", " << rowSpan << ", " << colSpan;
if (!node->attributeAlignment().isEmpty())
m_output << ", " << language::enumValue(node->attributeAlignment());
- } else if (layout->attributeClass() == QLatin1String("QFormLayout")) {
+ } else if (layout->attributeClass() == "QFormLayout"_L1) {
const int row = node->attributeRow();
const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1;
const QString role = formLayoutRole(node->attributeColumn(), colSpan);
m_output << row << ", " << language::enumValue(role) << ", " << itemName;
} else {
m_output << itemName;
- if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty())
+ if (layout->attributeClass().contains("Box"_L1) && !node->attributeAlignment().isEmpty())
m_output << ", 0, " << language::enumValue(node->attributeAlignment());
}
m_output << ")" << language::eol << "\n";
@@ -1066,7 +1091,7 @@ void WriteInitialization::acceptActionGroup(DomActionGroup *node)
m_output << m_indent << actionName << " = " << language::operatorNew
<< "QActionGroup(" << varName << ")" << language::eol;
- writeProperties(actionName, QLatin1String("QActionGroup"), node->elementProperty());
+ writeProperties(actionName, "QActionGroup"_L1, node->elementProperty());
m_actionGroupChain.push(node);
TreeWalker::acceptActionGroup(node);
@@ -1086,7 +1111,7 @@ void WriteInitialization::acceptAction(DomAction *node)
m_output << m_indent << actionName << " = " << language::operatorNew
<< "QAction(" << varName << ')' << language::eol;
- writeProperties(actionName, QLatin1String("QAction"), node->elementProperty());
+ writeProperties(actionName, "QAction"_L1, node->elementProperty());
}
void WriteInitialization::acceptActionRef(DomActionRef *node)
@@ -1099,7 +1124,7 @@ void WriteInitialization::acceptActionRef(DomActionRef *node)
const QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());
- if (m_widgetChain.top() && actionName == QLatin1String("separator")) {
+ if (m_widgetChain.top() && actionName == "separator"_L1) {
// separator is always reserved!
m_actionOut << m_indent << varName << language::derefPointer
<< "addSeparator()" << language::eol;
@@ -1130,35 +1155,50 @@ QString WriteInitialization::writeStringListProperty(const DomStringList *list)
{
QString propertyValue;
QTextStream str(&propertyValue);
- str << "QStringList()";
+ char trailingDelimiter = '}';
+ switch (language::language()) {
+ case Language::Cpp:
+ str << "QStringList{";
+ break;
+ case Language::Python:
+ str << '[';
+ trailingDelimiter = ']';
+ break;
+ }
const QStringList values = list->elementString();
- if (values.isEmpty())
- return propertyValue;
- if (needsTranslation(list)) {
- const QString comment = list->attributeComment();
- for (int i = 0; i < values.size(); ++i)
- str << '\n' << m_indent << " << " << trCall(values.at(i), comment);
- } else {
- for (int i = 0; i < values.size(); ++i)
- str << " << " << language::qstring(values.at(i), m_dindent);
+ if (!values.isEmpty()) {
+ if (needsTranslation(list)) {
+ const QString comment = list->attributeComment();
+ const qsizetype last = values.size() - 1;
+ for (qsizetype i = 0; i <= last; ++i) {
+ str << '\n' << m_indent << " " << trCall(values.at(i), comment);
+ if (i != last)
+ str << ',';
+ }
+ } else {
+ for (qsizetype i = 0; i < values.size(); ++i) {
+ if (i)
+ str << ", ";
+ str << language::qstring(values.at(i), m_dindent);
+ }
+ }
}
+ str << trailingDelimiter;
return propertyValue;
}
static QString configKeyForProperty(const QString &propertyName)
{
- if (propertyName == QLatin1String("toolTip"))
+ if (propertyName == "toolTip"_L1)
return toolTipConfigKey();
- if (propertyName == QLatin1String("whatsThis"))
+ if (propertyName == "whatsThis"_L1)
return whatsThisConfigKey();
- if (propertyName == QLatin1String("statusTip"))
+ if (propertyName == "statusTip"_L1)
return statusTipConfigKey();
- if (propertyName == QLatin1String("shortcut"))
+ if (propertyName == "shortcut"_L1)
return shortcutConfigKey();
- if (propertyName == QLatin1String("accessibleName")
- || propertyName == QLatin1String("accessibleDescription")) {
+ if (propertyName == "accessibleName"_L1 || propertyName == "accessibleDescription"_L1)
return accessibilityConfigKey();
- }
return QString();
}
@@ -1167,11 +1207,11 @@ void WriteInitialization::writeProperties(const QString &varName,
const DomPropertyList &lst,
unsigned flags)
{
- const bool isTopLevel = m_widgetChain.count() == 1;
+ const bool isTopLevel = m_widgetChain.size() == 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"))) {
+ if (DomProperty *p = properties.value("control"_L1)) {
m_output << m_indent << varName << language::derefPointer << "setControl("
<< language::qstring(toString(p->elementString()), m_dindent)
<< ')' << language::eol;
@@ -1196,7 +1236,7 @@ void WriteInitialization::writeProperties(const QString &varName,
objectName.remove(0, language::self.size());
m_output << m_indent << indent
<< varName << language::derefPointer << "setObjectName("
- << language::qstring(objectName, m_dindent) << ')' << language::eol;
+ << language::charliteral(objectName, m_dindent) << ')' << language::eol;
}
int leftMargin, topMargin, rightMargin, bottomMargin;
@@ -1204,65 +1244,65 @@ void WriteInitialization::writeProperties(const QString &varName,
bool frameShadowEncountered = false;
for (const DomProperty *p : lst) {
- if (!checkProperty(m_option.inputFile, p))
+ if (!checkProperty(m_uic->customWidgetsInfo(), m_option.inputFile, className, p))
continue;
QString propertyName = p->attributeName();
QString propertyValue;
bool delayProperty = false;
// special case for the property `geometry': Do not use position
- if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) {
+ if (isTopLevel && propertyName == "geometry"_L1 && p->elementRect()) {
const DomRect *r = p->elementRect();
m_output << m_indent << varName << language::derefPointer << "resize("
<< r->elementWidth() << ", " << r->elementHeight() << ')' << language::eol;
continue;
}
- if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow
- && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) {
+ if (propertyName == "currentRow"_L1 // QListWidget::currentRow
+ && m_uic->customWidgetsInfo()->extends(className, "QListWidget")) {
m_delayedOut << m_indent << varName << language::derefPointer
<< "setCurrentRow(" << p->elementNumber() << ')' << language::eol;
continue;
}
static const QStringList currentIndexWidgets = {
- QLatin1String("QComboBox"), QLatin1String("QStackedWidget"),
- QLatin1String("QTabWidget"), QLatin1String("QToolBox")
+ u"QComboBox"_s, u"QStackedWidget"_s,
+ u"QTabWidget"_s, u"QToolBox"_s
};
- if (propertyName == QLatin1String("currentIndex") // set currentIndex later
+ if (propertyName == "currentIndex"_L1 // set currentIndex later
&& (m_uic->customWidgetsInfo()->extendsOneOf(className, currentIndexWidgets))) {
m_delayedOut << m_indent << varName << language::derefPointer
<< "setCurrentIndex(" << p->elementNumber() << ')' << language::eol;
continue;
}
- if (propertyName == QLatin1String("tabSpacing")
- && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) {
+ if (propertyName == "tabSpacing"_L1
+ && 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"))) {
+ if (propertyName == "control"_L1 // ActiveQt support
+ && m_uic->customWidgetsInfo()->extends(className, "QAxWidget")) {
// already done ;)
continue;
}
- if (propertyName == QLatin1String("default")
- && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))) {
+ if (propertyName == "default"_L1
+ && 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")
+ } else if (propertyName == "database"_L1
&& p->elementStringList()) {
// Sql support
continue;
- } else if (propertyName == QLatin1String("frameworkCode")
+ } else if (propertyName == "frameworkCode"_L1
&& p->kind() == DomProperty::Bool) {
// Sql support
continue;
- } else if (propertyName == QLatin1String("orientation")
- && m_uic->customWidgetsInfo()->extends(className, QLatin1String("Line"))) {
+ } else if (propertyName == "orientation"_L1
+ && m_uic->customWidgetsInfo()->extends(className, "Line")) {
// Line support
- QString shape = QLatin1String("QFrame::HLine");
- if (p->elementEnum() == QLatin1String("Qt::Vertical"))
- shape = QLatin1String("QFrame::VLine");
+ QString shape = u"QFrame::Shape::HLine"_s;
+ if (p->elementEnum().endsWith("::Vertical"_L1))
+ shape = u"QFrame::Shape::VLine"_s;
m_output << m_indent << varName << language::derefPointer << "setFrameShape("
<< language::enumValue(shape) << ')' << language::eol;
@@ -1270,33 +1310,34 @@ void WriteInitialization::writeProperties(const QString &varName,
if (!frameShadowEncountered) {
m_output << m_indent << varName << language::derefPointer
<< "setFrameShadow("
- << language::enumValue(QLatin1String("QFrame::Sunken"))
+ << language::enumValue("QFrame::Shadow::Sunken"_L1)
<< ')' << language::eol;
}
continue;
- } else if ((flags & WritePropertyIgnoreMargin) && propertyName == QLatin1String("margin")) {
+ } else if ((flags & WritePropertyIgnoreMargin) && propertyName == "margin"_L1) {
continue;
- } else if ((flags & WritePropertyIgnoreSpacing) && propertyName == QLatin1String("spacing")) {
+ } else if ((flags & WritePropertyIgnoreSpacing) && propertyName == "spacing"_L1) {
continue;
- } else if (propertyName == QLatin1String("leftMargin") && p->kind() == DomProperty::Number) {
+ } else if (propertyName == "leftMargin"_L1 && p->kind() == DomProperty::Number) {
leftMargin = p->elementNumber();
continue;
- } else if (propertyName == QLatin1String("topMargin") && p->kind() == DomProperty::Number) {
+ } else if (propertyName == "topMargin"_L1 && p->kind() == DomProperty::Number) {
topMargin = p->elementNumber();
continue;
- } else if (propertyName == QLatin1String("rightMargin") && p->kind() == DomProperty::Number) {
+ } else if (propertyName == "rightMargin"_L1 && p->kind() == DomProperty::Number) {
rightMargin = p->elementNumber();
continue;
- } else if (propertyName == QLatin1String("bottomMargin") && p->kind() == DomProperty::Number) {
+ } else if (propertyName == "bottomMargin"_L1 && p->kind() == DomProperty::Number) {
bottomMargin = p->elementNumber();
continue;
- } else if (propertyName == QLatin1String("numDigits") // Deprecated in Qt 4, removed in Qt 5.
- && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QLCDNumber"))) {
+ } else if (propertyName == "numDigits"_L1 // Deprecated in Qt 4, removed in Qt 5.
+ && 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");
- } else if (propertyName == QLatin1String("frameShadow"))
+ propertyName = "digitCount"_L1;
+ } else if (propertyName == "frameShadow"_L1) {
frameShadowEncountered = true;
+ }
bool stdset = m_stdsetdef;
if (p->hasAttributeStdset())
@@ -1310,7 +1351,7 @@ void WriteInitialization::writeProperties(const QString &varName,
str << language::derefPointer <<"set" << propertyName.at(0).toUpper()
<< QStringView{propertyName}.mid(1) << '(';
} else {
- str << language::derefPointer << QLatin1String("setProperty(\"")
+ str << language::derefPointer << "setProperty(\""_L1
<< propertyName << "\", ";
if (language::language() == Language::Cpp) {
str << "QVariant";
@@ -1332,15 +1373,16 @@ 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 == "buddy"_L1 && m_uic->customWidgetsInfo()->extends(className, "QLabel")) {
Buddy buddy = { varName, p->elementCstring() };
m_buddies.append(std::move(buddy));
} else {
+ const bool useQByteArray = !stdset && language::language() == Language::Cpp;
QTextStream str(&propertyValue);
- if (!stdset)
+ if (useQByteArray)
str << "QByteArray(";
str << language::charliteral(p->elementCstring(), m_dindent);
- if (!stdset)
+ if (useQByteArray)
str << ')';
}
break;
@@ -1350,9 +1392,9 @@ void WriteInitialization::writeProperties(const QString &varName,
break;
case DomProperty::CursorShape:
if (p->hasAttributeStdset() && !p->attributeStdset())
- varNewName += language::derefPointer + QLatin1String("viewport()");
- propertyValue = QLatin1String("QCursor(Qt") + language::qualifier
- + p->elementCursorShape() + QLatin1Char(')');
+ varNewName += language::derefPointer + "viewport()"_L1;
+ propertyValue = "QCursor(Qt"_L1 + language::qualifier + "CursorShape"_L1
+ + language::qualifier + p->elementCursorShape() + u')';
break;
case DomProperty::Enum:
propertyValue = p->elementEnum();
@@ -1375,12 +1417,12 @@ void WriteInitialization::writeProperties(const QString &varName,
break;
case DomProperty::Palette: {
const DomPalette *pal = p->elementPalette();
- const QString paletteName = m_driver->unique(QLatin1String("palette"));
+ const QString paletteName = m_driver->unique("palette"_L1);
m_output << m_indent << language::stackVariable("QPalette", paletteName)
<< language::eol;
- writeColorGroup(pal->elementActive(), QLatin1String("QPalette::Active"), paletteName);
- writeColorGroup(pal->elementInactive(), QLatin1String("QPalette::Inactive"), paletteName);
- writeColorGroup(pal->elementDisabled(), QLatin1String("QPalette::Disabled"), paletteName);
+ writeColorGroup(pal->elementActive(), "QPalette::Active"_L1, paletteName);
+ writeColorGroup(pal->elementInactive(), "QPalette::Inactive"_L1, paletteName);
+ writeColorGroup(pal->elementDisabled(), "QPalette::Disabled"_L1, paletteName);
propertyValue = paletteName;
break;
@@ -1440,7 +1482,7 @@ void WriteInitialization::writeProperties(const QString &varName,
break;
}
case DomProperty::String: {
- if (propertyName == QLatin1String("objectName")) {
+ if (propertyName == "objectName"_L1) {
const QString v = p->elementString()->text();
if (v == varName)
break;
@@ -1456,17 +1498,17 @@ void WriteInitialization::writeProperties(const QString &varName,
break;
case DomProperty::UInt:
propertyValue = QString::number(p->elementUInt());
- propertyValue += QLatin1Char('u');
+ propertyValue += u'u';
break;
case DomProperty::LongLong:
- propertyValue = QLatin1String("Q_INT64_C(");
+ propertyValue = "Q_INT64_C("_L1;
propertyValue += QString::number(p->elementLongLong());
- propertyValue += QLatin1Char(')');;
+ propertyValue += u')';
break;
case DomProperty::ULongLong:
- propertyValue = QLatin1String("Q_UINT64_C(");
+ propertyValue = "Q_UINT64_C("_L1;
propertyValue += QString::number(p->elementULongLong());
- propertyValue += QLatin1Char(')');
+ propertyValue += u')';
break;
case DomProperty::Float:
propertyValue = QString::number(p->elementFloat(), 'f', 8);
@@ -1564,16 +1606,22 @@ QString WriteInitialization::writeSizePolicy(const DomSizePolicy *sp)
// insert with new name
- const QString spName = m_driver->unique(QLatin1String("sizePolicy"));
+ const QString spName = m_driver->unique("sizePolicy"_L1);
m_sizePolicyNameMap.insert(sizePolicyHandle, spName);
m_output << m_indent << language::stackVariableWithInitParameters("QSizePolicy", spName);
+ QString horizPolicy;
+ QString vertPolicy;
if (sp->hasElementHSizeType() && sp->hasElementVSizeType()) {
- m_output << "QSizePolicy" << language::qualifier << language::sizePolicy(sp->elementHSizeType())
- << ", QSizePolicy" << language::qualifier << language::sizePolicy(sp->elementVSizeType());
+ horizPolicy = language::sizePolicy(sp->elementHSizeType());
+ vertPolicy = language::sizePolicy(sp->elementVSizeType());
} else if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) {
- m_output << "QSizePolicy" << language::qualifier << sp->attributeHSizeType()
- << ", QSizePolicy" << language::qualifier << sp->attributeVSizeType();
+ horizPolicy = sp->attributeHSizeType();
+ vertPolicy = sp->attributeVSizeType();
+ }
+ if (!horizPolicy.isEmpty() && !vertPolicy.isEmpty()) {
+ m_output << language::enumValue(expandSizePolicyEnum(horizPolicy))
+ << ", " << language::enumValue(expandSizePolicyEnum(vertPolicy));
}
m_output << ')' << language::eol;
@@ -1596,24 +1644,30 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
}
// insert with new name
- const QString fontName = m_driver->unique(QLatin1String("font"));
+ const QString fontName = m_driver->unique("font"_L1);
m_fontPropertiesNameMap.insert(FontHandle(f), fontName);
m_output << m_indent << language::stackVariable("QFont", fontName)
<< language::eol;
if (f->hasElementFamily() && !f->elementFamily().isEmpty()) {
- m_output << m_indent << fontName << ".setFamilies(QStringList{"
- << language::qstring(f->elementFamily(), m_dindent) << "})" << language::eol;
+ m_output << m_indent << fontName << ".setFamilies("
+ << language::listStart
+ << language::qstring(f->elementFamily(), m_dindent)
+ << language::listEnd << ')' << language::eol;
}
if (f->hasElementPointSize() && f->elementPointSize() > 0) {
m_output << m_indent << fontName << ".setPointSize(" << f->elementPointSize()
<< ")" << language::eol;
}
- if (f->hasElementBold()) {
+ if (f->hasElementFontWeight()) {
+ m_output << m_indent << fontName << ".setWeight(QFont"
+ << language::qualifier << f->elementFontWeight() << ')' << language::eol;
+ } else if (f->hasElementBold()) {
m_output << m_indent << fontName << ".setBold("
<< language::boolValue(f->elementBold()) << ')' << language::eol;
}
+
if (f->hasElementItalic()) {
m_output << m_indent << fontName << ".setItalic("
<< language::boolValue(f->elementItalic()) << ')' << language::eol;
@@ -1640,6 +1694,11 @@ QString WriteInitialization::writeFontProperties(const DomFont *f)
m_output << m_indent << fontName << ".setStyleStrategy(QFont"
<< language::qualifier << f->elementStyleStrategy() << ')' << language::eol;
}
+ if (f->hasElementHintingPreference()) {
+ m_output << m_indent << fontName << ".setHintingPreference(QFont"
+ << language::qualifier << f->elementHintingPreference() << ')' << language::eol;
+ }
+
return fontName;
}
@@ -1649,8 +1708,9 @@ static void writeIconAddFile(QTextStream &output, const QString &indent,
{
output << indent << iconName << ".addFile("
<< language::qstring(fileName, indent) << ", QSize(), QIcon"
- << language::qualifier << mode << ", QIcon" << language::qualifier
- << state << ')' << language::eol;
+ << language::qualifier << "Mode" << language::qualifier << mode
+ << ", QIcon" << language::qualifier << "State" << language::qualifier << state
+ << ')' << language::eol;
}
// Post 4.4 write resource icon
@@ -1698,7 +1758,8 @@ static void writeIconAddPixmap(QTextStream &output, const QString &indent,
const char *mode, const char *state)
{
output << indent << iconName << ".addPixmap(" << call << ", QIcon"
- << language::qualifier << mode << ", QIcon" << language::qualifier
+ << language::qualifier << "Mode" << language::qualifier << mode
+ << ", QIcon" << language::qualifier << "State" << language::qualifier
<< state << ')' << language::eol;
}
@@ -1709,46 +1770,99 @@ void WriteInitialization::writePixmapFunctionIcon(QTextStream &output,
{
if (i->hasElementNormalOff()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementNormalOff()->text()),
+ pixCall("QPixmap"_L1, i->elementNormalOff()->text()),
"Normal", "Off");
}
if (i->hasElementNormalOn()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementNormalOn()->text()),
+ pixCall("QPixmap"_L1, i->elementNormalOn()->text()),
"Normal", "On");
}
if (i->hasElementDisabledOff()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementDisabledOff()->text()),
+ pixCall("QPixmap"_L1, i->elementDisabledOff()->text()),
"Disabled", "Off");
}
if (i->hasElementDisabledOn()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementDisabledOn()->text()),
+ pixCall("QPixmap"_L1, i->elementDisabledOn()->text()),
"Disabled", "On");
}
if (i->hasElementActiveOff()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementActiveOff()->text()),
+ pixCall("QPixmap"_L1, i->elementActiveOff()->text()),
"Active", "Off");
}
if (i->hasElementActiveOn()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementActiveOn()->text()),
+ pixCall("QPixmap"_L1, i->elementActiveOn()->text()),
"Active", "On");
}
if (i->hasElementSelectedOff()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementSelectedOff()->text()),
+ pixCall("QPixmap"_L1, i->elementSelectedOff()->text()),
"Selected", "Off");
}
if (i->hasElementSelectedOn()) {
writeIconAddPixmap(output, indent, iconName,
- pixCall(QLatin1String("QPixmap"), i->elementSelectedOn()->text()),
+ pixCall("QPixmap"_L1, i->elementSelectedOn()->text()),
"Selected", "On");
}
}
+// Write QIcon::fromTheme() (value from enum or variable)
+struct iconFromTheme
+{
+ explicit iconFromTheme(const QString &theme) : m_theme(theme) {}
+
+ QString m_theme;
+};
+
+QTextStream &operator<<(QTextStream &str, const iconFromTheme &i)
+{
+ str << "QIcon" << language::qualifier << "fromTheme(" << i.m_theme << ')';
+ return str;
+}
+
+// Write QIcon::fromTheme() for an XDG icon from string literal
+struct iconFromThemeStringLiteral
+{
+ explicit iconFromThemeStringLiteral(const QString &theme) : m_theme(theme) {}
+
+ QString m_theme;
+};
+
+QTextStream &operator<<(QTextStream &str, const iconFromThemeStringLiteral &i)
+{
+ str << "QIcon" << language::qualifier << "fromTheme(" << language::qstring(i.m_theme) << ')';
+ return str;
+}
+
+// Write QIcon::fromTheme() with a path as fallback, add a check using
+// QIcon::hasThemeIcon().
+void WriteInitialization::writeThemeIconCheckAssignment(const QString &themeValue,
+ const QString &iconName,
+ const DomResourceIcon *i)
+
+{
+ const bool isCpp = language::language() == Language::Cpp;
+ m_output << m_indent << "if ";
+ if (isCpp)
+ m_output << '(';
+ m_output << "QIcon" << language::qualifier << "hasThemeIcon("
+ << themeValue << ')' << (isCpp ? ") {" : ":") << '\n'
+ << m_dindent << iconName << " = " << iconFromTheme(themeValue)
+ << language::eol;
+ m_output << m_indent << (isCpp ? "} else {" : "else:") << '\n';
+ if (m_uic->pixmapFunction().isEmpty())
+ writeResourceIcon(m_output, iconName, m_dindent, i);
+ else
+ writePixmapFunctionIcon(m_output, iconName, m_dindent, i);
+ if (isCpp)
+ m_output << m_indent << '}';
+ m_output << '\n';
+}
+
QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
{
// check cache
@@ -1758,7 +1872,7 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
return it.value();
// insert with new name
- const QString iconName = m_driver->unique(QLatin1String("icon"));
+ const QString iconName = m_driver->unique("icon"_L1);
m_iconPropertiesNameMap.insert(IconHandle(i), iconName);
const bool isCpp = language::language() == Language::Cpp;
@@ -1767,13 +1881,14 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
m_output << m_indent;
if (isCpp)
m_output << "const QIcon ";
- m_output << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())
+ m_output << iconName << " = " << pixCall("QIcon"_L1, i->text())
<< language::eol;
return iconName;
}
// 4.4 onwards
- if (i->attributeTheme().isEmpty()) {
+ QString theme = i->attributeTheme();
+ if (theme.isEmpty()) {
// No theme: Write resource icon as is
m_output << m_indent << language::stackVariable("QIcon", iconName)
<< language::eol;
@@ -1784,12 +1899,21 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
return iconName;
}
+ const bool isThemeEnum = theme.startsWith("QIcon::"_L1);
+ if (isThemeEnum)
+ theme = language::enumValue(theme);
+
// Theme: Generate code to check the theme and default to resource
if (iconHasStatePixmaps(i)) {
// Theme + default state pixmaps:
// Generate code to check the theme and default to state pixmaps
m_output << m_indent << language::stackVariable("QIcon", iconName) << language::eol;
- const char themeNameStringVariableC[] = "iconThemeName";
+ if (isThemeEnum) {
+ writeThemeIconCheckAssignment(theme, iconName, i);
+ return iconName;
+ }
+
+ static constexpr auto themeNameStringVariableC = "iconThemeName"_L1;
// Store theme name in a variable
m_output << m_indent;
if (m_firstThemeIcon) { // Declare variable string
@@ -1798,32 +1922,19 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
m_firstThemeIcon = false;
}
m_output << themeNameStringVariableC << " = "
- << language::qstring(i->attributeTheme()) << language::eol;
- m_output << m_indent << "if ";
- if (isCpp)
- m_output << '(';
- m_output << "QIcon" << language::qualifier << "hasThemeIcon("
- << themeNameStringVariableC << ')' << (isCpp ? ") {" : ":") << '\n'
- << m_dindent << iconName << " = QIcon" << language::qualifier << "fromTheme("
- << themeNameStringVariableC << ')' << language::eol
- << m_indent << (isCpp ? "} else {" : "else:") << '\n';
- if (m_uic->pixmapFunction().isEmpty())
- writeResourceIcon(m_output, iconName, m_dindent, i);
- else
- writePixmapFunctionIcon(m_output, iconName, m_dindent, i);
- m_output << m_indent;
- if (isCpp)
- m_output << '}';
- m_output << '\n';
+ << language::qstring(theme) << language::eol;
+ writeThemeIconCheckAssignment(themeNameStringVariableC, iconName, i);
return iconName;
}
// Theme, but no state pixmaps: Construct from theme directly.
m_output << m_indent
- << language::stackVariableWithInitParameters("QIcon", iconName)
- << "QIcon" << language::qualifier << "fromTheme("
- << language::qstring(i->attributeTheme()) << "))"
- << language::eol;
+ << language::stackVariableWithInitParameters("QIcon", iconName);
+ if (isThemeEnum)
+ m_output << iconFromTheme(theme);
+ else
+ m_output << iconFromThemeStringLiteral(theme);
+ m_output << ')' << language::eol;
return iconName;
}
@@ -1843,7 +1954,7 @@ QString WriteInitialization::domColor2QString(const DomColor *c)
static inline QVersionNumber colorRoleVersionAdded(const QString &roleName)
{
- if (roleName == QLatin1String("PlaceholderText"))
+ if (roleName == "PlaceholderText"_L1)
return QVersionNumber(5, 12, 0);
return QVersionNumber();
}
@@ -1891,7 +2002,7 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri
QString WriteInitialization::writeBrushInitialization(const DomBrush *brush)
{
// Simple solid, colored brushes are cached
- const bool solidColoredBrush = !brush->hasAttributeBrushStyle() || brush->attributeBrushStyle() == QLatin1String("SolidPattern");
+ const bool solidColoredBrush = !brush->hasAttributeBrushStyle() || brush->attributeBrushStyle() == "SolidPattern"_L1;
uint rgb = 0;
if (solidColoredBrush) {
if (const DomColor *color = brush->elementColor()) {
@@ -1905,7 +2016,7 @@ QString WriteInitialization::writeBrushInitialization(const DomBrush *brush)
}
}
// Create and enter into cache if simple
- const QString brushName = m_driver->unique(QLatin1String("brush"));
+ const QString brushName = m_driver->unique("brush"_L1);
writeBrush(brush, brushName);
if (solidColoredBrush)
m_colorBrushHash.insert(rgb, brushName);
@@ -1914,24 +2025,24 @@ QString WriteInitialization::writeBrushInitialization(const DomBrush *brush)
void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brushName)
{
- QString style = QLatin1String("SolidPattern");
+ QString style = u"SolidPattern"_s;
if (brush->hasAttributeBrushStyle())
style = brush->attributeBrushStyle();
- if (style == QLatin1String("LinearGradientPattern") ||
- style == QLatin1String("RadialGradientPattern") ||
- style == QLatin1String("ConicalGradientPattern")) {
+ if (style == "LinearGradientPattern"_L1 ||
+ style == "RadialGradientPattern"_L1 ||
+ style == "ConicalGradientPattern"_L1) {
const DomGradient *gradient = brush->elementGradient();
const QString gradientType = gradient->attributeType();
- const QString gradientName = m_driver->unique(QLatin1String("gradient"));
- if (gradientType == QLatin1String("LinearGradient")) {
+ const QString gradientName = m_driver->unique("gradient"_L1);
+ if (gradientType == "LinearGradient"_L1) {
m_output << m_indent
<< language::stackVariableWithInitParameters("QLinearGradient", gradientName)
<< gradient->attributeStartX()
<< ", " << gradient->attributeStartY()
<< ", " << gradient->attributeEndX()
<< ", " << gradient->attributeEndY() << ')' << language::eol;
- } else if (gradientType == QLatin1String("RadialGradient")) {
+ } else if (gradientType == "RadialGradient"_L1) {
m_output << m_indent
<< language::stackVariableWithInitParameters("QRadialGradient", gradientName)
<< gradient->attributeCentralX()
@@ -1939,7 +2050,7 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush
<< ", " << gradient->attributeRadius()
<< ", " << gradient->attributeFocalX()
<< ", " << gradient->attributeFocalY() << ')' << language::eol;
- } else if (gradientType == QLatin1String("ConicalGradient")) {
+ } else if (gradientType == "ConicalGradient"_L1) {
m_output << m_indent
<< language::stackVariableWithInitParameters("QConicalGradient", gradientName)
<< gradient->attributeCentralX()
@@ -1967,7 +2078,7 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush
m_output << m_indent
<< language::stackVariableWithInitParameters("QBrush", brushName)
<< gradientName << ')' << language::eol;
- } else if (style == QLatin1String("TexturePattern")) {
+ } else if (style == "TexturePattern"_L1) {
const DomProperty *property = brush->elementTexture();
const QString iconValue = iconCall(property);
@@ -2032,42 +2143,42 @@ QString WriteInitialization::iconCall(const DomProperty *icon)
QString WriteInitialization::pixCall(const DomProperty *p) const
{
- QString type, s;
+ QLatin1StringView type;
+ QString s;
switch (p->kind()) {
case DomProperty::IconSet:
- type = QLatin1String("QIcon");
+ type = "QIcon"_L1;
s = p->elementIconSet()->text();
break;
case DomProperty::Pixmap:
- type = QLatin1String("QPixmap");
+ type = "QPixmap"_L1;
s = p->elementPixmap()->text();
break;
default:
qWarning("%s: Warning: Unknown icon format encountered. The ui-file was generated with a too-recent version of Designer.",
qPrintable(m_option.messagePrefix()));
- return QLatin1String("QIcon()");
+ return "QIcon()"_L1;
break;
}
return pixCall(type, s);
}
-QString WriteInitialization::pixCall(const QString &t, const QString &text) const
+QString WriteInitialization::pixCall(QLatin1StringView t, const QString &text) const
{
- QString type = t;
- if (text.isEmpty()) {
- type += QLatin1String("()");
- return type;
- }
+ if (text.isEmpty())
+ return t % "()"_L1;
- QTextStream str(&type);
+ QString result;
+ QTextStream str(&result);
+ str << t;
str << '(';
- QString pixFunc = m_uic->pixmapFunction();
+ const QString pixFunc = m_uic->pixmapFunction();
if (pixFunc.isEmpty())
str << language::qstring(text, m_dindent);
else
str << pixFunc << '(' << language::charliteral(text, m_dindent) << ')';
str << ')';
- return type;
+ return result;
}
void WriteInitialization::initializeComboBox(DomWidget *w)
@@ -2082,8 +2193,8 @@ void WriteInitialization::initializeComboBox(DomWidget *w)
for (int i = 0; i < items.size(); ++i) {
const DomItem *item = items.at(i);
const DomPropertyMap properties = propertyMap(item->elementProperty());
- const DomProperty *text = properties.value(QLatin1String("text"));
- const DomProperty *icon = properties.value(QLatin1String("icon"));
+ const DomProperty *text = properties.value("text"_L1);
+ const DomProperty *icon = properties.value("icon"_L1);
QString iconValue;
if (icon)
@@ -2110,7 +2221,7 @@ QString WriteInitialization::disableSorting(DomWidget *w, const QString &varName
// turn off sortingEnabled to force programmatic item order (setItem())
QString tempName;
if (!w->elementItem().isEmpty()) {
- tempName = m_driver->unique(QLatin1String("__sortingEnabled"));
+ tempName = m_driver->unique("__sortingEnabled"_L1);
m_refreshOut << "\n";
m_refreshOut << m_indent;
if (language::language() == Language::Cpp)
@@ -2202,10 +2313,10 @@ void WriteInitialization::addQtFlagsInitializer(Item *item,
const DomPropertyMap &properties, const QString &name, int column) const
{
if (const DomProperty *p = properties.value(name)) {
- const QString orOperator = QLatin1Char('|') + language::qtQualifier;
+ const QString orOperator = u'|' + language::qtQualifier;
QString v = p->elementSet();
if (!v.isEmpty()) {
- v.replace(QLatin1Char('|'), orOperator);
+ v.replace(u'|', orOperator);
addInitializer(item, name, column, language::qtQualifier + v);
}
}
@@ -2231,20 +2342,20 @@ void WriteInitialization::addQtEnumInitializer(Item *item,
void WriteInitialization::addCommonInitializers(Item *item,
const DomPropertyMap &properties, int column)
{
- if (const DomProperty *icon = properties.value(QLatin1String("icon")))
- addInitializer(item, QLatin1String("icon"), column, iconCall(icon));
- addBrushInitializer(item, properties, QLatin1String("foreground"), column);
- addBrushInitializer(item, properties, QLatin1String("background"), column);
- if (const DomProperty *font = properties.value(QLatin1String("font")))
- addInitializer(item, QLatin1String("font"), column, writeFontProperties(font->elementFont()));
- addQtFlagsInitializer(item, properties, QLatin1String("textAlignment"), column);
- addQtEnumInitializer(item, properties, QLatin1String("checkState"), column);
- addStringInitializer(item, properties, QLatin1String("text"), column);
- addStringInitializer(item, properties, QLatin1String("toolTip"), column,
+ if (const DomProperty *icon = properties.value("icon"_L1))
+ addInitializer(item, "icon"_L1, column, iconCall(icon));
+ addBrushInitializer(item, properties, "foreground"_L1, column);
+ addBrushInitializer(item, properties, "background"_L1, column);
+ if (const DomProperty *font = properties.value("font"_L1))
+ addInitializer(item, "font"_L1, column, writeFontProperties(font->elementFont()));
+ addQtFlagsInitializer(item, properties, "textAlignment"_L1, column);
+ addQtEnumInitializer(item, properties, "checkState"_L1, column);
+ addStringInitializer(item, properties, "text"_L1, column);
+ addStringInitializer(item, properties, "toolTip"_L1, column,
toolTipConfigKey());
- addStringInitializer(item, properties, QLatin1String("whatsThis"), column,
+ addStringInitializer(item, properties, "whatsThis"_L1, column,
whatsThisConfigKey());
- addStringInitializer(item, properties, QLatin1String("statusTip"), column,
+ addStringInitializer(item, properties, "statusTip"_L1, column,
statusTipConfigKey());
}
@@ -2265,8 +2376,8 @@ void WriteInitialization::initializeListWidget(DomWidget *w)
const DomPropertyMap properties = propertyMap(domItem->elementProperty());
- Item item(QLatin1String("QListWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
- addQtFlagsInitializer(&item, properties, QLatin1String("flags"));
+ Item item("QListWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
+ addQtFlagsInitializer(&item, properties, "flags"_L1);
addCommonInitializers(&item, properties);
item.writeSetupUi(varName);
@@ -2282,7 +2393,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w)
const QString varName = m_driver->findOrInsertWidget(w);
// columns
- Item item(QLatin1String("QTreeWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ Item item("QTreeWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
const auto &columns = w->elementColumn();
for (int i = 0; i < columns.size(); ++i) {
@@ -2291,7 +2402,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w)
const DomPropertyMap properties = propertyMap(column->elementProperty());
addCommonInitializers(&item, properties, i);
- if (const DomProperty *p = properties.value(QLatin1String("text"))) {
+ if (const DomProperty *p = properties.value("text"_L1)) {
DomString *str = p->elementString();
if (str && str->text().isEmpty()) {
m_output << m_indent << varName << language::derefPointer
@@ -2301,7 +2412,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w)
}
}
const QString itemName = item.writeSetupUi(QString(), Item::DontConstruct);
- item.writeRetranslateUi(varName + language::derefPointer + QLatin1String("headerItem()"));
+ item.writeRetranslateUi(varName + language::derefPointer + "headerItem()"_L1);
if (!itemName.isNull()) {
m_output << m_indent << varName << language::derefPointer
<< "setHeaderItem(" << itemName << ')' << language::eol;
@@ -2313,7 +2424,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w)
QString tempName = disableSorting(w, varName);
const auto items = initializeTreeWidgetItems(w->elementItem());
- for (int i = 0; i < items.count(); i++) {
+ for (int i = 0; i < items.size(); i++) {
Item *itm = items[i];
itm->writeSetupUi(varName);
QString parentPath;
@@ -2344,7 +2455,7 @@ WriteInitialization::Items WriteInitialization::initializeTreeWidgetItems(const
for (int i = 0; i < numDomItems; ++i) {
const DomItem *domItem = domItems.at(i);
- Item *item = new Item(QLatin1String("QTreeWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ Item *item = new Item("QTreeWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
items << item;
QHash<QString, DomProperty *> map;
@@ -2352,7 +2463,7 @@ WriteInitialization::Items WriteInitialization::initializeTreeWidgetItems(const
int col = -1;
const DomPropertyList properties = domItem->elementProperty();
for (DomProperty *p : properties) {
- if (p->attributeName() == QLatin1String("text")) {
+ if (p->attributeName() == "text"_L1) {
if (!map.isEmpty()) {
addCommonInitializers(item, map, col);
map.clear();
@@ -2363,7 +2474,7 @@ WriteInitialization::Items WriteInitialization::initializeTreeWidgetItems(const
}
addCommonInitializers(item, map, col);
// AbstractFromBuilder saves flags last, so they always end up in the last column's map.
- addQtFlagsInitializer(item, map, QLatin1String("flags"));
+ addQtFlagsInitializer(item, map, "flags"_L1);
const auto subItems = initializeTreeWidgetItems(domItem->elementItem());
for (Item *subItem : subItems)
@@ -2393,7 +2504,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w)
if (!column->elementProperty().isEmpty()) {
const DomPropertyMap properties = propertyMap(column->elementProperty());
- Item item(QLatin1String("QTableWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ Item item("QTableWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
addCommonInitializers(&item, properties);
QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable);
@@ -2423,7 +2534,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w)
if (!row->elementProperty().isEmpty()) {
const DomPropertyMap properties = propertyMap(row->elementProperty());
- Item item(QLatin1String("QTableWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ Item item("QTableWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
addCommonInitializers(&item, properties);
QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable);
@@ -2446,8 +2557,8 @@ void WriteInitialization::initializeTableWidget(DomWidget *w)
const int c = cell->attributeColumn();
const DomPropertyMap properties = propertyMap(cell->elementProperty());
- Item item(QLatin1String("QTableWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
- addQtFlagsInitializer(&item, properties, QLatin1String("flags"));
+ Item item("QTableWidgetItem"_L1, m_indent, m_output, m_refreshOut, m_driver);
+ addQtFlagsInitializer(&item, properties, "flags"_L1);
addCommonInitializers(&item, properties);
QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable);
@@ -2499,7 +2610,7 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi
void WriteInitialization::initializeMenu(DomWidget *w, const QString &/*parentWidget*/)
{
const QString menuName = m_driver->findOrInsertWidget(w);
- const QString menuAction = menuName + QLatin1String("Action");
+ const QString menuAction = menuName + "Action"_L1;
const DomAction *action = m_driver->actionByName(menuAction);
if (action && action->hasAttributeMenu()) {
@@ -2594,7 +2705,7 @@ ConnectionSyntax WriteInitialization::connectionSyntax(const language::SignalSlo
return ConnectionSyntax::StringBased;
}
- return sender.signature.endsWith(QLatin1String("()"))
+ return sender.signature.endsWith("()"_L1)
|| (!isCustomWidget(sender.className) && !isCustomWidget(receiver.className))
? ConnectionSyntax::MemberFunctionPtr : ConnectionSyntax::StringBased;
}
@@ -2616,10 +2727,21 @@ void WriteInitialization::acceptConnection(DomConnection *connection)
return;
}
const QString senderSignature = connection->elementSignal();
+ const QString slotSignature = connection->elementSlot();
+ const bool senderAmbiguous = m_uic->customWidgetsInfo()->isAmbiguousSignal(senderDecl.className,
+ senderSignature);
+ const bool slotAmbiguous = m_uic->customWidgetsInfo()->isAmbiguousSlot(receiverDecl.className,
+ slotSignature);
+
+ language::SignalSlotOptions signalOptions;
+ signalOptions.setFlag(language::SignalSlotOption::Ambiguous, senderAmbiguous);
+ language::SignalSlotOptions slotOptions;
+ slotOptions.setFlag(language::SignalSlotOption::Ambiguous, slotAmbiguous);
+
language::SignalSlot theSignal{senderDecl.name, senderSignature,
- senderDecl.className};
- language::SignalSlot theSlot{receiverDecl.name, connection->elementSlot(),
- receiverDecl.className};
+ senderDecl.className, signalOptions};
+ language::SignalSlot theSlot{receiverDecl.name, slotSignature,
+ receiverDecl.className, slotOptions};
m_output << m_indent;
language::formatConnection(m_output, theSignal, theSlot,
@@ -2690,7 +2812,7 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp
if (generateMultiDirective)
generateMultiDirectiveBegin(m_setupUiStream, m_setupUiData.directives);
- const QString uniqueName = m_driver->unique(QLatin1String("__") + m_itemClassName.toLower());
+ const QString uniqueName = m_driver->unique("__"_L1 + m_itemClassName.toLower());
m_setupUiStream << m_indent;
if (language::language() == Language::Cpp)
m_setupUiStream << m_itemClassName << " *";
@@ -2714,7 +2836,7 @@ QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::Emp
m_setupUiStream << language::closeQtConfig(it.key());
++it;
}
- for (Item *child : qAsConst(m_children))
+ for (Item *child : std::as_const(m_children))
child->writeSetupUi(uniqueName);
return uniqueName;
}
@@ -2727,7 +2849,7 @@ void WriteInitialization::Item::writeRetranslateUi(const QString &parentPath)
if (m_retranslateUiData.policy == ItemData::GenerateWithMultiDirective)
generateMultiDirectiveBegin(m_retranslateUiStream, m_retranslateUiData.directives);
- const QString uniqueName = m_driver->unique(QLatin1String("___") + m_itemClassName.toLower());
+ const QString uniqueName = m_driver->unique("___"_L1 + m_itemClassName.toLower());
m_retranslateUiStream << m_indent;
if (language::language() == Language::Cpp)
m_retranslateUiStream << m_itemClassName << " *";
diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h
index 784ef6fe3e..0973def52d 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.h
+++ b/src/tools/uic/cpp/cppwriteinitialization.h
@@ -1,36 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CPPWRITEINITIALIZATION_H
#define CPPWRITEINITIALIZATION_H
#include "treewalker.h"
-#include <qpair.h>
#include <qhash.h>
#include <qset.h>
#include <qmap.h>
@@ -144,7 +118,7 @@ private:
QString iconCall(const DomProperty *prop);
QString pixCall(const DomProperty *prop) const;
- QString pixCall(const QString &type, const QString &text) const;
+ QString pixCall(QLatin1StringView type, const QString &text) const;
QString trCall(const QString &str, const QString &comment = QString(), const QString &id = QString()) const;
QString trCall(DomString *str, const QString &defaultString = QString()) const;
QString noTrCall(DomString *str, const QString &defaultString = QString()) const;
@@ -235,6 +209,8 @@ private:
private:
QString writeFontProperties(const DomFont *f);
QString writeIconProperties(const DomResourceIcon *i);
+ void writeThemeIconCheckAssignment(const QString &themeValue, const QString &iconName,
+ const DomResourceIcon *i);
void writePixmapFunctionIcon(QTextStream &output, const QString &iconName,
const QString &indent, const DomResourceIcon *i) const;
QString writeSizePolicy(const DomSizePolicy *sp);
@@ -325,7 +301,7 @@ private:
} // namespace CPP
-Q_DECLARE_TYPEINFO(CPP::WriteInitialization::Buddy, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(CPP::WriteInitialization::Buddy, Q_RELOCATABLE_TYPE);
QT_END_NAMESPACE
diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp
index c838feaf73..6ec418634c 100644
--- a/src/tools/uic/customwidgetsinfo.cpp
+++ b/src/tools/uic/customwidgetsinfo.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "customwidgetsinfo.h"
#include "driver.h"
@@ -35,6 +10,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
CustomWidgetsInfo::CustomWidgetsInfo() = default;
void CustomWidgetsInfo::acceptUI(DomUI *node)
@@ -58,7 +35,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;
@@ -101,10 +78,95 @@ bool CustomWidgetsInfo::isCustomWidgetContainer(const QString &className) const
return false;
}
+// FIXME in 7.0 - QTBUG-124241
+// Remove isAmbiguous logic when widget slots have been disambiguated.
+bool CustomWidgetsInfo::isAmbiguous(const QString &className, const QString &signature,
+ QMetaMethod::MethodType type) const
+{
+ using TypeMap = QHash<QString, QMetaMethod::MethodType>;
+ struct AmbiguousInClass {
+ QLatin1StringView className;
+ TypeMap methodMap;
+ };
+
+ static const QList<AmbiguousInClass> ambiguousList = {
+
+ {"QAction"_L1, {{"triggered"_L1, QMetaMethod::Signal}}},
+ {"QCommandLinkButton"_L1, {{"triggered"_L1, QMetaMethod::Signal},
+ {"clicked"_L1, QMetaMethod::Signal}}},
+ {"QPushButton"_L1, {{"triggered"_L1, QMetaMethod::Signal},
+ {"clicked"_L1, QMetaMethod::Signal}}},
+ {"QCheckBox"_L1, {{"triggered"_L1, QMetaMethod::Signal},
+ {"clicked"_L1, QMetaMethod::Signal}}},
+ {"QRadioButton"_L1, {{"triggered"_L1, QMetaMethod::Signal},
+ {"clicked"_L1, QMetaMethod::Signal}}},
+ {"QToolButton"_L1, {{"triggered"_L1, QMetaMethod::Signal},
+ {"clicked"_L1, QMetaMethod::Signal}}},
+ {"QLabel"_L1, {{"setNum"_L1, QMetaMethod::Slot}}},
+ {"QGraphicsView"_L1, {{"invalidateScene"_L1, QMetaMethod::Slot}}},
+ {"QListView"_L1, {{"dataChanged"_L1, QMetaMethod::Slot}}},
+ {"QColumnView"_L1, {{"dataChanged"_L1, QMetaMethod::Slot}}},
+ {"QListWidget"_L1, {{"dataChanged"_L1, QMetaMethod::Slot},
+ {"scrollToItem"_L1, QMetaMethod::Slot}}},
+ {"QTableView"_L1, {{"dataChanged"_L1, QMetaMethod::Slot}}},
+ {"QTableWidget"_L1, {{"dataChanged"_L1, QMetaMethod::Slot},
+ {"scrollToItem"_L1, QMetaMethod::Slot}}},
+ {"QTreeView"_L1, {{"dataChanged"_L1, QMetaMethod::Slot},
+ {"verticalScrollbarValueChanged"_L1, QMetaMethod::Slot},
+ {"expandRecursively"_L1, QMetaMethod::Slot}}},
+ {"QTreeWidget"_L1, {{"dataChanged"_L1, QMetaMethod::Slot},
+ {"verticalScrollbarValueChanged"_L1, QMetaMethod::Slot}
+ ,{"expandRecursively"_L1, QMetaMethod::Slot}
+ ,{"scrollToItem"_L1, QMetaMethod::Slot}}},
+ {"QUndoView"_L1, {{"dataChanged"_L1, QMetaMethod::Slot}}},
+ {"QLCDNumber"_L1, {{"display"_L1, QMetaMethod::Slot}}},
+ {"QMenuBar"_L1, {{"setVisible"_L1, QMetaMethod::Slot}}},
+ {"QTextBrowser"_L1, {{"setSource"_L1, QMetaMethod::Slot}}},
+
+ /*
+ The following widgets with ambiguities are not used in the widget designer:
+
+ {"QSplashScreen"_L1, {{"showMessage"_L1, QMetaMethod::Slot}}},
+ {"QCompleter"_L1, {{"activated"_L1, QMetaMethod::Signal},
+ {"highlighted"_L1, QMetaMethod::Signal}}},
+ {"QSystemTrayIcon"_L1, {{"showMessage"_L1, QMetaMethod::Slot}}},
+ {"QStyledItemDelegate"_L1, {{"closeEditor"_L1, QMetaMethod::Signal}}},
+ {"QErrorMessage"_L1, {{"showMessage"_L1, QMetaMethod::Slot}}},
+ {"QGraphicsDropShadowEffect"_L1, {{"setOffset"_L1, QMetaMethod::Slot}}},
+ {"QGraphicsScene"_L1, {{"invalidate"_L1, QMetaMethod::Slot}}},
+ {"QItemDelegate"_L1, {{"closeEditor"_L1, QMetaMethod::Signal}}}
+ */
+ };
+
+ for (auto it = ambiguousList.constBegin(); it != ambiguousList.constEnd(); ++it) {
+ if (extends(className, it->className)) {
+ const qsizetype pos = signature.indexOf(u'(');
+ const QString method = signature.left(pos);
+ const auto methodIterator = it->methodMap.find(method);
+ return methodIterator != it->methodMap.constEnd() && type == methodIterator.value();
+ }
+ }
+ return false;
+}
+
+// Is it ambiguous, resulting in different signals for Python
+// "QAbstractButton::clicked(checked=false)"
+bool CustomWidgetsInfo::isAmbiguousSignal(const QString &className,
+ const QString &signalSignature) const
+{
+ return isAmbiguous(className, signalSignature, QMetaMethod::Signal);
+}
+
+bool CustomWidgetsInfo::isAmbiguousSlot(const QString &className,
+ const QString &signalSignature) const
+{
+ return isAmbiguous(className, signalSignature, QMetaMethod::Slot);
+}
+
QString CustomWidgetsInfo::realClassName(const QString &className) const
{
- if (className == QLatin1String("Line"))
- return QLatin1String("QFrame");
+ if (className == "Line"_L1)
+ return u"QFrame"_s;
return className;
}
@@ -119,19 +181,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"_s, u"addWidget"_s},
+ {u"QToolBar"_s, u"addWidget"_s},
+ {u"QDockWidget"_s, u"setWidget"_s},
+ {u"QScrollArea"_s, u"setWidget"_s},
+ {u"QSplitter"_s, u"addWidget"_s},
+ {u"QMdiArea"_s, u"addSubWindow"_s}
};
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..f336292f2a 100644
--- a/src/tools/uic/customwidgetsinfo.h
+++ b/src/tools/uic/customwidgetsinfo.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef CUSTOMWIDGETSINFO_H
#define CUSTOMWIDGETSINFO_H
@@ -32,6 +7,7 @@
#include "treewalker.h"
#include <qstringlist.h>
#include <qmap.h>
+#include <QtCore/qmetaobject.h>
QT_BEGIN_NAMESPACE
@@ -56,14 +32,21 @@ 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;
+ bool isAmbiguousSignal(const QString &className,
+ const QString &signalSignature) const;
+ bool isAmbiguousSlot(const QString &className,
+ const QString &slotSignature) const;
+
private:
using NameCustomWidgetMap = QMap<QString, DomCustomWidget*>;
NameCustomWidgetMap m_customWidgets;
+ bool isAmbiguous(const QString &className, const QString &signature,
+ QMetaMethod::MethodType type) const;
};
QT_END_NAMESPACE
diff --git a/src/tools/uic/databaseinfo.cpp b/src/tools/uic/databaseinfo.cpp
index 9b0d1614ab..5334f06baf 100644
--- a/src/tools/uic/databaseinfo.cpp
+++ b/src/tools/uic/databaseinfo.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "databaseinfo.h"
#include "driver.h"
@@ -33,6 +8,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
DatabaseInfo::DatabaseInfo() = default;
void DatabaseInfo::acceptUI(DomUI *node)
@@ -50,11 +27,11 @@ void DatabaseInfo::acceptWidget(DomWidget *node)
{
QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
- DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"));
+ DomProperty *frameworkCode = properties.value("frameworkCode"_L1);
if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
return;
- DomProperty *db = properties.value(QLatin1String("database"));
+ DomProperty *db = properties.value("database"_L1);
if (db && db->elementStringList()) {
QStringList info = db->elementStringList()->elementString();
if (info.isEmpty() || info.constFirst().isEmpty())
diff --git a/src/tools/uic/databaseinfo.h b/src/tools/uic/databaseinfo.h
index 4015e39dbc..0d2487a56f 100644
--- a/src/tools/uic/databaseinfo.h
+++ b/src/tools/uic/databaseinfo.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef DATABASEINFO_H
#define DATABASEINFO_H
diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp
index 8b9b4806e6..110764ee07 100644
--- a/src/tools/uic/driver.cpp
+++ b/src/tools/uic/driver.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "driver.h"
#include "uic.h"
@@ -39,6 +14,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Driver::Driver()
: m_stdout(stdout, QFile::WriteOnly | QFile::Text)
{
@@ -152,7 +129,7 @@ QString Driver::normalizedName(const QString &name)
QString result = name;
std::replace_if(result.begin(), result.end(),
[] (QChar c) { return !c.isLetterOrNumber(); },
- QLatin1Char('_'));
+ u'_');
return result;
}
@@ -172,7 +149,7 @@ QString Driver::unique(const QString &instanceName, const QString &className)
} else if (!className.isEmpty()) {
name = unique(qtify(className));
} else {
- name = unique(QLatin1String("var"));
+ name = unique("var"_L1);
}
if (alreadyUsed && !className.isEmpty()) {
@@ -190,7 +167,7 @@ QString Driver::qtify(const QString &name)
{
QString qname = name;
- if (qname.at(0) == QLatin1Char('Q') || qname.at(0) == QLatin1Char('K'))
+ if (qname.at(0) == u'Q' || qname.at(0) == u'K')
qname.remove(0, 1);
for (int i = 0, size = qname.size(); i < size && qname.at(i).isUpper(); ++i)
@@ -201,8 +178,7 @@ QString Driver::qtify(const QString &name)
static bool isAnsiCCharacter(QChar c)
{
- return (c.toUpper() >= QLatin1Char('A') && c.toUpper() <= QLatin1Char('Z'))
- || c.isDigit() || c == QLatin1Char('_');
+ return (c.toUpper() >= u'A' && c.toUpper() <= u'Z') || c.isDigit() || c == u'_';
}
QString Driver::headerFileName() const
@@ -210,7 +186,7 @@ QString Driver::headerFileName() const
QString name = m_option.outputFile;
if (name.isEmpty()) {
- name = QLatin1String("ui_"); // ### use ui_ as prefix.
+ name = "ui_"_L1; // ### use ui_ as prefix.
name.append(m_option.inputFile);
}
@@ -220,23 +196,23 @@ QString Driver::headerFileName() const
QString Driver::headerFileName(const QString &fileName)
{
if (fileName.isEmpty())
- return headerFileName(QLatin1String("noname"));
+ return headerFileName(u"noname"_s);
QFileInfo info(fileName);
QString baseName = info.baseName();
// Transform into a valid C++ identifier
if (!baseName.isEmpty() && baseName.at(0).isDigit())
- baseName.prepend(QLatin1Char('_'));
+ baseName.prepend(u'_');
for (int i = 0; i < baseName.size(); ++i) {
QChar c = baseName.at(i);
if (!isAnsiCCharacter(c)) {
// Replace character by its unicode value
QString hex = QString::number(c.unicode(), 16);
- baseName.replace(i, 1, QLatin1Char('_') + hex + QLatin1Char('_'));
+ baseName.replace(i, 1, u'_' + hex + u'_');
i += hex.size() + 1;
}
}
- return baseName.toUpper() + QLatin1String("_H");
+ return baseName.toUpper() + "_H"_L1;
}
bool Driver::printDependencies(const QString &fileName)
@@ -269,9 +245,10 @@ bool Driver::uic(const QString &fileName, DomUI *ui, QTextStream *out)
bool Driver::uic(const QString &fileName, QTextStream *out)
{
QFile f;
- if (fileName.isEmpty())
- f.open(stdin, QIODevice::ReadOnly);
- else {
+ if (fileName.isEmpty()) {
+ if (!f.open(stdin, QIODevice::ReadOnly))
+ return false;
+ } else {
f.setFileName(fileName);
if (!f.open(QIODevice::ReadOnly))
return false;
diff --git a/src/tools/uic/driver.h b/src/tools/uic/driver.h
index 45ec23b4aa..8c54d03d83 100644
--- a/src/tools/uic/driver.h
+++ b/src/tools/uic/driver.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef DRIVER_H
#define DRIVER_H
diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp
index cb21277086..d46b788419 100644
--- a/src/tools/uic/main.cpp
+++ b/src/tools/uic/main.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "uic.h"
#include "option.h"
@@ -38,15 +13,49 @@
#include <qcoreapplication.h>
#include <qcommandlineoption.h>
#include <qcommandlineparser.h>
+#include <qfileinfo.h>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+static const char pythonPathVar[] = "PYTHONPATH";
+
+// From the Python paths, find the component the UI file is under
+static QString pythonRoot(const QString &pythonPath, const QString &uiFileIn)
+{
+#ifdef Q_OS_WIN
+ static const Qt::CaseSensitivity fsSensitivity = Qt::CaseInsensitive;
+#else
+ static const Qt::CaseSensitivity fsSensitivity = Qt::CaseSensitive;
+#endif
+
+ if (pythonPath.isEmpty() || uiFileIn.isEmpty())
+ return {};
+ const QString uiFile = QFileInfo(uiFileIn).canonicalFilePath();
+ if (uiFile.isEmpty())
+ return {};
+ const auto uiFileSize = uiFile.size();
+ const auto paths = pythonPath.split(QDir::listSeparator(), Qt::SkipEmptyParts);
+ for (const auto &path : paths) {
+ const QString canonicalPath = QFileInfo(path).canonicalFilePath();
+ const auto canonicalPathSize = canonicalPath.size();
+ if (uiFileSize > canonicalPathSize
+ && uiFile.at(canonicalPathSize) == u'/'
+ && uiFile.startsWith(canonicalPath, fsSensitivity)) {
+ return canonicalPath;
+ }
+ }
+ return {};
+}
+
int runUic(int argc, char *argv[])
{
- qSetGlobalQHashSeed(0); // set the hash seed to 0
+ QHashSeed::setDeterministicGlobalSeed();
QCoreApplication app(argc, argv);
- QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_VERSION_STR));
+ const QString version = QString::fromLatin1(qVersion());
+ QCoreApplication::setApplicationVersion(version);
Driver driver;
@@ -54,65 +63,89 @@ int runUic(int argc, char *argv[])
// If you use this code as an example for a translated app, make sure to translate the strings.
QCommandLineParser parser;
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
- parser.setApplicationDescription(QStringLiteral("Qt User Interface Compiler version %1").arg(QString::fromLatin1(QT_VERSION_STR)));
+ parser.setApplicationDescription(u"Qt User Interface Compiler version %1"_s.arg(version));
parser.addHelpOption();
parser.addVersionOption();
- QCommandLineOption dependenciesOption(QStringList() << QStringLiteral("d") << QStringLiteral("dependencies"));
- dependenciesOption.setDescription(QStringLiteral("Display the dependencies."));
+ QCommandLineOption dependenciesOption(QStringList{u"d"_s, u"dependencies"_s});
+ dependenciesOption.setDescription(u"Display the dependencies."_s);
parser.addOption(dependenciesOption);
- QCommandLineOption outputOption(QStringList() << QStringLiteral("o") << QStringLiteral("output"));
- outputOption.setDescription(QStringLiteral("Place the output into <file>"));
- outputOption.setValueName(QStringLiteral("file"));
+ QCommandLineOption outputOption(QStringList{u"o"_s, u"output"_s});
+ outputOption.setDescription(u"Place the output into <file>"_s);
+ outputOption.setValueName(u"file"_s);
parser.addOption(outputOption);
- QCommandLineOption noAutoConnectionOption(QStringList() << QStringLiteral("a") << QStringLiteral("no-autoconnection"));
- noAutoConnectionOption.setDescription(QStringLiteral("Do not generate a call to QObject::connectSlotsByName()."));
+ QCommandLineOption noAutoConnectionOption(QStringList{u"a"_s, u"no-autoconnection"_s});
+ noAutoConnectionOption.setDescription(u"Do not generate a call to QObject::connectSlotsByName()."_s);
parser.addOption(noAutoConnectionOption);
- QCommandLineOption noProtOption(QStringList() << QStringLiteral("p") << QStringLiteral("no-protection"));
- noProtOption.setDescription(QStringLiteral("Disable header protection."));
+ QCommandLineOption noProtOption(QStringList{u"p"_s, u"no-protection"_s});
+ noProtOption.setDescription(u"Disable header protection."_s);
parser.addOption(noProtOption);
- QCommandLineOption noImplicitIncludesOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-implicit-includes"));
- noImplicitIncludesOption.setDescription(QStringLiteral("Disable generation of #include-directives."));
+ QCommandLineOption noImplicitIncludesOption(QStringList{u"n"_s, u"no-implicit-includes"_s});
+ noImplicitIncludesOption.setDescription(u"Disable generation of #include-directives."_s);
parser.addOption(noImplicitIncludesOption);
- QCommandLineOption postfixOption(QStringLiteral("postfix"));
- postfixOption.setDescription(QStringLiteral("Postfix to add to all generated classnames."));
- postfixOption.setValueName(QStringLiteral("postfix"));
+ QCommandLineOption postfixOption(u"postfix"_s);
+ postfixOption.setDescription(u"Postfix to add to all generated classnames."_s);
+ postfixOption.setValueName(u"postfix"_s);
parser.addOption(postfixOption);
- QCommandLineOption translateOption(QStringList() << QStringLiteral("tr") << QStringLiteral("translate"));
- translateOption.setDescription(QStringLiteral("Use <function> for i18n."));
- translateOption.setValueName(QStringLiteral("function"));
+ QCommandLineOption noQtNamespaceOption(u"no-qt-namespace"_s);
+ noQtNamespaceOption.setDescription(
+ u"Disable wrapping the definition of the generated class in QT_{BEGIN,END}_NAMESPACE."_s);
+ parser.addOption(noQtNamespaceOption);
+
+ QCommandLineOption translateOption(QStringList{u"tr"_s, u"translate"_s});
+ translateOption.setDescription(u"Use <function> for i18n."_s);
+ translateOption.setValueName(u"function"_s);
parser.addOption(translateOption);
- QCommandLineOption includeOption(QStringList() << QStringLiteral("include"));
- includeOption.setDescription(QStringLiteral("Add #include <include-file> to <file>."));
- includeOption.setValueName(QStringLiteral("include-file"));
+ QCommandLineOption includeOption(QStringList{u"include"_s});
+ includeOption.setDescription(u"Add #include <include-file> to <file>."_s);
+ includeOption.setValueName(u"include-file"_s);
parser.addOption(includeOption);
- QCommandLineOption generatorOption(QStringList() << QStringLiteral("g") << QStringLiteral("generator"));
- generatorOption.setDescription(QStringLiteral("Select generator."));
- generatorOption.setValueName(QStringLiteral("python|cpp"));
+ QCommandLineOption generatorOption(QStringList{u"g"_s, u"generator"_s});
+ generatorOption.setDescription(u"Select generator."_s);
+ generatorOption.setValueName(u"python|cpp"_s);
parser.addOption(generatorOption);
- QCommandLineOption connectionsOption(QStringList{QStringLiteral("c"), QStringLiteral("connections")});
- connectionsOption.setDescription(QStringLiteral("Connection syntax."));
- connectionsOption.setValueName(QStringLiteral("pmf|string"));
+ QCommandLineOption connectionsOption(QStringList{u"c"_s, u"connections"_s});
+ connectionsOption.setDescription(u"Connection syntax."_s);
+ connectionsOption.setValueName(u"pmf|string"_s);
parser.addOption(connectionsOption);
- QCommandLineOption idBasedOption(QStringLiteral("idbased"));
- idBasedOption.setDescription(QStringLiteral("Use id based function for i18n"));
+ QCommandLineOption idBasedOption(u"idbased"_s);
+ idBasedOption.setDescription(u"Use id based function for i18n"_s);
parser.addOption(idBasedOption);
- QCommandLineOption fromImportsOption(QStringLiteral("from-imports"));
- fromImportsOption.setDescription(QStringLiteral("Python: generate imports relative to '.'"));
+ QCommandLineOption fromImportsOption(u"from-imports"_s);
+ fromImportsOption.setDescription(u"Python: generate imports relative to '.'"_s);
parser.addOption(fromImportsOption);
- parser.addPositionalArgument(QStringLiteral("[uifile]"), QStringLiteral("Input file (*.ui), otherwise stdin."));
+ QCommandLineOption absoluteImportsOption(u"absolute-imports"_s);
+ absoluteImportsOption.setDescription(u"Python: generate absolute imports"_s);
+ parser.addOption(absoluteImportsOption);
+
+ // FIXME Qt 7: Flip the default?
+ QCommandLineOption rcPrefixOption(u"rc-prefix"_s);
+ rcPrefixOption.setDescription(uR"(Python: Generate "rc_file" instead of "file_rc" import)"_s);
+ parser.addOption(rcPrefixOption);
+
+ // FIXME Qt 7: Remove?
+ QCommandLineOption useStarImportsOption(u"star-imports"_s);
+ useStarImportsOption.setDescription(u"Python: Use * imports"_s);
+ parser.addOption(useStarImportsOption);
+
+ QCommandLineOption pythonPathOption(u"python-paths"_s);
+ pythonPathOption.setDescription(u"Python paths for --absolute-imports."_s);
+ pythonPathOption.setValueName(u"pathlist"_s);
+ parser.addOption(pythonPathOption);
+
+ parser.addPositionalArgument(u"[uifile]"_s, u"Input file (*.ui), otherwise stdin."_s);
parser.process(app);
@@ -121,30 +154,44 @@ int runUic(int argc, char *argv[])
driver.option().autoConnection = !parser.isSet(noAutoConnectionOption);
driver.option().headerProtection = !parser.isSet(noProtOption);
driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption);
+ driver.option().qtNamespace = !parser.isSet(noQtNamespaceOption);
driver.option().idBased = parser.isSet(idBasedOption);
- driver.option().fromImports = parser.isSet(fromImportsOption);
driver.option().postfix = parser.value(postfixOption);
driver.option().translateFunction = parser.value(translateOption);
driver.option().includeFile = parser.value(includeOption);
if (parser.isSet(connectionsOption)) {
const auto value = parser.value(connectionsOption);
- if (value == QLatin1String("pmf"))
+ if (value == "pmf"_L1)
driver.option().forceMemberFnPtrConnectionSyntax = 1;
- else if (value == QLatin1String("string"))
+ else if (value == "string"_L1)
driver.option().forceStringConnectionSyntax = 1;
}
+ const QString inputFile = parser.positionalArguments().value(0);
+
Language language = Language::Cpp;
if (parser.isSet(generatorOption)) {
- if (parser.value(generatorOption).compare(QLatin1String("python")) == 0)
+ if (parser.value(generatorOption).compare("python"_L1) == 0)
language = Language::Python;
}
language::setLanguage(language);
+ if (language == Language::Python) {
+ if (parser.isSet(fromImportsOption))
+ driver.option().pythonResourceImport = Option::PythonResourceImport::FromDot;
+ else if (parser.isSet(absoluteImportsOption))
+ driver.option().pythonResourceImport = Option::PythonResourceImport::Absolute;
+ driver.option().useStarImports = parser.isSet(useStarImportsOption);
+ if (parser.isSet(rcPrefixOption))
+ driver.option().rcPrefix = 1;
+ QString pythonPaths;
+ if (parser.isSet(pythonPathOption))
+ pythonPaths = parser.value(pythonPathOption);
+ else if (qEnvironmentVariableIsSet(pythonPathVar))
+ pythonPaths = QString::fromUtf8(qgetenv(pythonPathVar));
+ driver.option().pythonRoot = pythonRoot(pythonPaths, inputFile);
+ }
- QString inputFile;
- if (!parser.positionalArguments().isEmpty())
- inputFile = parser.positionalArguments().at(0);
- else // reading from stdin
+ if (inputFile.isEmpty()) // reading from stdin
driver.option().headerProtection = false;
if (driver.option().dependencies) {
diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h
index c869fec9a6..cfdd90fda3 100644
--- a/src/tools/uic/option.h
+++ b/src/tools/uic/option.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef OPTION_H
#define OPTION_H
@@ -36,6 +11,12 @@ QT_BEGIN_NAMESPACE
struct Option
{
+ enum class PythonResourceImport {
+ Default, // "import rc_file"
+ FromDot, // "from . import rc_file"
+ Absolute // "import path.rc_file"
+ };
+
unsigned int headerProtection : 1;
unsigned int copyrightHeader : 1;
unsigned int generateImplemetation : 1;
@@ -45,9 +26,11 @@ struct Option
unsigned int limitXPM_LineLength : 1;
unsigned int implicitIncludes: 1;
unsigned int idBased: 1;
- unsigned int fromImports: 1;
unsigned int forceMemberFnPtrConnectionSyntax: 1;
unsigned int forceStringConnectionSyntax: 1;
+ unsigned int useStarImports: 1;
+ unsigned int rcPrefix: 1; // Python: Generate "rc_file" instead of "file_rc" import
+ unsigned int qtNamespace: 1;
QString inputFile;
QString outputFile;
@@ -57,6 +40,9 @@ struct Option
QString postfix;
QString translateFunction;
QString includeFile;
+ QString pythonRoot;
+
+ PythonResourceImport pythonResourceImport = PythonResourceImport::Default;
Option()
: headerProtection(1),
@@ -68,16 +54,18 @@ struct Option
limitXPM_LineLength(0),
implicitIncludes(1),
idBased(0),
- fromImports(0),
forceMemberFnPtrConnectionSyntax(0),
forceStringConnectionSyntax(0),
- prefix(QLatin1String("Ui_"))
- { indent.fill(QLatin1Char(' '), 4); }
+ useStarImports(0),
+ rcPrefix(0),
+ qtNamespace(1),
+ prefix(QLatin1StringView("Ui_"))
+ { indent.fill(u' ', 4); }
QString messagePrefix() const
{
return inputFile.isEmpty() ?
- QString(QLatin1String("stdin")) :
+ QString(QLatin1StringView("stdin")) :
QDir::toNativeSeparators(inputFile);
}
};
diff --git a/src/tools/uic/python/python.pri b/src/tools/uic/python/python.pri
deleted file mode 100644
index 4dd31160a1..0000000000
--- a/src/tools/uic/python/python.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-INCLUDEPATH += $$PWD
-
-# Input
-HEADERS += $$PWD/pythonwritedeclaration.h \
- $$PWD/pythonwriteimports.h
-
-SOURCES += $$PWD/pythonwritedeclaration.cpp \
- $$PWD/pythonwriteimports.cpp
diff --git a/src/tools/uic/python/pythonwritedeclaration.cpp b/src/tools/uic/python/pythonwritedeclaration.cpp
index 5122b18e23..665eb8fe76 100644
--- a/src/tools/uic/python/pythonwritedeclaration.cpp
+++ b/src/tools/uic/python/pythonwritedeclaration.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "pythonwritedeclaration.h"
#include <cppwriteinitialization.h>
@@ -38,6 +13,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace Python {
WriteDeclaration::WriteDeclaration(Uic *uic) :
@@ -51,7 +28,7 @@ WriteDeclaration::WriteDeclaration(Uic *uic) :
void WriteDeclaration::acceptUI(DomUI *node)
{
// remove any left-over C++ namespaces
- const QString qualifiedClassName = QLatin1String("Ui_") + node->elementClass()
+ const QString qualifiedClassName = "Ui_"_L1 + node->elementClass()
+ m_option.postfix;
m_output << "class " << language::fixClassName(qualifiedClassName) << "(object):\n";
diff --git a/src/tools/uic/python/pythonwritedeclaration.h b/src/tools/uic/python/pythonwritedeclaration.h
index a8d50b6fbf..6aed86f382 100644
--- a/src/tools/uic/python/pythonwritedeclaration.h
+++ b/src/tools/uic/python/pythonwritedeclaration.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef PYTHONWRITEDECLARATION_H
#define PYTHONWRITEDECLARATION_H
diff --git a/src/tools/uic/python/pythonwriteimports.cpp b/src/tools/uic/python/pythonwriteimports.cpp
index f8d5e96729..74eeab8387 100644
--- a/src/tools/uic/python/pythonwriteimports.cpp
+++ b/src/tools/uic/python/pythonwriteimports.cpp
@@ -1,140 +1,269 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "pythonwriteimports.h"
#include <customwidgetsinfo.h>
#include <option.h>
#include <uic.h>
+#include <driver.h>
#include <ui4.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfileinfo.h>
#include <QtCore/qtextstream.h>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
-static const char *standardImports =
-R"I(from PySide2.QtCore import *
-from PySide2.QtGui import *
-from PySide2.QtWidgets import *
-)I";
+using namespace Qt::StringLiterals;
+
+// Generate imports for Python. Note some things differ from C++:
+// - qItemView->header()->setFoo() does not require QHeaderView to be imported
+// - qLabel->setFrameShape(QFrame::Box) however requires QFrame to be imported
+// (see acceptProperty())
+
+namespace Python {
-// Change the name of a qrc file "dir/foo.qrc" file to the Python
-// module name "foo_rc" according to project conventions.
-static QString pythonResource(QString resource)
+// Classes required for properties
+static WriteImports::ClassesPerModule defaultClasses()
{
- const int lastSlash = resource.lastIndexOf(QLatin1Char('/'));
- if (lastSlash != -1)
- resource.remove(0, lastSlash + 1);
- if (resource.endsWith(QLatin1String(".qrc"))) {
- resource.chop(4);
- resource.append(QLatin1String("_rc"));
+ return {
+ {QStringLiteral("QtCore"),
+ {QStringLiteral("QCoreApplication"), QStringLiteral("QDate"),
+ QStringLiteral("QDateTime"), QStringLiteral("QLocale"),
+ QStringLiteral("QMetaObject"), QStringLiteral("QObject"),
+ QStringLiteral("QPoint"), QStringLiteral("QRect"),
+ QStringLiteral("QSize"), QStringLiteral("QTime"),
+ QStringLiteral("QUrl"), QStringLiteral("Qt")},
+ },
+ {QStringLiteral("QtGui"),
+ {QStringLiteral("QBrush"), QStringLiteral("QColor"),
+ QStringLiteral("QConicalGradient"), QStringLiteral("QCursor"),
+ QStringLiteral("QGradient"), QStringLiteral("QFont"),
+ QStringLiteral("QFontDatabase"), QStringLiteral("QIcon"),
+ QStringLiteral("QImage"), QStringLiteral("QKeySequence"),
+ QStringLiteral("QLinearGradient"), QStringLiteral("QPalette"),
+ QStringLiteral("QPainter"), QStringLiteral("QPixmap"),
+ QStringLiteral("QTransform"), QStringLiteral("QRadialGradient")}
+ },
+ // Add QWidget for QWidget.setTabOrder()
+ {QStringLiteral("QtWidgets"),
+ {QStringLiteral("QSizePolicy"), QStringLiteral("QWidget")}
+ }
+ };
+}
+
+// Helpers for WriteImports::ClassesPerModule maps
+static void insertClass(const QString &module, const QString &className,
+ WriteImports::ClassesPerModule *c)
+{
+ auto usedIt = c->find(module);
+ if (usedIt == c->end())
+ c->insert(module, {className});
+ else if (!usedIt.value().contains(className))
+ usedIt.value().append(className);
+}
+
+// Format a class list: "from A import (B, C)"
+static void formatImportClasses(QTextStream &str, QStringList classList)
+{
+ std::sort(classList.begin(), classList.end());
+
+ const qsizetype size = classList.size();
+ if (size > 1)
+ str << '(';
+ for (qsizetype i = 0; i < size; ++i) {
+ if (i > 0)
+ str << (i % 4 == 0 ? ",\n " : ", ");
+ str << classList.at(i);
}
- return resource;
+ if (size > 1)
+ str << ')';
}
-namespace Python {
+static void formatClasses(QTextStream &str, const WriteImports::ClassesPerModule &c,
+ bool useStarImports = false,
+ const QByteArray &modulePrefix = {})
+{
+ for (auto it = c.cbegin(), end = c.cend(); it != end; ++it) {
+ str << "from " << modulePrefix << it.key() << " import ";
+ if (useStarImports)
+ str << "* # type: ignore";
+ else
+ formatImportClasses(str, it.value());
+ str << '\n';
+ }
+}
-WriteImports::WriteImports(Uic *uic) : m_uic(uic)
+WriteImports::WriteImports(Uic *uic) : WriteIncludesBase(uic),
+ m_qtClasses(defaultClasses())
{
+ for (const auto &e : classInfoEntries())
+ m_classToModule.insert(QLatin1StringView(e.klass), QLatin1StringView(e.module));
}
void WriteImports::acceptUI(DomUI *node)
{
- auto &output = m_uic->output();
- output << standardImports << '\n';
- if (auto customWidgets = node->elementCustomWidgets()) {
- TreeWalker::acceptCustomWidgets(customWidgets);
+ WriteIncludesBase::acceptUI(node);
+
+ auto &output = uic()->output();
+ const bool useStarImports = uic()->driver()->option().useStarImports;
+
+ const QByteArray qtPrefix = QByteArrayLiteral("PySide")
+ + QByteArray::number(QT_VERSION_MAJOR) + '.';
+
+ formatClasses(output, m_qtClasses, useStarImports, qtPrefix);
+
+ if (!m_customWidgets.isEmpty() || !m_plainCustomWidgets.isEmpty()) {
output << '\n';
+ formatClasses(output, m_customWidgets, useStarImports);
+ for (const auto &w : m_plainCustomWidgets)
+ output << "import " << w << '\n';
}
if (auto resources = node->elementResources()) {
const auto includes = resources->elementInclude();
for (auto include : includes) {
if (include->hasAttributeLocation())
- writeImport(pythonResource(include->attributeLocation()));
+ writeResourceImport(include->attributeLocation());
}
output << '\n';
}
}
-void WriteImports::writeImport(const QString &module)
+QString WriteImports::resourceAbsolutePath(QString resource) const
{
+ // If we know the project root, generate an absolute Python import
+ // to the resource. options. pythonRoot is the Python path component
+ // under which the UI file is.
+ const auto &options = uic()->option();
+ if (!options.inputFile.isEmpty() && !options.pythonRoot.isEmpty()) {
+ resource = QDir::cleanPath(QFileInfo(options.inputFile).canonicalPath() + u'/' + resource);
+ if (resource.size() > options.pythonRoot.size())
+ resource.remove(0, options.pythonRoot.size() + 1);
+ }
+ // If nothing is known, we assume the directory pointed by "../" is the root
+ while (resource.startsWith(u"../"))
+ resource.remove(0, 3);
+ resource.replace(u'/', u'.');
+ return resource;
+}
- if (m_uic->option().fromImports)
- m_uic->output() << "from . ";
- m_uic->output() << "import " << module << '\n';
+void WriteImports::writeResourceImport(const QString &module)
+{
+ const auto &options = uic()->option();
+ auto &str = uic()->output();
+
+ QString resource = QDir::cleanPath(module);
+ if (resource.endsWith(u".qrc"))
+ resource.chop(4);
+ const qsizetype basePos = resource.lastIndexOf(u'/') + 1;
+ // Change the name of a qrc file "dir/foo.qrc" file to the Python
+ // module name "foo_rc" according to project conventions.
+ if (options.rcPrefix)
+ resource.insert(basePos, u"rc_");
+ else
+ resource.append(u"_rc");
+
+ switch (options.pythonResourceImport) {
+ case Option::PythonResourceImport::Default:
+ str << "import " << QStringView{resource}.sliced(basePos) << '\n';
+ break;
+ case Option::PythonResourceImport::FromDot:
+ str << "from . import " << QStringView{resource}.sliced(basePos) << '\n';
+ break;
+ case Option::PythonResourceImport::Absolute:
+ str << "import " << resourceAbsolutePath(resource) << '\n';
+ break;
+ }
}
-QString WriteImports::qtModuleOf(const DomCustomWidget *node) const
+void WriteImports::doAdd(const QString &className, const DomCustomWidget *dcw)
{
- if (m_uic->customWidgetsInfo()->extends(node->elementClass(), QLatin1String("QAxWidget")))
- return QStringLiteral("QtAxContainer");
- if (const auto headerElement = node->elementHeader()) {
- const auto &header = headerElement->text();
- if (header.startsWith(QLatin1String("Qt"))) {
- const int slash = header.indexOf(QLatin1Char('/'));
- if (slash != -1)
- return header.left(slash);
- }
+ const CustomWidgetsInfo *cwi = uic()->customWidgetsInfo();
+ if (cwi->extends(className, "QListWidget"))
+ add(QStringLiteral("QListWidgetItem"));
+ else if (cwi->extends(className, "QTreeWidget"))
+ add(QStringLiteral("QTreeWidgetItem"));
+ else if (cwi->extends(className, "QTableWidget"))
+ add(QStringLiteral("QTableWidgetItem"));
+
+ if (dcw != nullptr) {
+ addPythonCustomWidget(className, dcw);
+ return;
}
- return QString();
+
+ if (!addQtClass(className))
+ qWarning("WriteImports::add(): Unknown Qt class %s", qPrintable(className));
+}
+
+bool WriteImports::addQtClass(const QString &className)
+{
+ // QVariant is not exposed in PySide
+ if (className == u"QVariant" || className == u"Qt")
+ return true;
+
+ const auto moduleIt = m_classToModule.constFind(className);
+ const bool result = moduleIt != m_classToModule.cend();
+ if (result)
+ insertClass(moduleIt.value(), className, &m_qtClasses);
+ return result;
}
-void WriteImports::acceptCustomWidget(DomCustomWidget *node)
+void WriteImports::addPythonCustomWidget(const QString &className, const DomCustomWidget *node)
{
- const auto &className = node->elementClass();
- if (className.contains(QLatin1String("::")))
+ if (className.contains("::"_L1))
return; // Exclude namespaced names (just to make tests pass).
- const QString &importModule = qtModuleOf(node);
- auto &output = m_uic->output();
- // For starting importing PySide2 modules
- if (!importModule.isEmpty()) {
- output << "from ";
- if (importModule.startsWith(QLatin1String("Qt")))
- output << "PySide2.";
- output << importModule;
- if (!className.isEmpty())
- output << " import " << className << "\n\n";
- } else {
- // When the elementHeader is not set, we know it's the continuation
- // of a PySide2 import or a normal import of another module.
- if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) {
- output << "import " << className << '\n';
- } else { // When we do have elementHeader, we know it's a relative import.
- QString modulePath = node->elementHeader()->text();
- // Replace the '/' by '.'
- modulePath.replace(QLatin1Char('/'), QLatin1Char('.'));
- // '.h' is added by default on headers for <customwidget>
- if (modulePath.endsWith(QLatin1String(".h")))
- modulePath.chop(2);
- output << "from " << modulePath << " import " << className << '\n';
- }
+
+ if (addQtClass(className)) // Qt custom widgets like QQuickWidget, QAxWidget, etc
+ return;
+
+ // When the elementHeader is not set, we know it's the continuation
+ // of a Qt for Python import or a normal import of another module.
+ if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) {
+ m_plainCustomWidgets.append(className);
+ } else { // When we do have elementHeader, we know it's a relative import.
+ QString modulePath = node->elementHeader()->text();
+ // Replace the '/' by '.'
+ modulePath.replace(u'/', u'.');
+ // '.h' is added by default on headers for <customwidget>.
+ if (modulePath.endsWith(".h"_L1, Qt::CaseInsensitive))
+ modulePath.chop(2);
+ else if (modulePath.endsWith(".hh"_L1))
+ modulePath.chop(3);
+ else if (modulePath.endsWith(".hpp"_L1))
+ modulePath.chop(4);
+ insertClass(modulePath, className, &m_customWidgets);
+ }
+}
+
+void WriteImports::acceptProperty(DomProperty *node)
+{
+ switch (node->kind()) {
+ case DomProperty::Enum:
+ addEnumBaseClass(node->elementEnum());
+ break;
+ case DomProperty::Set:
+ addEnumBaseClass(node->elementSet());
+ break;
+ default:
+ break;
+ }
+
+ WriteIncludesBase::acceptProperty(node);
+}
+
+void WriteImports::addEnumBaseClass(const QString &v)
+{
+ // Add base classes like QFrame for QLabel::frameShape()
+ const auto colonPos = v.indexOf(u"::");
+ if (colonPos > 0) {
+ const QString base = v.left(colonPos);
+ if (base.startsWith(u'Q') && base != u"Qt")
+ addQtClass(base);
}
}
diff --git a/src/tools/uic/python/pythonwriteimports.h b/src/tools/uic/python/pythonwriteimports.h
index 5462453962..4497b8dc33 100644
--- a/src/tools/uic/python/pythonwriteimports.h
+++ b/src/tools/uic/python/pythonwriteimports.h
@@ -1,55 +1,45 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef PYTHONWRITEIMPORTS_H
#define PYTHONWRITEIMPORTS_H
-#include <treewalker.h>
+#include <writeincludesbase.h>
-QT_BEGIN_NAMESPACE
+#include <QtCore/qhash.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qstringlist.h>
-class Uic;
+QT_BEGIN_NAMESPACE
namespace Python {
-struct WriteImports : public TreeWalker
+class WriteImports : public WriteIncludesBase
{
public:
+ using ClassesPerModule = QMap<QString, QStringList>;
+
explicit WriteImports(Uic *uic);
void acceptUI(DomUI *node) override;
- void acceptCustomWidget(DomCustomWidget *node) override;
+ void acceptProperty(DomProperty *node) override;
-private:
- void writeImport(const QString &module);
- QString qtModuleOf(const DomCustomWidget *node) const;
+protected:
+ void doAdd(const QString &className, const DomCustomWidget *dcw = nullptr) override;
- Uic *const m_uic;
+private:
+ void addPythonCustomWidget(const QString &className, const DomCustomWidget *dcw);
+ bool addQtClass(const QString &className);
+ void addEnumBaseClass(const QString &v);
+ void writeResourceImport(const QString &module);
+ QString resourceAbsolutePath(QString resource) const;
+
+ QHash<QString, QString> m_classToModule;
+ // Module->class (modules sorted)
+
+ ClassesPerModule m_qtClasses;
+ ClassesPerModule m_customWidgets;
+ QStringList m_plainCustomWidgets; // Custom widgets without any module
};
} // namespace Python
diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h
index 0702076f15..e9e4cfde12 100644
--- a/src/tools/uic/qclass_lib_map.h
+++ b/src/tools/uic/qclass_lib_map.h
@@ -1,6 +1,7 @@
QT_CLASS_LIB(QAbstractAnimation, QtCore, qabstractanimation.h)
QT_CLASS_LIB(QAnimationDriver, QtCore, qabstractanimation.h)
QT_CLASS_LIB(QAnimationGroup, QtCore, qanimationgroup.h)
+QT_CLASS_LIB(QChartView, QtCharts, qchartview.h)
QT_CLASS_LIB(QParallelAnimationGroup, QtCore, qparallelanimationgroup.h)
QT_CLASS_LIB(QPauseAnimation, QtCore, qpauseanimation.h)
QT_CLASS_LIB(QPropertyAnimation, QtCore, qpropertyanimation.h)
@@ -61,7 +62,6 @@ QT_CLASS_LIB(QFileInfoList, QtCore, qfileinfo.h)
QT_CLASS_LIB(QFileInfoListIterator, QtCore, qfileinfo.h)
QT_CLASS_LIB(QFileSystemWatcher, QtCore, qfilesystemwatcher.h)
QT_CLASS_LIB(QIODevice, QtCore, qiodevice.h)
-QT_CLASS_LIB(Q_PID, QtCore, qprocess.h)
QT_CLASS_LIB(QProcessEnvironment, QtCore, qprocess.h)
QT_CLASS_LIB(QProcess, QtCore, qprocess.h)
QT_CLASS_LIB(QResource, QtCore, qresource.h)
@@ -71,8 +71,6 @@ QT_CLASS_LIB(QTextStream, QtCore, qtextstream.h)
QT_CLASS_LIB(QTextStreamFunction, QtCore, qtextstream.h)
QT_CLASS_LIB(QTextStreamManipulator, QtCore, qtextstream.h)
QT_CLASS_LIB(QTS, QtCore, qtextstream.h)
-QT_CLASS_LIB(QTextIStream, QtCore, qtextstream.h)
-QT_CLASS_LIB(QTextOStream, QtCore, qtextstream.h)
QT_CLASS_LIB(QUrl, QtCore, qurl.h)
QT_CLASS_LIB(QAbstractEventDispatcher, QtCore, qabstracteventdispatcher.h)
QT_CLASS_LIB(QModelIndex, QtCore, qabstractitemmodel.h)
@@ -95,8 +93,6 @@ QT_CLASS_LIB(QMetaEnum, QtCore, qmetaobject.h)
QT_CLASS_LIB(QMetaProperty, QtCore, qmetaobject.h)
QT_CLASS_LIB(QMetaClassInfo, QtCore, qmetaobject.h)
QT_CLASS_LIB(QMetaType, QtCore, qmetatype.h)
-QT_CLASS_LIB(QMetaTypeId, QtCore, qmetatype.h)
-QT_CLASS_LIB(QMetaTypeId2, QtCore, qmetatype.h)
QT_CLASS_LIB(QMimeData, QtCore, qmimedata.h)
QT_CLASS_LIB(QObjectList, QtCore, qobject.h)
QT_CLASS_LIB(QObjectData, QtCore, qobject.h)
@@ -108,8 +104,6 @@ QT_CLASS_LIB(QGenericReturnArgument, QtCore, qobjectdefs.h)
QT_CLASS_LIB(QArgument, QtCore, qobjectdefs.h)
QT_CLASS_LIB(QReturnArgument, QtCore, qobjectdefs.h)
QT_CLASS_LIB(QMetaObject, QtCore, qobjectdefs.h)
-QT_CLASS_LIB(QMetaObjectAccessor, QtCore, qobjectdefs.h)
-QT_CLASS_LIB(QMetaObjectExtraData, QtCore, qobjectdefs.h)
QT_CLASS_LIB(QPointer, QtCore, qpointer.h)
QT_CLASS_LIB(QSharedMemory, QtCore, qsharedmemory.h)
QT_CLASS_LIB(QSignalMapper, QtCore, qsignalmapper.h)
@@ -225,24 +219,14 @@ QT_CLASS_LIB(QStack, QtCore, qstack.h)
QT_CLASS_LIB(QStdWString, QtCore, qstring.h)
QT_CLASS_LIB(QString, QtCore, qstring.h)
QT_CLASS_LIB(QLatin1String, QtCore, qstring.h)
+QT_CLASS_LIB(QLatin1StringView, QtCore, qstring.h)
QT_CLASS_LIB(QCharRef, QtCore, qstring.h)
-QT_CLASS_LIB(QConstString, QtCore, qstring.h)
QT_CLASS_LIB(QLatin1Literal, QtCore, qstring.h)
QT_CLASS_LIB(QAbstractConcatenable, QtCore, qstringbuilder.h)
QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
QT_CLASS_LIB(QStringBuilder, QtCore, qstringbuilder.h)
QT_CLASS_LIB(QStringBuilder, QtCore, qstringbuilder.h)
QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
-QT_CLASS_LIB(QConcatenable, QtCore, qstringbuilder.h)
QT_CLASS_LIB(QStringListIterator, QtCore, qstringlist.h)
QT_CLASS_LIB(QMutableStringListIterator, QtCore, qstringlist.h)
QT_CLASS_LIB(QStringList, QtCore, qstringlist.h)
@@ -250,13 +234,6 @@ QT_CLASS_LIB(QStringMatcher, QtCore, qstringmatcher.h)
QT_CLASS_LIB(QTextBoundaryFinder, QtCore, qtextboundaryfinder.h)
QT_CLASS_LIB(QTimeLine, QtCore, qtimeline.h)
QT_CLASS_LIB(QVarLengthArray, QtCore, qvarlengtharray.h)
-QT_CLASS_LIB(QVectorData, QtCore, qvector.h)
-QT_CLASS_LIB(QVectorTypedData, QtCore, qvector.h)
-QT_CLASS_LIB(QVector, QtCore, qvector.h)
-QT_CLASS_LIB(QVectorIterator, QtCore, qvector.h)
-QT_CLASS_LIB(QMutableVectorIterator, QtCore, qvector.h)
-QT_CLASS_LIB(QVectorIterator, QtCore, qvector.h)
-QT_CLASS_LIB(QMutableVectorIterator, QtCore, qvector.h)
QT_CLASS_LIB(QXmlStreamAttribute, QtCore, qxmlstream.h)
QT_CLASS_LIB(QXmlStreamAttributes, QtCore, qxmlstream.h)
QT_CLASS_LIB(QXmlStreamNamespaceDeclaration, QtCore, qxmlstream.h)
@@ -268,29 +245,6 @@ QT_CLASS_LIB(QXmlStreamEntityDeclarations, QtCore, qxmlstream.h)
QT_CLASS_LIB(QXmlStreamEntityResolver, QtCore, qxmlstream.h)
QT_CLASS_LIB(QXmlStreamReader, QtCore, qxmlstream.h)
QT_CLASS_LIB(QXmlStreamWriter, QtCore, qxmlstream.h)
-QT_CLASS_LIB(QDeclarativeItem, QtDeclarative, qdeclarativeitem.h)
-QT_CLASS_LIB(QDeclarativeComponent, QtDeclarative, qdeclarativecomponent.h)
-QT_CLASS_LIB(QDeclarativeContext, QtDeclarative, qdeclarativecontext.h)
-QT_CLASS_LIB(QDeclarativeEngine, QtDeclarative, qdeclarativeengine.h)
-QT_CLASS_LIB(QDeclarativeError, QtDeclarative, qdeclarativeerror.h)
-QT_CLASS_LIB(QDeclarativeExpression, QtDeclarative, qdeclarativeexpression.h)
-QT_CLASS_LIB(QDeclarativeExtensionInterface, QtDeclarative, qdeclarativeextensioninterface.h)
-QT_CLASS_LIB(QDeclarativeExtensionPlugin, QtDeclarative, qdeclarativeextensionplugin.h)
-QT_CLASS_LIB(QDeclarativeImageProvider, QtDeclarative, qdeclarativeimageprovider.h)
-QT_CLASS_LIB(QDeclarativeInfo, QtDeclarative, qdeclarativeinfo.h)
-QT_CLASS_LIB(QDeclarativeListProperty, QtDeclarative, qdeclarativelist.h)
-QT_CLASS_LIB(QDeclarativeListReference, QtDeclarative, qdeclarativelist.h)
-QT_CLASS_LIB(QDeclarativeNetworkAccessManagerFactory, QtDeclarative, qdeclarativenetworkaccessmanagerfactory.h)
-QT_CLASS_LIB(QDeclarativeParserStatus, QtDeclarative, qdeclarativeparserstatus.h)
-QT_CLASS_LIB(QDeclarativeAttachedPropertiesFunc, QtDeclarative, qdeclarativeprivate.h)
-QT_CLASS_LIB(QDeclarativeTypeInfo, QtDeclarative, qdeclarativeprivate.h)
-QT_CLASS_LIB(QDeclarativeProperty, QtDeclarative, qdeclarativeproperty.h)
-QT_CLASS_LIB(QDeclarativeProperties, QtDeclarative, qdeclarativeproperty.h)
-QT_CLASS_LIB(QDeclarativePropertyValueInterceptor, QtDeclarative, qdeclarativepropertyvalueinterceptor.h)
-QT_CLASS_LIB(QDeclarativePropertyValueSource, QtDeclarative, qdeclarativepropertyvaluesource.h)
-QT_CLASS_LIB(QDeclarativeScriptString, QtDeclarative, qdeclarativescriptstring.h)
-QT_CLASS_LIB(QDeclarativePropertyMap, QtDeclarative, qdeclarativepropertymap.h)
-QT_CLASS_LIB(QDeclarativeView, QtDeclarative, qdeclarativeview.h)
QT_CLASS_LIB(QMacGLCompatTypes, QtOpenGL, qgl.h)
QT_CLASS_LIB(QMacGLCompatTypes, QtOpenGL, qgl.h)
QT_CLASS_LIB(QMacCompatGLint, QtOpenGL, qgl.h)
@@ -342,7 +296,6 @@ QT_CLASS_LIB(QNetworkInterface, QtNetwork, qnetworkinterface.h)
QT_CLASS_LIB(QNetworkProxyQuery, QtNetwork, qnetworkproxy.h)
QT_CLASS_LIB(QNetworkProxy, QtNetwork, qnetworkproxy.h)
QT_CLASS_LIB(QNetworkProxyFactory, QtNetwork, qnetworkproxy.h)
-QT_CLASS_LIB(QUrlInfo, QtNetwork, qurlinfo.h)
QT_CLASS_LIB(QAbstractSocket, QtNetwork, qabstractsocket.h)
QT_CLASS_LIB(QLocalServer, QtNetwork, qlocalserver.h)
QT_CLASS_LIB(QLocalSocket, QtNetwork, qlocalsocket.h)
@@ -368,22 +321,6 @@ QT_CLASS_LIB(QHelpSearchQuery, QtHelp, qhelpsearchengine.h)
QT_CLASS_LIB(QHelpSearchEngine, QtHelp, qhelpsearchengine.h)
QT_CLASS_LIB(QHelpSearchQueryWidget, QtHelp, qhelpsearchquerywidget.h)
QT_CLASS_LIB(QHelpSearchResultWidget, QtHelp, qhelpsearchresultwidget.h)
-QT_CLASS_LIB(QAbstractMessageHandler, QtXmlPatterns, qabstractmessagehandler.h)
-QT_CLASS_LIB(QAbstractUriResolver, QtXmlPatterns, qabstracturiresolver.h)
-QT_CLASS_LIB(QXmlNodeModelIndex, QtXmlPatterns, qabstractxmlnodemodel.h)
-QT_CLASS_LIB(QAbstractXmlNodeModel, QtXmlPatterns, qabstractxmlnodemodel.h)
-QT_CLASS_LIB(QXmlItem, QtXmlPatterns, qabstractxmlnodemodel.h)
-QT_CLASS_LIB(QAbstractXmlReceiver, QtXmlPatterns, qabstractxmlreceiver.h)
-QT_CLASS_LIB(QSimpleXmlNodeModel, QtXmlPatterns, qsimplexmlnodemodel.h)
-QT_CLASS_LIB(QSourceLocation, QtXmlPatterns, qsourcelocation.h)
-QT_CLASS_LIB(QXmlFormatter, QtXmlPatterns, qxmlformatter.h)
-QT_CLASS_LIB(QXmlName, QtXmlPatterns, qxmlname.h)
-QT_CLASS_LIB(QXmlNamePool, QtXmlPatterns, qxmlnamepool.h)
-QT_CLASS_LIB(QXmlQuery, QtXmlPatterns, qxmlquery.h)
-QT_CLASS_LIB(QXmlResultItems, QtXmlPatterns, qxmlresultitems.h)
-QT_CLASS_LIB(QXmlSchema, QtXmlPatterns, qxmlschema.h)
-QT_CLASS_LIB(QXmlSchemaValidator, QtXmlPatterns, qxmlschemavalidator.h)
-QT_CLASS_LIB(QXmlSerializer, QtXmlPatterns, qxmlserializer.h)
QT_CLASS_LIB(QAxBase, QtAxContainer, qaxbase.h)
QT_CLASS_LIB(QAxObject, QtAxContainer, qaxobject.h)
QT_CLASS_LIB(QAxScriptEngine, QtAxContainer, qaxscript.h)
@@ -395,21 +332,6 @@ QT_CLASS_LIB(QAxAggregated, QtAxContainer, qaxaggregated.h)
QT_CLASS_LIB(QAxBindable, QtAxContainer, qaxbindable.h)
QT_CLASS_LIB(QAxFactory, QtAxContainer, qaxfactory.h)
QT_CLASS_LIB(QAxClass, QtAxContainer, qaxfactory.h)
-QT_CLASS_LIB(QGraphicsWebView, QtWebKitWidgets, qgraphicswebview.h)
-QT_CLASS_LIB(QWebDatabase, QtWebKit, qwebdatabase.h)
-QT_CLASS_LIB(QWebElement, QtWebKit, qwebelement.h)
-QT_CLASS_LIB(QWebElementCollection, QtWebKit, qwebelement.h)
-QT_CLASS_LIB(QWebHitTestResult, QtWebKitWidgets, qwebframe.h)
-QT_CLASS_LIB(QWebFrame, QtWebKitWidgets, qwebframe.h)
-QT_CLASS_LIB(QWebHistoryItem, QtWebKit, qwebhistory.h)
-QT_CLASS_LIB(QWebHistory, QtWebKit, qwebhistory.h)
-QT_CLASS_LIB(QWebHistoryInterface, QtWebKit, qwebhistoryinterface.h)
-QT_CLASS_LIB(QWebInspector, QtWebKitWidgets, qwebinspector.h)
-QT_CLASS_LIB(QWebPage, QtWebKitWidgets, qwebpage.h)
-QT_CLASS_LIB(QWebPluginFactory, QtWebKit, qwebpluginfactory.h)
-QT_CLASS_LIB(QWebSecurityOrigin, QtWebKit, qwebsecurityorigin.h)
-QT_CLASS_LIB(QWebSettings, QtWebKit, qwebsettings.h)
-QT_CLASS_LIB(QWebView, QtWebKitWidgets, qwebview.h)
QT_CLASS_LIB(QAudio, QtMultimedia, qaudio.h)
QT_CLASS_LIB(QAudioDeviceInfo, QtMultimedia, qaudiodeviceinfo.h)
QT_CLASS_LIB(QAbstractAudioDeviceInfo, QtMultimedia, qaudioengine.h)
@@ -462,22 +384,6 @@ QT_CLASS_LIB(QDBusReply, QtDBus, qdbusreply.h)
QT_CLASS_LIB(QDBusReply, QtDBus, qdbusreply.h)
QT_CLASS_LIB(QDBusServer, QtDBus, qdbusserver.h)
QT_CLASS_LIB(QDBusServiceWatcher, QtDBus, qdbusservicewatcher.h)
-QT_CLASS_LIB(QScriptable, QtScript, qscriptable.h)
-QT_CLASS_LIB(QScriptClass, QtScript, qscriptclass.h)
-QT_CLASS_LIB(QScriptClassPropertyIterator, QtScript, qscriptclasspropertyiterator.h)
-QT_CLASS_LIB(QScriptContext, QtScript, qscriptcontext.h)
-QT_CLASS_LIB(QScriptContextInfo, QtScript, qscriptcontextinfo.h)
-QT_CLASS_LIB(QScriptContextInfoList, QtScript, qscriptcontextinfo.h)
-QT_CLASS_LIB(QScriptSyntaxCheckResult, QtScript, qscriptengine.h)
-QT_CLASS_LIB(QScriptEngine, QtScript, qscriptengine.h)
-QT_CLASS_LIB(QScriptEngineAgent, QtScript, qscriptengineagent.h)
-QT_CLASS_LIB(QScriptExtensionInterface, QtScript, qscriptextensioninterface.h)
-QT_CLASS_LIB(QScriptExtensionPlugin, QtScript, qscriptextensionplugin.h)
-QT_CLASS_LIB(QScriptProgram, QtScript, qscriptprogram.h)
-QT_CLASS_LIB(QScriptString, QtScript, qscriptstring.h)
-QT_CLASS_LIB(QScriptValueList, QtScript, qscriptvalue.h)
-QT_CLASS_LIB(QScriptValue, QtScript, qscriptvalue.h)
-QT_CLASS_LIB(QScriptValueIterator, QtScript, qscriptvalueiterator.h)
QT_CLASS_LIB(QSqlDriverCreatorBase, QtSql, qsqldatabase.h)
QT_CLASS_LIB(QSqlDriverCreator, QtSql, qsqldatabase.h)
QT_CLASS_LIB(QSqlDatabase, QtSql, qsqldatabase.h)
@@ -516,7 +422,7 @@ QT_CLASS_LIB(QAccessibleFactoryInterface, QtWidgets, qaccessibleplugin.h)
QT_CLASS_LIB(QAccessiblePlugin, QtWidgets, qaccessibleplugin.h)
QT_CLASS_LIB(QAccessibleWidget, QtWidgets, qaccessiblewidget.h)
QT_CLASS_LIB(QAccessibleWidgetEx, QtWidgets, qaccessiblewidget.h)
-QT_CLASS_LIB(QAbstractPrintDialog, QtWidgets, qabstractprintdialog.h)
+QT_CLASS_LIB(QAbstractPrintDialog, QtPrintSupport, qabstractprintdialog.h)
QT_CLASS_LIB(QColorDialog, QtWidgets, qcolordialog.h)
QT_CLASS_LIB(QDialog, QtWidgets, qdialog.h)
QT_CLASS_LIB(QErrorMessage, QtWidgets, qerrormessage.h)
@@ -525,7 +431,7 @@ QT_CLASS_LIB(QFileSystemModel, QtGui, qfilesystemmodel.h)
QT_CLASS_LIB(QFontDialog, QtWidgets, qfontdialog.h)
QT_CLASS_LIB(QInputDialog, QtWidgets, qinputdialog.h)
QT_CLASS_LIB(QMessageBox, QtWidgets, qmessagebox.h)
-QT_CLASS_LIB(QPageSetupDialog, QtWidgets, qpagesetupdialog.h)
+QT_CLASS_LIB(QPageSetupDialog, QtPrintSupport, qpagesetupdialog.h)
QT_CLASS_LIB(QOpenGLWidget, QtOpenGLWidgets, qopenglwidget.h)
QT_CLASS_LIB(QPrintDialog, QtPrintSupport, qprintdialog.h)
QT_CLASS_LIB(QPrintPreviewDialog, QtPrintSupport, qprintpreviewdialog.h)
@@ -575,11 +481,9 @@ QT_CLASS_LIB(QGraphicsWidget, QtWidgets, qgraphicswidget.h)
QT_CLASS_LIB(QBitmap, QtGui, qbitmap.h)
QT_CLASS_LIB(QIcon, QtGui, qicon.h)
QT_CLASS_LIB(QIconEngine, QtGui, qiconengine.h)
-QT_CLASS_LIB(QIconEngineV2, QtGui, qiconengine.h)
QT_CLASS_LIB(QIconEngineFactoryInterface, QtGui, qiconengineplugin.h)
QT_CLASS_LIB(QIconEnginePlugin, QtGui, qiconengineplugin.h)
QT_CLASS_LIB(QIconEngineFactoryInterfaceV2, QtGui, qiconengineplugin.h)
-QT_CLASS_LIB(QIconEnginePluginV2, QtGui, qiconengineplugin.h)
QT_CLASS_LIB(QImage, QtGui, qimage.h)
QT_CLASS_LIB(QImageIOHandler, QtGui, qimageiohandler.h)
QT_CLASS_LIB(QImageIOHandlerFactoryInterface, QtGui, qimageiohandler.h)
@@ -592,7 +496,7 @@ QT_CLASS_LIB(QPixmap, QtGui, qpixmap.h)
QT_CLASS_LIB(QPixmapCache, QtGui, qpixmapcache.h)
QT_CLASS_LIB(QAbstractItemDelegate, QtWidgets, qabstractitemdelegate.h)
QT_CLASS_LIB(QAbstractItemView, QtWidgets, qabstractitemview.h)
-QT_CLASS_LIB(QAbstractProxyModel, QtWidgets, qabstractproxymodel.h)
+QT_CLASS_LIB(QAbstractProxyModel, QtCore, qabstractproxymodel.h)
QT_CLASS_LIB(QColumnView, QtWidgets, qcolumnview.h)
QT_CLASS_LIB(QDataWidgetMapper, QtWidgets, qdatawidgetmapper.h)
QT_CLASS_LIB(QFileIconProvider, QtWidgets, qfileiconprovider.h)
@@ -608,10 +512,10 @@ QT_CLASS_LIB(QItemSelection, QtWidgets, qitemselectionmodel.h)
QT_CLASS_LIB(QListView, QtWidgets, qlistview.h)
QT_CLASS_LIB(QListWidgetItem, QtWidgets, qlistwidget.h)
QT_CLASS_LIB(QListWidget, QtWidgets, qlistwidget.h)
-QT_CLASS_LIB(QSortFilterProxyModel, QtWidgets, qsortfilterproxymodel.h)
-QT_CLASS_LIB(QStandardItem, QtWidgets, qstandarditemmodel.h)
-QT_CLASS_LIB(QStandardItemModel, QtWidgets, qstandarditemmodel.h)
-QT_CLASS_LIB(QStringListModel, QtWidgets, qstringlistmodel.h)
+QT_CLASS_LIB(QSortFilterProxyModel, QtCore, qsortfilterproxymodel.h)
+QT_CLASS_LIB(QStandardItem, QtGui, qstandarditemmodel.h)
+QT_CLASS_LIB(QStandardItemModel, QtGui, qstandarditemmodel.h)
+QT_CLASS_LIB(QStringListModel, QtCore, qstringlistmodel.h)
QT_CLASS_LIB(QStyledItemDelegate, QtWidgets, qstyleditemdelegate.h)
QT_CLASS_LIB(QTableView, QtWidgets, qtableview.h)
QT_CLASS_LIB(QTableWidgetSelectionRange, QtWidgets, qtablewidget.h)
@@ -747,7 +651,6 @@ QT_CLASS_LIB(QRegion, QtGui, qregion.h)
QT_CLASS_LIB(QRgb, QtGui, qrgb.h)
QT_CLASS_LIB(QStylePainter, QtGui, qstylepainter.h)
QT_CLASS_LIB(QTransform, QtGui, qtransform.h)
-QT_CLASS_LIB(QWMatrix, QtGui, qwmatrix.h)
QT_CLASS_LIB(QCommonStyle, QtWidgets, qcommonstyle.h)
QT_CLASS_LIB(QProxyStyle, QtWidgets, qproxystyle.h)
QT_CLASS_LIB(QStyle, QtWidgets, qstyle.h)
@@ -930,59 +833,11 @@ QT_CLASS_LIB(QDesignerCustomWidgetInterface, QtDesigner, customwidget.h)
QT_CLASS_LIB(QDesignerCustomWidgetCollectionInterface, QtDesigner, customwidget.h)
QT_CLASS_LIB(QFormBuilder, QtDesigner, formbuilder.h)
QT_CLASS_LIB(QDesignerExportWidget, QtDesigner, qdesignerexportwidget.h)
-QT_CLASS_LIB(Phonon::AbstractAudioOutput, phonon, abstractaudiooutput.h)
-QT_CLASS_LIB(Phonon::AbstractMediaStream, phonon, abstractmediastream.h)
-QT_CLASS_LIB(Phonon::AbstractVideoOutput, phonon, abstractvideooutput.h)
-QT_CLASS_LIB(Phonon::AddonInterface, phonon, addoninterface.h)
-QT_CLASS_LIB(Phonon::AudioDataOutput, phonon, audiodataoutput.h)
-QT_CLASS_LIB(Phonon::AudioDataOutputInterface, phonon, audiodataoutputinterface.h)
-QT_CLASS_LIB(Phonon::AudioOutput, phonon, audiooutput.h)
-QT_CLASS_LIB(Phonon::AudioOutputInterface40, phonon, audiooutputinterface.h)
-QT_CLASS_LIB(Phonon::AudioOutputInterface42, phonon, audiooutputinterface.h)
-QT_CLASS_LIB(Phonon::AudioOutputInterface, phonon, audiooutputinterface.h)
-QT_CLASS_LIB(Phonon::AudioOutputInterface, phonon, audiooutputinterface.h)
-QT_CLASS_LIB(Phonon::BackendCapabilities, phonon, backendcapabilities.h)
-QT_CLASS_LIB(Phonon::BackendInterface, phonon, backendinterface.h)
-QT_CLASS_LIB(Phonon::Effect, phonon, effect.h)
-QT_CLASS_LIB(Phonon::EffectInterface, phonon, effectinterface.h)
-QT_CLASS_LIB(Phonon::EffectParameter, phonon, effectparameter.h)
-QT_CLASS_LIB(Phonon::EffectWidget, phonon, effectwidget.h)
-QT_CLASS_LIB(Phonon::GlobalConfig, phonon, globalconfig.h)
-QT_CLASS_LIB(Phonon::MediaController, phonon, mediacontroller.h)
-QT_CLASS_LIB(Phonon::MediaNode, phonon, medianode.h)
-QT_CLASS_LIB(Phonon::MediaObject, phonon, mediaobject.h)
-QT_CLASS_LIB(Phonon::MediaObjectInterface, phonon, mediaobjectinterface.h)
-QT_CLASS_LIB(Phonon::MediaSource, phonon, mediasource.h)
-QT_CLASS_LIB(Phonon::ObjectDescriptionData, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::ObjectDescription, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::AudioOutputDevice, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::AudioCaptureDevice, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::EffectDescription, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::AudioChannelDescription, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::SubtitleDescription, phonon, objectdescription.h)
-QT_CLASS_LIB(Phonon::ObjectDescriptionModelData, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::ObjectDescriptionModel, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::AudioOutputDeviceModel, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::AudioCaptureDeviceModel, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::EffectDescriptionModel, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::AudioChannelDescriptionModel, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::SubtitleDescriptionModel, phonon, objectdescriptionmodel.h)
-QT_CLASS_LIB(Phonon::Path, phonon, path.h)
-QT_CLASS_LIB(Phonon::Global, phonon, phononnamespace.h)
-QT_CLASS_LIB(Phonon::PlatformPlugin, phonon, platformplugin.h)
-QT_CLASS_LIB(Phonon::PulseSupport, phonon, pulsesupport.h)
-QT_CLASS_LIB(Phonon::SeekSlider, phonon, seekslider.h)
-QT_CLASS_LIB(Phonon::StreamInterface, phonon, streaminterface.h)
-QT_CLASS_LIB(Phonon::VideoPlayer, phonon, videoplayer.h)
-QT_CLASS_LIB(Phonon::VideoWidget, phonon, videowidget.h)
-QT_CLASS_LIB(Phonon::VideoWidgetInterface, phonon, videowidgetinterface.h)
-QT_CLASS_LIB(Phonon::VideoWidgetInterface44, phonon, videowidgetinterface.h)
-QT_CLASS_LIB(Phonon::VideoWidgetInterfaceLatest, phonon, videowidgetinterface.h)
-QT_CLASS_LIB(Phonon::VideoWidgetInterfaceLatest, phonon, videowidgetinterface.h)
-QT_CLASS_LIB(Phonon::VolumeFaderEffect, phonon, volumefadereffect.h)
-QT_CLASS_LIB(Phonon::VolumeFaderInterface, phonon, volumefaderinterface.h)
-QT_CLASS_LIB(Phonon::VolumeSlider, phonon, volumeslider.h)
QT_CLASS_LIB(QGraphicsSvgItem, QtSvgWidgets, qgraphicssvgitem.h)
QT_CLASS_LIB(QSvgWidget, QtSvgWidgets, qsvgwidget.h)
QT_CLASS_LIB(QSvgGenerator, QtSvg, qsvggenerator.h)
QT_CLASS_LIB(QSvgRenderer, QtSvg, qsvgrenderer.h)
+QT_CLASS_LIB(QPdfView, QtPdfWidgets, qpdfview.h)
+QT_CLASS_LIB(QQuickWidget, QtQuickWidgets, qquickwidget.h)
+QT_CLASS_LIB(QVideoWidget, QtMultimediaWidgets, qvideowidget.h)
+QT_CLASS_LIB(QWebEngineView, QtWebEngineWidgets, qwebengineview.h)
diff --git a/src/tools/uic/shared/language.cpp b/src/tools/uic/shared/language.cpp
index cbcc7a2b57..d59688e346 100644
--- a/src/tools/uic/shared/language.cpp
+++ b/src/tools/uic/shared/language.cpp
@@ -1,37 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "language.h"
#include <QtCore/qtextstream.h>
+#include <QtCore/QList>
namespace language {
+using namespace Qt::StringLiterals;
+
static Encoding encoding = Encoding::Utf8;
static Language _language = Language::Cpp;
@@ -42,31 +20,37 @@ void setLanguage(Language l)
_language = l;
switch (_language) {
case Language::Cpp:
- derefPointer = QLatin1String("->");
- nullPtr = QLatin1String("nullptr");
- operatorNew = QLatin1String("new ");
- qtQualifier = QLatin1String("Qt::");
- qualifier = QLatin1String("::");
- self = QLatin1String(""); // for testing: change to "this->";
- eol = QLatin1String(";\n");
- emptyString = QLatin1String("QString()");
+ derefPointer = u"->"_s;
+ listStart = '{';
+ listEnd = '}';
+ nullPtr = u"nullptr"_s;
+ operatorNew = u"new "_s;
+ qtQualifier = u"Qt::"_s;
+ qualifier = u"::"_s;
+ self = u""_s; // for testing: change to "this->";
+ eol = u";\n"_s;
+ emptyString = u"QString()"_s;
encoding = Encoding::Utf8;
break;
case Language::Python:
- derefPointer = QLatin1String(".");
- nullPtr = QLatin1String("None");
- operatorNew = QLatin1String("");
- qtQualifier = QLatin1String("Qt.");
- qualifier = QLatin1String(".");
- self = QLatin1String("self.");
- eol = QLatin1String("\n");
- emptyString = QLatin1String("\"\"");
+ derefPointer = u"."_s;
+ listStart = '[';
+ listEnd = ']';
+ nullPtr = u"None"_s;
+ operatorNew = u""_s;
+ qtQualifier = u"Qt."_s;
+ qualifier = u"."_s;
+ self = u"self."_s;
+ eol = u"\n"_s;
+ emptyString = u"\"\""_s;
encoding = Encoding::Unicode;
break;
}
}
QString derefPointer;
+char listStart;
+char listEnd;
QString nullPtr;
QString operatorNew;
QString qtQualifier;
@@ -75,9 +59,9 @@ QString self;
QString eol;
QString emptyString;
-QString cppQualifier = QLatin1String("::");
-QString cppTrue = QLatin1String("true");
-QString cppFalse = QLatin1String("false");
+QString cppQualifier = u"::"_s;
+QString cppTrue = u"true"_s;
+QString cppFalse = u"false"_s;
QTextStream &operator<<(QTextStream &str, const qtConfig &c)
{
@@ -100,97 +84,97 @@ QTextStream &operator<<(QTextStream &str, const closeQtConfig &c)
struct EnumLookup
{
int value;
- const char *valueString;
+ QLatin1StringView valueString;
};
template <int N>
-const char *lookupEnum(const EnumLookup(&array)[N], int value, int defaultIndex = 0)
+QLatin1StringView lookupEnum(const EnumLookup(&array)[N], int value, int defaultIndex = 0)
{
for (int i = 0; i < N; ++i) {
if (value == array[i].value)
return array[i].valueString;
}
- const char *defaultValue = array[defaultIndex].valueString;
+ auto defaultValue = array[defaultIndex].valueString;
qWarning("uic: Warning: Invalid enumeration value %d, defaulting to %s",
- value, defaultValue);
+ value, defaultValue.data());
return defaultValue;
}
QString fixClassName(QString className)
{
if (language() == Language::Python)
- className.replace(cppQualifier, QLatin1String("_"));
+ className.replace(cppQualifier, "_"_L1);
return className;
}
-const char *toolbarArea(int v)
+QLatin1StringView toolbarArea(int v)
{
static const EnumLookup toolBarAreas[] =
{
- {0, "NoToolBarArea"},
- {0x1, "LeftToolBarArea"},
- {0x2, "RightToolBarArea"},
- {0x4, "TopToolBarArea"},
- {0x8, "BottomToolBarArea"},
- {0xf, "AllToolBarAreas"}
+ {0, "NoToolBarArea"_L1},
+ {0x1, "LeftToolBarArea"_L1},
+ {0x2, "RightToolBarArea"_L1},
+ {0x4, "TopToolBarArea"_L1},
+ {0x8, "BottomToolBarArea"_L1},
+ {0xf, "AllToolBarAreas"_L1}
};
return lookupEnum(toolBarAreas, v);
}
-const char *sizePolicy(int v)
+QLatin1StringView sizePolicy(int v)
{
static const EnumLookup sizePolicies[] =
{
- {0, "Fixed"},
- {0x1, "Minimum"},
- {0x4, "Maximum"},
- {0x5, "Preferred"},
- {0x3, "MinimumExpanding"},
- {0x7, "Expanding"},
- {0xD, "Ignored"}
+ {0, "Fixed"_L1},
+ {0x1, "Minimum"_L1},
+ {0x4, "Maximum"_L1},
+ {0x5, "Preferred"_L1},
+ {0x3, "MinimumExpanding"_L1},
+ {0x7, "Expanding"_L1},
+ {0xD, "Ignored"_L1}
};
return lookupEnum(sizePolicies, v, 3);
}
-const char *dockWidgetArea(int v)
+QLatin1StringView dockWidgetArea(int v)
{
static const EnumLookup dockWidgetAreas[] =
{
- {0, "NoDockWidgetArea"},
- {0x1, "LeftDockWidgetArea"},
- {0x2, "RightDockWidgetArea"},
- {0x4, "TopDockWidgetArea"},
- {0x8, "BottomDockWidgetArea"},
- {0xf, "AllDockWidgetAreas"}
+ {0, "NoDockWidgetArea"_L1},
+ {0x1, "LeftDockWidgetArea"_L1},
+ {0x2, "RightDockWidgetArea"_L1},
+ {0x4, "TopDockWidgetArea"_L1},
+ {0x8, "BottomDockWidgetArea"_L1},
+ {0xf, "AllDockWidgetAreas"_L1}
};
return lookupEnum(dockWidgetAreas, v);
}
-const char *paletteColorRole(int v)
+QLatin1StringView paletteColorRole(int v)
{
static const EnumLookup colorRoles[] =
{
- {0, "WindowText"},
- {1, "Button"},
- {2, "Light"},
- {3, "Midlight"},
- {4, "Dark"},
- {5, "Mid"},
- {6, "Text"},
- {7, "BrightText"},
- {8, "ButtonText"},
- {9, "Base"},
- {10, "Window"},
- {11, "Shadow"},
- {12, "Highlight"},
- {13, "HighlightedText"},
- {14, "Link"},
- {15, "LinkVisited"},
- {16, "AlternateBase"},
- {17, "NoRole"},
- {18, "ToolTipBase"},
- {19, "ToolTipText"},
- {20, "PlaceholderText"},
+ {0, "WindowText"_L1},
+ {1, "Button"_L1},
+ {2, "Light"_L1},
+ {3, "Midlight"_L1},
+ {4, "Dark"_L1},
+ {5, "Mid"_L1},
+ {6, "Text"_L1},
+ {7, "BrightText"_L1},
+ {8, "ButtonText"_L1},
+ {9, "Base"_L1},
+ {10, "Window"_L1},
+ {11, "Shadow"_L1},
+ {12, "Highlight"_L1},
+ {13, "HighlightedText"_L1},
+ {14, "Link"_L1},
+ {15, "LinkVisited"_L1},
+ {16, "AlternateBase"_L1},
+ {17, "NoRole"_L1},
+ {18, "ToolTipBase"_L1},
+ {19, "ToolTipText"_L1},
+ {20, "PlaceholderText"_L1},
};
return lookupEnum(colorRoles, v);
}
@@ -211,7 +195,7 @@ static int formatEscapedNumber(QTextStream &str, ushort value, int base, int wid
const auto oldFieldWidth = str.fieldWidth();
const auto oldFieldAlignment = str.fieldAlignment();
const auto oldIntegerBase = str.integerBase();
- str.setPadChar(QLatin1Char('0'));
+ str.setPadChar(u'0');
str.setFieldWidth(width);
str.setFieldAlignment(QTextStream::AlignRight);
str.setIntegerBase(base);
@@ -387,22 +371,69 @@ void _formatStackVariable(QTextStream &str, const char *className, QStringView v
}
}
+enum class OverloadUse {
+ Always,
+ WhenAmbiguousOrEmpty, // Use overload if
+ // - signal/slot is ambiguous
+ // - argument list is empty (chance of connecting mismatching T against const T &)
+ Never,
+};
+
// Format a member function for a signal slot connection
-static void formatMemberFnPtr(QTextStream &str, const SignalSlot &s,
- bool useQOverload = false)
+static bool isConstRef(const QStringView &arg)
{
- const int parenPos = s.signature.indexOf(QLatin1Char('('));
- Q_ASSERT(parenPos >= 0);
- if (useQOverload) {
- const auto parameters = QStringView{s.signature}.mid(parenPos + 1,
- s.signature.size() - parenPos - 2);
- str << "qOverload<" << parameters << ">(";
+ return arg.startsWith(u'Q') && arg != "QPoint"_L1 && arg != "QSize"_L1;
+}
+
+static QString formatOverload(const QStringView &parameters)
+{
+ QString result = "qOverload<"_L1;
+ const auto args = QStringView{parameters}.split(u',');
+ for (qsizetype i = 0, size = args.size(); i < size; ++i) {
+ const auto &arg = args.at(i);
+ if (i > 0)
+ result += u',';
+ const bool constRef = isConstRef(arg);
+ if (constRef)
+ result += "const "_L1;
+ result += arg;
+ if (constRef)
+ result += u'&';
}
+ result += u'>';
+ return result;
+}
+static void formatMemberFnPtr(QTextStream &str, const SignalSlot &s, OverloadUse useQOverload)
+{
+ const qsizetype parenPos = s.signature.indexOf(u'(');
+ Q_ASSERT(parenPos >= 0);
const auto functionName = QStringView{s.signature}.left(parenPos);
+
+ const auto parameters = QStringView{s.signature}.mid(parenPos + 1,
+ s.signature.size() - parenPos - 2);
+
+ const bool isAmbiguous = s.options.testFlag(SignalSlotOption::Ambiguous);
+ bool withOverload = false; // just to silence the compiler
+
+ switch (useQOverload) {
+ case OverloadUse::Always:
+ withOverload = true;
+ break;
+ case OverloadUse::Never:
+ withOverload = false;
+ break;
+ case OverloadUse::WhenAmbiguousOrEmpty:
+ withOverload = parameters.empty() || isAmbiguous;
+ break;
+ }
+
+ if (withOverload)
+ str << formatOverload(parameters) << '(';
+
str << '&' << s.className << "::" << functionName;
- if (useQOverload)
+ if (withOverload)
str << ')';
}
@@ -411,9 +442,9 @@ static void formatMemberFnPtrConnection(QTextStream &str,
const SignalSlot &receiver)
{
str << "QObject::connect(" << sender.name << ", ";
- formatMemberFnPtr(str, sender);
+ formatMemberFnPtr(str, sender, OverloadUse::Never);
str << ", " << receiver.name << ", ";
- formatMemberFnPtr(str, receiver);
+ formatMemberFnPtr(str, receiver, OverloadUse::WhenAmbiguousOrEmpty);
str << ')';
}
@@ -439,12 +470,22 @@ void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSl
break;
}
break;
- case Language::Python:
- str << sender.name << '.'
- << QStringView{sender.signature}.left(sender.signature.indexOf(QLatin1Char('(')))
- << ".connect(" << receiver.name << '.'
- << QStringView{receiver.signature}.left(receiver.signature.indexOf(QLatin1Char('(')))
+ case Language::Python: {
+ const auto paren = sender.signature.indexOf(u'(');
+ auto senderSignature = QStringView{sender.signature};
+ str << sender.name << '.' << senderSignature.left(paren);
+ // Signals like "QAbstractButton::clicked(checked=false)" require
+ // the parameter if it is used.
+ if (sender.options.testFlag(SignalSlotOption::Ambiguous)) {
+ const QStringView parameters =
+ senderSignature.mid(paren + 1, senderSignature.size() - paren - 2);
+ if (!parameters.isEmpty() && !parameters.contains(u','))
+ str << "[\"" << parameters << "\"]";
+ }
+ str << ".connect(" << receiver.name << '.'
+ << QStringView{receiver.signature}.left(receiver.signature.indexOf(u'('))
<< ')';
+ }
break;
}
}
diff --git a/src/tools/uic/shared/language.h b/src/tools/uic/shared/language.h
index fcc2d5d258..de39122ee8 100644
--- a/src/tools/uic/shared/language.h
+++ b/src/tools/uic/shared/language.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef LANGUAGE_H
#define LANGUAGE_H
@@ -48,6 +23,8 @@ ConnectionSyntax connectionSyntax();
void setConnectionSyntax(ConnectionSyntax cs);
extern QString derefPointer;
+extern char listStart;
+extern char listEnd;
extern QString nullPtr;
extern QString operatorNew;
extern QString qtQualifier;
@@ -98,10 +75,10 @@ QTextStream &operator<<(QTextStream &, const closeQtConfig &c);
QString fixClassName(QString className);
-const char *toolbarArea(int v);
-const char *sizePolicy(int v);
-const char *dockWidgetArea(int v);
-const char *paletteColorRole(int v);
+QLatin1StringView toolbarArea(int v);
+QLatin1StringView sizePolicy(int v);
+QLatin1StringView dockWidgetArea(int v);
+QLatin1StringView paletteColorRole(int v);
enum class Encoding { Utf8, Unicode };
@@ -196,11 +173,19 @@ inline QTextStream &operator<<(QTextStream &str, const _stackVariable<withInitPa
using stackVariable = _stackVariable<false>;
using stackVariableWithInitParameters = _stackVariable<true>;
+enum class SignalSlotOption
+{
+ Ambiguous = 0x1
+};
+
+Q_DECLARE_FLAGS(SignalSlotOptions, SignalSlotOption)
+
struct SignalSlot
{
QString name;
QString signature;
QString className;
+ SignalSlotOptions options;
};
void formatConnection(QTextStream &str, const SignalSlot &sender, const SignalSlot &receiver,
diff --git a/src/tools/uic/shared/shared.pri b/src/tools/uic/shared/shared.pri
deleted file mode 100644
index dce2af8bf1..0000000000
--- a/src/tools/uic/shared/shared.pri
+++ /dev/null
@@ -1,5 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += $$PWD/language.h
-
-SOURCES += $$PWD/language.cpp
diff --git a/src/tools/uic/shared/writeincludesbase.cpp b/src/tools/uic/shared/writeincludesbase.cpp
new file mode 100644
index 0000000000..78f69d5391
--- /dev/null
+++ b/src/tools/uic/shared/writeincludesbase.cpp
@@ -0,0 +1,135 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#include "writeincludesbase.h"
+#include "ui4.h"
+#include <uic.h>
+#include <databaseinfo.h>
+
+QT_BEGIN_NAMESPACE
+
+static const ClassInfoEntry qclass_lib_map[] = {
+#define QT_CLASS_LIB(klass, module, header) { #klass, #module, #header },
+#include "qclass_lib_map.h"
+#undef QT_CLASS_LIB
+};
+
+ClassInfoEntries classInfoEntries()
+{
+ const ClassInfoEntry *classLibEnd = qclass_lib_map + sizeof(qclass_lib_map)/sizeof(ClassInfoEntry);
+ return {qclass_lib_map, classLibEnd};
+}
+
+// Base class for implementing a class that determines includes and equivalents
+// in other languages by implementing doAdd(). It makes sure all dependent
+// classes are known.
+WriteIncludesBase::WriteIncludesBase(Uic *uic) : m_uic(uic)
+{
+}
+
+void WriteIncludesBase::acceptUI(DomUI *node)
+{
+ m_knownClasses.clear();
+ m_laidOut = false;
+
+ if (node->elementIncludes())
+ acceptIncludes(node->elementIncludes());
+
+ // Populate known custom widgets first
+ if (node->elementCustomWidgets())
+ TreeWalker::acceptCustomWidgets(node->elementCustomWidgets());
+
+ add(QStringLiteral("QApplication"));
+ add(QStringLiteral("QVariant"));
+
+ if (node->elementButtonGroups())
+ add(QStringLiteral("QButtonGroup"));
+
+ TreeWalker::acceptUI(node);
+}
+
+void WriteIncludesBase::acceptWidget(DomWidget *node)
+{
+ add(node->attributeClass());
+ TreeWalker::acceptWidget(node);
+}
+
+void WriteIncludesBase::acceptLayout(DomLayout *node)
+{
+ add(node->attributeClass());
+ m_laidOut = true;
+ TreeWalker::acceptLayout(node);
+}
+
+void WriteIncludesBase::acceptSpacer(DomSpacer *node)
+{
+ add(QStringLiteral("QSpacerItem"));
+ TreeWalker::acceptSpacer(node);
+}
+
+void WriteIncludesBase::acceptProperty(DomProperty *node)
+{
+ if (node->kind() == DomProperty::Date)
+ add(QStringLiteral("QDate"));
+ if (node->kind() == DomProperty::Locale)
+ add(QStringLiteral("QLocale"));
+ if (node->kind() == DomProperty::IconSet)
+ add(QStringLiteral("QIcon"));
+ TreeWalker::acceptProperty(node);
+}
+
+void WriteIncludesBase::add(const QString &className, const DomCustomWidget *dcw)
+{
+ if (className.isEmpty() || m_knownClasses.contains(className))
+ return;
+
+ m_knownClasses.insert(className);
+
+ const CustomWidgetsInfo *cwi = m_uic->customWidgetsInfo();
+ static const QStringList treeViewsWithHeaders = {
+ QStringLiteral("QTreeView"), QStringLiteral("QTreeWidget"),
+ QStringLiteral("QTableView"), QStringLiteral("QTableWidget")
+ };
+ if (cwi->extendsOneOf(className, treeViewsWithHeaders))
+ add(QStringLiteral("QHeaderView"));
+
+ if (!m_laidOut && cwi->extends(className, "QToolBox"))
+ add(QStringLiteral("QLayout")); // spacing property of QToolBox)
+
+ if (className == QStringLiteral("Line")) { // ### hmm, deprecate me!
+ add(QStringLiteral("QFrame"));
+ return;
+ }
+
+ if (cwi->extends(className, "QDialogButtonBox"))
+ add(QStringLiteral("QAbstractButton")); // for signal "clicked(QAbstractButton*)"
+
+ doAdd(className, dcw);
+}
+
+void WriteIncludesBase::acceptCustomWidget(DomCustomWidget *node)
+{
+ const QString className = node->elementClass();
+ if (!className.isEmpty())
+ add(className, node);
+}
+
+void WriteIncludesBase::acceptActionGroup(DomActionGroup *node)
+{
+ add(QStringLiteral("QActionGroup"));
+ TreeWalker::acceptActionGroup(node);
+}
+
+void WriteIncludesBase::acceptAction(DomAction *node)
+{
+ add(QStringLiteral("QAction"));
+ TreeWalker::acceptAction(node);
+}
+
+void WriteIncludesBase::acceptActionRef(DomActionRef *node)
+{
+ add(QStringLiteral("QAction"));
+ TreeWalker::acceptActionRef(node);
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/shared/writeincludesbase.h b/src/tools/uic/shared/writeincludesbase.h
new file mode 100644
index 0000000000..71ddcc80d9
--- /dev/null
+++ b/src/tools/uic/shared/writeincludesbase.h
@@ -0,0 +1,74 @@
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef WRITEINCLUDES_BASE_H
+#define WRITEINCLUDES_BASE_H
+
+#include <treewalker.h>
+
+#include <QtCore/qset.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+class DomCustomWidget;
+class Uic;
+
+struct ClassInfoEntry
+{
+ const char *klass;
+ const char *module;
+ const char *header;
+};
+
+struct ClassInfoEntries
+{
+ const ClassInfoEntry *begin() const { return m_begin; }
+ const ClassInfoEntry *end() const { return m_end; }
+
+ const ClassInfoEntry *m_begin;
+ const ClassInfoEntry *m_end;
+};
+
+ClassInfoEntries classInfoEntries();
+
+class WriteIncludesBase : public TreeWalker
+{
+public:
+ explicit WriteIncludesBase(Uic *uic);
+
+ void acceptUI(DomUI *node) override;
+ void acceptWidget(DomWidget *node) override;
+ void acceptLayout(DomLayout *node) override;
+ void acceptSpacer(DomSpacer *node) override;
+ void acceptProperty(DomProperty *node) override;
+
+ //
+ // actions
+ //
+ void acceptActionGroup(DomActionGroup *node) override;
+ void acceptAction(DomAction *node) override;
+ void acceptActionRef(DomActionRef *node) override;
+
+ //
+ // custom widgets
+ //
+ void acceptCustomWidget(DomCustomWidget *node) override;
+
+protected:
+ void add(const QString &className, const DomCustomWidget *dcw = nullptr);
+
+ virtual void doAdd(const QString &className, const DomCustomWidget *dcw = nullptr) = 0;
+
+ const Uic *uic() const { return m_uic; }
+ Uic *uic() { return m_uic; }
+
+private:
+ QSet<QString> m_knownClasses;
+ Uic *m_uic;
+ bool m_laidOut = false;
+};
+
+QT_END_NAMESPACE
+
+#endif // WRITEINCLUDES_BASE_H
diff --git a/src/tools/uic/treewalker.cpp b/src/tools/uic/treewalker.cpp
index 4c9981580b..731017b1a2 100644
--- a/src/tools/uic/treewalker.cpp
+++ b/src/tools/uic/treewalker.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "treewalker.h"
#include "ui4.h"
diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h
index abc5658924..ff5d032648 100644
--- a/src/tools/uic/treewalker.h
+++ b/src/tools/uic/treewalker.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TREEWALKER_H
#define TREEWALKER_H
diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp
index a155df9b6c..d65fc4a8c3 100644
--- a/src/tools/uic/ui4.cpp
+++ b/src/tools/uic/ui4.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT!
@@ -32,6 +7,9 @@
QT_BEGIN_NAMESPACE
+
+using namespace Qt::StringLiterals;
+
#ifdef QFORMINTERNAL_NAMESPACE
using namespace QFormInternal;
#endif
@@ -60,133 +38,133 @@ void DomUI::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("version")) {
+ if (name == u"version"_s) {
setAttributeVersion(attribute.value().toString());
continue;
}
- if (name == QLatin1String("language")) {
+ if (name == u"language"_s) {
setAttributeLanguage(attribute.value().toString());
continue;
}
- if (name == QLatin1String("displayname")) {
+ if (name == u"displayname"_s) {
setAttributeDisplayname(attribute.value().toString());
continue;
}
- if (name == QLatin1String("idbasedtr")) {
- setAttributeIdbasedtr(attribute.value() == QLatin1String("true"));
+ if (name == u"idbasedtr"_s) {
+ setAttributeIdbasedtr(attribute.value() == u"true"_s);
continue;
}
- if (name == QLatin1String("connectslotsbyname")) {
- setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true"));
+ if (name == u"connectslotsbyname"_s) {
+ setAttributeConnectslotsbyname(attribute.value() == u"true"_s);
continue;
}
- if (name == QLatin1String("stdsetdef")) {
+ if (name == u"stdsetdef"_s) {
setAttributeStdsetdef(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("stdSetDef")) {
+ if (name == u"stdSetDef"_s) {
setAttributeStdSetDef(attribute.value().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("author"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"author"_s, Qt::CaseInsensitive)) {
setElementAuthor(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("comment"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"comment"_s, Qt::CaseInsensitive)) {
setElementComment(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("exportmacro"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"exportmacro"_s, Qt::CaseInsensitive)) {
setElementExportMacro(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"class"_s, Qt::CaseInsensitive)) {
setElementClass(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"widget"_s, Qt::CaseInsensitive)) {
auto *v = new DomWidget();
v->read(reader);
setElementWidget(v);
continue;
}
- if (!tag.compare(QLatin1String("layoutdefault"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"layoutdefault"_s, Qt::CaseInsensitive)) {
auto *v = new DomLayoutDefault();
v->read(reader);
setElementLayoutDefault(v);
continue;
}
- if (!tag.compare(QLatin1String("layoutfunction"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"layoutfunction"_s, Qt::CaseInsensitive)) {
auto *v = new DomLayoutFunction();
v->read(reader);
setElementLayoutFunction(v);
continue;
}
- if (!tag.compare(QLatin1String("pixmapfunction"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"pixmapfunction"_s, Qt::CaseInsensitive)) {
setElementPixmapFunction(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("customwidgets"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"customwidgets"_s, Qt::CaseInsensitive)) {
auto *v = new DomCustomWidgets();
v->read(reader);
setElementCustomWidgets(v);
continue;
}
- if (!tag.compare(QLatin1String("tabstops"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"tabstops"_s, Qt::CaseInsensitive)) {
auto *v = new DomTabStops();
v->read(reader);
setElementTabStops(v);
continue;
}
- if (!tag.compare(QLatin1String("images"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"images"_s, Qt::CaseInsensitive)) {
qWarning("Omitting deprecated element <images>.");
reader.skipCurrentElement();
continue;
}
- if (!tag.compare(QLatin1String("includes"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"includes"_s, Qt::CaseInsensitive)) {
auto *v = new DomIncludes();
v->read(reader);
setElementIncludes(v);
continue;
}
- if (!tag.compare(QLatin1String("resources"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"resources"_s, Qt::CaseInsensitive)) {
auto *v = new DomResources();
v->read(reader);
setElementResources(v);
continue;
}
- if (!tag.compare(QLatin1String("connections"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"connections"_s, Qt::CaseInsensitive)) {
auto *v = new DomConnections();
v->read(reader);
setElementConnections(v);
continue;
}
- if (!tag.compare(QLatin1String("designerdata"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"designerdata"_s, Qt::CaseInsensitive)) {
auto *v = new DomDesignerData();
v->read(reader);
setElementDesignerdata(v);
continue;
}
- if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"slots"_s, Qt::CaseInsensitive)) {
auto *v = new DomSlots();
v->read(reader);
setElementSlots(v);
continue;
}
- if (!tag.compare(QLatin1String("buttongroups"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"buttongroups"_s, Qt::CaseInsensitive)) {
auto *v = new DomButtonGroups();
v->read(reader);
setElementButtonGroups(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -202,73 +180,73 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("ui") : tagName.toLower());
if (hasAttributeVersion())
- writer.writeAttribute(QStringLiteral("version"), attributeVersion());
+ writer.writeAttribute(u"version"_s, attributeVersion());
if (hasAttributeLanguage())
- writer.writeAttribute(QStringLiteral("language"), attributeLanguage());
+ writer.writeAttribute(u"language"_s, attributeLanguage());
if (hasAttributeDisplayname())
- writer.writeAttribute(QStringLiteral("displayname"), attributeDisplayname());
+ writer.writeAttribute(u"displayname"_s, attributeDisplayname());
if (hasAttributeIdbasedtr())
- writer.writeAttribute(QStringLiteral("idbasedtr"), (attributeIdbasedtr() ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeAttribute(u"idbasedtr"_s, (attributeIdbasedtr() ? u"true"_s : u"false"_s));
if (hasAttributeConnectslotsbyname())
- writer.writeAttribute(QStringLiteral("connectslotsbyname"), (attributeConnectslotsbyname() ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeAttribute(u"connectslotsbyname"_s, (attributeConnectslotsbyname() ? u"true"_s : u"false"_s));
if (hasAttributeStdsetdef())
- writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdsetdef()));
+ writer.writeAttribute(u"stdsetdef"_s, QString::number(attributeStdsetdef()));
if (hasAttributeStdSetDef())
- writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdSetDef()));
+ writer.writeAttribute(u"stdsetdef"_s, QString::number(attributeStdSetDef()));
if (m_children & Author)
- writer.writeTextElement(QStringLiteral("author"), m_author);
+ writer.writeTextElement(u"author"_s, m_author);
if (m_children & Comment)
- writer.writeTextElement(QStringLiteral("comment"), m_comment);
+ writer.writeTextElement(u"comment"_s, m_comment);
if (m_children & ExportMacro)
- writer.writeTextElement(QStringLiteral("exportmacro"), m_exportMacro);
+ writer.writeTextElement(u"exportmacro"_s, m_exportMacro);
if (m_children & Class)
- writer.writeTextElement(QStringLiteral("class"), m_class);
+ writer.writeTextElement(u"class"_s, m_class);
if (m_children & Widget)
- m_widget->write(writer, QStringLiteral("widget"));
+ m_widget->write(writer, u"widget"_s);
if (m_children & LayoutDefault)
- m_layoutDefault->write(writer, QStringLiteral("layoutdefault"));
+ m_layoutDefault->write(writer, u"layoutdefault"_s);
if (m_children & LayoutFunction)
- m_layoutFunction->write(writer, QStringLiteral("layoutfunction"));
+ m_layoutFunction->write(writer, u"layoutfunction"_s);
if (m_children & PixmapFunction)
- writer.writeTextElement(QStringLiteral("pixmapfunction"), m_pixmapFunction);
+ writer.writeTextElement(u"pixmapfunction"_s, m_pixmapFunction);
if (m_children & CustomWidgets)
- m_customWidgets->write(writer, QStringLiteral("customwidgets"));
+ m_customWidgets->write(writer, u"customwidgets"_s);
if (m_children & TabStops)
- m_tabStops->write(writer, QStringLiteral("tabstops"));
+ m_tabStops->write(writer, u"tabstops"_s);
if (m_children & Includes)
- m_includes->write(writer, QStringLiteral("includes"));
+ m_includes->write(writer, u"includes"_s);
if (m_children & Resources)
- m_resources->write(writer, QStringLiteral("resources"));
+ m_resources->write(writer, u"resources"_s);
if (m_children & Connections)
- m_connections->write(writer, QStringLiteral("connections"));
+ m_connections->write(writer, u"connections"_s);
if (m_children & Designerdata)
- m_designerdata->write(writer, QStringLiteral("designerdata"));
+ m_designerdata->write(writer, u"designerdata"_s);
if (m_children & Slots)
- m_slots->write(writer, QStringLiteral("slots"));
+ m_slots->write(writer, u"slots"_s);
if (m_children & ButtonGroups)
- m_buttonGroups->write(writer, QStringLiteral("buttongroups"));
+ m_buttonGroups->write(writer, u"buttongroups"_s);
writer.writeEndElement();
}
@@ -582,13 +560,13 @@ void DomIncludes::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"include"_s, Qt::CaseInsensitive)) {
auto *v = new DomInclude();
v->read(reader);
m_include.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -604,7 +582,7 @@ void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("includes") : tagName.toLower());
for (DomInclude *v : m_include)
- v->write(writer, QStringLiteral("include"));
+ v->write(writer, u"include"_s);
writer.writeEndElement();
}
@@ -622,22 +600,22 @@ void DomInclude::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("location")) {
+ if (name == u"location"_s) {
setAttributeLocation(attribute.value().toString());
continue;
}
- if (name == QLatin1String("impldecl")) {
+ if (name == u"impldecl"_s) {
setAttributeImpldecl(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -657,10 +635,10 @@ void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("include") : tagName.toLower());
if (hasAttributeLocation())
- writer.writeAttribute(QStringLiteral("location"), attributeLocation());
+ writer.writeAttribute(u"location"_s, attributeLocation());
if (hasAttributeImpldecl())
- writer.writeAttribute(QStringLiteral("impldecl"), attributeImpldecl());
+ writer.writeAttribute(u"impldecl"_s, attributeImpldecl());
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -679,24 +657,24 @@ void DomResources::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"include"_s, Qt::CaseInsensitive)) {
auto *v = new DomResource();
v->read(reader);
m_include.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -712,10 +690,10 @@ void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resources") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
for (DomResource *v : m_include)
- v->write(writer, QStringLiteral("include"));
+ v->write(writer, u"include"_s);
writer.writeEndElement();
}
@@ -733,18 +711,18 @@ void DomResource::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("location")) {
+ if (name == u"location"_s) {
setAttributeLocation(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -760,7 +738,7 @@ void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resource") : tagName.toLower());
if (hasAttributeLocation())
- writer.writeAttribute(QStringLiteral("location"), attributeLocation());
+ writer.writeAttribute(u"location"_s, attributeLocation());
writer.writeEndElement();
}
@@ -782,42 +760,42 @@ void DomActionGroup::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"action"_s, Qt::CaseInsensitive)) {
auto *v = new DomAction();
v->read(reader);
m_action.append(v);
continue;
}
- if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"actiongroup"_s, Qt::CaseInsensitive)) {
auto *v = new DomActionGroup();
v->read(reader);
m_actionGroup.append(v);
continue;
}
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_attribute.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -833,19 +811,19 @@ void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) con
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actiongroup") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
for (DomAction *v : m_action)
- v->write(writer, QStringLiteral("action"));
+ v->write(writer, u"action"_s);
for (DomActionGroup *v : m_actionGroup)
- v->write(writer, QStringLiteral("actiongroup"));
+ v->write(writer, u"actiongroup"_s);
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
for (DomProperty *v : m_attribute)
- v->write(writer, QStringLiteral("attribute"));
+ v->write(writer, u"attribute"_s);
writer.writeEndElement();
}
@@ -887,34 +865,34 @@ void DomAction::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- if (name == QLatin1String("menu")) {
+ if (name == u"menu"_s) {
setAttributeMenu(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_attribute.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -930,16 +908,16 @@ void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("action") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
if (hasAttributeMenu())
- writer.writeAttribute(QStringLiteral("menu"), attributeMenu());
+ writer.writeAttribute(u"menu"_s, attributeMenu());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
for (DomProperty *v : m_attribute)
- v->write(writer, QStringLiteral("attribute"));
+ v->write(writer, u"attribute"_s);
writer.writeEndElement();
}
@@ -963,18 +941,18 @@ void DomActionRef::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -990,7 +968,7 @@ void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actionref") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
writer.writeEndElement();
}
@@ -1008,30 +986,30 @@ void DomButtonGroup::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_attribute.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1047,13 +1025,13 @@ void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) con
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroup") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
for (DomProperty *v : m_attribute)
- v->write(writer, QStringLiteral("attribute"));
+ v->write(writer, u"attribute"_s);
writer.writeEndElement();
}
@@ -1082,13 +1060,13 @@ void DomButtonGroups::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("buttongroup"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"buttongroup"_s, Qt::CaseInsensitive)) {
auto *v = new DomButtonGroup();
v->read(reader);
m_buttonGroup.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1104,7 +1082,7 @@ void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) co
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroups") : tagName.toLower());
for (DomButtonGroup *v : m_buttonGroup)
- v->write(writer, QStringLiteral("buttongroup"));
+ v->write(writer, u"buttongroup"_s);
writer.writeEndElement();
}
@@ -1127,13 +1105,13 @@ void DomCustomWidgets::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("customwidget"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"customwidget"_s, Qt::CaseInsensitive)) {
auto *v = new DomCustomWidget();
v->read(reader);
m_customWidget.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1149,7 +1127,7 @@ void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) c
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidgets") : tagName.toLower());
for (DomCustomWidget *v : m_customWidget)
- v->write(writer, QStringLiteral("customwidget"));
+ v->write(writer, u"customwidget"_s);
writer.writeEndElement();
}
@@ -1167,18 +1145,18 @@ void DomHeader::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("location")) {
+ if (name == u"location"_s) {
setAttributeLocation(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1198,7 +1176,7 @@ void DomHeader::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("header") : tagName.toLower());
if (hasAttributeLocation())
- writer.writeAttribute(QStringLiteral("location"), attributeLocation());
+ writer.writeAttribute(u"location"_s, attributeLocation());
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -1220,66 +1198,66 @@ void DomCustomWidget::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"class"_s, Qt::CaseInsensitive)) {
setElementClass(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("extends"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"extends"_s, Qt::CaseInsensitive)) {
setElementExtends(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("header"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"header"_s, Qt::CaseInsensitive)) {
auto *v = new DomHeader();
v->read(reader);
setElementHeader(v);
continue;
}
- if (!tag.compare(QLatin1String("sizehint"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"sizehint"_s, Qt::CaseInsensitive)) {
auto *v = new DomSize();
v->read(reader);
setElementSizeHint(v);
continue;
}
- if (!tag.compare(QLatin1String("addpagemethod"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"addpagemethod"_s, Qt::CaseInsensitive)) {
setElementAddPageMethod(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("container"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"container"_s, Qt::CaseInsensitive)) {
setElementContainer(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"sizepolicy"_s, Qt::CaseInsensitive)) {
qWarning("Omitting deprecated element <sizepolicy>.");
reader.skipCurrentElement();
continue;
}
- if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"pixmap"_s, Qt::CaseInsensitive)) {
setElementPixmap(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("script"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"script"_s, Qt::CaseInsensitive)) {
qWarning("Omitting deprecated element <script>.");
reader.skipCurrentElement();
continue;
}
- if (!tag.compare(QLatin1String("properties"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"properties"_s, Qt::CaseInsensitive)) {
qWarning("Omitting deprecated element <properties>.");
reader.skipCurrentElement();
continue;
}
- if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"slots"_s, Qt::CaseInsensitive)) {
auto *v = new DomSlots();
v->read(reader);
setElementSlots(v);
continue;
}
- if (!tag.compare(QLatin1String("propertyspecifications"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"propertyspecifications"_s, Qt::CaseInsensitive)) {
auto *v = new DomPropertySpecifications();
v->read(reader);
setElementPropertyspecifications(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1295,31 +1273,31 @@ void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) co
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidget") : tagName.toLower());
if (m_children & Class)
- writer.writeTextElement(QStringLiteral("class"), m_class);
+ writer.writeTextElement(u"class"_s, m_class);
if (m_children & Extends)
- writer.writeTextElement(QStringLiteral("extends"), m_extends);
+ writer.writeTextElement(u"extends"_s, m_extends);
if (m_children & Header)
- m_header->write(writer, QStringLiteral("header"));
+ m_header->write(writer, u"header"_s);
if (m_children & SizeHint)
- m_sizeHint->write(writer, QStringLiteral("sizehint"));
+ m_sizeHint->write(writer, u"sizehint"_s);
if (m_children & AddPageMethod)
- writer.writeTextElement(QStringLiteral("addpagemethod"), m_addPageMethod);
+ writer.writeTextElement(u"addpagemethod"_s, m_addPageMethod);
if (m_children & Container)
- writer.writeTextElement(QStringLiteral("container"), QString::number(m_container));
+ writer.writeTextElement(u"container"_s, QString::number(m_container));
if (m_children & Pixmap)
- writer.writeTextElement(QStringLiteral("pixmap"), m_pixmap);
+ writer.writeTextElement(u"pixmap"_s, m_pixmap);
if (m_children & Slots)
- m_slots->write(writer, QStringLiteral("slots"));
+ m_slots->write(writer, u"slots"_s);
if (m_children & Propertyspecifications)
- m_propertyspecifications->write(writer, QStringLiteral("propertyspecifications"));
+ m_propertyspecifications->write(writer, u"propertyspecifications"_s);
writer.writeEndElement();
}
@@ -1474,22 +1452,22 @@ void DomLayoutDefault::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("spacing")) {
+ if (name == u"spacing"_s) {
setAttributeSpacing(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("margin")) {
+ if (name == u"margin"_s) {
setAttributeMargin(attribute.value().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1505,10 +1483,10 @@ void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) c
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutdefault") : tagName.toLower());
if (hasAttributeSpacing())
- writer.writeAttribute(QStringLiteral("spacing"), QString::number(attributeSpacing()));
+ writer.writeAttribute(u"spacing"_s, QString::number(attributeSpacing()));
if (hasAttributeMargin())
- writer.writeAttribute(QStringLiteral("margin"), QString::number(attributeMargin()));
+ writer.writeAttribute(u"margin"_s, QString::number(attributeMargin()));
writer.writeEndElement();
}
@@ -1520,22 +1498,22 @@ void DomLayoutFunction::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("spacing")) {
+ if (name == u"spacing"_s) {
setAttributeSpacing(attribute.value().toString());
continue;
}
- if (name == QLatin1String("margin")) {
+ if (name == u"margin"_s) {
setAttributeMargin(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1551,10 +1529,10 @@ void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName)
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutfunction") : tagName.toLower());
if (hasAttributeSpacing())
- writer.writeAttribute(QStringLiteral("spacing"), attributeSpacing());
+ writer.writeAttribute(u"spacing"_s, attributeSpacing());
if (hasAttributeMargin())
- writer.writeAttribute(QStringLiteral("margin"), attributeMargin());
+ writer.writeAttribute(u"margin"_s, attributeMargin());
writer.writeEndElement();
}
@@ -1570,11 +1548,11 @@ void DomTabStops::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("tabstop"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"tabstop"_s, Qt::CaseInsensitive)) {
m_tabStop.append(reader.readElementText());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1590,7 +1568,7 @@ void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("tabstops") : tagName.toLower());
for (const QString &v : m_tabStop)
- writer.writeTextElement(QStringLiteral("tabstop"), v);
+ writer.writeTextElement(u"tabstop"_s, v);
writer.writeEndElement();
}
@@ -1616,60 +1594,60 @@ void DomLayout::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("class")) {
+ if (name == u"class"_s) {
setAttributeClass(attribute.value().toString());
continue;
}
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- if (name == QLatin1String("stretch")) {
+ if (name == u"stretch"_s) {
setAttributeStretch(attribute.value().toString());
continue;
}
- if (name == QLatin1String("rowstretch")) {
+ if (name == u"rowstretch"_s) {
setAttributeRowStretch(attribute.value().toString());
continue;
}
- if (name == QLatin1String("columnstretch")) {
+ if (name == u"columnstretch"_s) {
setAttributeColumnStretch(attribute.value().toString());
continue;
}
- if (name == QLatin1String("rowminimumheight")) {
+ if (name == u"rowminimumheight"_s) {
setAttributeRowMinimumHeight(attribute.value().toString());
continue;
}
- if (name == QLatin1String("columnminimumwidth")) {
+ if (name == u"columnminimumwidth"_s) {
setAttributeColumnMinimumWidth(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_attribute.append(v);
continue;
}
- if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"item"_s, Qt::CaseInsensitive)) {
auto *v = new DomLayoutItem();
v->read(reader);
m_item.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1685,34 +1663,34 @@ void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layout") : tagName.toLower());
if (hasAttributeClass())
- writer.writeAttribute(QStringLiteral("class"), attributeClass());
+ writer.writeAttribute(u"class"_s, attributeClass());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
if (hasAttributeStretch())
- writer.writeAttribute(QStringLiteral("stretch"), attributeStretch());
+ writer.writeAttribute(u"stretch"_s, attributeStretch());
if (hasAttributeRowStretch())
- writer.writeAttribute(QStringLiteral("rowstretch"), attributeRowStretch());
+ writer.writeAttribute(u"rowstretch"_s, attributeRowStretch());
if (hasAttributeColumnStretch())
- writer.writeAttribute(QStringLiteral("columnstretch"), attributeColumnStretch());
+ writer.writeAttribute(u"columnstretch"_s, attributeColumnStretch());
if (hasAttributeRowMinimumHeight())
- writer.writeAttribute(QStringLiteral("rowminimumheight"), attributeRowMinimumHeight());
+ writer.writeAttribute(u"rowminimumheight"_s, attributeRowMinimumHeight());
if (hasAttributeColumnMinimumWidth())
- writer.writeAttribute(QStringLiteral("columnminimumwidth"), attributeColumnMinimumWidth());
+ writer.writeAttribute(u"columnminimumwidth"_s, attributeColumnMinimumWidth());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
for (DomProperty *v : m_attribute)
- v->write(writer, QStringLiteral("attribute"));
+ v->write(writer, u"attribute"_s);
for (DomLayoutItem *v : m_item)
- v->write(writer, QStringLiteral("item"));
+ v->write(writer, u"item"_s);
writer.writeEndElement();
}
@@ -1760,52 +1738,52 @@ void DomLayoutItem::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("row")) {
+ if (name == u"row"_s) {
setAttributeRow(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("column")) {
+ if (name == u"column"_s) {
setAttributeColumn(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("rowspan")) {
+ if (name == u"rowspan"_s) {
setAttributeRowSpan(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("colspan")) {
+ if (name == u"colspan"_s) {
setAttributeColSpan(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("alignment")) {
+ if (name == u"alignment"_s) {
setAttributeAlignment(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"widget"_s, Qt::CaseInsensitive)) {
auto *v = new DomWidget();
v->read(reader);
setElementWidget(v);
continue;
}
- if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"layout"_s, Qt::CaseInsensitive)) {
auto *v = new DomLayout();
v->read(reader);
setElementLayout(v);
continue;
}
- if (!tag.compare(QLatin1String("spacer"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"spacer"_s, Qt::CaseInsensitive)) {
auto *v = new DomSpacer();
v->read(reader);
setElementSpacer(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1821,34 +1799,34 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutitem") : tagName.toLower());
if (hasAttributeRow())
- writer.writeAttribute(QStringLiteral("row"), QString::number(attributeRow()));
+ writer.writeAttribute(u"row"_s, QString::number(attributeRow()));
if (hasAttributeColumn())
- writer.writeAttribute(QStringLiteral("column"), QString::number(attributeColumn()));
+ writer.writeAttribute(u"column"_s, QString::number(attributeColumn()));
if (hasAttributeRowSpan())
- writer.writeAttribute(QStringLiteral("rowspan"), QString::number(attributeRowSpan()));
+ writer.writeAttribute(u"rowspan"_s, QString::number(attributeRowSpan()));
if (hasAttributeColSpan())
- writer.writeAttribute(QStringLiteral("colspan"), QString::number(attributeColSpan()));
+ writer.writeAttribute(u"colspan"_s, QString::number(attributeColSpan()));
if (hasAttributeAlignment())
- writer.writeAttribute(QStringLiteral("alignment"), attributeAlignment());
+ writer.writeAttribute(u"alignment"_s, attributeAlignment());
switch (kind()) {
case Widget:
if (m_widget != nullptr)
- m_widget->write(writer, QStringLiteral("widget"));
+ m_widget->write(writer, u"widget"_s);
break;
case Layout:
if (m_layout != nullptr)
- m_layout->write(writer, QStringLiteral("layout"));
+ m_layout->write(writer, u"layout"_s);
break;
case Spacer:
if (m_spacer != nullptr)
- m_spacer->write(writer, QStringLiteral("spacer"));
+ m_spacer->write(writer, u"spacer"_s);
break;
default:
@@ -1911,13 +1889,13 @@ void DomRow::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1933,7 +1911,7 @@ void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("row") : tagName.toLower());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
writer.writeEndElement();
}
@@ -1956,13 +1934,13 @@ void DomColumn::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -1978,7 +1956,7 @@ void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("column") : tagName.toLower());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
writer.writeEndElement();
}
@@ -2002,34 +1980,34 @@ void DomItem::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("row")) {
+ if (name == u"row"_s) {
setAttributeRow(attribute.value().toInt());
continue;
}
- if (name == QLatin1String("column")) {
+ if (name == u"column"_s) {
setAttributeColumn(attribute.value().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"item"_s, Qt::CaseInsensitive)) {
auto *v = new DomItem();
v->read(reader);
m_item.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2045,16 +2023,16 @@ void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("item") : tagName.toLower());
if (hasAttributeRow())
- writer.writeAttribute(QStringLiteral("row"), QString::number(attributeRow()));
+ writer.writeAttribute(u"row"_s, QString::number(attributeRow()));
if (hasAttributeColumn())
- writer.writeAttribute(QStringLiteral("column"), QString::number(attributeColumn()));
+ writer.writeAttribute(u"column"_s, QString::number(attributeColumn()));
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
for (DomItem *v : m_item)
- v->write(writer, QStringLiteral("item"));
+ v->write(writer, u"item"_s);
writer.writeEndElement();
}
@@ -2102,104 +2080,104 @@ void DomWidget::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("class")) {
+ if (name == u"class"_s) {
setAttributeClass(attribute.value().toString());
continue;
}
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- if (name == QLatin1String("native")) {
- setAttributeNative(attribute.value() == QLatin1String("true"));
+ if (name == u"native"_s) {
+ setAttributeNative(attribute.value() == u"true"_s);
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"class"_s, Qt::CaseInsensitive)) {
m_class.append(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- if (!tag.compare(QLatin1String("script"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"script"_s, Qt::CaseInsensitive)) {
qWarning("Omitting deprecated element <script>.");
reader.skipCurrentElement();
continue;
}
- if (!tag.compare(QLatin1String("widgetdata"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"widgetdata"_s, Qt::CaseInsensitive)) {
qWarning("Omitting deprecated element <widgetdata>.");
reader.skipCurrentElement();
continue;
}
- if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"attribute"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_attribute.append(v);
continue;
}
- if (!tag.compare(QLatin1String("row"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"row"_s, Qt::CaseInsensitive)) {
auto *v = new DomRow();
v->read(reader);
m_row.append(v);
continue;
}
- if (!tag.compare(QLatin1String("column"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"column"_s, Qt::CaseInsensitive)) {
auto *v = new DomColumn();
v->read(reader);
m_column.append(v);
continue;
}
- if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"item"_s, Qt::CaseInsensitive)) {
auto *v = new DomItem();
v->read(reader);
m_item.append(v);
continue;
}
- if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"layout"_s, Qt::CaseInsensitive)) {
auto *v = new DomLayout();
v->read(reader);
m_layout.append(v);
continue;
}
- if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"widget"_s, Qt::CaseInsensitive)) {
auto *v = new DomWidget();
v->read(reader);
m_widget.append(v);
continue;
}
- if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"action"_s, Qt::CaseInsensitive)) {
auto *v = new DomAction();
v->read(reader);
m_action.append(v);
continue;
}
- if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"actiongroup"_s, Qt::CaseInsensitive)) {
auto *v = new DomActionGroup();
v->read(reader);
m_actionGroup.append(v);
continue;
}
- if (!tag.compare(QLatin1String("addaction"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"addaction"_s, Qt::CaseInsensitive)) {
auto *v = new DomActionRef();
v->read(reader);
m_addAction.append(v);
continue;
}
- if (!tag.compare(QLatin1String("zorder"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"zorder"_s, Qt::CaseInsensitive)) {
m_zOrder.append(reader.readElementText());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2215,49 +2193,49 @@ void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("widget") : tagName.toLower());
if (hasAttributeClass())
- writer.writeAttribute(QStringLiteral("class"), attributeClass());
+ writer.writeAttribute(u"class"_s, attributeClass());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
if (hasAttributeNative())
- writer.writeAttribute(QStringLiteral("native"), (attributeNative() ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeAttribute(u"native"_s, (attributeNative() ? u"true"_s : u"false"_s));
for (const QString &v : m_class)
- writer.writeTextElement(QStringLiteral("class"), v);
+ writer.writeTextElement(u"class"_s, v);
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
for (DomProperty *v : m_attribute)
- v->write(writer, QStringLiteral("attribute"));
+ v->write(writer, u"attribute"_s);
for (DomRow *v : m_row)
- v->write(writer, QStringLiteral("row"));
+ v->write(writer, u"row"_s);
for (DomColumn *v : m_column)
- v->write(writer, QStringLiteral("column"));
+ v->write(writer, u"column"_s);
for (DomItem *v : m_item)
- v->write(writer, QStringLiteral("item"));
+ v->write(writer, u"item"_s);
for (DomLayout *v : m_layout)
- v->write(writer, QStringLiteral("layout"));
+ v->write(writer, u"layout"_s);
for (DomWidget *v : m_widget)
- v->write(writer, QStringLiteral("widget"));
+ v->write(writer, u"widget"_s);
for (DomAction *v : m_action)
- v->write(writer, QStringLiteral("action"));
+ v->write(writer, u"action"_s);
for (DomActionGroup *v : m_actionGroup)
- v->write(writer, QStringLiteral("actiongroup"));
+ v->write(writer, u"actiongroup"_s);
for (DomActionRef *v : m_addAction)
- v->write(writer, QStringLiteral("addaction"));
+ v->write(writer, u"addaction"_s);
for (const QString &v : m_zOrder)
- writer.writeTextElement(QStringLiteral("zorder"), v);
+ writer.writeTextElement(u"zorder"_s, v);
writer.writeEndElement();
}
@@ -2345,24 +2323,24 @@ void DomSpacer::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2378,10 +2356,10 @@ void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("spacer") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
writer.writeEndElement();
}
@@ -2399,30 +2377,30 @@ void DomColor::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("alpha")) {
+ if (name == u"alpha"_s) {
setAttributeAlpha(attribute.value().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("red"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"red"_s, Qt::CaseInsensitive)) {
setElementRed(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("green"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"green"_s, Qt::CaseInsensitive)) {
setElementGreen(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("blue"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"blue"_s, Qt::CaseInsensitive)) {
setElementBlue(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2438,16 +2416,16 @@ void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("color") : tagName.toLower());
if (hasAttributeAlpha())
- writer.writeAttribute(QStringLiteral("alpha"), QString::number(attributeAlpha()));
+ writer.writeAttribute(u"alpha"_s, QString::number(attributeAlpha()));
if (m_children & Red)
- writer.writeTextElement(QStringLiteral("red"), QString::number(m_red));
+ writer.writeTextElement(u"red"_s, QString::number(m_red));
if (m_children & Green)
- writer.writeTextElement(QStringLiteral("green"), QString::number(m_green));
+ writer.writeTextElement(u"green"_s, QString::number(m_green));
if (m_children & Blue)
- writer.writeTextElement(QStringLiteral("blue"), QString::number(m_blue));
+ writer.writeTextElement(u"blue"_s, QString::number(m_blue));
writer.writeEndElement();
}
@@ -2495,24 +2473,24 @@ void DomGradientStop::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("position")) {
+ if (name == u"position"_s) {
setAttributePosition(attribute.value().toDouble());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) {
auto *v = new DomColor();
v->read(reader);
setElementColor(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2528,10 +2506,10 @@ void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) co
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradientstop") : tagName.toLower());
if (hasAttributePosition())
- writer.writeAttribute(QStringLiteral("position"), QString::number(attributePosition(), 'f', 15));
+ writer.writeAttribute(u"position"_s, QString::number(attributePosition(), 'f', 15));
if (m_children & Color)
- m_color->write(writer, QStringLiteral("color"));
+ m_color->write(writer, u"color"_s);
writer.writeEndElement();
}
@@ -2569,72 +2547,72 @@ void DomGradient::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("startx")) {
+ if (name == u"startx"_s) {
setAttributeStartX(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("starty")) {
+ if (name == u"starty"_s) {
setAttributeStartY(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("endx")) {
+ if (name == u"endx"_s) {
setAttributeEndX(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("endy")) {
+ if (name == u"endy"_s) {
setAttributeEndY(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("centralx")) {
+ if (name == u"centralx"_s) {
setAttributeCentralX(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("centraly")) {
+ if (name == u"centraly"_s) {
setAttributeCentralY(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("focalx")) {
+ if (name == u"focalx"_s) {
setAttributeFocalX(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("focaly")) {
+ if (name == u"focaly"_s) {
setAttributeFocalY(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("radius")) {
+ if (name == u"radius"_s) {
setAttributeRadius(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("angle")) {
+ if (name == u"angle"_s) {
setAttributeAngle(attribute.value().toDouble());
continue;
}
- if (name == QLatin1String("type")) {
+ if (name == u"type"_s) {
setAttributeType(attribute.value().toString());
continue;
}
- if (name == QLatin1String("spread")) {
+ if (name == u"spread"_s) {
setAttributeSpread(attribute.value().toString());
continue;
}
- if (name == QLatin1String("coordinatemode")) {
+ if (name == u"coordinatemode"_s) {
setAttributeCoordinateMode(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("gradientstop"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"gradientstop"_s, Qt::CaseInsensitive)) {
auto *v = new DomGradientStop();
v->read(reader);
m_gradientStop.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2650,46 +2628,46 @@ void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradient") : tagName.toLower());
if (hasAttributeStartX())
- writer.writeAttribute(QStringLiteral("startx"), QString::number(attributeStartX(), 'f', 15));
+ writer.writeAttribute(u"startx"_s, QString::number(attributeStartX(), 'f', 15));
if (hasAttributeStartY())
- writer.writeAttribute(QStringLiteral("starty"), QString::number(attributeStartY(), 'f', 15));
+ writer.writeAttribute(u"starty"_s, QString::number(attributeStartY(), 'f', 15));
if (hasAttributeEndX())
- writer.writeAttribute(QStringLiteral("endx"), QString::number(attributeEndX(), 'f', 15));
+ writer.writeAttribute(u"endx"_s, QString::number(attributeEndX(), 'f', 15));
if (hasAttributeEndY())
- writer.writeAttribute(QStringLiteral("endy"), QString::number(attributeEndY(), 'f', 15));
+ writer.writeAttribute(u"endy"_s, QString::number(attributeEndY(), 'f', 15));
if (hasAttributeCentralX())
- writer.writeAttribute(QStringLiteral("centralx"), QString::number(attributeCentralX(), 'f', 15));
+ writer.writeAttribute(u"centralx"_s, QString::number(attributeCentralX(), 'f', 15));
if (hasAttributeCentralY())
- writer.writeAttribute(QStringLiteral("centraly"), QString::number(attributeCentralY(), 'f', 15));
+ writer.writeAttribute(u"centraly"_s, QString::number(attributeCentralY(), 'f', 15));
if (hasAttributeFocalX())
- writer.writeAttribute(QStringLiteral("focalx"), QString::number(attributeFocalX(), 'f', 15));
+ writer.writeAttribute(u"focalx"_s, QString::number(attributeFocalX(), 'f', 15));
if (hasAttributeFocalY())
- writer.writeAttribute(QStringLiteral("focaly"), QString::number(attributeFocalY(), 'f', 15));
+ writer.writeAttribute(u"focaly"_s, QString::number(attributeFocalY(), 'f', 15));
if (hasAttributeRadius())
- writer.writeAttribute(QStringLiteral("radius"), QString::number(attributeRadius(), 'f', 15));
+ writer.writeAttribute(u"radius"_s, QString::number(attributeRadius(), 'f', 15));
if (hasAttributeAngle())
- writer.writeAttribute(QStringLiteral("angle"), QString::number(attributeAngle(), 'f', 15));
+ writer.writeAttribute(u"angle"_s, QString::number(attributeAngle(), 'f', 15));
if (hasAttributeType())
- writer.writeAttribute(QStringLiteral("type"), attributeType());
+ writer.writeAttribute(u"type"_s, attributeType());
if (hasAttributeSpread())
- writer.writeAttribute(QStringLiteral("spread"), attributeSpread());
+ writer.writeAttribute(u"spread"_s, attributeSpread());
if (hasAttributeCoordinateMode())
- writer.writeAttribute(QStringLiteral("coordinatemode"), attributeCoordinateMode());
+ writer.writeAttribute(u"coordinatemode"_s, attributeCoordinateMode());
for (DomGradientStop *v : m_gradientStop)
- v->write(writer, QStringLiteral("gradientstop"));
+ v->write(writer, u"gradientstop"_s);
writer.writeEndElement();
}
@@ -2725,36 +2703,36 @@ void DomBrush::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("brushstyle")) {
+ if (name == u"brushstyle"_s) {
setAttributeBrushStyle(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) {
auto *v = new DomColor();
v->read(reader);
setElementColor(v);
continue;
}
- if (!tag.compare(QLatin1String("texture"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"texture"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
setElementTexture(v);
continue;
}
- if (!tag.compare(QLatin1String("gradient"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"gradient"_s, Qt::CaseInsensitive)) {
auto *v = new DomGradient();
v->read(reader);
setElementGradient(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2770,22 +2748,22 @@ void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("brush") : tagName.toLower());
if (hasAttributeBrushStyle())
- writer.writeAttribute(QStringLiteral("brushstyle"), attributeBrushStyle());
+ writer.writeAttribute(u"brushstyle"_s, attributeBrushStyle());
switch (kind()) {
case Color:
if (m_color != nullptr)
- m_color->write(writer, QStringLiteral("color"));
+ m_color->write(writer, u"color"_s);
break;
case Texture:
if (m_texture != nullptr)
- m_texture->write(writer, QStringLiteral("texture"));
+ m_texture->write(writer, u"texture"_s);
break;
case Gradient:
if (m_gradient != nullptr)
- m_gradient->write(writer, QStringLiteral("gradient"));
+ m_gradient->write(writer, u"gradient"_s);
break;
default:
@@ -2846,24 +2824,24 @@ void DomColorRole::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("role")) {
+ if (name == u"role"_s) {
setAttributeRole(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"brush"_s, Qt::CaseInsensitive)) {
auto *v = new DomBrush();
v->read(reader);
setElementBrush(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2879,10 +2857,10 @@ void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorrole") : tagName.toLower());
if (hasAttributeRole())
- writer.writeAttribute(QStringLiteral("role"), attributeRole());
+ writer.writeAttribute(u"role"_s, attributeRole());
if (m_children & Brush)
- m_brush->write(writer, QStringLiteral("brush"));
+ m_brush->write(writer, u"brush"_s);
writer.writeEndElement();
}
@@ -2923,19 +2901,19 @@ void DomColorGroup::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("colorrole"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"colorrole"_s, Qt::CaseInsensitive)) {
auto *v = new DomColorRole();
v->read(reader);
m_colorRole.append(v);
continue;
}
- if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) {
auto *v = new DomColor();
v->read(reader);
m_color.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -2951,10 +2929,10 @@ void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) cons
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorgroup") : tagName.toLower());
for (DomColorRole *v : m_colorRole)
- v->write(writer, QStringLiteral("colorrole"));
+ v->write(writer, u"colorrole"_s);
for (DomColor *v : m_color)
- v->write(writer, QStringLiteral("color"));
+ v->write(writer, u"color"_s);
writer.writeEndElement();
}
@@ -2984,25 +2962,25 @@ void DomPalette::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("active"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"active"_s, Qt::CaseInsensitive)) {
auto *v = new DomColorGroup();
v->read(reader);
setElementActive(v);
continue;
}
- if (!tag.compare(QLatin1String("inactive"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"inactive"_s, Qt::CaseInsensitive)) {
auto *v = new DomColorGroup();
v->read(reader);
setElementInactive(v);
continue;
}
- if (!tag.compare(QLatin1String("disabled"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"disabled"_s, Qt::CaseInsensitive)) {
auto *v = new DomColorGroup();
v->read(reader);
setElementDisabled(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3018,13 +2996,13 @@ void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("palette") : tagName.toLower());
if (m_children & Active)
- m_active->write(writer, QStringLiteral("active"));
+ m_active->write(writer, u"active"_s);
if (m_children & Inactive)
- m_inactive->write(writer, QStringLiteral("inactive"));
+ m_inactive->write(writer, u"inactive"_s);
if (m_children & Disabled)
- m_disabled->write(writer, QStringLiteral("disabled"));
+ m_disabled->write(writer, u"disabled"_s);
writer.writeEndElement();
}
@@ -3103,47 +3081,55 @@ void DomFont::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("family"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"family"_s, Qt::CaseInsensitive)) {
setElementFamily(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("pointsize"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"pointsize"_s, Qt::CaseInsensitive)) {
setElementPointSize(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("weight"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"weight"_s, Qt::CaseInsensitive)) {
setElementWeight(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("italic"), Qt::CaseInsensitive)) {
- setElementItalic(reader.readElementText() == QLatin1String("true"));
+ if (!tag.compare(u"italic"_s, Qt::CaseInsensitive)) {
+ setElementItalic(reader.readElementText() == u"true"_s);
continue;
}
- if (!tag.compare(QLatin1String("bold"), Qt::CaseInsensitive)) {
- setElementBold(reader.readElementText() == QLatin1String("true"));
+ if (!tag.compare(u"bold"_s, Qt::CaseInsensitive)) {
+ setElementBold(reader.readElementText() == u"true"_s);
continue;
}
- if (!tag.compare(QLatin1String("underline"), Qt::CaseInsensitive)) {
- setElementUnderline(reader.readElementText() == QLatin1String("true"));
+ if (!tag.compare(u"underline"_s, Qt::CaseInsensitive)) {
+ setElementUnderline(reader.readElementText() == u"true"_s);
continue;
}
- if (!tag.compare(QLatin1String("strikeout"), Qt::CaseInsensitive)) {
- setElementStrikeOut(reader.readElementText() == QLatin1String("true"));
+ if (!tag.compare(u"strikeout"_s, Qt::CaseInsensitive)) {
+ setElementStrikeOut(reader.readElementText() == u"true"_s);
continue;
}
- if (!tag.compare(QLatin1String("antialiasing"), Qt::CaseInsensitive)) {
- setElementAntialiasing(reader.readElementText() == QLatin1String("true"));
+ if (!tag.compare(u"antialiasing"_s, Qt::CaseInsensitive)) {
+ setElementAntialiasing(reader.readElementText() == u"true"_s);
continue;
}
- if (!tag.compare(QLatin1String("stylestrategy"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"stylestrategy"_s, Qt::CaseInsensitive)) {
setElementStyleStrategy(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("kerning"), Qt::CaseInsensitive)) {
- setElementKerning(reader.readElementText() == QLatin1String("true"));
+ if (!tag.compare(u"kerning"_s, Qt::CaseInsensitive)) {
+ setElementKerning(reader.readElementText() == u"true"_s);
+ continue;
+ }
+ if (!tag.compare(u"hintingpreference"_s, Qt::CaseInsensitive)) {
+ setElementHintingPreference(reader.readElementText());
+ continue;
+ }
+ if (!tag.compare(u"fontweight"_s, Qt::CaseInsensitive)) {
+ setElementFontWeight(reader.readElementText());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3159,34 +3145,40 @@ void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("font") : tagName.toLower());
if (m_children & Family)
- writer.writeTextElement(QStringLiteral("family"), m_family);
+ writer.writeTextElement(u"family"_s, m_family);
if (m_children & PointSize)
- writer.writeTextElement(QStringLiteral("pointsize"), QString::number(m_pointSize));
+ writer.writeTextElement(u"pointsize"_s, QString::number(m_pointSize));
if (m_children & Weight)
- writer.writeTextElement(QStringLiteral("weight"), QString::number(m_weight));
+ writer.writeTextElement(u"weight"_s, QString::number(m_weight));
if (m_children & Italic)
- writer.writeTextElement(QStringLiteral("italic"), (m_italic ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeTextElement(u"italic"_s, (m_italic ? u"true"_s : u"false"_s));
if (m_children & Bold)
- writer.writeTextElement(QStringLiteral("bold"), (m_bold ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeTextElement(u"bold"_s, (m_bold ? u"true"_s : u"false"_s));
if (m_children & Underline)
- writer.writeTextElement(QStringLiteral("underline"), (m_underline ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeTextElement(u"underline"_s, (m_underline ? u"true"_s : u"false"_s));
if (m_children & StrikeOut)
- writer.writeTextElement(QStringLiteral("strikeout"), (m_strikeOut ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeTextElement(u"strikeout"_s, (m_strikeOut ? u"true"_s : u"false"_s));
if (m_children & Antialiasing)
- writer.writeTextElement(QStringLiteral("antialiasing"), (m_antialiasing ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeTextElement(u"antialiasing"_s, (m_antialiasing ? u"true"_s : u"false"_s));
if (m_children & StyleStrategy)
- writer.writeTextElement(QStringLiteral("stylestrategy"), m_styleStrategy);
+ writer.writeTextElement(u"stylestrategy"_s, m_styleStrategy);
if (m_children & Kerning)
- writer.writeTextElement(QStringLiteral("kerning"), (m_kerning ? QLatin1String("true") : QLatin1String("false")));
+ writer.writeTextElement(u"kerning"_s, (m_kerning ? u"true"_s : u"false"_s));
+
+ if (m_children & HintingPreference)
+ writer.writeTextElement(u"hintingpreference"_s, m_hintingPreference);
+
+ if (m_children & FontWeight)
+ writer.writeTextElement(u"fontweight"_s, m_fontWeight);
writer.writeEndElement();
}
@@ -3251,6 +3243,18 @@ void DomFont::setElementKerning(bool a)
m_kerning = a;
}
+void DomFont::setElementHintingPreference(const QString &a)
+{
+ m_children |= HintingPreference;
+ m_hintingPreference = a;
+}
+
+void DomFont::setElementFontWeight(const QString &a)
+{
+ m_children |= FontWeight;
+ m_fontWeight = a;
+}
+
void DomFont::clearElementFamily()
{
m_children &= ~Family;
@@ -3301,6 +3305,16 @@ void DomFont::clearElementKerning()
m_children &= ~Kerning;
}
+void DomFont::clearElementHintingPreference()
+{
+ m_children &= ~HintingPreference;
+}
+
+void DomFont::clearElementFontWeight()
+{
+ m_children &= ~FontWeight;
+}
+
DomPoint::~DomPoint() = default;
void DomPoint::read(QXmlStreamReader &reader)
@@ -3309,15 +3323,15 @@ void DomPoint::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) {
setElementX(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) {
setElementY(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3333,10 +3347,10 @@ void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("point") : tagName.toLower());
if (m_children & X)
- writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x));
+ writer.writeTextElement(u"x"_s, QString::number(m_x));
if (m_children & Y)
- writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y));
+ writer.writeTextElement(u"y"_s, QString::number(m_y));
writer.writeEndElement();
}
@@ -3371,23 +3385,23 @@ void DomRect::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) {
setElementX(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) {
setElementY(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) {
setElementWidth(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) {
setElementHeight(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3403,16 +3417,16 @@ void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rect") : tagName.toLower());
if (m_children & X)
- writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x));
+ writer.writeTextElement(u"x"_s, QString::number(m_x));
if (m_children & Y)
- writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y));
+ writer.writeTextElement(u"y"_s, QString::number(m_y));
if (m_children & Width)
- writer.writeTextElement(QStringLiteral("width"), QString::number(m_width));
+ writer.writeTextElement(u"width"_s, QString::number(m_width));
if (m_children & Height)
- writer.writeTextElement(QStringLiteral("height"), QString::number(m_height));
+ writer.writeTextElement(u"height"_s, QString::number(m_height));
writer.writeEndElement();
}
@@ -3468,22 +3482,22 @@ void DomLocale::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("language")) {
+ if (name == u"language"_s) {
setAttributeLanguage(attribute.value().toString());
continue;
}
- if (name == QLatin1String("country")) {
+ if (name == u"country"_s) {
setAttributeCountry(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3499,10 +3513,10 @@ void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("locale") : tagName.toLower());
if (hasAttributeLanguage())
- writer.writeAttribute(QStringLiteral("language"), attributeLanguage());
+ writer.writeAttribute(u"language"_s, attributeLanguage());
if (hasAttributeCountry())
- writer.writeAttribute(QStringLiteral("country"), attributeCountry());
+ writer.writeAttribute(u"country"_s, attributeCountry());
writer.writeEndElement();
}
@@ -3514,38 +3528,38 @@ void DomSizePolicy::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("hsizetype")) {
+ if (name == u"hsizetype"_s) {
setAttributeHSizeType(attribute.value().toString());
continue;
}
- if (name == QLatin1String("vsizetype")) {
+ if (name == u"vsizetype"_s) {
setAttributeVSizeType(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("hsizetype"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"hsizetype"_s, Qt::CaseInsensitive)) {
setElementHSizeType(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("vsizetype"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"vsizetype"_s, Qt::CaseInsensitive)) {
setElementVSizeType(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("horstretch"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"horstretch"_s, Qt::CaseInsensitive)) {
setElementHorStretch(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("verstretch"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"verstretch"_s, Qt::CaseInsensitive)) {
setElementVerStretch(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3561,22 +3575,22 @@ void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) cons
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizepolicy") : tagName.toLower());
if (hasAttributeHSizeType())
- writer.writeAttribute(QStringLiteral("hsizetype"), attributeHSizeType());
+ writer.writeAttribute(u"hsizetype"_s, attributeHSizeType());
if (hasAttributeVSizeType())
- writer.writeAttribute(QStringLiteral("vsizetype"), attributeVSizeType());
+ writer.writeAttribute(u"vsizetype"_s, attributeVSizeType());
if (m_children & HSizeType)
- writer.writeTextElement(QStringLiteral("hsizetype"), QString::number(m_hSizeType));
+ writer.writeTextElement(u"hsizetype"_s, QString::number(m_hSizeType));
if (m_children & VSizeType)
- writer.writeTextElement(QStringLiteral("vsizetype"), QString::number(m_vSizeType));
+ writer.writeTextElement(u"vsizetype"_s, QString::number(m_vSizeType));
if (m_children & HorStretch)
- writer.writeTextElement(QStringLiteral("horstretch"), QString::number(m_horStretch));
+ writer.writeTextElement(u"horstretch"_s, QString::number(m_horStretch));
if (m_children & VerStretch)
- writer.writeTextElement(QStringLiteral("verstretch"), QString::number(m_verStretch));
+ writer.writeTextElement(u"verstretch"_s, QString::number(m_verStretch));
writer.writeEndElement();
}
@@ -3633,15 +3647,15 @@ void DomSize::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) {
setElementWidth(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) {
setElementHeight(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3657,10 +3671,10 @@ void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("size") : tagName.toLower());
if (m_children & Width)
- writer.writeTextElement(QStringLiteral("width"), QString::number(m_width));
+ writer.writeTextElement(u"width"_s, QString::number(m_width));
if (m_children & Height)
- writer.writeTextElement(QStringLiteral("height"), QString::number(m_height));
+ writer.writeTextElement(u"height"_s, QString::number(m_height));
writer.writeEndElement();
}
@@ -3695,19 +3709,19 @@ void DomDate::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"year"_s, Qt::CaseInsensitive)) {
setElementYear(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("month"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"month"_s, Qt::CaseInsensitive)) {
setElementMonth(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("day"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"day"_s, Qt::CaseInsensitive)) {
setElementDay(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3723,13 +3737,13 @@ void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("date") : tagName.toLower());
if (m_children & Year)
- writer.writeTextElement(QStringLiteral("year"), QString::number(m_year));
+ writer.writeTextElement(u"year"_s, QString::number(m_year));
if (m_children & Month)
- writer.writeTextElement(QStringLiteral("month"), QString::number(m_month));
+ writer.writeTextElement(u"month"_s, QString::number(m_month));
if (m_children & Day)
- writer.writeTextElement(QStringLiteral("day"), QString::number(m_day));
+ writer.writeTextElement(u"day"_s, QString::number(m_day));
writer.writeEndElement();
}
@@ -3775,19 +3789,19 @@ void DomTime::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"hour"_s, Qt::CaseInsensitive)) {
setElementHour(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("minute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"minute"_s, Qt::CaseInsensitive)) {
setElementMinute(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("second"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"second"_s, Qt::CaseInsensitive)) {
setElementSecond(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3803,13 +3817,13 @@ void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("time") : tagName.toLower());
if (m_children & Hour)
- writer.writeTextElement(QStringLiteral("hour"), QString::number(m_hour));
+ writer.writeTextElement(u"hour"_s, QString::number(m_hour));
if (m_children & Minute)
- writer.writeTextElement(QStringLiteral("minute"), QString::number(m_minute));
+ writer.writeTextElement(u"minute"_s, QString::number(m_minute));
if (m_children & Second)
- writer.writeTextElement(QStringLiteral("second"), QString::number(m_second));
+ writer.writeTextElement(u"second"_s, QString::number(m_second));
writer.writeEndElement();
}
@@ -3855,31 +3869,31 @@ void DomDateTime::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"hour"_s, Qt::CaseInsensitive)) {
setElementHour(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("minute"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"minute"_s, Qt::CaseInsensitive)) {
setElementMinute(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("second"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"second"_s, Qt::CaseInsensitive)) {
setElementSecond(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"year"_s, Qt::CaseInsensitive)) {
setElementYear(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("month"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"month"_s, Qt::CaseInsensitive)) {
setElementMonth(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("day"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"day"_s, Qt::CaseInsensitive)) {
setElementDay(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -3895,22 +3909,22 @@ void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("datetime") : tagName.toLower());
if (m_children & Hour)
- writer.writeTextElement(QStringLiteral("hour"), QString::number(m_hour));
+ writer.writeTextElement(u"hour"_s, QString::number(m_hour));
if (m_children & Minute)
- writer.writeTextElement(QStringLiteral("minute"), QString::number(m_minute));
+ writer.writeTextElement(u"minute"_s, QString::number(m_minute));
if (m_children & Second)
- writer.writeTextElement(QStringLiteral("second"), QString::number(m_second));
+ writer.writeTextElement(u"second"_s, QString::number(m_second));
if (m_children & Year)
- writer.writeTextElement(QStringLiteral("year"), QString::number(m_year));
+ writer.writeTextElement(u"year"_s, QString::number(m_year));
if (m_children & Month)
- writer.writeTextElement(QStringLiteral("month"), QString::number(m_month));
+ writer.writeTextElement(u"month"_s, QString::number(m_month));
if (m_children & Day)
- writer.writeTextElement(QStringLiteral("day"), QString::number(m_day));
+ writer.writeTextElement(u"day"_s, QString::number(m_day));
writer.writeEndElement();
}
@@ -3991,34 +4005,34 @@ void DomStringList::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("notr")) {
+ if (name == u"notr"_s) {
setAttributeNotr(attribute.value().toString());
continue;
}
- if (name == QLatin1String("comment")) {
+ if (name == u"comment"_s) {
setAttributeComment(attribute.value().toString());
continue;
}
- if (name == QLatin1String("extracomment")) {
+ if (name == u"extracomment"_s) {
setAttributeExtraComment(attribute.value().toString());
continue;
}
- if (name == QLatin1String("id")) {
+ if (name == u"id"_s) {
setAttributeId(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"string"_s, Qt::CaseInsensitive)) {
m_string.append(reader.readElementText());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4034,19 +4048,19 @@ void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) cons
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringlist") : tagName.toLower());
if (hasAttributeNotr())
- writer.writeAttribute(QStringLiteral("notr"), attributeNotr());
+ writer.writeAttribute(u"notr"_s, attributeNotr());
if (hasAttributeComment())
- writer.writeAttribute(QStringLiteral("comment"), attributeComment());
+ writer.writeAttribute(u"comment"_s, attributeComment());
if (hasAttributeExtraComment())
- writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment());
+ writer.writeAttribute(u"extracomment"_s, attributeExtraComment());
if (hasAttributeId())
- writer.writeAttribute(QStringLiteral("id"), attributeId());
+ writer.writeAttribute(u"id"_s, attributeId());
for (const QString &v : m_string)
- writer.writeTextElement(QStringLiteral("string"), v);
+ writer.writeTextElement(u"string"_s, v);
writer.writeEndElement();
}
@@ -4064,22 +4078,22 @@ void DomResourcePixmap::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("resource")) {
+ if (name == u"resource"_s) {
setAttributeResource(attribute.value().toString());
continue;
}
- if (name == QLatin1String("alias")) {
+ if (name == u"alias"_s) {
setAttributeAlias(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4099,10 +4113,10 @@ void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName)
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourcepixmap") : tagName.toLower());
if (hasAttributeResource())
- writer.writeAttribute(QStringLiteral("resource"), attributeResource());
+ writer.writeAttribute(u"resource"_s, attributeResource());
if (hasAttributeAlias())
- writer.writeAttribute(QStringLiteral("alias"), attributeAlias());
+ writer.writeAttribute(u"alias"_s, attributeAlias());
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -4127,70 +4141,70 @@ void DomResourceIcon::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("theme")) {
+ if (name == u"theme"_s) {
setAttributeTheme(attribute.value().toString());
continue;
}
- if (name == QLatin1String("resource")) {
+ if (name == u"resource"_s) {
setAttributeResource(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("normaloff"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"normaloff"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementNormalOff(v);
continue;
}
- if (!tag.compare(QLatin1String("normalon"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"normalon"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementNormalOn(v);
continue;
}
- if (!tag.compare(QLatin1String("disabledoff"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"disabledoff"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementDisabledOff(v);
continue;
}
- if (!tag.compare(QLatin1String("disabledon"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"disabledon"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementDisabledOn(v);
continue;
}
- if (!tag.compare(QLatin1String("activeoff"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"activeoff"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementActiveOff(v);
continue;
}
- if (!tag.compare(QLatin1String("activeon"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"activeon"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementActiveOn(v);
continue;
}
- if (!tag.compare(QLatin1String("selectedoff"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"selectedoff"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementSelectedOff(v);
continue;
}
- if (!tag.compare(QLatin1String("selectedon"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"selectedon"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementSelectedOn(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4210,34 +4224,34 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourceicon") : tagName.toLower());
if (hasAttributeTheme())
- writer.writeAttribute(QStringLiteral("theme"), attributeTheme());
+ writer.writeAttribute(u"theme"_s, attributeTheme());
if (hasAttributeResource())
- writer.writeAttribute(QStringLiteral("resource"), attributeResource());
+ writer.writeAttribute(u"resource"_s, attributeResource());
if (m_children & NormalOff)
- m_normalOff->write(writer, QStringLiteral("normaloff"));
+ m_normalOff->write(writer, u"normaloff"_s);
if (m_children & NormalOn)
- m_normalOn->write(writer, QStringLiteral("normalon"));
+ m_normalOn->write(writer, u"normalon"_s);
if (m_children & DisabledOff)
- m_disabledOff->write(writer, QStringLiteral("disabledoff"));
+ m_disabledOff->write(writer, u"disabledoff"_s);
if (m_children & DisabledOn)
- m_disabledOn->write(writer, QStringLiteral("disabledon"));
+ m_disabledOn->write(writer, u"disabledon"_s);
if (m_children & ActiveOff)
- m_activeOff->write(writer, QStringLiteral("activeoff"));
+ m_activeOff->write(writer, u"activeoff"_s);
if (m_children & ActiveOn)
- m_activeOn->write(writer, QStringLiteral("activeon"));
+ m_activeOn->write(writer, u"activeon"_s);
if (m_children & SelectedOff)
- m_selectedOff->write(writer, QStringLiteral("selectedoff"));
+ m_selectedOff->write(writer, u"selectedoff"_s);
if (m_children & SelectedOn)
- m_selectedOn->write(writer, QStringLiteral("selectedon"));
+ m_selectedOn->write(writer, u"selectedon"_s);
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -4428,30 +4442,30 @@ void DomString::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("notr")) {
+ if (name == u"notr"_s) {
setAttributeNotr(attribute.value().toString());
continue;
}
- if (name == QLatin1String("comment")) {
+ if (name == u"comment"_s) {
setAttributeComment(attribute.value().toString());
continue;
}
- if (name == QLatin1String("extracomment")) {
+ if (name == u"extracomment"_s) {
setAttributeExtraComment(attribute.value().toString());
continue;
}
- if (name == QLatin1String("id")) {
+ if (name == u"id"_s) {
setAttributeId(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4471,16 +4485,16 @@ void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("string") : tagName.toLower());
if (hasAttributeNotr())
- writer.writeAttribute(QStringLiteral("notr"), attributeNotr());
+ writer.writeAttribute(u"notr"_s, attributeNotr());
if (hasAttributeComment())
- writer.writeAttribute(QStringLiteral("comment"), attributeComment());
+ writer.writeAttribute(u"comment"_s, attributeComment());
if (hasAttributeExtraComment())
- writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment());
+ writer.writeAttribute(u"extracomment"_s, attributeExtraComment());
if (hasAttributeId())
- writer.writeAttribute(QStringLiteral("id"), attributeId());
+ writer.writeAttribute(u"id"_s, attributeId());
if (!m_text.isEmpty())
writer.writeCharacters(m_text);
@@ -4496,15 +4510,15 @@ void DomPointF::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) {
setElementX(reader.readElementText().toDouble());
continue;
}
- if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) {
setElementY(reader.readElementText().toDouble());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4520,10 +4534,10 @@ void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("pointf") : tagName.toLower());
if (m_children & X)
- writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15));
+ writer.writeTextElement(u"x"_s, QString::number(m_x, 'f', 15));
if (m_children & Y)
- writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15));
+ writer.writeTextElement(u"y"_s, QString::number(m_y, 'f', 15));
writer.writeEndElement();
}
@@ -4558,23 +4572,23 @@ void DomRectF::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) {
setElementX(reader.readElementText().toDouble());
continue;
}
- if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) {
setElementY(reader.readElementText().toDouble());
continue;
}
- if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) {
setElementWidth(reader.readElementText().toDouble());
continue;
}
- if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) {
setElementHeight(reader.readElementText().toDouble());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4590,16 +4604,16 @@ void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rectf") : tagName.toLower());
if (m_children & X)
- writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15));
+ writer.writeTextElement(u"x"_s, QString::number(m_x, 'f', 15));
if (m_children & Y)
- writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15));
+ writer.writeTextElement(u"y"_s, QString::number(m_y, 'f', 15));
if (m_children & Width)
- writer.writeTextElement(QStringLiteral("width"), QString::number(m_width, 'f', 15));
+ writer.writeTextElement(u"width"_s, QString::number(m_width, 'f', 15));
if (m_children & Height)
- writer.writeTextElement(QStringLiteral("height"), QString::number(m_height, 'f', 15));
+ writer.writeTextElement(u"height"_s, QString::number(m_height, 'f', 15));
writer.writeEndElement();
}
@@ -4656,15 +4670,15 @@ void DomSizeF::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"width"_s, Qt::CaseInsensitive)) {
setElementWidth(reader.readElementText().toDouble());
continue;
}
- if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"height"_s, Qt::CaseInsensitive)) {
setElementHeight(reader.readElementText().toDouble());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4680,10 +4694,10 @@ void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizef") : tagName.toLower());
if (m_children & Width)
- writer.writeTextElement(QStringLiteral("width"), QString::number(m_width, 'f', 15));
+ writer.writeTextElement(u"width"_s, QString::number(m_width, 'f', 15));
if (m_children & Height)
- writer.writeTextElement(QStringLiteral("height"), QString::number(m_height, 'f', 15));
+ writer.writeTextElement(u"height"_s, QString::number(m_height, 'f', 15));
writer.writeEndElement();
}
@@ -4718,11 +4732,11 @@ void DomChar::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("unicode"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"unicode"_s, Qt::CaseInsensitive)) {
setElementUnicode(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4738,7 +4752,7 @@ void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("char") : tagName.toLower());
if (m_children & Unicode)
- writer.writeTextElement(QStringLiteral("unicode"), QString::number(m_unicode));
+ writer.writeTextElement(u"unicode"_s, QString::number(m_unicode));
writer.writeEndElement();
}
@@ -4765,13 +4779,13 @@ void DomUrl::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"string"_s, Qt::CaseInsensitive)) {
auto *v = new DomString();
v->read(reader);
setElementString(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -4787,7 +4801,7 @@ void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("url") : tagName.toLower());
if (m_children & String)
- m_string->write(writer, QStringLiteral("string"));
+ m_string->write(writer, u"string"_s);
writer.writeEndElement();
}
@@ -4900,196 +4914,196 @@ void DomProperty::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- if (name == QLatin1String("stdset")) {
+ if (name == u"stdset"_s) {
setAttributeStdset(attribute.value().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("bool"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"bool"_s, Qt::CaseInsensitive)) {
setElementBool(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"color"_s, Qt::CaseInsensitive)) {
auto *v = new DomColor();
v->read(reader);
setElementColor(v);
continue;
}
- if (!tag.compare(QLatin1String("cstring"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"cstring"_s, Qt::CaseInsensitive)) {
setElementCstring(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("cursor"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"cursor"_s, Qt::CaseInsensitive)) {
setElementCursor(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("cursorshape"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"cursorshape"_s, Qt::CaseInsensitive)) {
setElementCursorShape(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("enum"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"enum"_s, Qt::CaseInsensitive)) {
setElementEnum(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("font"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"font"_s, Qt::CaseInsensitive)) {
auto *v = new DomFont();
v->read(reader);
setElementFont(v);
continue;
}
- if (!tag.compare(QLatin1String("iconset"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"iconset"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourceIcon();
v->read(reader);
setElementIconSet(v);
continue;
}
- if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"pixmap"_s, Qt::CaseInsensitive)) {
auto *v = new DomResourcePixmap();
v->read(reader);
setElementPixmap(v);
continue;
}
- if (!tag.compare(QLatin1String("palette"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"palette"_s, Qt::CaseInsensitive)) {
auto *v = new DomPalette();
v->read(reader);
setElementPalette(v);
continue;
}
- if (!tag.compare(QLatin1String("point"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"point"_s, Qt::CaseInsensitive)) {
auto *v = new DomPoint();
v->read(reader);
setElementPoint(v);
continue;
}
- if (!tag.compare(QLatin1String("rect"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"rect"_s, Qt::CaseInsensitive)) {
auto *v = new DomRect();
v->read(reader);
setElementRect(v);
continue;
}
- if (!tag.compare(QLatin1String("set"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"set"_s, Qt::CaseInsensitive)) {
setElementSet(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("locale"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"locale"_s, Qt::CaseInsensitive)) {
auto *v = new DomLocale();
v->read(reader);
setElementLocale(v);
continue;
}
- if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"sizepolicy"_s, Qt::CaseInsensitive)) {
auto *v = new DomSizePolicy();
v->read(reader);
setElementSizePolicy(v);
continue;
}
- if (!tag.compare(QLatin1String("size"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"size"_s, Qt::CaseInsensitive)) {
auto *v = new DomSize();
v->read(reader);
setElementSize(v);
continue;
}
- if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"string"_s, Qt::CaseInsensitive)) {
auto *v = new DomString();
v->read(reader);
setElementString(v);
continue;
}
- if (!tag.compare(QLatin1String("stringlist"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"stringlist"_s, Qt::CaseInsensitive)) {
auto *v = new DomStringList();
v->read(reader);
setElementStringList(v);
continue;
}
- if (!tag.compare(QLatin1String("number"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"number"_s, Qt::CaseInsensitive)) {
setElementNumber(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("float"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"float"_s, Qt::CaseInsensitive)) {
setElementFloat(reader.readElementText().toFloat());
continue;
}
- if (!tag.compare(QLatin1String("double"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"double"_s, Qt::CaseInsensitive)) {
setElementDouble(reader.readElementText().toDouble());
continue;
}
- if (!tag.compare(QLatin1String("date"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"date"_s, Qt::CaseInsensitive)) {
auto *v = new DomDate();
v->read(reader);
setElementDate(v);
continue;
}
- if (!tag.compare(QLatin1String("time"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"time"_s, Qt::CaseInsensitive)) {
auto *v = new DomTime();
v->read(reader);
setElementTime(v);
continue;
}
- if (!tag.compare(QLatin1String("datetime"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"datetime"_s, Qt::CaseInsensitive)) {
auto *v = new DomDateTime();
v->read(reader);
setElementDateTime(v);
continue;
}
- if (!tag.compare(QLatin1String("pointf"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"pointf"_s, Qt::CaseInsensitive)) {
auto *v = new DomPointF();
v->read(reader);
setElementPointF(v);
continue;
}
- if (!tag.compare(QLatin1String("rectf"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"rectf"_s, Qt::CaseInsensitive)) {
auto *v = new DomRectF();
v->read(reader);
setElementRectF(v);
continue;
}
- if (!tag.compare(QLatin1String("sizef"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"sizef"_s, Qt::CaseInsensitive)) {
auto *v = new DomSizeF();
v->read(reader);
setElementSizeF(v);
continue;
}
- if (!tag.compare(QLatin1String("longlong"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"longlong"_s, Qt::CaseInsensitive)) {
setElementLongLong(reader.readElementText().toLongLong());
continue;
}
- if (!tag.compare(QLatin1String("char"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"char"_s, Qt::CaseInsensitive)) {
auto *v = new DomChar();
v->read(reader);
setElementChar(v);
continue;
}
- if (!tag.compare(QLatin1String("url"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"url"_s, Qt::CaseInsensitive)) {
auto *v = new DomUrl();
v->read(reader);
setElementUrl(v);
continue;
}
- if (!tag.compare(QLatin1String("uint"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"uint"_s, Qt::CaseInsensitive)) {
setElementUInt(reader.readElementText().toUInt());
continue;
}
- if (!tag.compare(QLatin1String("ulonglong"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"ulonglong"_s, Qt::CaseInsensitive)) {
setElementULongLong(reader.readElementText().toULongLong());
continue;
}
- if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"brush"_s, Qt::CaseInsensitive)) {
auto *v = new DomBrush();
v->read(reader);
setElementBrush(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -5105,163 +5119,163 @@ void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("property") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
if (hasAttributeStdset())
- writer.writeAttribute(QStringLiteral("stdset"), QString::number(attributeStdset()));
+ writer.writeAttribute(u"stdset"_s, QString::number(attributeStdset()));
switch (kind()) {
case Bool:
- writer.writeTextElement(QStringLiteral("bool"), elementBool());
+ writer.writeTextElement(u"bool"_s, elementBool());
break;
case Color:
if (m_color != nullptr)
- m_color->write(writer, QStringLiteral("color"));
+ m_color->write(writer, u"color"_s);
break;
case Cstring:
- writer.writeTextElement(QStringLiteral("cstring"), elementCstring());
+ writer.writeTextElement(u"cstring"_s, elementCstring());
break;
case Cursor:
- writer.writeTextElement(QStringLiteral("cursor"), QString::number(elementCursor()));
+ writer.writeTextElement(u"cursor"_s, QString::number(elementCursor()));
break;
case CursorShape:
- writer.writeTextElement(QStringLiteral("cursorShape"), elementCursorShape());
+ writer.writeTextElement(u"cursorShape"_s, elementCursorShape());
break;
case Enum:
- writer.writeTextElement(QStringLiteral("enum"), elementEnum());
+ writer.writeTextElement(u"enum"_s, elementEnum());
break;
case Font:
if (m_font != nullptr)
- m_font->write(writer, QStringLiteral("font"));
+ m_font->write(writer, u"font"_s);
break;
case IconSet:
if (m_iconSet != nullptr)
- m_iconSet->write(writer, QStringLiteral("iconset"));
+ m_iconSet->write(writer, u"iconset"_s);
break;
case Pixmap:
if (m_pixmap != nullptr)
- m_pixmap->write(writer, QStringLiteral("pixmap"));
+ m_pixmap->write(writer, u"pixmap"_s);
break;
case Palette:
if (m_palette != nullptr)
- m_palette->write(writer, QStringLiteral("palette"));
+ m_palette->write(writer, u"palette"_s);
break;
case Point:
if (m_point != nullptr)
- m_point->write(writer, QStringLiteral("point"));
+ m_point->write(writer, u"point"_s);
break;
case Rect:
if (m_rect != nullptr)
- m_rect->write(writer, QStringLiteral("rect"));
+ m_rect->write(writer, u"rect"_s);
break;
case Set:
- writer.writeTextElement(QStringLiteral("set"), elementSet());
+ writer.writeTextElement(u"set"_s, elementSet());
break;
case Locale:
if (m_locale != nullptr)
- m_locale->write(writer, QStringLiteral("locale"));
+ m_locale->write(writer, u"locale"_s);
break;
case SizePolicy:
if (m_sizePolicy != nullptr)
- m_sizePolicy->write(writer, QStringLiteral("sizepolicy"));
+ m_sizePolicy->write(writer, u"sizepolicy"_s);
break;
case Size:
if (m_size != nullptr)
- m_size->write(writer, QStringLiteral("size"));
+ m_size->write(writer, u"size"_s);
break;
case String:
if (m_string != nullptr)
- m_string->write(writer, QStringLiteral("string"));
+ m_string->write(writer, u"string"_s);
break;
case StringList:
if (m_stringList != nullptr)
- m_stringList->write(writer, QStringLiteral("stringlist"));
+ m_stringList->write(writer, u"stringlist"_s);
break;
case Number:
- writer.writeTextElement(QStringLiteral("number"), QString::number(elementNumber()));
+ writer.writeTextElement(u"number"_s, QString::number(elementNumber()));
break;
case Float:
- writer.writeTextElement(QStringLiteral("float"), QString::number(elementFloat(), 'f', 8));
+ writer.writeTextElement(u"float"_s, QString::number(elementFloat(), 'f', 8));
break;
case Double:
- writer.writeTextElement(QStringLiteral("double"), QString::number(elementDouble(), 'f', 15));
+ writer.writeTextElement(u"double"_s, QString::number(elementDouble(), 'f', 15));
break;
case Date:
if (m_date != nullptr)
- m_date->write(writer, QStringLiteral("date"));
+ m_date->write(writer, u"date"_s);
break;
case Time:
if (m_time != nullptr)
- m_time->write(writer, QStringLiteral("time"));
+ m_time->write(writer, u"time"_s);
break;
case DateTime:
if (m_dateTime != nullptr)
- m_dateTime->write(writer, QStringLiteral("datetime"));
+ m_dateTime->write(writer, u"datetime"_s);
break;
case PointF:
if (m_pointF != nullptr)
- m_pointF->write(writer, QStringLiteral("pointf"));
+ m_pointF->write(writer, u"pointf"_s);
break;
case RectF:
if (m_rectF != nullptr)
- m_rectF->write(writer, QStringLiteral("rectf"));
+ m_rectF->write(writer, u"rectf"_s);
break;
case SizeF:
if (m_sizeF != nullptr)
- m_sizeF->write(writer, QStringLiteral("sizef"));
+ m_sizeF->write(writer, u"sizef"_s);
break;
case LongLong:
- writer.writeTextElement(QStringLiteral("longLong"), QString::number(elementLongLong()));
+ writer.writeTextElement(u"longLong"_s, QString::number(elementLongLong()));
break;
case Char:
if (m_char != nullptr)
- m_char->write(writer, QStringLiteral("char"));
+ m_char->write(writer, u"char"_s);
break;
case Url:
if (m_url != nullptr)
- m_url->write(writer, QStringLiteral("url"));
+ m_url->write(writer, u"url"_s);
break;
case UInt:
- writer.writeTextElement(QStringLiteral("UInt"), QString::number(elementUInt()));
+ writer.writeTextElement(u"UInt"_s, QString::number(elementUInt()));
break;
case ULongLong:
- writer.writeTextElement(QStringLiteral("uLongLong"), QString::number(elementULongLong()));
+ writer.writeTextElement(u"uLongLong"_s, QString::number(elementULongLong()));
break;
case Brush:
if (m_brush != nullptr)
- m_brush->write(writer, QStringLiteral("brush"));
+ m_brush->write(writer, u"brush"_s);
break;
default:
@@ -5660,13 +5674,13 @@ void DomConnections::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("connection"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"connection"_s, Qt::CaseInsensitive)) {
auto *v = new DomConnection();
v->read(reader);
m_connection.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -5682,7 +5696,7 @@ void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) con
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connections") : tagName.toLower());
for (DomConnection *v : m_connection)
- v->write(writer, QStringLiteral("connection"));
+ v->write(writer, u"connection"_s);
writer.writeEndElement();
}
@@ -5704,29 +5718,29 @@ void DomConnection::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("sender"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"sender"_s, Qt::CaseInsensitive)) {
setElementSender(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"signal"_s, Qt::CaseInsensitive)) {
setElementSignal(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("receiver"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"receiver"_s, Qt::CaseInsensitive)) {
setElementReceiver(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("slot"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"slot"_s, Qt::CaseInsensitive)) {
setElementSlot(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("hints"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"hints"_s, Qt::CaseInsensitive)) {
auto *v = new DomConnectionHints();
v->read(reader);
setElementHints(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -5742,19 +5756,19 @@ void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) cons
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connection") : tagName.toLower());
if (m_children & Sender)
- writer.writeTextElement(QStringLiteral("sender"), m_sender);
+ writer.writeTextElement(u"sender"_s, m_sender);
if (m_children & Signal)
- writer.writeTextElement(QStringLiteral("signal"), m_signal);
+ writer.writeTextElement(u"signal"_s, m_signal);
if (m_children & Receiver)
- writer.writeTextElement(QStringLiteral("receiver"), m_receiver);
+ writer.writeTextElement(u"receiver"_s, m_receiver);
if (m_children & Slot)
- writer.writeTextElement(QStringLiteral("slot"), m_slot);
+ writer.writeTextElement(u"slot"_s, m_slot);
if (m_children & Hints)
- m_hints->write(writer, QStringLiteral("hints"));
+ m_hints->write(writer, u"hints"_s);
writer.writeEndElement();
}
@@ -5837,13 +5851,13 @@ void DomConnectionHints::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("hint"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"hint"_s, Qt::CaseInsensitive)) {
auto *v = new DomConnectionHint();
v->read(reader);
m_hint.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -5859,7 +5873,7 @@ void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName)
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhints") : tagName.toLower());
for (DomConnectionHint *v : m_hint)
- v->write(writer, QStringLiteral("hint"));
+ v->write(writer, u"hint"_s);
writer.writeEndElement();
}
@@ -5877,26 +5891,26 @@ void DomConnectionHint::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("type")) {
+ if (name == u"type"_s) {
setAttributeType(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"x"_s, Qt::CaseInsensitive)) {
setElementX(reader.readElementText().toInt());
continue;
}
- if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"y"_s, Qt::CaseInsensitive)) {
setElementY(reader.readElementText().toInt());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -5912,13 +5926,13 @@ void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName)
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhint") : tagName.toLower());
if (hasAttributeType())
- writer.writeAttribute(QStringLiteral("type"), attributeType());
+ writer.writeAttribute(u"type"_s, attributeType());
if (m_children & X)
- writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x));
+ writer.writeTextElement(u"x"_s, QString::number(m_x));
if (m_children & Y)
- writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y));
+ writer.writeTextElement(u"y"_s, QString::number(m_y));
writer.writeEndElement();
}
@@ -5957,13 +5971,13 @@ void DomDesignerData::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"property"_s, Qt::CaseInsensitive)) {
auto *v = new DomProperty();
v->read(reader);
m_property.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -5979,7 +5993,7 @@ void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) co
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("designerdata") : tagName.toLower());
for (DomProperty *v : m_property)
- v->write(writer, QStringLiteral("property"));
+ v->write(writer, u"property"_s);
writer.writeEndElement();
}
@@ -6002,15 +6016,15 @@ void DomSlots::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"signal"_s, Qt::CaseInsensitive)) {
m_signal.append(reader.readElementText());
continue;
}
- if (!tag.compare(QLatin1String("slot"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"slot"_s, Qt::CaseInsensitive)) {
m_slot.append(reader.readElementText());
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -6026,10 +6040,10 @@ void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("slots") : tagName.toLower());
for (const QString &v : m_signal)
- writer.writeTextElement(QStringLiteral("signal"), v);
+ writer.writeTextElement(u"signal"_s, v);
for (const QString &v : m_slot)
- writer.writeTextElement(QStringLiteral("slot"), v);
+ writer.writeTextElement(u"slot"_s, v);
writer.writeEndElement();
}
@@ -6060,19 +6074,19 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader)
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- if (!tag.compare(QLatin1String("tooltip"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"tooltip"_s, Qt::CaseInsensitive)) {
auto *v = new DomPropertyToolTip();
v->read(reader);
m_tooltip.append(v);
continue;
}
- if (!tag.compare(QLatin1String("stringpropertyspecification"), Qt::CaseInsensitive)) {
+ if (!tag.compare(u"stringpropertyspecification"_s, Qt::CaseInsensitive)) {
auto *v = new DomStringPropertySpecification();
v->read(reader);
m_stringpropertyspecification.append(v);
continue;
}
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -6088,10 +6102,10 @@ void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &t
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertyspecifications") : tagName.toLower());
for (DomPropertyToolTip *v : m_tooltip)
- v->write(writer, QStringLiteral("tooltip"));
+ v->write(writer, u"tooltip"_s);
for (DomStringPropertySpecification *v : m_stringpropertyspecification)
- v->write(writer, QStringLiteral("stringpropertyspecification"));
+ v->write(writer, u"stringpropertyspecification"_s);
writer.writeEndElement();
}
@@ -6115,18 +6129,18 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -6142,7 +6156,7 @@ void DomPropertyToolTip::write(QXmlStreamWriter &writer, const QString &tagName)
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertytooltip") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
writer.writeEndElement();
}
@@ -6154,26 +6168,26 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader)
const QXmlStreamAttributes &attributes = reader.attributes();
for (const QXmlStreamAttribute &attribute : attributes) {
const auto name = attribute.name();
- if (name == QLatin1String("name")) {
+ if (name == u"name"_s) {
setAttributeName(attribute.value().toString());
continue;
}
- if (name == QLatin1String("type")) {
+ if (name == u"type"_s) {
setAttributeType(attribute.value().toString());
continue;
}
- if (name == QLatin1String("notr")) {
+ if (name == u"notr"_s) {
setAttributeNotr(attribute.value().toString());
continue;
}
- reader.raiseError(QLatin1String("Unexpected attribute ") + name);
+ reader.raiseError("Unexpected attribute "_L1 + name);
}
while (!reader.hasError()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartElement : {
const auto tag = reader.name();
- reader.raiseError(QLatin1String("Unexpected element ") + tag);
+ reader.raiseError("Unexpected element "_L1 + tag);
}
break;
case QXmlStreamReader::EndElement :
@@ -6189,13 +6203,13 @@ void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QStri
writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringpropertyspecification") : tagName.toLower());
if (hasAttributeName())
- writer.writeAttribute(QStringLiteral("name"), attributeName());
+ writer.writeAttribute(u"name"_s, attributeName());
if (hasAttributeType())
- writer.writeAttribute(QStringLiteral("type"), attributeType());
+ writer.writeAttribute(u"type"_s, attributeType());
if (hasAttributeNotr())
- writer.writeAttribute(QStringLiteral("notr"), attributeNotr());
+ writer.writeAttribute(u"notr"_s, attributeNotr());
writer.writeEndElement();
}
diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h
index a5ac51f521..333f7f4e6a 100644
--- a/src/tools/uic/ui4.h
+++ b/src/tools/uic/ui4.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
//
// W A R N I N G
@@ -1670,6 +1645,16 @@ public:
inline bool hasElementKerning() const { return m_children & Kerning; }
void clearElementKerning();
+ inline QString elementHintingPreference() const { return m_hintingPreference; }
+ void setElementHintingPreference(const QString &a);
+ inline bool hasElementHintingPreference() const { return m_children & HintingPreference; }
+ void clearElementHintingPreference();
+
+ inline QString elementFontWeight() const { return m_fontWeight; }
+ void setElementFontWeight(const QString &a);
+ inline bool hasElementFontWeight() const { return m_children & FontWeight; }
+ void clearElementFontWeight();
+
private:
// child element data
@@ -1684,6 +1669,8 @@ private:
bool m_antialiasing = false;
QString m_styleStrategy;
bool m_kerning = false;
+ QString m_hintingPreference;
+ QString m_fontWeight;
enum Child {
Family = 1,
@@ -1695,7 +1682,9 @@ private:
StrikeOut = 64,
Antialiasing = 128,
StyleStrategy = 256,
- Kerning = 512
+ Kerning = 512,
+ HintingPreference = 1024,
+ FontWeight = 2048
};
};
diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
index 3601280144..fb0a37d21d 100644
--- a/src/tools/uic/uic.cpp
+++ b/src/tools/uic/uic.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "uic.h"
#include "ui4.h"
@@ -47,6 +22,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Uic::Uic(Driver *d)
: drv(d),
out(d->output()),
@@ -61,9 +38,10 @@ bool Uic::printDependencies()
QString fileName = opt.inputFile;
QFile f;
- if (fileName.isEmpty())
- f.open(stdin, QIODevice::ReadOnly);
- else {
+ if (fileName.isEmpty()) {
+ if (!f.open(stdin, QIODevice::ReadOnly))
+ return false;
+ } else {
f.setFileName(fileName);
if (!f.open(QIODevice::ReadOnly))
return false;
@@ -127,7 +105,7 @@ void Uic::writeCopyrightHeaderCpp(const DomUI *ui) const
static inline bool isCppCommentChar(QChar c)
{
- return c == QLatin1Char('/') || c == QLatin1Char('*');
+ return c == u'/' || c == u'*';
}
static int leadingCppCommentCharCount(QStringView s)
@@ -142,13 +120,13 @@ void Uic::writeCopyrightHeaderPython(const DomUI *ui) const
{
QString comment = ui->elementComment();
if (!comment.isEmpty()) {
- const auto lines = QStringView{comment}.split(QLatin1Char('\n'));
+ const auto lines = QStringView{comment}.split(u'\n');
for (const auto &line : lines) {
if (const int leadingCommentChars = leadingCppCommentCharCount(line)) {
out << language::repeat(leadingCommentChars, '#')
<< line.right(line.size() - leadingCommentChars);
} else {
- if (!line.startsWith(QLatin1Char('#')))
+ if (!line.startsWith(u'#'))
out << "# ";
out << line;
}
@@ -169,7 +147,7 @@ void Uic::writeCopyrightHeaderPython(const DomUI *ui) const
static double versionFromUiAttribute(QXmlStreamReader &reader)
{
const QXmlStreamAttributes attributes = reader.attributes();
- const QString versionAttribute = QLatin1String("version");
+ const auto versionAttribute = "version"_L1;
if (!attributes.hasAttribute(versionAttribute))
return 4.0;
const QStringView version = attributes.value(versionAttribute);
@@ -180,7 +158,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
{
DomUI *ui = nullptr;
- const QString uiElement = QLatin1String("ui");
+ const auto uiElement = "ui"_L1;
while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement) {
if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0
@@ -195,7 +173,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
ui = new DomUI();
ui->read(reader);
} else {
- reader.raiseError(QLatin1String("Unexpected element ") + reader.name().toString());
+ reader.raiseError("Unexpected element "_L1 + reader.name().toString());
}
}
}
@@ -231,7 +209,7 @@ bool Uic::write(QIODevice *in)
const QString &language = ui->attributeLanguage();
driver()->setUseIdBasedTranslations(ui->attributeIdbasedtr());
- if (!language.isEmpty() && language.compare(QLatin1String("c++"), Qt::CaseInsensitive) != 0) {
+ if (!language.isEmpty() && language.compare("c++"_L1, Qt::CaseInsensitive) != 0) {
fprintf(stderr, "uic: File is not a \"c++\" ui file, language=%s\n", qPrintable(language));
return false;
}
@@ -266,8 +244,7 @@ bool Uic::write(DomUI *ui)
}
pixFunction = ui->elementPixmapFunction();
- if (pixFunction == QLatin1String("QPixmap::fromMimeSource")
- || pixFunction == QLatin1String("qPixmapFromMimeSource")) {
+ if (pixFunction == "QPixmap::fromMimeSource"_L1 || pixFunction == "qPixmapFromMimeSource"_L1) {
fprintf(stderr, "%s: Warning: Obsolete pixmap function '%s' specified in the UI file.\n",
qPrintable(opt.messagePrefix()), qPrintable(pixFunction));
pixFunction.clear();
@@ -315,9 +292,9 @@ void Uic::writeHeaderProtectionEnd()
bool Uic::isButton(const QString &className) const
{
static const QStringList buttons = {
- QLatin1String("QRadioButton"), QLatin1String("QToolButton"),
- QLatin1String("QCheckBox"), QLatin1String("QPushButton"),
- QLatin1String("QCommandLinkButton")
+ u"QRadioButton"_s, u"QToolButton"_s,
+ u"QCheckBox"_s, u"QPushButton"_s,
+ u"QCommandLinkButton"_s
};
return customWidgetsInfo()->extendsOneOf(className, buttons);
}
@@ -325,10 +302,10 @@ bool Uic::isButton(const QString &className) const
bool Uic::isContainer(const QString &className) const
{
static const QStringList containers = {
- QLatin1String("QStackedWidget"), QLatin1String("QToolBox"),
- QLatin1String("QTabWidget"), QLatin1String("QScrollArea"),
- QLatin1String("QMdiArea"), QLatin1String("QWizard"),
- QLatin1String("QDockWidget")
+ u"QStackedWidget"_s, u"QToolBox"_s,
+ u"QTabWidget"_s, u"QScrollArea"_s,
+ u"QMdiArea"_s, u"QWizard"_s,
+ u"QDockWidget"_s
};
return customWidgetsInfo()->extendsOneOf(className, containers);
@@ -337,7 +314,7 @@ bool Uic::isContainer(const QString &className) const
bool Uic::isMenu(const QString &className) const
{
static const QStringList menus = {
- QLatin1String("QMenu"), QLatin1String("QPopupMenu")
+ u"QMenu"_s, u"QPopupMenu"_s
};
return customWidgetsInfo()->extendsOneOf(className, menus);
}
diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h
index f3dfd49149..ef5f0a90bd 100644
--- a/src/tools/uic/uic.h
+++ b/src/tools/uic/uic.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef UIC_H
#define UIC_H
diff --git a/src/tools/uic/uic.pri b/src/tools/uic/uic.pri
deleted file mode 100644
index 1c9098dcf9..0000000000
--- a/src/tools/uic/uic.pri
+++ /dev/null
@@ -1,20 +0,0 @@
-
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/customwidgetsinfo.h \
- $$PWD/databaseinfo.h \
- $$PWD/driver.h \
- $$PWD/option.h \
- $$PWD/treewalker.h \
- $$PWD/utils.h \
- $$PWD/ui4.h \
- $$PWD/validator.h
-
-SOURCES += \
- $$PWD/customwidgetsinfo.cpp \
- $$PWD/databaseinfo.cpp \
- $$PWD/driver.cpp \
- $$PWD/treewalker.cpp \
- $$PWD/ui4.cpp \
- $$PWD/validator.cpp
diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro
deleted file mode 100644
index 8b579cb575..0000000000
--- a/src/tools/uic/uic.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-option(host_build)
-!force_bootstrap:if(!qtConfig(commandlineparser)|!qtConfig(xmlstreamreader)|!qtConfig(xmlstreamwriter)): \
- CONFIG += force_bootstrap
-
-DEFINES += QT_UIC QT_NO_CAST_FROM_ASCII QT_NO_FOREACH
-
-include(uic.pri)
-include(shared/shared.pri)
-include(cpp/cpp.pri)
-include(python/python.pri)
-
-HEADERS += uic.h
-
-SOURCES += main.cpp \
- uic.cpp
-
-QMAKE_TARGET_DESCRIPTION = "Qt User Interface Compiler"
-load(qt_tool)
diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h
index 34c4ab23d4..37247cdea6 100644
--- a/src/tools/uic/utils.h
+++ b/src/tools/uic/utils.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef UTILS_H
#define UTILS_H
@@ -37,7 +12,7 @@
QT_BEGIN_NAMESPACE
inline bool toBool(const QString &str)
-{ return str.toLower() == QLatin1String("true"); }
+{ return QString::compare(str, QLatin1StringView("true"), Qt::CaseInsensitive) == 0; }
inline QString toString(const DomString *str)
{ return str ? str->text() : QString(); }
diff --git a/src/tools/uic/validator.cpp b/src/tools/uic/validator.cpp
index d3b1300ee7..c9f8c0a496 100644
--- a/src/tools/uic/validator.cpp
+++ b/src/tools/uic/validator.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "validator.h"
#include "driver.h"
diff --git a/src/tools/uic/validator.h b/src/tools/uic/validator.h
index f7f7401991..6f965b84d5 100644
--- a/src/tools/uic/validator.h
+++ b/src/tools/uic/validator.h
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef VALIDATOR_H
#define VALIDATOR_H