diff options
134 files changed, 3357 insertions, 6583 deletions
diff --git a/.qmake.conf b/.qmake.conf index 2108ac6fd..138038d54 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,3 +1,3 @@ load(qt_build_config) -MODULE_VERSION = 5.9.3 +MODULE_VERSION = 5.10.0 diff --git a/dist/changes-5.10.0 b/dist/changes-5.10.0 new file mode 100644 index 000000000..8b71dea4b --- /dev/null +++ b/dist/changes-5.10.0 @@ -0,0 +1,27 @@ +Qt 5.10 introduces many new features and improvements as well as bugfixes +over the 5.9.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.10 series is binary compatible with the 5.9.x series. +Applications compiled for 5.9 will continue to run with 5.10. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Qt 5.10.0 Changes * +**************************************************************************** + + - This release contains only minor code improvements. + +UNSPECIFIED +----------- + + - Added option "-no-untranslated" to lconvert diff --git a/examples/examples.pro b/examples/examples.pro index 8fb90f846..0300e3c04 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs qtHaveModule(widgets): SUBDIRS += help designer linguist uitools assistant -!qtConfig(process): SUBDIRS -= assistant -winrt: SUBDIRS -= designer +!qtConfig(process): SUBDIRS -= assistant designer diff --git a/src/assistant/assistant/assistant.pro b/src/assistant/assistant/assistant.pro index 82f55092c..1374c0738 100644 --- a/src/assistant/assistant/assistant.pro +++ b/src/assistant/assistant/assistant.pro @@ -102,8 +102,7 @@ FORMS += bookmarkdialog.ui \ RESOURCES += assistant.qrc \ assistant_images.qrc -QMAKE_TARGET_PRODUCT = Qt Assistant -QMAKE_TARGET_DESCRIPTION = Tool for viewing on-line documentation in Qt help file format +QMAKE_TARGET_DESCRIPTION = Qt Assistant win32 { LIBS += -lshell32 diff --git a/src/assistant/assistant/centralwidget.cpp b/src/assistant/assistant/centralwidget.cpp index 43a8b9a3d..6efa2fe62 100644 --- a/src/assistant/assistant/centralwidget.cpp +++ b/src/assistant/assistant/centralwidget.cpp @@ -35,6 +35,7 @@ #include "tracer.h" #include "../shared/collectionconfiguration.h" +#include <QtCore/QRegExp> #include <QtCore/QTimer> #include <QtGui/QKeyEvent> diff --git a/src/assistant/assistant/main.cpp b/src/assistant/assistant/main.cpp index 1782aee5a..04f0fc968 100644 --- a/src/assistant/assistant/main.cpp +++ b/src/assistant/assistant/main.cpp @@ -267,9 +267,7 @@ void setupTranslations() int main(int argc, char *argv[]) { -#ifdef Q_OS_WIN QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif TRACE_OBJ QScopedPointer<QCoreApplication> a(createApplication(argc, argv)); #if QT_CONFIG(library) diff --git a/src/assistant/help/qhelpdbreader.cpp b/src/assistant/help/qhelpdbreader.cpp index 3b364dfb1..6574ac90e 100644 --- a/src/assistant/help/qhelpdbreader.cpp +++ b/src/assistant/help/qhelpdbreader.cpp @@ -79,6 +79,19 @@ bool QHelpDBReader::init() if (!QFile::exists(m_dbName)) return false; + if (!initDB()) { + QSqlDatabase::removeDatabase(m_uniqueId); + return false; + } + + m_initDone = true; + m_query = new QSqlQuery(QSqlDatabase::database(m_uniqueId)); + + return true; +} + +bool QHelpDBReader::initDB() +{ QSqlDatabase db = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), m_uniqueId); db.setConnectOptions(QLatin1String("QSQLITE_OPEN_READONLY")); db.setDatabaseName(m_dbName); @@ -87,13 +100,8 @@ bool QHelpDBReader::init() %2 - The unique id for the connection %3 - The actual error string */ m_error = tr("Cannot open database '%1' '%2': %3").arg(m_dbName, m_uniqueId, db.lastError().text()); - QSqlDatabase::removeDatabase(m_uniqueId); return false; } - - m_initDone = true; - m_query = new QSqlQuery(db); - return true; } diff --git a/src/assistant/help/qhelpdbreader_p.h b/src/assistant/help/qhelpdbreader_p.h index 48005d35e..aca4c8afa 100644 --- a/src/assistant/help/qhelpdbreader_p.h +++ b/src/assistant/help/qhelpdbreader_p.h @@ -108,6 +108,7 @@ private: const QString &relFileName, const QString &anchor) const; QString mergeList(const QStringList &list) const; QString quote(const QString &string) const; + bool initDB(); bool m_initDone = false; QString m_dbName; diff --git a/src/assistant/help/qhelpgenerator.cpp b/src/assistant/help/qhelpgenerator.cpp index c8722499e..d341a04de 100644 --- a/src/assistant/help/qhelpgenerator.cpp +++ b/src/assistant/help/qhelpgenerator.cpp @@ -311,9 +311,6 @@ bool QHelpGenerator::createTables() "NamespaceId INTEGER, " "FileId INTEGER, " "Anchor TEXT )") - << QLatin1String("CREATE TABLE IndexItemTable (" - "Id INTEGER, " - "IndexId INTEGER )") << QLatin1String("CREATE TABLE IndexFilterTable (" "FilterAttributeId INTEGER, " "IndexId INTEGER )") diff --git a/src/assistant/help/qhelpsearchindexreader_default.cpp b/src/assistant/help/qhelpsearchindexreader_default.cpp index 7f8c1bbf8..1154e49f0 100644 --- a/src/assistant/help/qhelpsearchindexreader_default.cpp +++ b/src/assistant/help/qhelpsearchindexreader_default.cpp @@ -94,7 +94,6 @@ static QString namespacePlaceholders(const QMultiMap<QString, QStringList> &name static void bindNamespacesAndAttributes(QSqlQuery *query, const QMultiMap<QString, QStringList> &namespaces) { - QString placeholders; const auto &namespaceList = namespaces.uniqueKeys(); for (const QString &ns : namespaceList) { query->addBindValue(ns); diff --git a/src/assistant/qcollectiongenerator/qcollectiongenerator.pro b/src/assistant/qcollectiongenerator/qcollectiongenerator.pro index 608fca6bc..cf9b9a257 100644 --- a/src/assistant/qcollectiongenerator/qcollectiongenerator.pro +++ b/src/assistant/qcollectiongenerator/qcollectiongenerator.pro @@ -7,4 +7,5 @@ HEADERS += ../shared/helpgenerator.h \ ../shared/collectionconfiguration.h QTPLUGIN.platforms = qminimal +QMAKE_TARGET_DESCRIPTION = "Qt Help Collection File Generator" load(qt_tool) diff --git a/src/assistant/qhelpgenerator/qhelpgenerator.pro b/src/assistant/qhelpgenerator/qhelpgenerator.pro index a7ec6f00a..d4e84a74f 100644 --- a/src/assistant/qhelpgenerator/qhelpgenerator.pro +++ b/src/assistant/qhelpgenerator/qhelpgenerator.pro @@ -7,4 +7,5 @@ SOURCES += ../shared/helpgenerator.cpp \ HEADERS += ../shared/helpgenerator.h +QMAKE_TARGET_DESCRIPTION = "Qt Compressed Help File Generator" load(qt_tool) diff --git a/src/designer/data/README b/src/designer/data/README new file mode 100644 index 000000000..b7160b8f6 --- /dev/null +++ b/src/designer/data/README @@ -0,0 +1,8 @@ +You may generate ui4.h and ui4.cpp parser files by using the generate_ui script +or manually by invoking the xsltproc command: + +xsltproc generate_header.xsl ui4.xsd > ui4.h +xsltproc generate_impl.xsl ui4.xsd > ui4.cpp + +Remember to update uic sources in qtbase module accordingly, +adapting the license. diff --git a/src/designer/data/generate_header.xsl b/src/designer/data/generate_header.xsl index b5203d454..ec1ea7aa9 100644 --- a/src/designer/data/generate_header.xsl +++ b/src/designer/data/generate_header.xsl @@ -25,6 +25,26 @@ <xsl:template name="child-element-accessors"> <xsl:param name="node"/> + <xsl:variable name="set" select="$node/xs:sequence | $node/xs:choice | $node/xs:all"/> + <xsl:variable name="count" select="count($set)"/> + + <xsl:if test="$count > 0"> + <xsl:text> // child element accessors&endl;</xsl:text> + </xsl:if> + + <xsl:for-each select="$set"> + <xsl:call-template name="child-element-accessor"> + <xsl:with-param name="node" select="."/> + </xsl:call-template> + </xsl:for-each> + + </xsl:template> + +<!-- Class declaration: child element accessor --> + + <xsl:template name="child-element-accessor"> + <xsl:param name="node"/> + <xsl:variable name="isChoice" select="name($node)='xs:choice'"/> <xsl:if test="$isChoice"> @@ -48,7 +68,7 @@ <xsl:text> inline Kind kind() const { return m_kind; }&endl;&endl;</xsl:text> </xsl:if> - <xsl:for-each select="$node/xs:element"> + <xsl:for-each select="$node/xs:element[not(@use) or (@use!='deprecated')]"> <xsl:variable name="array" select="@maxOccurs='unbounded'"/> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> @@ -81,7 +101,7 @@ <xsl:text> inline </xsl:text> <xsl:value-of select="$return-cpp-type"/> - <xsl:text> element</xsl:text> + <xsl:text>element</xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>() const { return m_</xsl:text> <xsl:value-of select="$camel-case-name"/> @@ -90,7 +110,7 @@ <xsl:if test="$xs-type-cat = 'pointer'"> <xsl:text> </xsl:text> <xsl:value-of select="$return-cpp-type"/> - <xsl:text> takeElement</xsl:text> + <xsl:text>takeElement</xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>();&endl;</xsl:text> </xsl:if> @@ -99,7 +119,7 @@ <xsl:value-of select="$cap-name"/> <xsl:text>(</xsl:text> <xsl:value-of select="$argument-cpp-type"/> - <xsl:text> a);&endl;</xsl:text> + <xsl:text>a);&endl;</xsl:text> <xsl:if test="not($isChoice) and not(@maxOccurs='unbounded')"> <xsl:text> inline bool hasElement</xsl:text> @@ -116,6 +136,31 @@ </xsl:for-each> </xsl:template> +<!-- Class declaration: child elements data --> + + <xsl:template name="child-elements-data"> + <xsl:param name="node"/> + + <xsl:variable name="set" select="$node/xs:sequence | $node/xs:choice | $node/xs:all"/> + <xsl:variable name="count" select="count($set)"/> + + <xsl:if test="boolean($node/xs:choice)"> + <xsl:text>&endl; // child element data&endl;</xsl:text> + <xsl:text> Kind m_kind = Unknown;&endl;</xsl:text> + </xsl:if> + <xsl:if test="not($node/xs:choice) and $count > 0"> + <xsl:text>&endl; // child element data&endl;</xsl:text> + <xsl:text> uint m_children = 0;&endl;</xsl:text> + </xsl:if> + + <xsl:for-each select="$set"> + <xsl:call-template name="child-element-data"> + <xsl:with-param name="node" select="."/> + </xsl:call-template> + </xsl:for-each> + + </xsl:template> + <!-- Class declaration: child element data --> <xsl:template name="child-element-data"> @@ -123,7 +168,7 @@ <xsl:variable name="isChoice" select="$node[name()='xs:choice']"/> - <xsl:for-each select="$node/xs:element"> + <xsl:for-each select="$node/xs:element[not(@use) or (@use!='deprecated')]"> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> @@ -137,15 +182,36 @@ </xsl:variable> <xsl:text> </xsl:text> <xsl:value-of select="$cpp-type"/> - <xsl:text> m_</xsl:text> + <xsl:text>m_</xsl:text> <xsl:value-of select="$camel-case-name"/> + + <xsl:variable name="array" select="@maxOccurs='unbounded'"/> + <xsl:if test="not($array)"> + <xsl:choose> + <xsl:when test="@type = 'xs:integer' or @type = 'xs:unsignedInt' or @type = 'xs:long' or @type = 'xs:unsignedLong'"> + <xsl:text> = 0</xsl:text> + </xsl:when> + <xsl:when test="@type = 'xs:double' or @type = 'xs:float'"> + <xsl:text> = 0.0</xsl:text> + </xsl:when> + <xsl:when test="@type = 'xs:boolean'"> + <xsl:text> = false</xsl:text> + </xsl:when> + <xsl:when test="@type = 'xs:string'"> + </xsl:when> + <xsl:otherwise> + <xsl:text> = nullptr</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:if> + <xsl:text>;&endl;</xsl:text> </xsl:for-each> <xsl:if test="not($isChoice) and not(@macOccurs='unbounded')"> - <xsl:text> enum Child {&endl;</xsl:text> - <xsl:for-each select="$node/xs:element"> - <xsl:variable name="camel-case-name"> + <xsl:text>&endl; enum Child {&endl;</xsl:text> + <xsl:for-each select="$node/xs:element[not(@use) or (@use!='deprecated')]"> + <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> </xsl:call-template> @@ -174,7 +240,14 @@ <xsl:template name="attribute-accessors"> <xsl:param name="node"/> - <xsl:for-each select="$node/xs:attribute"> + <xsl:variable name="set" select="$node//xs:attribute"/> + <xsl:variable name="count" select="count($set)"/> + + <xsl:if test="$count > 0"> + <xsl:text> // attribute accessors&endl;</xsl:text> + </xsl:if> + + <xsl:for-each select="$set"> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> @@ -204,7 +277,7 @@ <xsl:text> inline </xsl:text> <xsl:value-of select="$cpp-return-type"/> - <xsl:text> attribute</xsl:text> + <xsl:text>attribute</xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>() const { return m_attr_</xsl:text> <xsl:value-of select="$camel-case-name"/> @@ -214,7 +287,7 @@ <xsl:value-of select="$cap-name"/> <xsl:text>(</xsl:text> <xsl:value-of select="$cpp-argument-type"/> - <xsl:text> a) { m_attr_</xsl:text> + <xsl:text>a) { m_attr_</xsl:text> <xsl:value-of select="$camel-case-name"/> <xsl:text> = a; m_has_attr_</xsl:text> <xsl:value-of select="$camel-case-name"/> @@ -233,8 +306,7 @@ <xsl:template name="class-declaration"> <xsl:param name="node"/> <xsl:variable name="name" select="concat('Dom', $node/@name)"/> -<!-- <xsl:variable name="hasText" select="$node[@mixed='true']"/>--> - <xsl:variable name="hasText" select="true()"/> + <xsl:variable name="hasText" select="$node[@mixed='true']"/> <xsl:text>class QDESIGNER_UILIB_EXPORT </xsl:text> <xsl:value-of select="$name"/> @@ -244,44 +316,44 @@ <xsl:text>public:&endl;</xsl:text> <xsl:text> </xsl:text> <xsl:value-of select="$name"/> - <xsl:text>();&endl;</xsl:text> + <xsl:text>() = default;&endl;</xsl:text> <xsl:text> ~</xsl:text> <xsl:value-of select="$name"/> <xsl:text>();&endl;&endl;</xsl:text> <xsl:text> void read(QXmlStreamReader &reader);&endl;</xsl:text> - <xsl:text> void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;&endl;</xsl:text> + <xsl:text> void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;&endl;&endl;</xsl:text> <xsl:if test="$hasText"> <xsl:text> inline QString text() const { return m_text; }&endl;</xsl:text> - <xsl:text> inline void setText(const QString &s) { m_text = s; }&endl;</xsl:text> + <xsl:text> inline void setText(const QString &s) { m_text = s; }&endl;&endl;</xsl:text> </xsl:if> - <xsl:text>&endl;</xsl:text> - - <xsl:text> // attribute accessors&endl;</xsl:text> <xsl:call-template name="attribute-accessors"> <xsl:with-param name="node" select="$node"/> </xsl:call-template> - <xsl:text> // child element accessors&endl;</xsl:text> - - <xsl:for-each select="$node/xs:sequence | $node/xs:choice | $node/xs:all"> - <xsl:call-template name="child-element-accessors"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - </xsl:for-each> + <xsl:call-template name="child-element-accessors"> + <xsl:with-param name="node" select="$node"/> + </xsl:call-template> <xsl:text>private:&endl;</xsl:text> <xsl:if test="$hasText"> - <xsl:text> QString m_text;&endl;</xsl:text> + <xsl:text> QString m_text;&endl;&endl;</xsl:text> </xsl:if> - <xsl:text> void clear(bool clear_all = true);&endl;&endl;</xsl:text> + <xsl:if test="boolean($node/xs:choice)"> + <xsl:text> void clear();&endl;&endl;</xsl:text> + </xsl:if> - <xsl:text> // attribute data&endl;</xsl:text> - <xsl:for-each select="$node/xs:attribute"> + <xsl:variable name="set" select="$node//xs:attribute"/> + <xsl:variable name="count" select="count($set)"/> + + <xsl:if test="$count > 0"> + <xsl:text> // attribute data&endl;</xsl:text> + </xsl:if> + <xsl:for-each select="$set"> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> @@ -296,25 +368,31 @@ <xsl:value-of select="$cpp-type"/> <xsl:text> m_attr_</xsl:text> <xsl:value-of select="$camel-case-name"/> + + <xsl:choose> + <xsl:when test="@type = 'xs:integer'"> + <xsl:text> = 0</xsl:text> + </xsl:when> + <xsl:when test="@type = 'xs:double' or @type = 'xs:float'"> + <xsl:text> = 0.0</xsl:text> + </xsl:when> + <xsl:when test="@type = 'xs:boolean'"> + <xsl:text> = false</xsl:text> + </xsl:when> + </xsl:choose> + <xsl:text>;&endl;</xsl:text> <xsl:text> bool m_has_attr_</xsl:text> <xsl:value-of select="$camel-case-name"/> - <xsl:text>;&endl;&endl;</xsl:text> + <xsl:text> = false;&endl;</xsl:text> + <xsl:if test="position()!=last()"> + <xsl:text>&endl;</xsl:text> + </xsl:if> </xsl:for-each> - <xsl:text> // child element data&endl;</xsl:text> - <xsl:if test="boolean($node/xs:choice)"> - <xsl:text> Kind m_kind;&endl;</xsl:text> - </xsl:if> - <xsl:if test="not($node/xs:choice)"> - <!-- TODO: if there are no elements with maxOccurs='1', m_children is never used--> - <xsl:text> uint m_children;&endl;</xsl:text> - </xsl:if> - <xsl:for-each select="$node/xs:sequence | $node/xs:choice | $node/xs:all"> - <xsl:call-template name="child-element-data"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - </xsl:for-each> + <xsl:call-template name="child-elements-data"> + <xsl:with-param name="node" select="$node"/> + </xsl:call-template> <xsl:text>};&endl;&endl;</xsl:text> </xsl:template> @@ -381,6 +459,7 @@ #include <qlist.h> #include <qstring.h> #include <qstringlist.h> +#include <qvector.h> #include <qxmlstream.h> #include <qglobal.h> diff --git a/src/designer/data/generate_impl.xsl b/src/designer/data/generate_impl.xsl index 8b650f88f..6a538b697 100644 --- a/src/designer/data/generate_impl.xsl +++ b/src/designer/data/generate_impl.xsl @@ -11,65 +11,23 @@ <!-- Implementation: constructor --> - <xsl:template name="ctor-init-attributes"> - <xsl:param name="node"/> - <xsl:for-each select="$node/xs:attribute"> - <xsl:variable name="camel-case-name"> - <xsl:call-template name="camel-case"> - <xsl:with-param name="text" select="@name"/> - </xsl:call-template> - </xsl:variable> - <xsl:text> m_has_attr_</xsl:text> - <xsl:value-of select="$camel-case-name"/> - <xsl:text> = false;&endl;</xsl:text> - <xsl:choose> - <xsl:when test="@type = 'xs:integer'"> - <xsl:text> m_attr_</xsl:text> - <xsl:value-of select="$camel-case-name"/> - <xsl:text> = 0;&endl;</xsl:text> - </xsl:when> - <xsl:when test="@type = 'xs:double'"> - <xsl:text> m_attr_</xsl:text> - <xsl:value-of select="$camel-case-name"/> - <xsl:text> = 0.0;&endl;</xsl:text> - </xsl:when> - <xsl:when test="@type = 'xs:float'"> - <xsl:text> m_attr_</xsl:text> - <xsl:value-of select="$camel-case-name"/> - <xsl:text> = 0.0;&endl;</xsl:text> - </xsl:when> - <xsl:when test="@type = 'xs:boolean'"> - <xsl:text> m_attr_</xsl:text> - <xsl:value-of select="$camel-case-name"/> - <xsl:text> = false;&endl;</xsl:text> - </xsl:when> - </xsl:choose> - </xsl:for-each> - </xsl:template> - <xsl:template name="ctor-init-child-elements"> <xsl:param name="node"/> <xsl:for-each select="$node/xs:element"> <xsl:variable name="array" select="@maxOccurs='unbounded'"/> <xsl:if test="not($array)"> - <xsl:variable name="cpp-type"> - <xsl:call-template name="xs-type-to-cpp-type"> - <xsl:with-param name="xs-type" select="@type"/> - <xsl:with-param name="array" select="$array"/> - </xsl:call-template> - </xsl:variable> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> </xsl:call-template> </xsl:variable> <xsl:choose> - <xsl:when test="@type = 'xs:integer'"> + <xsl:when test="@type = 'xs:integer' or @type = 'xs:unsignedInt' or @type = 'xs:long' or @type = 'xs:unsignedLong'"> <xsl:text> m_</xsl:text> <xsl:value-of select="$camel-case-name"/> <xsl:text> = 0;&endl;</xsl:text> </xsl:when> - <xsl:when test="@type = 'xs:float'"> + <xsl:when test="@type = 'xs:double' or @type = 'xs:float'"> <xsl:text> m_</xsl:text> <xsl:value-of select="$camel-case-name"/> <xsl:text> = 0.0;&endl;</xsl:text> @@ -79,64 +37,24 @@ <xsl:value-of select="$camel-case-name"/> <xsl:text> = false;&endl;</xsl:text> </xsl:when> - <xsl:when test="@type = 'xs:string'"></xsl:when> + <xsl:when test="@type = 'xs:string'"> + </xsl:when> <xsl:otherwise> <xsl:text> m_</xsl:text> <xsl:value-of select="$camel-case-name"/> - <xsl:text> = 0;&endl;</xsl:text> + <xsl:text> = nullptr;&endl;</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:for-each> </xsl:template> - <xsl:template name="ctor-init-members"> - <xsl:param name="node"/> - - <xsl:if test="boolean($node/xs:choice)"> - <xsl:text> m_kind = Unknown;&endl;&endl;</xsl:text> - </xsl:if> - - <xsl:if test="not($node/xs:choice)"> - <xsl:text> m_children = 0;&endl;</xsl:text> - </xsl:if> - - <xsl:call-template name="ctor-init-attributes"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - - <xsl:if test="$node[@mixed='true']"> - <xsl:text> m_text.clear();&endl;</xsl:text> - </xsl:if> - - <xsl:for-each select="$node//xs:sequence | $node//xs:choice | $node//xs:all"> - <xsl:call-template name="ctor-init-child-elements"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - </xsl:for-each> - </xsl:template> - - <xsl:template name="ctor-impl"> - <xsl:param name="node"/> - <xsl:variable name="name" select="concat('Dom', $node/@name)"/> - - <xsl:value-of select="$name"/> - <xsl:text>::</xsl:text> - <xsl:value-of select="$name"/> - <xsl:text>()&endl;</xsl:text> - <xsl:text>{&endl;</xsl:text> - <xsl:call-template name="ctor-init-members"> - <xsl:with-param name="node" select="$node"/> - </xsl:call-template> - <xsl:text>}&endl;&endl;</xsl:text> - </xsl:template> - <!-- Implementation: destructor --> <xsl:template name="dtor-delete-members"> <xsl:param name="node"/> - <xsl:for-each select="$node/xs:element"> + <xsl:for-each select="$node/xs:element[not(@use) or (@use!='deprecated')]"> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> @@ -194,48 +112,42 @@ <xsl:param name="node"/> <xsl:variable name="name" select="concat('Dom', $node/@name)"/> - <xsl:text>void </xsl:text><xsl:value-of select="$name"/> - <xsl:text>::clear(bool clear_all)&endl;</xsl:text> - <xsl:text>{&endl;</xsl:text> + <xsl:if test="boolean($node/xs:choice)"> + <xsl:text>void </xsl:text><xsl:value-of select="$name"/> + <xsl:text>::clear()&endl;</xsl:text> + <xsl:text>{&endl;</xsl:text> - <xsl:for-each select="$node//xs:sequence | $node//xs:choice | $node//xs:all"> - <xsl:call-template name="dtor-delete-members"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - </xsl:for-each> + <xsl:variable name="set" select="$node//xs:sequence | $node//xs:choice | $node//xs:all"/> + <xsl:variable name="count" select="count($set)"/> + <xsl:for-each select="$set"> + <xsl:call-template name="dtor-delete-members"> + <xsl:with-param name="node" select="."/> + </xsl:call-template> + </xsl:for-each> - <xsl:text>&endl; if (clear_all) {&endl;</xsl:text> + <xsl:if test="$count > 0"> + <xsl:text>&endl;</xsl:text> + </xsl:if> - <xsl:choose> - <xsl:when test="$node[@mixed='true']"> - <xsl:text> m_text.clear();&endl;</xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:text> m_text.clear();&endl;</xsl:text> - </xsl:otherwise> - </xsl:choose> + <xsl:if test="boolean($node/xs:choice)"> + <xsl:text> m_kind = Unknown;&endl;&endl;</xsl:text> + </xsl:if> - <xsl:call-template name="ctor-init-attributes"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - <xsl:text> }&endl;&endl;</xsl:text> + <xsl:if test="not($node/xs:choice)"> + <xsl:if test="$count > 0"> + <xsl:text> m_children = 0;&endl;</xsl:text> + </xsl:if> + </xsl:if> - <xsl:if test="boolean($node/xs:choice)"> - <xsl:text> m_kind = Unknown;&endl;&endl;</xsl:text> - </xsl:if> + <xsl:for-each select="$set"> + <xsl:call-template name="ctor-init-child-elements"> + <xsl:with-param name="node" select="."/> + </xsl:call-template> + </xsl:for-each> - <xsl:if test="not($node/xs:choice)"> - <xsl:text> m_children = 0;&endl;</xsl:text> + <xsl:text>}&endl;&endl;</xsl:text> </xsl:if> - <xsl:for-each select="$node//xs:sequence | $node//xs:choice | $node//xs:all"> - <xsl:call-template name="ctor-init-child-elements"> - <xsl:with-param name="node" select="."/> - </xsl:call-template> - </xsl:for-each> - - <xsl:text>}&endl;&endl;</xsl:text> - </xsl:template> <!-- Format a string constant for comparison as QLatin1String("foo") - they're all ascii-only --> @@ -269,10 +181,9 @@ <xsl:param name="node"/> <xsl:if test="$node/xs:attribute"> - <xsl:text>&endl;</xsl:text> - <xsl:text> const QXmlStreamAttributes attributes = reader.attributes();&endl;</xsl:text> + <xsl:text> const QXmlStreamAttributes &attributes = reader.attributes();&endl;</xsl:text> <xsl:text> for (const QXmlStreamAttribute &attribute : attributes) {&endl;</xsl:text> - <xsl:text> QStringRef name = attribute.name();&endl;</xsl:text> + <xsl:text> const QStringRef name = attribute.name();&endl;</xsl:text> <xsl:for-each select="$node/xs:attribute"> <xsl:variable name="camel-case-name"> @@ -310,6 +221,7 @@ <xsl:text> reader.raiseError(QLatin1String("Unexpected attribute ") + name);&endl;</xsl:text> <xsl:text> }&endl;</xsl:text> + <xsl:text>&endl;</xsl:text> </xsl:if> </xsl:template> @@ -340,13 +252,19 @@ </xsl:variable> <xsl:variable name="array" select="@maxOccurs = 'unbounded'"/> - <xsl:text> if (tag == </xsl:text> + <xsl:text> if (!tag.compare(</xsl:text> <xsl:call-template name="string-constant-for-comparison"> <xsl:with-param name="literal" select="$lower-name"/> </xsl:call-template> - <xsl:text>) {&endl;</xsl:text> + <xsl:text>, Qt::CaseInsensitive)) {&endl;</xsl:text> <xsl:choose> + <xsl:when test="@use='deprecated'"> + <xsl:text> qWarning("Omitting deprecated element <</xsl:text> + <xsl:value-of select="$lower-name"/> + <xsl:text>>.");&endl;</xsl:text> + <xsl:text> reader.skipCurrentElement();&endl;</xsl:text> + </xsl:when> <xsl:when test="not($array) and $xs-type-cat = 'value'"> <xsl:variable name="qstring-func"> <xsl:call-template name="xs-type-from-qstring-func"> @@ -417,12 +335,10 @@ <xsl:with-param name="node" select="$node"/> </xsl:call-template> - <xsl:text>&endl;</xsl:text> - - <xsl:text> for (bool finished = false; !finished && !reader.hasError();) {&endl;</xsl:text> + <xsl:text> while (!reader.hasError()) {&endl;</xsl:text> <xsl:text> switch (reader.readNext()) {&endl;</xsl:text> <xsl:text> case QXmlStreamReader::StartElement : {&endl;</xsl:text> - <xsl:text> const QString tag = reader.name().toString().toLower();&endl;</xsl:text> + <xsl:text> const QStringRef tag = reader.name();&endl;</xsl:text> <xsl:for-each select="$node//xs:sequence | $node//xs:choice | $node//xs:all"> <xsl:call-template name="read-impl-load-child-element"> @@ -434,15 +350,18 @@ <xsl:text> }&endl;</xsl:text> <xsl:text> break;&endl;</xsl:text> <xsl:text> case QXmlStreamReader::EndElement :&endl;</xsl:text> - <xsl:text> finished = true;&endl;</xsl:text> - <xsl:text> break;&endl;</xsl:text> - <xsl:text> case QXmlStreamReader::Characters :&endl;</xsl:text> - <xsl:text> if (!reader.isWhitespace())&endl;</xsl:text> - <xsl:text> m_text.append(reader.text().toString());&endl;</xsl:text> - <xsl:text> break;&endl;</xsl:text> + <xsl:text> return;&endl;</xsl:text> + + <xsl:variable name="hasText" select="$node[@mixed='true']"/> + <xsl:if test="$hasText"> + <xsl:text> case QXmlStreamReader::Characters :&endl;</xsl:text> + <xsl:text> if (!reader.isWhitespace())&endl;</xsl:text> + <xsl:text> m_text.append(reader.text().toString());&endl;</xsl:text> + <xsl:text> break;&endl;</xsl:text> + </xsl:if> + <xsl:text> default :&endl;</xsl:text> <xsl:text> break;&endl;</xsl:text> - <xsl:text> }&endl;</xsl:text> <xsl:text> }&endl;</xsl:text> <xsl:text>}&endl;&endl;</xsl:text> @@ -517,7 +436,7 @@ </xsl:call-template> </xsl:variable> - <xsl:text> case </xsl:text> + <xsl:text> case </xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>: {&endl;</xsl:text> <xsl:choose> @@ -529,7 +448,7 @@ </xsl:call-template> </xsl:variable> - <xsl:text> writer.writeTextElement(</xsl:text> + <xsl:text> writer.writeTextElement(</xsl:text> <xsl:call-template name="string-constant-for-storage"> <xsl:with-param name="literal" select="$camel-case-name"/> </xsl:call-template> @@ -544,33 +463,32 @@ </xsl:call-template> </xsl:variable> - <xsl:text> </xsl:text> + <xsl:text> </xsl:text> <xsl:value-of select="$cpp-return-type"/> - <xsl:text> v = element</xsl:text> + <xsl:text>v = element</xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>();&endl;</xsl:text> - <xsl:text> if (v != 0) {&endl;</xsl:text> - <xsl:text> v->write(writer, </xsl:text> + <xsl:text> if (v != 0)&endl;</xsl:text> + <xsl:text> v->write(writer, </xsl:text> <xsl:call-template name="string-constant-for-storage"> <xsl:with-param name="literal" select="$lower-name"/> </xsl:call-template> <xsl:text>);&endl;</xsl:text> - <xsl:text> }&endl;</xsl:text> </xsl:when> </xsl:choose> - <xsl:text> break;&endl;</xsl:text> - <xsl:text> }&endl;</xsl:text> + <xsl:text> break;&endl;</xsl:text> + <xsl:text> }&endl;</xsl:text> </xsl:for-each> - <xsl:text> default:&endl;</xsl:text> - <xsl:text> break;&endl;</xsl:text> + <xsl:text> default:&endl;</xsl:text> + <xsl:text> break;&endl;</xsl:text> <xsl:text> }&endl;</xsl:text> </xsl:template> <xsl:template name="write-impl-save-sequence-child-element"> <xsl:param name="node"/> <xsl:variable name="name" select="concat('Dom', $node/@name)"/> - <xsl:for-each select="$node/xs:element"> + <xsl:for-each select="$node/xs:element[not(@use) or (@use!='deprecated')]"> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> <xsl:with-param name="text" select="@name"/> @@ -591,22 +509,19 @@ <xsl:with-param name="xs-type" select="@type"/> </xsl:call-template> </xsl:variable> - <xsl:variable name="cpp-return-type"> - <xsl:call-template name="xs-type-to-cpp-return-type"> + <xsl:variable name="cpp-argument-type"> + <xsl:call-template name="xs-type-to-cpp-argument-type"> <xsl:with-param name="xs-type" select="@type"/> </xsl:call-template> </xsl:variable> <xsl:choose> <xsl:when test="@maxOccurs='unbounded'"> - <xsl:text> for (int i = 0; i < m_</xsl:text> + <xsl:text> for (</xsl:text> + <xsl:value-of select="$cpp-argument-type"/> + <xsl:text>v : m_</xsl:text> <xsl:value-of select="$camel-case-name"/> - <xsl:text>.size(); ++i) {&endl;</xsl:text> - <xsl:text> </xsl:text> - <xsl:value-of select="$cpp-return-type"/> - <xsl:text> v = m_</xsl:text> - <xsl:value-of select="$camel-case-name"/> - <xsl:text>[i];&endl;</xsl:text> + <xsl:text>)&endl;</xsl:text> <xsl:choose> <xsl:when test="$xs-type-cat = 'pointer'"> <xsl:text> v->write(writer, </xsl:text> @@ -632,12 +547,12 @@ <xsl:text>);&endl;</xsl:text> </xsl:otherwise> </xsl:choose> - <xsl:text> }&endl;</xsl:text> + <xsl:text>&endl;</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> if (m_children & </xsl:text> <xsl:value-of select="$cap-name"/> - <xsl:text>) {&endl;</xsl:text> + <xsl:text>)&endl;</xsl:text> <xsl:choose> <xsl:when test="$xs-type-cat = 'pointer'"> <xsl:text> m_</xsl:text> @@ -664,7 +579,7 @@ <xsl:text>);&endl;</xsl:text> </xsl:otherwise> </xsl:choose> - <xsl:text> }&endl;&endl;</xsl:text> + <xsl:text>&endl;</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> @@ -684,7 +599,7 @@ <xsl:text>::write(QXmlStreamWriter &writer, const QString &tagName) const&endl;</xsl:text> <xsl:text>{&endl;</xsl:text> - <xsl:text> writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("</xsl:text> + <xsl:text> writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("</xsl:text> <xsl:value-of select="$lower-name"/> <xsl:text>") : tagName.toLower());&endl;&endl;</xsl:text> @@ -704,8 +619,11 @@ </xsl:call-template> </xsl:for-each> - <xsl:text> if (!m_text.isEmpty())&endl;</xsl:text> - <xsl:text> writer.writeCharacters(m_text);&endl;&endl;</xsl:text> + <xsl:variable name="hasText" select="$node[@mixed='true']"/> + <xsl:if test="$hasText"> + <xsl:text> if (!m_text.isEmpty())&endl;</xsl:text> + <xsl:text> writer.writeCharacters(m_text);&endl;&endl;</xsl:text> + </xsl:if> <xsl:text> writer.writeEndElement();&endl;</xsl:text> <xsl:text>}&endl;&endl;</xsl:text> @@ -716,10 +634,9 @@ <xsl:template name="child-setter-impl-helper"> <xsl:param name="node"/> <xsl:param name="name"/> - <xsl:variable name="make-kind-enum" select="name($node)='xs:choice'"/> <xsl:variable name="isChoice" select="name($node)='xs:choice'"/> - <xsl:for-each select="$node/xs:element"> + <xsl:for-each select="$node/xs:element[not(@use) or (@use!='deprecated')]"> <xsl:variable name="array" select="@maxOccurs = 'unbounded'"/> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> @@ -752,14 +669,13 @@ <xsl:if test="$xs-type-cat = 'pointer'"> <xsl:value-of select="$return-cpp-type"/> - <xsl:text> </xsl:text> <xsl:value-of select="$name"/> <xsl:text>::takeElement</xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>()&endl;{&endl;</xsl:text> <xsl:text> </xsl:text> <xsl:value-of select="$return-cpp-type"/> - <xsl:text> a = m_</xsl:text> + <xsl:text>a = m_</xsl:text> <xsl:value-of select="$camel-case-name"/> <xsl:text>;&endl;</xsl:text> <xsl:text> m_</xsl:text> @@ -780,11 +696,11 @@ <xsl:value-of select="$cap-name"/> <xsl:text>(</xsl:text> <xsl:value-of select="$argument-cpp-type"/> - <xsl:text> a)&endl;</xsl:text> + <xsl:text>a)&endl;</xsl:text> <xsl:text>{&endl;</xsl:text> <xsl:choose> - <xsl:when test="$make-kind-enum"> - <xsl:text> clear(false);&endl;</xsl:text> + <xsl:when test="$isChoice"> + <xsl:text> clear();&endl;</xsl:text> <xsl:text> m_kind = </xsl:text> <xsl:value-of select="$cap-name"/> <xsl:text>;&endl;</xsl:text> @@ -828,7 +744,7 @@ <xsl:variable name="isChoice" select="name()='xs:choice'"/> <xsl:variable name="make-child-enum" select="boolean(xs:sequence) and not(@maxOccurs='unbounded')"/> - <xsl:for-each select="xs:element"> + <xsl:for-each select="xs:element[not(@use) or (@use!='deprecated')]"> <xsl:if test="not($isChoice) and not(@maxOccurs='unbounded')"> <xsl:variable name="camel-case-name"> <xsl:call-template name="camel-case"> @@ -876,15 +792,11 @@ <xsl:template name="class-implementation"> <xsl:param name="node"/> - <xsl:call-template name="clear-impl"> - <xsl:with-param name="node" select="$node"/> - </xsl:call-template> - - <xsl:call-template name="ctor-impl"> + <xsl:call-template name="dtor-impl"> <xsl:with-param name="node" select="$node"/> </xsl:call-template> - <xsl:call-template name="dtor-impl"> + <xsl:call-template name="clear-impl"> <xsl:with-param name="node" select="$node"/> </xsl:call-template> diff --git a/src/designer/data/generate_shared.xsl b/src/designer/data/generate_shared.xsl index 740caaa29..3ac05a42b 100644 --- a/src/designer/data/generate_shared.xsl +++ b/src/designer/data/generate_shared.xsl @@ -260,7 +260,11 @@ <xsl:when test="$xs-type='xs:long'">QList<qlonglong></xsl:when> <xsl:when test="$xs-type='xs:unsignedInt'">QList<uint></xsl:when> <xsl:when test="$xs-type='xs:unsignedLong'">QList<qulonglong></xsl:when> - <xsl:otherwise>QList<Dom<xsl:value-of select="$xs-type"/>*></xsl:otherwise> +<!-- ### fixme Qt 6: Change the QList<DomProperty*> to QVector<DomProperty*> by + removing the below line and change the virtual methods QAbstractFormBuilder::applyProperties() + and QAbstractFormBuilder::computeProperties(QObject *obj) accordingly (repeats 2 times below). --> + <xsl:when test="$xs-type='Property'">QList<DomProperty *></xsl:when> + <xsl:otherwise>QVector<Dom<xsl:value-of select="$xs-type"/> *></xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> @@ -285,28 +289,29 @@ <xsl:choose> <xsl:when test="$array"> <xsl:choose> - <xsl:when test="$xs-type='xs:string'">QStringList</xsl:when> - <xsl:when test="$xs-type='xs:integer'">QList<int></xsl:when> - <xsl:when test="$xs-type='xs:float'">QList<float></xsl:when> - <xsl:when test="$xs-type='xs:double'">QList<double></xsl:when> - <xsl:when test="$xs-type='xs:boolean'">QList<bool></xsl:when> - <xsl:when test="$xs-type='xs:long'">QList<qlonglong></xsl:when> - <xsl:when test="$xs-type='xs:unsignedInt'">QList<uint></xsl:when> - <xsl:when test="$xs-type='xs:unsignedLong'">QList<qulonglong></xsl:when> - <xsl:otherwise>QList<Dom<xsl:value-of select="$xs-type"/>*></xsl:otherwise> + <xsl:when test="$xs-type='xs:string'">QStringList </xsl:when> + <xsl:when test="$xs-type='xs:integer'">QList<int> </xsl:when> + <xsl:when test="$xs-type='xs:float'">QList<float> </xsl:when> + <xsl:when test="$xs-type='xs:double'">QList<double> </xsl:when> + <xsl:when test="$xs-type='xs:boolean'">QList<bool> </xsl:when> + <xsl:when test="$xs-type='xs:long'">QList<qlonglong> </xsl:when> + <xsl:when test="$xs-type='xs:unsignedInt'">QList<uint> </xsl:when> + <xsl:when test="$xs-type='xs:unsignedLong'">QList<qulonglong> </xsl:when> + <xsl:when test="$xs-type='Property'">QList<DomProperty*> </xsl:when> + <xsl:otherwise>QVector<Dom<xsl:value-of select="$xs-type"/> *> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> - <xsl:when test="$xs-type='xs:string'">QString</xsl:when> - <xsl:when test="$xs-type='xs:integer'">int</xsl:when> - <xsl:when test="$xs-type='xs:float'">float</xsl:when> - <xsl:when test="$xs-type='xs:double'">double</xsl:when> - <xsl:when test="$xs-type='xs:boolean'">bool</xsl:when> - <xsl:when test="$xs-type='xs:long'">qlonglong</xsl:when> - <xsl:when test="$xs-type='xs:unsignedInt'">uint</xsl:when> - <xsl:when test="$xs-type='xs:unsignedLong'">qulonglong</xsl:when> - <xsl:otherwise>Dom<xsl:value-of select="$xs-type"/>*</xsl:otherwise> + <xsl:when test="$xs-type='xs:string'">QString </xsl:when> + <xsl:when test="$xs-type='xs:integer'">int </xsl:when> + <xsl:when test="$xs-type='xs:float'">float </xsl:when> + <xsl:when test="$xs-type='xs:double'">double </xsl:when> + <xsl:when test="$xs-type='xs:boolean'">bool </xsl:when> + <xsl:when test="$xs-type='xs:long'">qlonglong </xsl:when> + <xsl:when test="$xs-type='xs:unsignedInt'">uint </xsl:when> + <xsl:when test="$xs-type='xs:unsignedLong'">qulonglong </xsl:when> + <xsl:otherwise>Dom<xsl:value-of select="$xs-type"/> *</xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> @@ -318,28 +323,29 @@ <xsl:choose> <xsl:when test="$array"> <xsl:choose> - <xsl:when test="$xs-type='xs:string'">const QStringList&</xsl:when> - <xsl:when test="$xs-type='xs:integer'">const QList<int>&</xsl:when> - <xsl:when test="$xs-type='xs:float'">const QList<float>&</xsl:when> - <xsl:when test="$xs-type='xs:double'">const QList<double>&</xsl:when> - <xsl:when test="$xs-type='xs:boolean'">const QList<bool>&</xsl:when> - <xsl:when test="$xs-type='xs:long'">const QList<qlonglong>&</xsl:when> - <xsl:when test="$xs-type='xs:unsignedInt'">const QList<uint>&</xsl:when> - <xsl:when test="$xs-type='xs:unsignedLong'">const QList<qulonglong>&</xsl:when> - <xsl:otherwise>const QList<Dom<xsl:value-of select="$xs-type"/>*>&</xsl:otherwise> + <xsl:when test="$xs-type='xs:string'">const QStringList &</xsl:when> + <xsl:when test="$xs-type='xs:integer'">const QList<int> &</xsl:when> + <xsl:when test="$xs-type='xs:float'">const QList<float> &</xsl:when> + <xsl:when test="$xs-type='xs:double'">const QList<double> &</xsl:when> + <xsl:when test="$xs-type='xs:boolean'">const QList<bool> &</xsl:when> + <xsl:when test="$xs-type='xs:long'">const QList<qlonglong> &</xsl:when> + <xsl:when test="$xs-type='xs:unsignedInt'">const QList<uint> &</xsl:when> + <xsl:when test="$xs-type='xs:unsignedLong'">const QList<qulonglong> &</xsl:when> + <xsl:when test="$xs-type='Property'">const QList<DomProperty *> &</xsl:when> + <xsl:otherwise>const QVector<Dom<xsl:value-of select="$xs-type"/> *> &</xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:choose> - <xsl:when test="$xs-type='xs:string'">const QString&</xsl:when> - <xsl:when test="$xs-type='xs:integer'">int</xsl:when> - <xsl:when test="$xs-type='xs:float'">float</xsl:when> - <xsl:when test="$xs-type='xs:double'">double</xsl:when> - <xsl:when test="$xs-type='xs:boolean'">bool</xsl:when> - <xsl:when test="$xs-type='xs:long'">qlonglong</xsl:when> - <xsl:when test="$xs-type='xs:unsignedInt'">uint</xsl:when> - <xsl:when test="$xs-type='xs:unsignedLong'">qulonglong</xsl:when> - <xsl:otherwise>Dom<xsl:value-of select="$xs-type"/>*</xsl:otherwise> + <xsl:when test="$xs-type='xs:string'">const QString &</xsl:when> + <xsl:when test="$xs-type='xs:integer'">int </xsl:when> + <xsl:when test="$xs-type='xs:float'">float </xsl:when> + <xsl:when test="$xs-type='xs:double'">double </xsl:when> + <xsl:when test="$xs-type='xs:boolean'">bool </xsl:when> + <xsl:when test="$xs-type='xs:long'">qlonglong </xsl:when> + <xsl:when test="$xs-type='xs:unsignedInt'">uint </xsl:when> + <xsl:when test="$xs-type='xs:unsignedLong'">qulonglong </xsl:when> + <xsl:otherwise>Dom<xsl:value-of select="$xs-type"/> *</xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> diff --git a/src/designer/data/ui4.xsd b/src/designer/data/ui4.xsd index e5474a65c..8c4576ea6 100644 --- a/src/designer/data/ui4.xsd +++ b/src/designer/data/ui4.xsd @@ -15,7 +15,7 @@ <xs:element name="pixmapfunction" type="xs:string" minOccurs="0" /> <xs:element name="customwidgets" type="CustomWidgets" minOccurs="0" /> <xs:element name="tabstops" type="TabStops" minOccurs="0" /> - <xs:element name="images" type="Images" minOccurs="0" /> + <xs:element name="images" use="deprecated" /> <xs:element name="includes" type="Includes" minOccurs="0" /> <xs:element name="resources" type="Resources" minOccurs="0" /> <xs:element name="connections" type="Connections" minOccurs="0" /> @@ -23,7 +23,7 @@ <xs:element name="slots" type="Slots" minOccurs="0" /> <xs:element name="buttongroups" type="ButtonGroups" minOccurs="0" /> </xs:all> - <xs:attribute name="version" type="xs:string" use="required" /> + <xs:attribute name="version" type="xs:string" /> <xs:attribute name="language" type="xs:string" /> <xs:attribute name="displayname" type="xs:string" /> <!-- Legacy attribute generated by uic3 --> @@ -40,7 +40,7 @@ </xs:complexType> <xs:complexType name="Include" mixed="true" > - <xs:attribute name="location" type="xs:string" use="required" /> + <xs:attribute name="location" type="xs:string" /> <xs:attribute name="impldecl" type="xs:string" /> </xs:complexType> <!-- include end --> @@ -54,7 +54,7 @@ </xs:complexType> <xs:complexType name="Resource"> - <xs:attribute name="location" type="xs:string" use="required" /> + <xs:attribute name="location" type="xs:string" /> </xs:complexType> <!-- resource end --> @@ -66,7 +66,7 @@ <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="name" type="xs:string" /> </xs:complexType> <xs:complexType name="Action"> @@ -74,12 +74,12 @@ <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="name" type="xs:string" /> <xs:attribute name="menu" type="xs:string" /> </xs:complexType> <xs:complexType name="ActionRef"> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="name" type="xs:string" /> </xs:complexType> <!-- actions end --> @@ -89,7 +89,7 @@ <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="name" type="xs:string" /> </xs:complexType> <xs:complexType name="ButtonGroups"> @@ -99,26 +99,6 @@ </xs:complexType> <!-- button groups end --> -<!-- images begin --> - <xs:complexType name="Images"> - <xs:sequence> - <xs:element name="image" type="Image" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - - <xs:complexType name="Image"> - <xs:sequence> - <xs:element name="data" type="ImageData" /> - </xs:sequence> - <xs:attribute name="name" type="xs:string" use="required" /> - </xs:complexType> - - <xs:complexType name="ImageData" mixed="true" > - <xs:attribute name="format" type="xs:string" use="required" /> - <xs:attribute name="length" type="xs:integer" use="required" /> - </xs:complexType> -<!-- images end --> - <!-- custom widget support begin --> <xs:complexType name="CustomWidgets"> <xs:sequence> @@ -138,42 +118,25 @@ <xs:element name="sizehint" type="Size" minOccurs="0" /> <xs:element name="addpagemethod" type="xs:string" minOccurs="0" /> <xs:element name="container" type="xs:integer" minOccurs="0" /> - <xs:element name="sizepolicy" type="SizePolicyData" minOccurs="0" /> + <xs:element name="sizepolicy" use="deprecated" /> <xs:element name="pixmap" type="xs:string" minOccurs="0" /> - <xs:element name="script" type="Script" minOccurs="0" /> - <xs:element name="properties" type="Properties" minOccurs="0" /> + <xs:element name="script" use="deprecated" /> + <xs:element name="properties" use="deprecated" /> <xs:element name="slots" type="Slots" minOccurs="0" /> <xs:element name="propertyspecifications" type="PropertySpecifications" minOccurs="0" /> </xs:all> </xs:complexType> - <xs:complexType name="Properties"> - <xs:sequence> - <xs:element name="property" type="PropertyData" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - - <xs:complexType name="PropertyData"> - <xs:attribute name="type" type="xs:string" use="required" /> - </xs:complexType> - - <xs:complexType name="SizePolicyData"> - <xs:all> - <xs:element name="hordata" type="xs:integer" /> - <xs:element name="verdata" type="xs:integer" /> - </xs:all> - </xs:complexType> - <!-- custom widget support end --> <xs:complexType name="LayoutDefault"> - <xs:attribute name="spacing" type="xs:integer" use="required" /> - <xs:attribute name="margin" type="xs:integer" use="required" /> + <xs:attribute name="spacing" type="xs:integer" /> + <xs:attribute name="margin" type="xs:integer" /> </xs:complexType> <xs:complexType name="LayoutFunction"> - <xs:attribute name="spacing" type="xs:string" use="required" /> - <xs:attribute name="margin" type="xs:string" use="required" /> + <xs:attribute name="spacing" type="xs:string" /> + <xs:attribute name="margin" type="xs:string" /> </xs:complexType> <xs:complexType name="TabStops"> @@ -188,7 +151,7 @@ <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="item" type="LayoutItem" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> - <xs:attribute name="class" type="xs:string" use="required" /> + <xs:attribute name="class" type="xs:string" /> <xs:attribute name="name" type="xs:string" /> <xs:attribute name="stretch" type="xs:string" /> <xs:attribute name="rowstretch" type="xs:string" /> @@ -239,8 +202,8 @@ <xs:sequence> <xs:element name="class" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> <!-- unbounded kept for compatibility reasons --> <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" /> - <xs:element name="script" type="Script" minOccurs="0" maxOccurs="unbounded" /> <!-- unbounded kept for compatibility reasons --> - <xs:element name="widgetdata" type="WidgetData" minOccurs="0" maxOccurs="unbounded" /> <!-- unbounded kept for compatibility reasons --> + <xs:element name="script" use="deprecated" /> + <xs:element name="widgetdata" use="deprecated" /> <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" /> <!-- item view begin --> <xs:element name="row" type="Row" minOccurs="0" maxOccurs="unbounded" /> @@ -254,7 +217,7 @@ <xs:element name="addaction" type="ActionRef" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="zorder" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> - <xs:attribute name="class" type="xs:string" use="required" /> + <xs:attribute name="class" type="xs:string" /> <xs:attribute name="name" type="xs:string" /> <xs:attribute name="native" type="xs:boolean" /> </xs:complexType> @@ -279,26 +242,26 @@ <xs:sequence> <xs:element name="color" type="Color" /> </xs:sequence> - <xs:attribute name="position" type="xs:double" use="required" /> + <xs:attribute name="position" type="xs:double" /> </xs:complexType> <xs:complexType name="Gradient"> <xs:sequence> <xs:element name="gradientStop" type="GradientStop" maxOccurs="unbounded" /> </xs:sequence> - <xs:attribute name="startx" type="xs:double" use="required" /> - <xs:attribute name="starty" type="xs:double" use="required" /> - <xs:attribute name="endx" type="xs:double" use="required" /> - <xs:attribute name="endy" type="xs:double" use="required" /> - <xs:attribute name="centralx" type="xs:double" use="required" /> - <xs:attribute name="centraly" type="xs:double" use="required" /> - <xs:attribute name="focalx" type="xs:double" use="required" /> - <xs:attribute name="focaly" type="xs:double" use="required" /> - <xs:attribute name="radius" type="xs:double" use="required" /> - <xs:attribute name="angle" type="xs:double" use="required" /> - <xs:attribute name="type" type="xs:string" use="required" /> - <xs:attribute name="spread" type="xs:string" use="required" /> - <xs:attribute name="coordinatemode" type="xs:string" use="required" /> + <xs:attribute name="startx" type="xs:double" /> + <xs:attribute name="starty" type="xs:double" /> + <xs:attribute name="endx" type="xs:double" /> + <xs:attribute name="endy" type="xs:double" /> + <xs:attribute name="centralx" type="xs:double" /> + <xs:attribute name="centraly" type="xs:double" /> + <xs:attribute name="focalx" type="xs:double" /> + <xs:attribute name="focaly" type="xs:double" /> + <xs:attribute name="radius" type="xs:double" /> + <xs:attribute name="angle" type="xs:double" /> + <xs:attribute name="type" type="xs:string" /> + <xs:attribute name="spread" type="xs:string" /> + <xs:attribute name="coordinatemode" type="xs:string" /> </xs:complexType> <xs:complexType name="Brush"> @@ -307,14 +270,14 @@ <xs:element name="texture" type="Property" /> <xs:element name="gradient" type="Gradient" /> </xs:choice> - <xs:attribute name="brushstyle" type="xs:string" use="required" /> + <xs:attribute name="brushstyle" type="xs:string" /> </xs:complexType> <xs:complexType name="ColorRole"> <xs:sequence> <xs:element name="brush" type="Brush" /> </xs:sequence> - <xs:attribute name="role" type="xs:string" use="required" /> + <xs:attribute name="role" type="xs:string" /> </xs:complexType> <xs:complexType name="ColorGroup"> @@ -364,8 +327,8 @@ </xs:complexType> <xs:complexType name="Locale"> - <xs:attribute name="language" type="xs:string" use="required" /> - <xs:attribute name="country" type="xs:string" use="required" /> + <xs:attribute name="language" type="xs:string" /> + <xs:attribute name="country" type="xs:string" /> </xs:complexType> <xs:complexType name="SizePolicy"> @@ -519,7 +482,7 @@ <xs:element name="ulonglong" type="xs:unsignedLong" /> <xs:element name="brush" type="Brush" /> </xs:choice> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="name" type="xs:string" /> <xs:attribute name="stdset" type="xs:integer" /> </xs:complexType> @@ -550,18 +513,7 @@ <xs:element name="x" type="xs:integer"/> <xs:element name="y" type="xs:integer"/> </xs:all> - <xs:attribute name="type" type="xs:string" use="required" /> - </xs:complexType> - - <xs:complexType name="Script"> - <xs:attribute name="source" type="xs:string" use="required" /> - <xs:attribute name="language" type="xs:string" use="required" /> - </xs:complexType> - - <xs:complexType name="WidgetData"> - <xs:sequence> - <xs:element name="property" type="Property" maxOccurs="unbounded" /> - </xs:sequence> + <xs:attribute name="type" type="xs:string" /> </xs:complexType> <xs:complexType name="DesignerData"> @@ -577,21 +529,21 @@ </xs:sequence> </xs:complexType> - <xs:complexType name="PropertySpecifications"> + <xs:complexType name="PropertySpecifications"> <xs:sequence maxOccurs="unbounded"> - <xs:element name="tooltip" type="PropertyToolTip" minOccurs="0" maxOccurs="unbounded" /> - <xs:element name="stringpropertyspecification" type="StringPropertySpecification" minOccurs="0" maxOccurs="unbounded" /> + <xs:element name="tooltip" type="PropertyToolTip" minOccurs="0" maxOccurs="unbounded" /> + <xs:element name="stringpropertyspecification" type="StringPropertySpecification" minOccurs="0" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> - <xs:complexType name="PropertyToolTip"> - <xs:attribute name="name" type="xs:string" use="required" /> + <xs:complexType name="PropertyToolTip"> + <xs:attribute name="name" type="xs:string" /> </xs:complexType> - <xs:complexType name="StringPropertySpecification"> - <xs:attribute name="name" type="xs:string" use="required" /> - <xs:attribute name="type" type="xs:string" use="required" /> - <xs:attribute name="notr" type="xs:string"/> + <xs:complexType name="StringPropertySpecification"> + <xs:attribute name="name" type="xs:string" /> + <xs:attribute name="type" type="xs:string" /> + <xs:attribute name="notr" type="xs:string" /> </xs:complexType> </xs:schema> diff --git a/src/designer/src/components/buddyeditor/buddyeditor.cpp b/src/designer/src/components/buddyeditor/buddyeditor.cpp index feb07a60e..d679cd5ff 100644 --- a/src/designer/src/components/buddyeditor/buddyeditor.cpp +++ b/src/designer/src/components/buddyeditor/buddyeditor.cpp @@ -271,7 +271,7 @@ void BuddyEditor::endConnection(QWidget *target, const QPoint &pos) void BuddyEditor::widgetRemoved(QWidget *widget) { - QList<QWidget*> child_list = widget->findChildren<QWidget*>(); + QWidgetList child_list = widget->findChildren<QWidget*>(); child_list.prepend(widget); ConnectionSet remove_set; diff --git a/src/designer/src/components/formeditor/formeditor_optionspage.cpp b/src/designer/src/components/formeditor/formeditor_optionspage.cpp index 72bd26b16..9ede312f4 100644 --- a/src/designer/src/components/formeditor/formeditor_optionspage.cpp +++ b/src/designer/src/components/formeditor/formeditor_optionspage.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -typedef QList<int> IntList; - namespace qdesigner_internal { // Zoom, currently for preview only @@ -72,12 +70,10 @@ ZoomSettingsWidget::ZoomSettingsWidget(QWidget *parent) : m_zoomCombo(new QComboBox) { m_zoomCombo->setEditable(false); - const IntList zoomValues = ZoomMenu::zoomValues(); - const IntList::const_iterator cend = zoomValues.constEnd(); - - for (IntList::const_iterator it = zoomValues.constBegin(); it != cend; ++it) { + const QVector<int> &zoomValues = ZoomMenu::zoomValues(); + for (int z : zoomValues) { //: Zoom percentage - m_zoomCombo->addItem(QCoreApplication::translate("FormEditorOptionsPage", "%1 %").arg(*it), QVariant(*it)); + m_zoomCombo->addItem(QCoreApplication::translate("FormEditorOptionsPage", "%1 %").arg(z), QVariant(z)); } // Layout diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h index 86027a625..aca354728 100644 --- a/src/designer/src/components/formeditor/formwindow.h +++ b/src/designer/src/components/formeditor/formwindow.h @@ -135,7 +135,7 @@ public: bool hasInsertedChildren(QWidget *w) const; - QList<QWidget *> selectedWidgets() const; + QWidgetList selectedWidgets() const; void clearSelection(bool changePropertyDisplay = true) Q_DECL_OVERRIDE; bool isWidgetSelected(QWidget *w) const; void selectWidget(QWidget *w, bool select = true) Q_DECL_OVERRIDE; @@ -147,11 +147,11 @@ public: void raiseChildSelections(QWidget *w); void raiseSelection(QWidget *w); - inline const QList<QWidget *>& widgets() const { return m_widgets; } + inline const QWidgetList& widgets() const { return m_widgets; } inline int widgetCount() const { return m_widgets.count(); } inline QWidget *widgetAt(int index) const { return m_widgets.at(index); } - QList<QWidget *> widgets(QWidget *widget) const; + QWidgetList widgets(QWidget *widget) const; QWidget *createWidget(DomUI *ui, const QRect &rect, QWidget *target); diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index 1650e1450..0341c920b 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -565,7 +565,7 @@ void FormWindowManager::slotActionRaiseActivated() static inline QWidget *findLayoutContainer(const FormWindow *fw) { - QList<QWidget*> l(fw->selectedWidgets()); + QWidgetList l(fw->selectedWidgets()); fw->simplifySelection(&l); return l.empty() ? fw->mainContainer() : l.front(); } @@ -593,7 +593,7 @@ void FormWindowManager::createLayout() void FormWindowManager::slotActionBreakLayoutActivated() { - const QList<QWidget *> layouts = layoutsToBeBroken(); + const QWidgetList layouts = layoutsToBeBroken(); if (layouts.isEmpty()) return; @@ -630,7 +630,7 @@ void FormWindowManager::slotActionAdjustSizeActivated() m_activeFormWindow->beginCommand(tr("Adjust Size")); - QList<QWidget*> selectedWidgets = m_activeFormWindow->selectedWidgets(); + QWidgetList selectedWidgets = m_activeFormWindow->selectedWidgets(); m_activeFormWindow->simplifySelection(&selectedWidgets); if (selectedWidgets.isEmpty()) { @@ -681,7 +681,7 @@ void FormWindowManager::slotActionGroupPreviewInStyle(const QString &style, int QWidgetList FormWindowManager::layoutsToBeBroken(QWidget *w) const { if (!w) - return QList<QWidget *>(); + return QWidgetList(); if (debugFWM) qDebug() << "layoutsToBeBroken: " << w; @@ -715,17 +715,17 @@ QWidgetList FormWindowManager::layoutsToBeBroken(QWidget *w) const if (qobject_cast<const QSplitter *>(widget)) { if (debugFWM) qDebug() << "layoutsToBeBroken: Splitter special"; - QList<QWidget *> list = layoutsToBeBroken(parent); + QWidgetList list = layoutsToBeBroken(parent); list.append(widget); return list; } if (debugFWM) qDebug() << "layoutsToBeBroken: Is a container but doesn't have a managed layout (has an internal layout), returning 0"; - return QList<QWidget *>(); + return QWidgetList(); } if (managedLayout) { - QList<QWidget *> list; + QWidgetList list; if (debugFWM) qDebug() << "layoutsToBeBroken: Is a container and has a layout"; if (qobject_cast<const QLayoutWidget *>(widget)) { @@ -738,7 +738,7 @@ QWidgetList FormWindowManager::layoutsToBeBroken(QWidget *w) const } if (debugFWM) qDebug() << "layoutsToBeBroken: Is a container but doesn't have a layout at all, returning 0"; - return QList<QWidget *>(); + return QWidgetList(); } @@ -747,19 +747,16 @@ QMap<QWidget *, bool> FormWindowManager::getUnsortedLayoutsToBeBroken(bool first // Return a set of layouts to be broken. QMap<QWidget *, bool> layouts; - QList<QWidget *> selection = m_activeFormWindow->selectedWidgets(); + QWidgetList selection = m_activeFormWindow->selectedWidgets(); if (selection.isEmpty() && m_activeFormWindow->mainContainer()) selection.append(m_activeFormWindow->mainContainer()); - const QList<QWidget *>::const_iterator scend = selection.constEnd(); - for (QList<QWidget *>::const_iterator sit = selection.constBegin(); sit != scend; ++sit) { + for (QWidget *selectedWidget : qAsConst(selection)) { // find all layouts - const QList<QWidget *> list = layoutsToBeBroken(*sit); + const QWidgetList &list = layoutsToBeBroken(selectedWidget); if (!list.empty()) { - const QList<QWidget *>::const_iterator lbcend = list.constEnd(); - for (QList<QWidget *>::const_iterator lbit = list.constBegin(); lbit != lbcend; ++lbit) { - layouts.insert(*lbit, true); - } + for (QWidget *widget : list) + layouts.insert(widget, true); if (firstOnly) return layouts; } @@ -779,13 +776,13 @@ QWidgetList FormWindowManager::layoutsToBeBroken() const // up to the first 'real' widget with a layout in hierarchy order. QMap<QWidget *, bool> unsortedLayouts = getUnsortedLayoutsToBeBroken(false); // Sort in order of hierarchy - QList<QWidget *> orderedLayoutList; + QWidgetList orderedLayoutList; const QMap<QWidget *, bool>::const_iterator lscend = unsortedLayouts.constEnd(); for (QMap<QWidget *, bool>::const_iterator itLay = unsortedLayouts.constBegin(); itLay != lscend; ++itLay) { QWidget *wToBeInserted = itLay.key(); if (!orderedLayoutList.contains(wToBeInserted)) { // try to find first child, use as insertion position, else append - const QList<QWidget *>::iterator firstChildPos = findFirstChildOf(orderedLayoutList.begin(), orderedLayoutList.end(), wToBeInserted); + const QWidgetList::iterator firstChildPos = findFirstChildOf(orderedLayoutList.begin(), orderedLayoutList.end(), wToBeInserted); if (firstChildPos == orderedLayoutList.end()) { orderedLayoutList.push_back(wToBeInserted); } else { diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index ac14eb0bf..96f86d169 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -34,9 +34,11 @@ #include <QtWidgets/QStyle> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> #include <QtCore/QDebug> +#include <algorithm> + QT_BEGIN_NAMESPACE namespace qdesigner_internal { @@ -200,17 +202,13 @@ FormWindowData FormWindowSettings::data() const const QString hints = m_ui->includeHintsTextEdit->toPlainText(); if (!hints.isEmpty()) { - rc.includeHints = hints.split(QString(QLatin1Char('\n'))); + rc.includeHints = hints.split(QLatin1Char('\n')); // Purge out any lines consisting of blanks only - QRegExp blankLine = QRegExp(QStringLiteral("^\\s*$")); + const QRegularExpression blankLine(QStringLiteral("^\\s*$")); Q_ASSERT(blankLine.isValid()); - for (QStringList::iterator it = rc.includeHints.begin(); it != rc.includeHints.end(); ) - if (blankLine.exactMatch(*it)) { - it = rc.includeHints.erase(it); - } else { - ++it; - } - rc.includeHints.removeAll(QString()); + rc.includeHints.erase(std::remove_if(rc.includeHints.begin(), rc.includeHints.end(), + [blankLine](const QString &hint){ return blankLine.match(hint).hasMatch(); }), + rc.includeHints.end()); } rc.hasFormGrid = m_ui->gridPanel->isChecked(); diff --git a/src/designer/src/components/formeditor/layout_propertysheet.cpp b/src/designer/src/components/formeditor/layout_propertysheet.cpp index 553a2514f..1f6b237d5 100644 --- a/src/designer/src/components/formeditor/layout_propertysheet.cpp +++ b/src/designer/src/components/formeditor/layout_propertysheet.cpp @@ -44,7 +44,7 @@ #include <QtCore/QDebug> #include <QtCore/QTextStream> #include <QtCore/QByteArray> -#include <QtCore/QRegExp> // Remove once there is an editor for lists +#include <QtCore/QRegularExpression> // Remove once there is an editor for lists QT_BEGIN_NAMESPACE @@ -94,9 +94,9 @@ namespace { static bool isIntegerList(const QString &s) { // Check for empty string or comma-separated list of integers - static QRegExp re(QStringLiteral("[0-9]+(,[0-9]+)+")); + static const QRegularExpression re(QStringLiteral("^[0-9]+(,[0-9]+)+$")); Q_ASSERT(re.isValid()); - return s.isEmpty() || re.exactMatch(s); + return s.isEmpty() || re.match(s).hasMatch(); } // Quick lookup by name diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index 5fa4ef698..c2a6c250a 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -520,8 +520,9 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) if (!m_formWindow->includeHints().isEmpty()) { const QString local = QStringLiteral("local"); const QString global = QStringLiteral("global"); - QList<DomInclude*> ui_includes; + QVector<DomInclude *> ui_includes; const QStringList &includeHints = m_formWindow->includeHints(); + ui_includes.reserve(includeHints.size()); for (QString includeHint : includeHints) { if (includeHint.isEmpty()) continue; @@ -656,7 +657,7 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) if (DomIncludes *includes = ui->elementIncludes()) { const QString global = QStringLiteral("global"); QStringList includeHints; - const QList<DomInclude *> &elementInclude = includes->elementInclude(); + const auto &elementInclude = includes->elementInclude(); for (DomInclude *incl : elementInclude) { QString text = incl->text(); @@ -709,7 +710,7 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) if (mainWidget) { // Initialize the mainwindow geometry. Has it been explicitly specified? bool hasExplicitGeometry = false; - const QList<DomProperty *> properties = ui->elementWidget()->elementProperty(); + const auto &properties = ui->elementWidget()->elementProperty(); if (!properties.empty()) { const QString geometry = QStringLiteral("geometry"); for (const DomProperty *p : properties) { @@ -768,8 +769,8 @@ QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) } // save the actions - const QList<DomActionRef*> actionRefs = ui_widget->elementAddAction(); - ui_widget->setElementAddAction(QList<DomActionRef*>()); + const auto &actionRefs = ui_widget->elementAddAction(); + ui_widget->setElementAddAction(QVector<DomActionRef *>()); QWidget *w = QAbstractFormBuilder::create(ui_widget, parentWidget); @@ -927,16 +928,14 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p const bool dynamicPropertiesAllowed = dynamicSheet && dynamicSheet->dynamicPropertiesAllowed(); const QString objectNameProperty = QStringLiteral("objectName"); - const DomPropertyList::const_iterator cend = properties.constEnd(); - for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) { - const DomProperty *p = *it; + for (DomProperty *p : properties) { QString propertyName = p->attributeName(); if (propertyName == QLatin1String("numDigits") && o->inherits("QLCDNumber")) // Deprecated in Qt 4, removed in Qt 5. propertyName = QLatin1String("digitCount"); const int index = sheet->indexOf(propertyName); QVariant v; if (!readDomEnumerationValue(p, sheet, index, v)) - v = toVariant(o->metaObject(), *it); + v = toVariant(o->metaObject(), p); switch (p->kind()) { case DomProperty::String: @@ -1023,10 +1022,10 @@ QWidget *QDesignerResource::createWidget(const QString &widgetName, QWidget *par if (!qobject_cast<QMenu*>(w) && (!parentWidget || !container)) { m_formWindow->manageWidget(w); if (parentWidget) { - QList<QWidget *> list = qvariant_cast<QWidgetList>(parentWidget->property("_q_widgetOrder")); + QWidgetList list = qvariant_cast<QWidgetList>(parentWidget->property("_q_widgetOrder")); list.append(w); parentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(list)); - QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(parentWidget->property("_q_zOrder")); + QWidgetList zOrder = qvariant_cast<QWidgetList>(parentWidget->property("_q_zOrder")); zOrder.append(w); parentWidget->setProperty("_q_zOrder", QVariant::fromValue(zOrder)); } @@ -1131,7 +1130,7 @@ DomWidget *QDesignerResource::createDom(QWidget *widget, DomWidget *ui_parentWid w->setAttributeName(widget->objectName()); w->setAttributeClass(widgetInfo->name()); - const QList<DomProperty*> &prop_list = w->elementProperty(); + const auto &prop_list = w->elementProperty(); for (DomProperty *prop : prop_list) { if (prop->attributeName() == QStringLiteral("geometry")) { if (DomRect *rect = prop->elementRect()) { @@ -1192,9 +1191,8 @@ DomLayoutItem *QDesignerResource::createDom(QLayoutItem *item, DomLayout *ui_lay const QString objectName = s->objectName(); if (!objectName.isEmpty()) spacer->setAttributeName(objectName); - const QList<DomProperty*> properties = computeProperties(item->widget()); // ### filter the properties - spacer->setElementProperty(properties); + spacer->setElementProperty(computeProperties(item->widget())); ui_item = new DomLayoutItem(); ui_item->setElementSpacer(spacer); @@ -1245,7 +1243,7 @@ void QDesignerResource::applyTabStops(QWidget *widget, DomTabStops *tabStops) if (!tabStops) return; - QList<QWidget*> tabOrder; + QWidgetList tabOrder; const QStringList &elementTabStop = tabStops->elementTabStop(); for (const QString &widgetName : elementTabStop) { if (QWidget *w = widget->findChild<QWidget*>(widgetName)) { @@ -1275,7 +1273,7 @@ inline QString msgUnmanagedPage(QDesignerFormEditorInterface *core, DomWidget *QDesignerResource::saveWidget(QWidget *widget, QDesignerContainerExtension *container, DomWidget *ui_parentWidget) { DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget, false); - QList<DomWidget*> ui_widget_list; + QVector<DomWidget *> ui_widget_list; for (int i=0; i<container->count(); ++i) { QWidget *page = container->widget(i); @@ -1296,7 +1294,7 @@ DomWidget *QDesignerResource::saveWidget(QWidget *widget, QDesignerContainerExte DomWidget *QDesignerResource::saveWidget(QStackedWidget *widget, DomWidget *ui_parentWidget) { DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget, false); - QList<DomWidget*> ui_widget_list; + QVector<DomWidget *> ui_widget_list; if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), widget)) { for (int i=0; i<container->count(); ++i) { QWidget *page = container->widget(i); @@ -1321,7 +1319,7 @@ DomWidget *QDesignerResource::saveWidget(QToolBar *toolBar, DomWidget *ui_parent const bool toolBarBreak = mainWindow->toolBarBreak(toolBar); const Qt::ToolBarArea area = mainWindow->toolBarArea(toolBar); - QList<DomProperty*> attributes = ui_widget->elementAttribute(); + auto attributes = ui_widget->elementAttribute(); DomProperty *attr = new DomProperty(); attr->setAttributeName(QStringLiteral("toolBarArea")); @@ -1355,7 +1353,7 @@ DomWidget *QDesignerResource::saveWidget(QDesignerDockWidget *dockWidget, DomWid DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_parentWidget) { DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget, false); - QList<DomWidget*> ui_widget_list; + QVector<DomWidget *> ui_widget_list; if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), widget)) { const int current = widget->currentIndex(); @@ -1422,7 +1420,7 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren DomWidget *QDesignerResource::saveWidget(QToolBox *widget, DomWidget *ui_parentWidget) { DomWidget *ui_widget = QAbstractFormBuilder::createDom(widget, ui_parentWidget, false); - QList<DomWidget*> ui_widget_list; + QVector<DomWidget *> ui_widget_list; if (QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), widget)) { const int current = widget->currentIndex(); @@ -1673,7 +1671,7 @@ DomUI *QDesignerResource::copy(const FormBuilderClipboard &selection) bool hasItems = false; // Widgets if (!selection.m_widgets.empty()) { - QList<DomWidget*> ui_widget_list; + QVector<DomWidget *> ui_widget_list; const int size = selection.m_widgets.size(); for (int i=0; i< size; ++i) { QWidget *w = selection.m_widgets.at(i); @@ -1690,7 +1688,7 @@ DomUI *QDesignerResource::copy(const FormBuilderClipboard &selection) } // actions if (!selection.m_actions.empty()) { - QList<DomAction*> domActions; + QVector<DomAction *> domActions; for (QAction* action : qAsConst(selection.m_actions)) { if (DomAction *domAction = createDom(action)) domActions += domAction; @@ -1729,7 +1727,7 @@ FormBuilderClipboard QDesignerResource::paste(DomUI *ui, QWidget *widgetParent, // Widgets const DomWidget *topLevel = ui->elementWidget(); initialize(ui); - const QList<DomWidget*> domWidgets = topLevel->elementWidget(); + const auto &domWidgets = topLevel->elementWidget(); if (!domWidgets.empty()) { const QPoint offset = m_formWindow->grid(); for (DomWidget* domWidget : domWidgets) { @@ -1740,7 +1738,7 @@ FormBuilderClipboard QDesignerResource::paste(DomUI *ui, QWidget *widgetParent, } } } - const QList<DomAction*> domActions = topLevel->elementAction(); + const auto domActions = topLevel->elementAction(); for (DomAction *domAction : domActions) { if (QAction *a = create(domAction, actionParent)) rc.m_actions .append(a); @@ -1852,7 +1850,7 @@ DomCustomWidgets *QDesignerResource::saveCustomWidgets() } DomCustomWidgets *customWidgets = new DomCustomWidgets; - customWidgets->setElementCustomWidget(orderedMap.values()); + customWidgets->setElementCustomWidget(orderedMap.values().toVector()); return customWidgets; } @@ -2024,7 +2022,7 @@ void QDesignerResource::createResources(DomResources *resources) { QStringList paths; if (resources != 0) { - const QList<DomResource*> dom_include = resources->elementInclude(); + const auto &dom_include = resources->elementInclude(); for (DomResource *res : dom_include) { QString path = QDir::cleanPath(m_formWindow->absoluteDir().absoluteFilePath(res->attributeLocation())); while (!QFile::exists(path)) { @@ -2091,7 +2089,7 @@ DomResources *QDesignerResource::saveResources() DomResources *QDesignerResource::saveResources(const QStringList &qrcPaths) { QtResourceSet *resourceSet = m_formWindow->resourceSet(); - QList<DomResource*> dom_include; + QVector<DomResource *> dom_include; if (resourceSet) { const QStringList activePaths = resourceSet->activeResourceFilePaths(); for (const QString &path : activePaths) { diff --git a/src/designer/src/components/formeditor/qmainwindow_container.h b/src/designer/src/components/formeditor/qmainwindow_container.h index 6bb8c08bf..b0c2d1677 100644 --- a/src/designer/src/components/formeditor/qmainwindow_container.h +++ b/src/designer/src/components/formeditor/qmainwindow_container.h @@ -57,7 +57,7 @@ public: private: QMainWindow *m_mainWindow; - QList<QWidget*> m_widgets; + QWidgetList m_widgets; }; typedef ExtensionFactory<QDesignerContainerExtension, QMainWindow, QMainWindowContainer> QMainWindowContainerFactory; diff --git a/src/designer/src/components/formeditor/tool_widgeteditor.cpp b/src/designer/src/components/formeditor/tool_widgeteditor.cpp index 05610f175..0a658a86b 100644 --- a/src/designer/src/components/formeditor/tool_widgeteditor.cpp +++ b/src/designer/src/components/formeditor/tool_widgeteditor.cpp @@ -335,7 +335,7 @@ void WidgetEditorTool::activated() if (m_formWindow == 0) return; - const QList<QWidget*> &sel = m_formWindow->selectedWidgets(); + const QWidgetList &sel = m_formWindow->selectedWidgets(); for (QWidget *w : sel) m_formWindow->raiseSelection(w); } diff --git a/src/designer/src/components/lib/lib.pro b/src/designer/src/components/lib/lib.pro index 7b80ae130..5a4690e80 100644 --- a/src/designer/src/components/lib/lib.pro +++ b/src/designer/src/components/lib/lib.pro @@ -11,10 +11,6 @@ DEFINES += QDESIGNER_COMPONENTS_LIBRARY static:DEFINES += QT_DESIGNER_STATIC -# Override qt_targets -QMAKE_TARGET_PRODUCT = Designer -QMAKE_TARGET_DESCRIPTION = Graphical user interface designer. - SOURCES += qdesigner_components.cpp INCLUDEPATH += . .. \ diff --git a/src/designer/src/components/lib/lib_pch.h b/src/designer/src/components/lib/lib_pch.h index f2f226797..d03a498c2 100644 --- a/src/designer/src/components/lib/lib_pch.h +++ b/src/designer/src/components/lib/lib_pch.h @@ -26,5 +26,7 @@ ** ****************************************************************************/ +#if defined __cplusplus #include <QtDesigner/QtDesigner> #include <QtDesigner/QExtensionManager> +#endif diff --git a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp index d40eb7404..c50e9d2bf 100644 --- a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -132,7 +132,6 @@ const BrushPropertyManager::EnumIndexIconMap &BrushPropertyManager::brushStyleIc if (brushIcons()->empty()) { const int brushStyleCount = sizeof(brushStyles)/sizeof(const char *); QBrush brush(Qt::black); - const QIcon solidIcon = QtPropertyBrowserUtils::brushValueIcon(brush); for (int i = 0; i < brushStyleCount; i++) { const Qt::BrushStyle style = brushStyleIndexToStyle(i); brush.setStyle(style); diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index 9730dff64..670dfcc1f 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -1576,8 +1576,6 @@ void DesignerPropertyManager::reloadResourceProperties() defaultIcon = iconCache->icon(icon); } - QMap<QPair<QIcon::Mode, QIcon::State>, PropertySheetPixmapValue> iconPaths = icon.paths(); - QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> subProperties = m_propertyToIconSubProperties.value(property); for (auto itSub = subProperties.cbegin(), end = subProperties.cend(); itSub != end; ++itSub) { const QPair<QIcon::Mode, QIcon::State> pair = itSub.key(); diff --git a/src/designer/src/components/propertyeditor/paletteeditorbutton.cpp b/src/designer/src/components/propertyeditor/paletteeditorbutton.cpp index c63b4a297..f8bff2a2a 100644 --- a/src/designer/src/components/propertyeditor/paletteeditorbutton.cpp +++ b/src/designer/src/components/propertyeditor/paletteeditorbutton.cpp @@ -64,7 +64,6 @@ void PaletteEditorButton::setSuperPalette(const QPalette &palette) void PaletteEditorButton::showPaletteEditor() { int result; - QPalette p = QPalette(); QPalette pal = PaletteEditor::getPalette(m_core, 0, m_palette, m_superPalette, &result); if (result == QDialog::Accepted) { m_palette = pal; diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index ee30614b5..2c0a60c4b 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -175,7 +175,6 @@ void PropertyEditor::setupStringProperty(QtVariantProperty *property, bool isMai void PropertyEditor::setupPaletteProperty(QtVariantProperty *property) { - QPalette value = qvariant_cast<QPalette>(property->value()); QPalette superPalette = QPalette(); QWidget *currentWidget = qobject_cast<QWidget *>(m_object); if (currentWidget) { diff --git a/src/designer/src/components/signalsloteditor/signalsloteditor.cpp b/src/designer/src/components/signalsloteditor/signalsloteditor.cpp index 5ec3ed6ac..14e0b007b 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditor.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditor.cpp @@ -69,7 +69,7 @@ DomConnection *SignalSlotConnection::toUi() const result->setElementSlot(slot()); DomConnectionHints *hints = new DomConnectionHints; - QList<DomConnectionHint*> list; + QVector<DomConnectionHint *> list; QPoint sp = endPointPos(EndPoint::Source); QPoint tp = endPointPos(EndPoint::Target); @@ -321,9 +321,10 @@ Connection *SignalSlotEditor::createConnection(QWidget *source, QWidget *destina DomConnections *SignalSlotEditor::toUi() const { DomConnections *result = new DomConnections; - QList<DomConnection*> list; + QVector<DomConnection *> list; const int count = connectionCount(); + list.reserve(count); for (int i = 0; i < count; ++i) { const SignalSlotConnection *con = static_cast<const SignalSlotConnection*>(connection(i)); Q_ASSERT(con != 0); @@ -373,7 +374,7 @@ void SignalSlotEditor::fromUi(const DomConnections *connections, QWidget *parent setBackground(parent); clear(); - const QList<DomConnection*> list = connections->elementConnection(); + const auto &list = connections->elementConnection(); for (const DomConnection *dom_con : list) { QObject *source = objectByName(parent, dom_con->elementSender()); if (source == 0) { @@ -391,7 +392,7 @@ void SignalSlotEditor::fromUi(const DomConnections *connections, QWidget *parent QPoint sp = QPoint(20, 20), tp = QPoint(20, 20); const DomConnectionHints *dom_hints = dom_con->elementHints(); if (dom_hints != 0) { - const QList<DomConnectionHint*> &hints = dom_hints->elementHint(); + const auto &hints = dom_hints->elementHint(); for (DomConnectionHint *hint : hints) { QString attr_type = hint->attributeType(); QPoint p = QPoint(hint->elementX(), hint->elementY()); diff --git a/src/designer/src/components/tabordereditor/tabordereditor.cpp b/src/designer/src/components/tabordereditor/tabordereditor.cpp index 45a4b5ef0..936591ce1 100644 --- a/src/designer/src/components/tabordereditor/tabordereditor.cpp +++ b/src/designer/src/components/tabordereditor/tabordereditor.cpp @@ -222,7 +222,7 @@ void TabOrderEditor::initTabOrder() } // Append any widgets that are in the form but are not in the tab order - QList<QWidget *> childQueue; + QWidgetList childQueue; childQueue.append(formWindow()->mainContainer()); while (!childQueue.isEmpty()) { QWidget *child = childQueue.takeFirst(); diff --git a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp index 367e01b82..9811ddf12 100644 --- a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp +++ b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp @@ -123,7 +123,7 @@ void WidgetBoxResource::createCustomWidgets(DomCustomWidgets *dc) static QSize geometryProp(const DomWidget *dw) { - const QList<DomProperty*> prop_list = dw->elementProperty(); + const auto &prop_list = dw->elementProperty(); const QString geometry = QStringLiteral("geometry"); for (DomProperty *prop : prop_list) { if (prop->attributeName() != geometry) @@ -142,16 +142,16 @@ static QSize domWidgetSize(const DomWidget *dw) if (size.isValid()) return size; - const QList<DomWidget*> &elementWidgets = dw->elementWidget(); + const auto &elementWidgets = dw->elementWidget(); for (const DomWidget *child : elementWidgets) { size = geometryProp(child); if (size.isValid()) return size; } - const QList<DomLayout *> elementLayouts = dw->elementLayout(); + const auto &elementLayouts = dw->elementLayout(); for (const DomLayout *dl : elementLayouts) { - const QList<DomLayoutItem *> &elementItems = dl->elementItem(); + const auto &elementItems = dl->elementItem(); for (DomLayoutItem *item : elementItems) { const DomWidget *child = item->elementWidget(); if (child == 0) diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp index bd00bc2c7..e278ac417 100644 --- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp +++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp @@ -34,6 +34,7 @@ #include <QtXml/QDomDocument> #include <QtGui/QIcon> +#include <QtGui/QRegularExpressionValidator> #include <QtWidgets/QListView> #include <QtWidgets/QLineEdit> #include <QtWidgets/QItemDelegate> @@ -42,7 +43,7 @@ #include <QtCore/QAbstractListModel> #include <QtCore/QList> #include <QtCore/QTextStream> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> static const char *widgetElementC = "widget"; static const char *nameAttributeC = "name"; @@ -130,7 +131,6 @@ public: private: typedef QList<WidgetBoxCategoryEntry> WidgetBoxCategoryEntrys; - QRegExp m_classNameRegExp; QDesignerFormEditorInterface *m_core; WidgetBoxCategoryEntrys m_items; QListView::ViewMode m_viewMode; @@ -138,11 +138,9 @@ private: WidgetBoxCategoryModel::WidgetBoxCategoryModel(QDesignerFormEditorInterface *core, QObject *parent) : QAbstractListModel(parent), - m_classNameRegExp(QStringLiteral("<widget +class *= *\"([^\"]+)\"")), m_core(core), m_viewMode(QListView::ListMode) { - Q_ASSERT(m_classNameRegExp.isValid()); } QListView::ViewMode WidgetBoxCategoryModel::viewMode() const @@ -203,10 +201,15 @@ void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget { // build item. Filter on name + class name if it is different and not a layout. QString filter = widget.name(); - if (!filter.contains(QStringLiteral("Layout")) && m_classNameRegExp.indexIn(widget.domXml()) != -1) { - const QString className = m_classNameRegExp.cap(1); - if (!filter.contains(className)) - filter += className; + if (!filter.contains(QStringLiteral("Layout"))) { + static const QRegularExpression classNameRegExp(QStringLiteral("<widget +class *= *\"([^\"]+)\"")); + Q_ASSERT(classNameRegExp.isValid()); + const QRegularExpressionMatch match = classNameRegExp.match(widget.domXml()); + if (match.hasMatch()) { + const QString className = match.captured(1); + if (!filter.contains(className)) + filter += className; + } } WidgetBoxCategoryEntry item(widget, filter, icon, editable); const QDesignerWidgetDataBaseInterface *db = m_core->widgetDataBase(); @@ -345,9 +348,9 @@ QWidget *WidgetBoxCategoryEntryDelegate::createEditor(QWidget *parent, { QWidget *result = QItemDelegate::createEditor(parent, option, index); if (QLineEdit *line_edit = qobject_cast<QLineEdit*>(result)) { - QRegExp re = QRegExp(QStringLiteral("[_a-zA-Z][_a-zA-Z0-9]*")); + static const QRegularExpression re(QStringLiteral("^[_a-zA-Z][_a-zA-Z0-9]*$")); Q_ASSERT(re.isValid()); - line_edit->setValidator(new QRegExpValidator(re, line_edit)); + line_edit->setValidator(new QRegularExpressionValidator(re, line_edit)); } return result; } diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp index b6ebc7d47..ce0905026 100644 --- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp +++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp @@ -465,7 +465,6 @@ bool WidgetBoxTreeWidget::readWidget(Widget *w, const QString &xml, QXmlStreamRe int nesting = 0; bool endEncountered = false; bool parsedWidgetTag = false; - QString outmostElement; while (!endEncountered) { const qint64 currentPosition = r.characterOffset(); switch(r.readNext()) { @@ -530,7 +529,6 @@ void WidgetBoxTreeWidget::writeCategories(QXmlStreamWriter &writer, const Catego const QString category = QLatin1String(categoryElementC); const QString categoryEntry = QLatin1String(categoryEntryElementC); const QString iconPrefix = QLatin1String(iconPrefixC); - const QString widgetTag = QLatin1String(widgetElementC); // // <widgetbox> diff --git a/src/designer/src/designer/designer.pro b/src/designer/src/designer/designer.pro index 0201ea6c2..6a925202a 100644 --- a/src/designer/src/designer/designer.pro +++ b/src/designer/src/designer/designer.pro @@ -59,8 +59,7 @@ FORMS += saveformastemplate.ui \ preferencesdialog.ui \ qdesigner_appearanceoptions.ui -QMAKE_TARGET_PRODUCT = Qt Designer -QMAKE_TARGET_DESCRIPTION = Tool for designing and building graphical user interfaces with Qt Widgets +QMAKE_TARGET_DESCRIPTION = Qt Designer win32 { RC_ICONS = designer.ico diff --git a/src/designer/src/designer/main.cpp b/src/designer/src/designer/main.cpp index 236f24138..a0a6667c5 100644 --- a/src/designer/src/designer/main.cpp +++ b/src/designer/src/designer/main.cpp @@ -38,6 +38,9 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(designer); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + // required for QWebEngineView QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); diff --git a/src/designer/src/designer/mainwindow.cpp b/src/designer/src/designer/mainwindow.cpp index 5e11f5b26..fcfa4ecac 100644 --- a/src/designer/src/designer/mainwindow.cpp +++ b/src/designer/src/designer/mainwindow.cpp @@ -97,11 +97,11 @@ void MainWindowBase::closeEvent(QCloseEvent *e) } } -QList<QToolBar *> MainWindowBase::createToolBars(const QDesignerActions *actions, bool singleToolBar) +QVector<QToolBar *> MainWindowBase::createToolBars(const QDesignerActions *actions, bool singleToolBar) { // Note that whenever you want to add a new tool bar here, you also have to update the default // action groups added to the toolbar manager in the mainwindow constructor - QList<QToolBar *> rc; + QVector<QToolBar *> rc; if (singleToolBar) { //: Not currently used (main tool bar) QToolBar *main = createToolBar(tr("Main"), QStringLiteral("mainToolBar"), actions->fileActions()->actions()); @@ -203,8 +203,8 @@ ToolBarManager::ToolBarManager(QMainWindow *configureableMainWindow, QWidget *parent, QMenu *toolBarMenu, const QDesignerActions *actions, - const QList<QToolBar *> &toolbars, - const QList<QDesignerToolWindow*> &toolWindows) : + const QVector<QToolBar *> &toolbars, + const QVector<QDesignerToolWindow *> &toolWindows) : QObject(parent), m_configureableMainWindow(configureableMainWindow), m_parent(parent), @@ -291,13 +291,13 @@ bool ToolBarManager::restoreState(const QByteArray &state, int version) DockedMainWindow::DockedMainWindow(QDesignerWorkbench *wb, QMenu *toolBarMenu, - const QList<QDesignerToolWindow*> &toolWindows) : + const QVector<QDesignerToolWindow *> &toolWindows) : m_toolBarManager(0) { setObjectName(QStringLiteral("MDIWindow")); setWindowTitle(mainWindowTitle()); - const QList<QToolBar *> toolbars = createToolBars(wb->actionManager(), false); + const QVector<QToolBar *> toolbars = createToolBars(wb->actionManager(), false); for (QToolBar *tb : toolbars) addToolBar(tb); DockedMdiArea *dma = new DockedMdiArea(wb->actionManager()->uiExtension()); diff --git a/src/designer/src/designer/mainwindow.h b/src/designer/src/designer/mainwindow.h index 5fcc5aa94..5420e619d 100644 --- a/src/designer/src/designer/mainwindow.h +++ b/src/designer/src/designer/mainwindow.h @@ -30,7 +30,7 @@ #define MAINWINDOW_H #include <QtWidgets/QMainWindow> -#include <QtCore/QList> +#include <QtCore/QVector> #include <QtWidgets/QMdiArea> QT_BEGIN_NAMESPACE @@ -70,7 +70,7 @@ public: CloseEventPolicy closeEventPolicy() const { return m_policy; } void setCloseEventPolicy(CloseEventPolicy pol) { m_policy = pol; } - static QList<QToolBar *> createToolBars(const QDesignerActions *actions, bool singleToolBar); + static QVector<QToolBar *> createToolBars(const QDesignerActions *actions, bool singleToolBar); static QString mainWindowTitle(); // Use the minor Qt version as settings versions to avoid conflicts @@ -117,8 +117,8 @@ public: QWidget *parent, QMenu *toolBarMenu, const QDesignerActions *actions, - const QList<QToolBar *> &toolbars, - const QList<QDesignerToolWindow*> &toolWindows); + const QVector<QToolBar *> &toolbars, + const QVector<QDesignerToolWindow *> &toolWindows); QByteArray saveState(int version = 0) const; bool restoreState(const QByteArray &state, int version = 0); @@ -133,7 +133,7 @@ private: QMenu *m_toolBarMenu; QtToolBarManager *m_manager; QAction *m_configureAction; - QList<QToolBar *> m_toolbars; + QVector<QToolBar *> m_toolbars; }; /* Main window to be used for docked mode */ @@ -141,8 +141,8 @@ class DockedMainWindow : public MainWindowBase { Q_OBJECT Q_DISABLE_COPY(DockedMainWindow) public: - typedef QList<QDesignerToolWindow*> DesignerToolWindowList; - typedef QList<QDockWidget *> DockWidgetList; + typedef QVector<QDesignerToolWindow *> DesignerToolWindowList; + typedef QVector<QDockWidget *> DockWidgetList; explicit DockedMainWindow(QDesignerWorkbench *wb, QMenu *toolBarMenu, diff --git a/src/designer/src/designer/qdesigner_formwindow.cpp b/src/designer/src/designer/qdesigner_formwindow.cpp index e36c388e1..cbf2c48a2 100644 --- a/src/designer/src/designer/qdesigner_formwindow.cpp +++ b/src/designer/src/designer/qdesigner_formwindow.cpp @@ -41,6 +41,7 @@ #include <QtCore/QEvent> #include <QtCore/QFile> +#include <QtCore/QRegularExpression> #include <QtWidgets/QAction> #include <QtGui/QCloseEvent> @@ -163,16 +164,18 @@ int QDesignerFormWindow::getNumberOfUntitledWindows() const // Find the number of untitled windows excluding ourselves. // Do not fall for 'untitled.ui', match with modified place holder. // This will cause some problems with i18n, but for now I need the string to be "static" - QRegExp rx(QStringLiteral("untitled( (\\d+))?\\[\\*\\]")); + static const QRegularExpression rx(QStringLiteral("untitled( (\\d+))?\\[\\*\\]$")); + Q_ASSERT(rx.isValid()); for (int i = 0; i < totalWindows; ++i) { QDesignerFormWindow *fw = m_workbench->formWindow(i); if (fw != this) { const QString title = m_workbench->formWindow(i)->windowTitle(); - if (rx.indexIn(title) != -1) { + const QRegularExpressionMatch match = rx.match(title); + if (match.hasMatch()) { if (maxUntitled == 0) ++maxUntitled; - if (rx.captureCount() > 1) { - const QString numberCapture = rx.cap(2); + if (match.lastCapturedIndex() >= 2) { + const QStringRef numberCapture = match.capturedRef(2); if (!numberCapture.isEmpty()) maxUntitled = qMax(numberCapture.toInt(), maxUntitled); } diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index b85b49c0b..5c919dd1c 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -622,7 +622,7 @@ void QDesignerWorkbench::removeFormWindow(QDesignerFormWindow *formWindow) void QDesignerWorkbench::initializeCorePlugins() { - QList<QObject*> plugins = QPluginLoader::staticInstances(); + QObjectList plugins = QPluginLoader::staticInstances(); plugins += core()->pluginManager()->instances(); for (QObject *plugin : qAsConst(plugins)) { @@ -769,11 +769,8 @@ void QDesignerWorkbench::updateWindowMenu(QDesignerFormWindowInterface *fwi) m_actionManager->minimizeAction()->setEnabled(minimizeEnabled); m_actionManager->minimizeAction()->setChecked(minimizeChecked); - if (!m_formWindows.empty()) { - const QList<QDesignerFormWindow*>::const_iterator cend = m_formWindows.constEnd(); - for (QList<QDesignerFormWindow*>::const_iterator it = m_formWindows.constBegin(); it != cend; ++it) - (*it)->action()->setChecked(*it == activeFormWindow); - } + for (QDesignerFormWindow *fw : qAsConst(m_formWindows)) + fw->action()->setChecked(fw == activeFormWindow); } void QDesignerWorkbench::formWindowActionTriggered(QAction *a) diff --git a/src/designer/src/designer/qdesigner_workbench.h b/src/designer/src/designer/qdesigner_workbench.h index 89e438266..8f0e4cc38 100644 --- a/src/designer/src/designer/qdesigner_workbench.h +++ b/src/designer/src/designer/qdesigner_workbench.h @@ -34,8 +34,8 @@ #include <QtCore/QObject> #include <QtCore/QHash> #include <QtCore/QSet> -#include <QtCore/QList> #include <QtCore/QRect> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE @@ -158,15 +158,15 @@ private: struct TopLevelData { ToolBarManager *toolbarManager; - QList<QToolBar *> toolbars; + QVector<QToolBar *> toolbars; }; TopLevelData m_topLevelData; UIMode m_mode; DockedMainWindow *m_dockedMainWindow; - QList<QDesignerToolWindow*> m_toolWindows; - QList<QDesignerFormWindow*> m_formWindows; + QVector<QDesignerToolWindow *> m_toolWindows; + QVector<QDesignerFormWindow *> m_formWindows; QMenu *m_toolbarMenu; diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp index 96ecf5795..bb43652dd 100644 --- a/src/designer/src/lib/shared/formlayoutmenu.cpp +++ b/src/designer/src/lib/shared/formlayoutmenu.cpp @@ -47,11 +47,11 @@ #include <QtWidgets/QUndoStack> #include <QtWidgets/QDialog> #include <QtWidgets/QPushButton> -#include <QtGui/QRegExpValidator> +#include <QtGui/QRegularExpressionValidator> #include <QtCore/QPair> #include <QtCore/QCoreApplication> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> #include <QtCore/QMultiHash> #include <QtCore/QDebug> @@ -115,7 +115,7 @@ private: void updateOkButton(); // Check for buddy marker in string - QRegExp m_buddyMarkerRegexp; + const QRegularExpression m_buddyMarkerRegexp; Ui::FormLayoutRowDialog m_ui; bool m_labelNameEdited; @@ -140,8 +140,8 @@ FormLayoutRowDialog::FormLayoutRowDialog(QDesignerFormEditorInterface *core, m_ui.setupUi(this); connect(m_ui.labelTextLineEdit, &QLineEdit::textEdited, this, &FormLayoutRowDialog::labelTextEdited); - QRegExpValidator *nameValidator = new QRegExpValidator(QRegExp(QStringLiteral("^[a-zA-Z0-9_]+$")), this); - Q_ASSERT(nameValidator->regExp().isValid()); + QRegularExpressionValidator *nameValidator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[a-zA-Z0-9_]+$")), this); + Q_ASSERT(nameValidator->regularExpression().isValid()); m_ui.labelNameLineEdit->setValidator(nameValidator); connect(m_ui.labelNameLineEdit, &QLineEdit::textEdited, diff --git a/src/designer/src/lib/shared/metadatabase.cpp b/src/designer/src/lib/shared/metadatabase.cpp index 59b0fd024..bf3ad5c68 100644 --- a/src/designer/src/lib/shared/metadatabase.cpp +++ b/src/designer/src/lib/shared/metadatabase.cpp @@ -77,12 +77,12 @@ void MetaDataBaseItem::setCustomClassName(const QString &customClassName) } -MetaDataBaseItem::TabOrder MetaDataBaseItem::tabOrder() const +QWidgetList MetaDataBaseItem::tabOrder() const { return m_tabOrder; } -void MetaDataBaseItem::setTabOrder(const TabOrder &tabOrder) +void MetaDataBaseItem::setTabOrder(const QWidgetList &tabOrder) { m_tabOrder = tabOrder; } @@ -168,9 +168,9 @@ void MetaDataBase::remove(QObject *object) } } -QList<QObject*> MetaDataBase::objects() const +QObjectList MetaDataBase::objects() const { - QList<QObject*> result; + QObjectList result; ItemMap::const_iterator it = m_items.begin(); for (; it != m_items.end(); ++it) { diff --git a/src/designer/src/lib/shared/metadatabase_p.h b/src/designer/src/lib/shared/metadatabase_p.h index 33366a5c7..5770b4201 100644 --- a/src/designer/src/lib/shared/metadatabase_p.h +++ b/src/designer/src/lib/shared/metadatabase_p.h @@ -61,9 +61,8 @@ public: QString name() const Q_DECL_OVERRIDE; void setName(const QString &name) Q_DECL_OVERRIDE; - typedef QList<QWidget*> TabOrder; - TabOrder tabOrder() const Q_DECL_OVERRIDE; - void setTabOrder(const TabOrder &tabOrder) Q_DECL_OVERRIDE; + QWidgetList tabOrder() const Q_DECL_OVERRIDE; + void setTabOrder(const QWidgetList &tabOrder) Q_DECL_OVERRIDE; bool enabled() const Q_DECL_OVERRIDE; void setEnabled(bool b) Q_DECL_OVERRIDE; @@ -79,7 +78,7 @@ public: private: QObject *m_object; - TabOrder m_tabOrder; + QWidgetList m_tabOrder; bool m_enabled; QString m_customClassName; QStringList m_fakeSlots; @@ -100,7 +99,7 @@ public: void add(QObject *object) Q_DECL_OVERRIDE; void remove(QObject *object) Q_DECL_OVERRIDE; - QList<QObject*> objects() const Q_DECL_OVERRIDE; + QObjectList objects() const Q_DECL_OVERRIDE; private slots: void slotDestroyed(QObject *object); diff --git a/src/designer/src/lib/shared/newactiondialog.cpp b/src/designer/src/lib/shared/newactiondialog.cpp index afddd7589..0b4c08533 100644 --- a/src/designer/src/lib/shared/newactiondialog.cpp +++ b/src/designer/src/lib/shared/newactiondialog.cpp @@ -38,7 +38,6 @@ #include <QtDesigner/abstractformeditor.h> #include <QtWidgets/QPushButton> -#include <QtCore/QRegExp> QT_BEGIN_NAMESPACE diff --git a/src/designer/src/lib/shared/qdesigner_command.cpp b/src/designer/src/lib/shared/qdesigner_command.cpp index d0b270cfa..90dd00bf2 100644 --- a/src/designer/src/lib/shared/qdesigner_command.cpp +++ b/src/designer/src/lib/shared/qdesigner_command.cpp @@ -493,7 +493,7 @@ void DeleteWidgetCommand::redo() m_widget->hide(); if (m_tabOrderIndex != -1) { - QList<QWidget*> tab_order = m_formItem->tabOrder(); + QWidgetList tab_order = m_formItem->tabOrder(); tab_order.removeAt(m_tabOrderIndex); m_formItem->setTabOrder(tab_order); } @@ -542,7 +542,7 @@ void DeleteWidgetCommand::undo() m_widget->show(); if (m_tabOrderIndex != -1) { - QList<QWidget*> tab_order = m_formItem->tabOrder(); + QWidgetList tab_order = m_formItem->tabOrder(); tab_order.insert(m_tabOrderIndex, m_widget); m_formItem->setTabOrder(tab_order); } @@ -1438,7 +1438,7 @@ TabOrderCommand::TabOrderCommand(QDesignerFormWindowInterface *formWindow) { } -void TabOrderCommand::init(const QList<QWidget*> &newTabOrder) +void TabOrderCommand::init(const QWidgetList &newTabOrder) { QDesignerFormEditorInterface *core = formWindow()->core(); Q_ASSERT(core); diff --git a/src/designer/src/lib/shared/qdesigner_command_p.h b/src/designer/src/lib/shared/qdesigner_command_p.h index 50075b503..7b9d4ed71 100644 --- a/src/designer/src/lib/shared/qdesigner_command_p.h +++ b/src/designer/src/lib/shared/qdesigner_command_p.h @@ -127,7 +127,7 @@ protected: private: QPointer<QWidget> m_widget; QPointer<QWidget> m_oldPreceding; - QList<QWidget *> m_oldParentZOrder; + QWidgetList m_oldParentZOrder; }; class QDESIGNER_SHARED_EXPORT RaiseWidgetCommand: public ChangeZOrderCommand @@ -242,8 +242,8 @@ private: QPoint m_newPos; QPointer<QWidget> m_oldParentWidget; QPointer<QWidget> m_newParentWidget; - QList<QWidget *> m_oldParentList; - QList<QWidget *> m_oldParentZOrder; + QWidgetList m_oldParentList; + QWidgetList m_oldParentZOrder; }; class QDESIGNER_SHARED_EXPORT ChangeFormLayoutItemRoleCommand : public QDesignerFormWindowCommand @@ -296,12 +296,12 @@ class QDESIGNER_SHARED_EXPORT TabOrderCommand: public QDesignerFormWindowCommand public: explicit TabOrderCommand(QDesignerFormWindowInterface *formWindow); - void init(const QList<QWidget*> &newTabOrder); + void init(const QWidgetList &newTabOrder); - inline QList<QWidget*> oldTabOrder() const + inline QWidgetList oldTabOrder() const { return m_oldTabOrder; } - inline QList<QWidget*> newTabOrder() const + inline QWidgetList newTabOrder() const { return m_newTabOrder; } virtual void redo(); @@ -309,8 +309,8 @@ public: private: QDesignerMetaDataBaseItemInterface *m_widgetItem; - QList<QWidget*> m_oldTabOrder; - QList<QWidget*> m_newTabOrder; + QWidgetList m_oldTabOrder; + QWidgetList m_newTabOrder; }; class QDESIGNER_SHARED_EXPORT PromoteToCustomWidgetCommand : public QDesignerFormWindowCommand diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp index a809ab4af..cbd7b0a46 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -226,8 +226,6 @@ static bool readDomEnumerationValue(const DomProperty *p, void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { - typedef QList<DomProperty*> DomPropertyList; - if (properties.empty()) return; @@ -247,9 +245,7 @@ void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> designerPropertySheet->setIconCache(m_iconCache); } - const DomPropertyList::const_iterator cend = properties.constEnd(); - for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) { - DomProperty *p = *it; + for (DomProperty *p : properties) { QVariant v; if (!readDomEnumerationValue(p, sheet, v)) v = toVariant(o->metaObject(), p); @@ -300,7 +296,7 @@ void QDesignerFormBuilder::createResources(DomResources *resources) return; QStringList paths; if (resources != 0) { - const QList<DomResource*> dom_include = resources->elementInclude(); + const auto &dom_include = resources->elementInclude(); for (DomResource *res : dom_include) { QString path = QDir::cleanPath(workingDirectory().absoluteFilePath(res->attributeLocation())); paths << path; diff --git a/src/designer/src/lib/shared/qdesigner_membersheet.cpp b/src/designer/src/lib/shared/qdesigner_membersheet.cpp index 10de9f3d4..2c1fc2ef0 100644 --- a/src/designer/src/lib/shared/qdesigner_membersheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_membersheet.cpp @@ -184,7 +184,6 @@ bool QDesignerMemberSheet::isSlot(int index) const bool QDesignerMemberSheet::inheritedFromWidget(int index) const { - const QString name = d->m_meta->method(index)->signature(); return declaredInClass(index) == QStringLiteral("QWidget") || declaredInClass(index) == QStringLiteral("QObject"); } diff --git a/src/designer/src/lib/shared/qdesigner_promotion.cpp b/src/designer/src/lib/shared/qdesigner_promotion.cpp index 13f055ae2..a1e2acd42 100644 --- a/src/designer/src/lib/shared/qdesigner_promotion.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotion.cpp @@ -252,10 +252,9 @@ namespace qdesigner_internal { if (!metaDataBase) return rc; - const QList<QObject*> objs = metaDataBase->objects(); - const QList<QObject*>::const_iterator cend = objs.constEnd(); - for ( QList<QObject*>::const_iterator it = objs.constBegin(); it != cend; ++it) { - const QString customClass = metaDataBase->metaDataBaseItem(*it)->customClassName(); + const QObjectList &objects = metaDataBase->objects(); + for (QObject *object : objects) { + const QString customClass = metaDataBase->metaDataBaseItem(object)->customClassName(); if (!customClass.isEmpty()) rc.insert(customClass); diff --git a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp index cec794fb5..5830549e3 100644 --- a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp @@ -52,7 +52,7 @@ #include <QtWidgets/QComboBox> #include <QtWidgets/QLineEdit> #include <QtWidgets/QCheckBox> -#include <QtGui/QRegExpValidator> +#include <QtGui/QRegularExpressionValidator> #include <QtWidgets/QLabel> #include <QtWidgets/QSpacerItem> #include <QtWidgets/QMenu> @@ -83,7 +83,7 @@ namespace qdesigner_internal { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); QHBoxLayout *hboxLayout = new QHBoxLayout(this); - m_classNameEdit->setValidator(new QRegExpValidator(QRegExp(QStringLiteral("[_a-zA-Z:][:_a-zA-Z0-9]*")), m_classNameEdit)); + m_classNameEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[_a-zA-Z:][:_a-zA-Z0-9]*$")), m_classNameEdit)); connect(m_classNameEdit, &QLineEdit::textChanged, this, &NewPromotedClassPanel::slotNameChanged); connect(m_includeFileEdit, &QLineEdit::textChanged, diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index bce74ecb0..6c7417f81 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -1358,7 +1358,7 @@ AddDynamicPropertyCommand::AddDynamicPropertyCommand(QDesignerFormWindowInterfac } -bool AddDynamicPropertyCommand::init(const QList<QObject *> &selection, QObject *current, +bool AddDynamicPropertyCommand::init(const QObjectList &selection, QObject *current, const QString &propertyName, const QVariant &value) { Q_ASSERT(current); @@ -1437,7 +1437,7 @@ RemoveDynamicPropertyCommand::RemoveDynamicPropertyCommand(QDesignerFormWindowIn } -bool RemoveDynamicPropertyCommand::init(const QList<QObject *> &selection, QObject *current, +bool RemoveDynamicPropertyCommand::init(const QObjectList &selection, QObject *current, const QString &propertyName) { Q_ASSERT(current); diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp index 601fb657b..af3c2af83 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -34,6 +34,7 @@ #include "stylesheeteditor_p.h" #include "qlayout_widget_p.h" #include "layout_p.h" +#include "selectsignaldialog_p.h" #include "spacer_widget_p.h" #include "textpropertyeditor_p.h" #include "promotiontaskmenu_p.h" @@ -45,7 +46,6 @@ #include "qdesigner_objectinspector_p.h" #include "morphmenu_p.h" #include "formlayoutmenu_p.h" -#include "ui_selectsignaldialog.h" #include "widgetfactory_p.h" #include "abstractintrospection_p.h" #include "widgetdatabase_p.h" @@ -600,22 +600,6 @@ void QDesignerTaskMenu::containerFakeMethods() SignalSlotDialog::editMetaDataBase(fw, d->m_widget, fw); } -static QString declaredInClass(const QDesignerMetaObjectInterface *metaObject, const QString &member) -{ - // Find class whose superclass does not contain the method. - const QDesignerMetaObjectInterface *meta = metaObject; - - for (;;) { - const QDesignerMetaObjectInterface *tmpMeta = meta->superClass(); - if (tmpMeta == 0) - break; - if (tmpMeta->indexOfMethod(member) == -1) - break; - meta = tmpMeta; - } - return meta->className(); -} - bool QDesignerTaskMenu::isSlotNavigationEnabled(const QDesignerFormEditorInterface *core) { return core->integration()->hasFeature(QDesignerIntegration::SlotNavigationFeature); @@ -632,93 +616,17 @@ void QDesignerTaskMenu::navigateToSlot(QDesignerFormEditorInterface *core, QObject *object, const QString &defaultSignal) { - const QString objectName = objName(core, object); - QMap<QString, QMap<QString, QStringList> > classToSignalList; - - // "real" signals - if (const QDesignerMetaObjectInterface *metaObject = core->introspection()->metaObject(object)) { - const int methodCount = metaObject->methodCount(); - for (int i = 0; i < methodCount; ++i) { - const QDesignerMetaMethodInterface *metaMethod = metaObject->method(i); - if (metaMethod->methodType() == QDesignerMetaMethodInterface::Signal) { - const QString signature = metaMethod->signature(); - const QStringList parameterNames = metaMethod->parameterNames(); - classToSignalList[declaredInClass(metaObject, signature)][signature] = parameterNames; - } - } - } - - // fake signals - if (qdesigner_internal::MetaDataBase *metaDataBase - = qobject_cast<qdesigner_internal::MetaDataBase *>(core->metaDataBase())) { - qdesigner_internal::MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(object); - Q_ASSERT(item); - const QStringList fakeSignals = item->fakeSignals(); - for (const QString &fakeSignal : fakeSignals) - classToSignalList[item->customClassName()][fakeSignal] = QStringList(); - } - - if (object->isWidgetType()) { - QWidget *widget = static_cast<QWidget *>(object); - if (WidgetDataBase *db = qobject_cast<WidgetDataBase *>(core->widgetDataBase())) { - const QString promotedClassName = promotedCustomClassName(core, widget); - const int index = core->widgetDataBase()->indexOfClassName(promotedClassName); - if (index >= 0) { - WidgetDataBaseItem* item = static_cast<WidgetDataBaseItem*>(db->item(index)); - const QStringList fakeSignals = item->fakeSignals(); - for (const QString &fakeSignal : fakeSignals) - classToSignalList[promotedClassName][fakeSignal] = QStringList(); - } - } - } - - Ui::SelectSignalDialog dialogUi; - QDialog selectSignalDialog(0, Qt::WindowTitleHint | Qt::WindowSystemMenuHint); - dialogUi.setupUi(&selectSignalDialog); - - QMap<QString, QMap<QString, QStringList> >::const_iterator iter(classToSignalList.constBegin()); - for (; iter != classToSignalList.constEnd(); ++iter) { - const QString className = iter.key(); - QMap<QString, QStringList> signalNames = iter.value(); - - QMap<QString, QStringList>::const_iterator itSignal(signalNames.constBegin()); - for (; itSignal != signalNames.constEnd(); ++itSignal) { - const QString signalName = itSignal.key(); - QTreeWidgetItem *row = new QTreeWidgetItem(QStringList() << signalName << className); - row->setData(0, Qt::UserRole, itSignal.value()); - dialogUi.signalList->addTopLevelItem(row); - } - } - if (dialogUi.signalList->topLevelItemCount() == 0) { - QTreeWidgetItem *row = new QTreeWidgetItem(QStringList() << tr("no signals available")); - dialogUi.signalList->addTopLevelItem(row); - dialogUi.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - } else { - connect(dialogUi.signalList, &QTreeWidget::itemDoubleClicked, - &selectSignalDialog, &QDialog::accept); - } - - if (defaultSignal.isEmpty()) { - dialogUi.signalList->setCurrentItem(dialogUi.signalList->topLevelItem(0)); - } else { - const QList<QTreeWidgetItem *> items = dialogUi.signalList->findItems (defaultSignal, Qt::MatchExactly, 0); - if (!items.empty()) - dialogUi.signalList->setCurrentItem(items.front()); - } - - dialogUi.signalList->resizeColumnToContents(0); - - if (selectSignalDialog.exec() != QDialog::Accepted) + SelectSignalDialog dialog; + dialog.populate(core, object, defaultSignal); + if (dialog.exec() != QDialog::Accepted) return; - const QList<QTreeWidgetItem *> &selectedItems = dialogUi.signalList->selectedItems(); - if (selectedItems.isEmpty()) - return; - const QTreeWidgetItem *selectedItem = selectedItems.constFirst(); - const QString signalSignature = selectedItem->text(0); - const QStringList parameterNames = qvariant_cast<QStringList>(selectedItem->data(0, Qt::UserRole)); - // TODO: Check whether signal is connected to slot - core->integration()->emitNavigateToSlot(objectName, signalSignature, parameterNames); + const SelectSignalDialog::Method method = dialog.selectedMethod(); + if (method.isValid()) { + core->integration()->emitNavigateToSlot(objName(core, object), + method.signature, + method.parameterNames); + } } // Add a command that takes over the value of the current geometry as diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu_p.h b/src/designer/src/lib/shared/qdesigner_taskmenu_p.h index facdafe53..5893114d6 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu_p.h +++ b/src/designer/src/lib/shared/qdesigner_taskmenu_p.h @@ -44,6 +44,8 @@ #include "extensionfactory_p.h" #include <QtDesigner/QDesignerTaskMenuExtension> +#include <QtGui/qwindowdefs.h> + #include <QtCore/QObject> #include <QtCore/QPointer> #include <QtCore/QList> @@ -53,8 +55,6 @@ QT_BEGIN_NAMESPACE class QDesignerFormWindowInterface; class QDesignerFormEditorInterface; -class QWidget; - namespace qdesigner_internal { class QDesignerTaskMenuPrivate; @@ -87,7 +87,7 @@ protected: * an unmanaged widget [as of 4.5], in which case it must not use the cursor selection, * but the unmanaged selection of the object inspector. */ QObjectList applicableObjects(const QDesignerFormWindowInterface *fw, PropertyMode pm) const; - QList<QWidget *> applicableWidgets(const QDesignerFormWindowInterface *fw, PropertyMode pm) const; + QWidgetList applicableWidgets(const QDesignerFormWindowInterface *fw, PropertyMode pm) const; void setProperty(QDesignerFormWindowInterface *fw, PropertyMode pm, const QString &name, const QVariant &newValue); diff --git a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp index b3490ff7d..1e581ba02 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp @@ -31,7 +31,7 @@ #include <QtDesigner/private/ui4_p.h> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> #include <QtCore/QDebug> #include <QtCore/QXmlStreamReader> #include <QtCore/QSharedData> @@ -157,7 +157,7 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox, QString pattern = QStringLiteral("^<widget\\s+class\\s*=\\s*\""); pattern += className; pattern += QStringLiteral("\".*$"); - QRegExp regexp(pattern); + const QRegularExpression regexp(pattern); Q_ASSERT(regexp.isValid()); const int catCount = wbox->categoryCount(); for (int c = 0; c < catCount; c++) { @@ -170,7 +170,7 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox, const int widgetTagIndex = xml.indexOf(widgetTag); if (widgetTagIndex != -1) { xml.remove(0, widgetTagIndex); - if (regexp.exactMatch(xml)) { + if (regexp.match(xml).hasMatch()) { *widgetData = widget; return true; } @@ -190,7 +190,6 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool // The xml description must either contain a root element "ui" with a child element "widget" // or "widget" as the root element (4.3 legacy) - const QString widgetTag = QStringLiteral("widget"); while (!reader.atEnd()) { if (reader.readNext() == QXmlStreamReader::StartElement) { @@ -233,7 +232,7 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool if (insertFakeTopLevel) { DomWidget *fakeTopLevel = new DomWidget; fakeTopLevel->setAttributeClass(QStringLiteral("QWidget")); - QList<DomWidget *> children; + QVector<DomWidget *> children; children.push_back(ui->takeElementWidget()); fakeTopLevel->setElementWidget(children); ui->setElementWidget(fakeTopLevel); diff --git a/src/designer/src/lib/shared/qlayout_widget.cpp b/src/designer/src/lib/shared/qlayout_widget.cpp index 3719c5aa5..948364276 100644 --- a/src/designer/src/lib/shared/qlayout_widget.cpp +++ b/src/designer/src/lib/shared/qlayout_widget.cpp @@ -1422,12 +1422,12 @@ int QLayoutSupport::indexOf(QWidget *widget) const return -1; } -QList<QWidget*> QLayoutSupport::widgets(QLayout *layout) const +QWidgetList QLayoutSupport::widgets(QLayout *layout) const { if (!layout) - return QList<QWidget*>(); + return QWidgetList(); - QList<QWidget*> lst; + QWidgetList lst; int index = 0; while (QLayoutItem *item = layout->itemAt(index)) { ++index; diff --git a/src/designer/src/lib/shared/qlayout_widget_p.h b/src/designer/src/lib/shared/qlayout_widget_p.h index 23c096759..2ff849d24 100644 --- a/src/designer/src/lib/shared/qlayout_widget_p.h +++ b/src/designer/src/lib/shared/qlayout_widget_p.h @@ -188,7 +188,7 @@ public: void adjustIndicator(const QPoint &pos, int index) Q_DECL_OVERRIDE; - QList<QWidget*> widgets(QLayout *layout) const Q_DECL_OVERRIDE; + QWidgetList widgets(QLayout *layout) const Q_DECL_OVERRIDE; // Pad empty cells with dummy spacers. Called by layouting commands. static void createEmptyCells(QGridLayout *gridLayout); diff --git a/src/designer/src/lib/shared/qsimpleresource.cpp b/src/designer/src/lib/shared/qsimpleresource.cpp index aba6fc7da..95210559c 100644 --- a/src/designer/src/lib/shared/qsimpleresource.cpp +++ b/src/designer/src/lib/shared/qsimpleresource.cpp @@ -49,12 +49,6 @@ QT_BEGIN_NAMESPACE -namespace { - typedef QList<DomWidgetData*> DomWidgetDataList; - typedef QList<DomProperty*> DomPropertyList; - typedef QList<QDesignerCustomWidgetInterface *> CustomWidgetInterfaces; -} - namespace qdesigner_internal { bool QSimpleResource::m_warningsEnabled = true; @@ -84,35 +78,6 @@ DomBrush *QSimpleResource::saveBrush(const QBrush &brush) return QAbstractFormBuilder::saveBrush(brush); } -DomScript *QSimpleResource::createScript(const QString &script, ScriptSource source) -{ - if (script.isEmpty()) - return 0; - DomScript *domScript = new DomScript(); - switch (source) { - case ScriptExtension: - domScript->setAttributeSource(QStringLiteral("extension")); - break; - case ScriptDesigner: - domScript->setAttributeSource(QStringLiteral("designer")); - break; - case ScriptCustomWidgetPlugin: - domScript->setAttributeSource(QStringLiteral("customwidgetplugin")); - break; - } - domScript->setAttributeLanguage(QStringLiteral("Qt Script")); - domScript->setText(script); - return domScript; -} - -// Add a script to a list of DomScripts unless empty -void QSimpleResource::addScript(const QString &script, ScriptSource source, DomScripts &domScripts) -{ - if (DomScript *domScript = createScript(script, source)) { - domScripts += domScript; - } -} - void QSimpleResource::addExtensionDataToDOM(QAbstractFormBuilder * /* afb */, QDesignerFormEditorInterface *core, DomWidget *ui_widget, QWidget *widget) @@ -194,7 +159,7 @@ void QSimpleResource::addFakeMethodsToWidgetDataBase(const DomCustomWidget *domC // Classes whose base class could not be found are left in the list. void QSimpleResource::addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core, - QList<DomCustomWidget*>& custom_widget_list) + QVector<DomCustomWidget *> &custom_widget_list) { QDesignerWidgetDataBaseInterface *db = core->widgetDataBase(); for (int i=0; i < custom_widget_list.size(); ) { @@ -256,7 +221,7 @@ void QSimpleResource::handleDomCustomWidgets(const QDesignerFormEditorInterface { if (dom_custom_widgets == 0) return; - QList<DomCustomWidget*> custom_widget_list = dom_custom_widgets->elementCustomWidget(); + auto custom_widget_list = dom_custom_widgets->elementCustomWidget(); // Attempt to insert each item derived from its base class. // This should at most require two iterations in the event that the classes are out of order // (derived first, max depth: promoted custom plugin = 2) diff --git a/src/designer/src/lib/shared/qsimpleresource_p.h b/src/designer/src/lib/shared/qsimpleresource_p.h index c8a2774d3..8bd5d5f0d 100644 --- a/src/designer/src/lib/shared/qsimpleresource_p.h +++ b/src/designer/src/lib/shared/qsimpleresource_p.h @@ -43,10 +43,10 @@ #include "shared_global_p.h" #include "abstractformbuilder.h" #include <QtCore/QStringList> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE -class DomScript; class DomCustomWidgets; class DomCustomWidget; class DomSlots; @@ -87,16 +87,11 @@ public: const DomCustomWidgets *dom_custom_widgets); protected: - enum ScriptSource { ScriptDesigner, ScriptExtension, ScriptCustomWidgetPlugin }; - static DomScript*createScript(const QString &script, ScriptSource source); - typedef QList<DomScript*> DomScripts; - static void addScript(const QString &script, ScriptSource source, DomScripts &domScripts); - static bool addFakeMethods(const DomSlots *domSlots, QStringList &fakeSlots, QStringList &fakeSignals); private: static void addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core, - QList<DomCustomWidget*>& custom_widget_list); + QVector<DomCustomWidget *> &custom_widget_list); static void addFakeMethodsToWidgetDataBase(const DomCustomWidget *domCustomWidget, WidgetDataBaseItem *item); static bool m_warningsEnabled; diff --git a/src/designer/src/lib/shared/selectsignaldialog.cpp b/src/designer/src/lib/shared/selectsignaldialog.cpp new file mode 100644 index 000000000..8350f1710 --- /dev/null +++ b/src/designer/src/lib/shared/selectsignaldialog.cpp @@ -0,0 +1,242 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Designer 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$ +** +****************************************************************************/ + +#include "selectsignaldialog_p.h" + +#include "ui_selectsignaldialog.h" + +#include <QtDesigner/QDesignerFormEditorInterface> +#include <QtDesigner/QDesignerPromotionInterface> + +#include "abstractintrospection_p.h" +#include "metadatabase_p.h" +#include "widgetdatabase_p.h" + +#include <QtWidgets/QApplication> +#include <QtWidgets/QDesktopWidget> +#include <QtWidgets/QPushButton> +#include <QtGui/QStandardItem> +#include <QtGui/QStandardItemModel> +#include <QtCore/QItemSelectionModel> +#include <QtCore/QVariant> +#include <QtCore/QVector> + +#include <algorithm> + +QT_BEGIN_NAMESPACE + +namespace qdesigner_internal { + +enum { MethodRole = Qt::UserRole + 1 }; + +typedef QVector<SelectSignalDialog::Method> Methods; + +SelectSignalDialog::SelectSignalDialog(QWidget *parent) + : QDialog(parent) + , m_ui(new Ui::SelectSignalDialog) + , m_model(new QStandardItemModel(0, 1, this)) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + m_ui->setupUi(this); + m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); + + m_ui->signalList->setModel(m_model); + connect(m_ui->signalList->selectionModel(), &QItemSelectionModel::currentChanged, + this, &SelectSignalDialog::currentChanged); + connect(m_ui->signalList, &QTreeView::activated, + this, &SelectSignalDialog::activated); + const QRect availableGeometry = QApplication::desktop()->availableGeometry(this); + resize(availableGeometry.width() / 5, availableGeometry.height() / 2); +} + +SelectSignalDialog::~SelectSignalDialog() +{ + delete m_ui; +} + +SelectSignalDialog::Method SelectSignalDialog::selectedMethod() const +{ + return methodFromIndex(m_ui->signalList->currentIndex()); +} + +SelectSignalDialog::Method SelectSignalDialog::methodFromIndex(const QModelIndex &index) const +{ + if (index.isValid()) { + const QStandardItem *item = m_model->itemFromIndex(index); + const QVariant data = item->data(MethodRole); + if (data.canConvert<Method>()) + return data.value<Method>(); + } + return Method(); +} + +static QStandardItem *createTopLevelItem(const QString &text) +{ + QStandardItem *result = new QStandardItem(text); + result->setFlags(Qt::ItemIsEnabled); + return result; +} + +static bool signatureLessThan(const SelectSignalDialog::Method &m1, const SelectSignalDialog::Method &m2) +{ + return m1.signature.compare(m2.signature) < 0; +} + +// Append a class with alphabetically sorted methods to the model +static void appendClass(const QString &className, Methods methods, QStandardItemModel *model) +{ + if (methods.isEmpty()) + return; + std::sort(methods.begin(), methods.end(), signatureLessThan); + QStandardItem *topLevelItem = createTopLevelItem(className); + model->appendRow(topLevelItem); + for (const SelectSignalDialog::Method &m : qAsConst(methods)) { + QStandardItem *item = new QStandardItem(m.signature); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setData(qVariantFromValue(m), MethodRole); + topLevelItem->appendRow(item); + } +} + +static QString declaredInClass(const QDesignerMetaObjectInterface *metaObject, const QString &member) +{ + // Find class whose superclass does not contain the method. + const QDesignerMetaObjectInterface *meta = metaObject; + + for (;;) { + const QDesignerMetaObjectInterface *tmpMeta = meta->superClass(); + if (tmpMeta == 0) + break; + if (tmpMeta->indexOfMethod(member) == -1) + break; + meta = tmpMeta; + } + return meta->className(); +} + +static inline QString msgNoSignals() +{ + return QCoreApplication::translate("QDesignerTaskMenu", "no signals available"); +} + +void SelectSignalDialog::populate(QDesignerFormEditorInterface *core, QObject *object, QString defaultSignal) +{ + m_okButton->setEnabled(false); + + populateModel(core, object); + + if (m_model->rowCount() == 0) { + m_model->appendRow(createTopLevelItem(msgNoSignals())); + return; + } + + m_ui->signalList->expandAll(); + m_ui->signalList->resizeColumnToContents(0); + + QModelIndex selectedIndex; + if (defaultSignal.isEmpty()) { + selectedIndex = m_model->index(0, 0, m_model->index(0, 0, QModelIndex())); // first method + } else { + const QList<QStandardItem *> items = m_model->findItems(defaultSignal, Qt::MatchExactly | Qt::MatchRecursive, 0); + if (!items.isEmpty()) + selectedIndex = m_model->indexFromItem(items.constFirst()); + } + + if (selectedIndex.isValid()) + m_ui->signalList->setCurrentIndex(selectedIndex); +} + +void SelectSignalDialog::populateModel(QDesignerFormEditorInterface *core, QObject *object) +{ + m_model->removeRows(0, m_model->rowCount()); + + // Populate methods list in reverse order, starting from derived class. + if (object->isWidgetType() && qobject_cast<WidgetDataBase *>(core->widgetDataBase())) { + const QDesignerWidgetDataBaseInterface *db = core->widgetDataBase(); + const QString promotedClassName = promotedCustomClassName(core, static_cast<QWidget *>(object)); + const int index = db->indexOfClassName(promotedClassName); + if (index >= 0) { + Methods methods; + WidgetDataBaseItem* item = static_cast<WidgetDataBaseItem*>(db->item(index)); + const QStringList fakeSignals = item->fakeSignals(); + for (const QString &fakeSignal : fakeSignals) + methods.append(SelectSignalDialog::Method(promotedClassName, fakeSignal)); + appendClass(promotedClassName, methods, m_model); + } + } + + // fake signals + if (qdesigner_internal::MetaDataBase *metaDataBase + = qobject_cast<qdesigner_internal::MetaDataBase *>(core->metaDataBase())) { + Methods methods; + qdesigner_internal::MetaDataBaseItem *item = metaDataBase->metaDataBaseItem(object); + Q_ASSERT(item); + const QStringList fakeSignals = item->fakeSignals(); + for (const QString &fakeSignal : fakeSignals) + methods.append(SelectSignalDialog::Method(item->customClassName(), fakeSignal)); + appendClass(item->customClassName(), methods, m_model); + } + + // "real" signals + if (const QDesignerMetaObjectInterface *metaObject = core->introspection()->metaObject(object)) { + QString lastClassName; + Methods methods; + for (int i = metaObject->methodCount() - 1; i >= 0; --i) { + const QDesignerMetaMethodInterface *metaMethod = metaObject->method(i); + if (metaMethod->methodType() == QDesignerMetaMethodInterface::Signal) { + const QString signature = metaMethod->signature(); + const QString className = declaredInClass(metaObject, signature); + if (lastClassName.isEmpty()) { + lastClassName = className; + } else if (className != lastClassName) { + appendClass(lastClassName, methods, m_model); + lastClassName = className; + methods.clear(); + } + methods.append(SelectSignalDialog::Method(className, signature, + metaMethod->parameterNames())); + } + } + appendClass(lastClassName, methods, m_model); + } +} + +void SelectSignalDialog::activated(const QModelIndex &index) +{ + if (methodFromIndex(index).isValid()) + m_okButton->animateClick(); +} + +void SelectSignalDialog::currentChanged(const QModelIndex ¤t, const QModelIndex &) +{ + m_okButton->setEnabled(methodFromIndex(current).isValid()); +} + +} // namespace qdesigner_internal + +QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/selectsignaldialog.ui b/src/designer/src/lib/shared/selectsignaldialog.ui index 99387dd2a..4228485c4 100644 --- a/src/designer/src/lib/shared/selectsignaldialog.ui +++ b/src/designer/src/lib/shared/selectsignaldialog.ui @@ -21,7 +21,7 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <widget class="QTreeWidget" name="signalList"> + <widget class="QTreeView" name="signalList"> <property name="sortingEnabled"> <bool>false</bool> </property> diff --git a/src/designer/src/lib/shared/selectsignaldialog_p.h b/src/designer/src/lib/shared/selectsignaldialog_p.h new file mode 100644 index 000000000..c29bfd60f --- /dev/null +++ b/src/designer/src/lib/shared/selectsignaldialog_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Designer 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$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of Qt Designer. This header +// file may change from version to version without notice, or even be removed. +// +// We mean it. +// + +#ifndef SELECTSIGNALDIALOG_H +#define SELECTSIGNALDIALOG_H + +#include <QtWidgets/QDialog> +#include <QtCore/QStringList> + +QT_BEGIN_NAMESPACE + +class QDesignerFormEditorInterface; +class QStandardItemModel; + +namespace Ui { class SelectSignalDialog; } + +namespace qdesigner_internal { + +class SelectSignalDialog : public QDialog +{ + Q_OBJECT +public: + struct Method + { + Method() {} + explicit Method(const QString &c, const QString &s, const QStringList &p = QStringList()) + : className(c), signature(s), parameterNames(p) {} + bool isValid() const { return !signature.isEmpty(); } + + QString className; + QString signature; + QStringList parameterNames; + }; + + explicit SelectSignalDialog(QWidget *parent = nullptr); + ~SelectSignalDialog(); + + Method selectedMethod() const; + + void populate(QDesignerFormEditorInterface *core, QObject *object, QString defaultSignal); + +private slots: + void currentChanged(const QModelIndex &, const QModelIndex &); + void activated(const QModelIndex &); + +private: + Method methodFromIndex(const QModelIndex &) const; + void populateModel(QDesignerFormEditorInterface *core, QObject *object); + + Ui::SelectSignalDialog *m_ui; + QPushButton *m_okButton; + QStandardItemModel *m_model; +}; + +} // namespace qdesigner_internal + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(qdesigner_internal::SelectSignalDialog::Method) + +#endif // SELECTSIGNALDIALOG_H diff --git a/src/designer/src/lib/shared/shared.pri b/src/designer/src/lib/shared/shared.pri index 229a607e3..99d52a4bf 100644 --- a/src/designer/src/lib/shared/shared.pri +++ b/src/designer/src/lib/shared/shared.pri @@ -107,7 +107,8 @@ HEADERS += \ $$PWD/shared_settings_p.h \ $$PWD/newformwidget_p.h \ $$PWD/plugindialog_p.h \ - $$PWD/rcc_p.h + $$PWD/rcc_p.h \ + $$PWD/selectsignaldialog_p.h SOURCES += \ $$PWD/spacer_widget.cpp \ @@ -183,7 +184,8 @@ SOURCES += \ $$PWD/shared_settings.cpp \ $$PWD/newformwidget.cpp \ $$PWD/plugindialog.cpp \ - $$PWD/rcc.cpp + $$PWD/rcc.cpp \ + $$PWD/selectsignaldialog.cpp RESOURCES += $$PWD/shared.qrc diff --git a/src/designer/src/lib/shared/signalslotdialog.cpp b/src/designer/src/lib/shared/signalslotdialog.cpp index a84adff07..2dd11f11b 100644 --- a/src/designer/src/lib/shared/signalslotdialog.cpp +++ b/src/designer/src/lib/shared/signalslotdialog.cpp @@ -42,13 +42,13 @@ #include <abstractdialoggui_p.h> #include <QtGui/QStandardItemModel> -#include <QtGui/QRegExpValidator> +#include <QtGui/QRegularExpressionValidator> #include <QtWidgets/QItemDelegate> #include <QtWidgets/QLineEdit> #include <QtWidgets/QApplication> #include <QtWidgets/QMessageBox> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> #include <QtCore/QDebug> QT_BEGIN_NAMESPACE @@ -125,8 +125,8 @@ namespace { void setModelData (QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE; private: - QRegExp m_signatureRegexp; - QRegExp m_methodNameRegexp; + const QRegularExpression m_signatureRegexp; + const QRegularExpression m_methodNameRegexp; }; SignatureDelegate::SignatureDelegate(QObject * parent) : @@ -143,7 +143,7 @@ namespace { QWidget *rc = QItemDelegate::createEditor(parent, option, index); QLineEdit *le = qobject_cast<QLineEdit *>(rc); Q_ASSERT(le); - le->setValidator(new QRegExpValidator(m_signatureRegexp, le)); + le->setValidator(new QRegularExpressionValidator(m_signatureRegexp, le)); return rc; } @@ -153,10 +153,8 @@ namespace { Q_ASSERT(le); // Did the user just type a name? .. Add parentheses QString signature = le->text(); - QRegExp signatureRegexp = m_signatureRegexp; - QRegExp methodNameRegexp = m_methodNameRegexp; - if (!signatureRegexp.exactMatch(signature )) { - if (methodNameRegexp.exactMatch(signature )) { + if (!m_signatureRegexp.match(signature).hasMatch()) { + if (m_methodNameRegexp.match(signature).hasMatch()) { signature += QStringLiteral("()"); le->setText(signature); } else { diff --git a/src/designer/src/lib/shared/spacer_widget_p.h b/src/designer/src/lib/shared/spacer_widget_p.h index 3858c644e..a982e99b0 100644 --- a/src/designer/src/lib/shared/spacer_widget_p.h +++ b/src/designer/src/lib/shared/spacer_widget_p.h @@ -54,7 +54,6 @@ class QDESIGNER_SHARED_EXPORT Spacer: public QWidget { Q_OBJECT - Q_ENUMS(SizeType) // Special hack: Make name appear as "spacer name" Q_PROPERTY(QString spacerName READ objectName WRITE setObjectName) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) diff --git a/src/designer/src/lib/shared/textpropertyeditor.cpp b/src/designer/src/lib/shared/textpropertyeditor.cpp index a1667d6e0..d24c06e68 100644 --- a/src/designer/src/lib/shared/textpropertyeditor.cpp +++ b/src/designer/src/lib/shared/textpropertyeditor.cpp @@ -31,11 +31,11 @@ #include "stylesheeteditor_p.h" #include <QtWidgets/QLineEdit> -#include <QtGui/QRegExpValidator> +#include <QtGui/QRegularExpressionValidator> #include <QtGui/QResizeEvent> #include <QtWidgets/QCompleter> #include <QtWidgets/QAbstractItemView> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> #include <QtCore/QUrl> #include <QtCore/QFile> #include <QtCore/QDebug> @@ -155,10 +155,11 @@ namespace { QUrl UrlValidator::guessUrlFromString(const QString &string) const { const QString urlStr = string.trimmed(); - QRegExp qualifiedUrl(QStringLiteral("^[a-zA-Z]+\\:.*")); + const QRegularExpression qualifiedUrl(QStringLiteral("^[a-zA-Z]+\\:.*$")); + Q_ASSERT(qualifiedUrl.isValid()); // Check if it looks like a qualified URL. Try parsing it and see. - const bool hasSchema = qualifiedUrl.exactMatch(urlStr); + const bool hasSchema = qualifiedUrl.match(urlStr).hasMatch(); if (hasSchema) { const QUrl url(urlStr, QUrl::TolerantMode); if (url.isValid()) @@ -252,11 +253,11 @@ namespace qdesigner_internal { m_lineEdit->setCompleter(0); break; case ValidationObjectName: - setRegExpValidator(QStringLiteral("[_a-zA-Z][_a-zA-Z0-9]{,1023}")); + setRegularExpressionValidator(QStringLiteral("^[_a-zA-Z][_a-zA-Z0-9]{1,1023}$")); m_lineEdit->setCompleter(0); break; case ValidationObjectNameScope: - setRegExpValidator(QStringLiteral("[_a-zA-Z:][_a-zA-Z0-9:]{,1023}")); + setRegularExpressionValidator(QStringLiteral("^[_a-zA-Z:][_a-zA-Z0-9:]{1,1023}$")); m_lineEdit->setCompleter(0); break; case ValidationURL: { @@ -284,11 +285,11 @@ namespace qdesigner_internal { markIntermediateState(); } - void TextPropertyEditor::setRegExpValidator(const QString &pattern) + void TextPropertyEditor::setRegularExpressionValidator(const QString &pattern) { - QRegExp regExp(pattern); + QRegularExpression regExp(pattern); Q_ASSERT(regExp.isValid()); - m_lineEdit->setValidator(new QRegExpValidator(regExp,m_lineEdit)); + m_lineEdit->setValidator(new QRegularExpressionValidator(regExp, m_lineEdit)); } QString TextPropertyEditor::text() const diff --git a/src/designer/src/lib/shared/textpropertyeditor_p.h b/src/designer/src/lib/shared/textpropertyeditor_p.h index a44e15143..c81b77f10 100644 --- a/src/designer/src/lib/shared/textpropertyeditor_p.h +++ b/src/designer/src/lib/shared/textpropertyeditor_p.h @@ -125,7 +125,7 @@ namespace qdesigner_internal { void slotEditingFinished(); private: - void setRegExpValidator(const QString &pattern); + void setRegularExpressionValidator(const QString &pattern); void markIntermediateState(); TextPropertyValidationMode m_validationMode; diff --git a/src/designer/src/lib/shared/widgetdatabase.cpp b/src/designer/src/lib/shared/widgetdatabase.cpp index 7abc5fadb..08726def9 100644 --- a/src/designer/src/lib/shared/widgetdatabase.cpp +++ b/src/designer/src/lib/shared/widgetdatabase.cpp @@ -47,7 +47,6 @@ #include <QtCore/qdebug.h> #include <QtCore/QMetaProperty> #include <QtCore/QTextStream> -#include <QtCore/QRegExp> #include <QtCore/QCoreApplication> QT_BEGIN_NAMESPACE @@ -648,7 +647,6 @@ QString WidgetDataBase::formTemplate(const QDesignerFormEditorInterface *core, c // Set a fixed size on a XML template QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, bool fixed) { - typedef QList<DomProperty*> PropertyList; DomUI *domUI = QDesignerWidgetBox::xmlToUi(QStringLiteral("Form"), xml, false); if (!domUI) return QString(); @@ -663,18 +661,17 @@ QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, DomProperty *minimumSizeProperty = 0; DomProperty *maximumSizeProperty = 0; - PropertyList properties = domWidget->elementProperty(); - const PropertyList::const_iterator cend = properties.constEnd(); - for (PropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) { - const QString name = (*it)->attributeName(); + auto properties = domWidget->elementProperty(); + for (DomProperty *p : properties) { + const QString name = p->attributeName(); if (name == geometryPropertyName) { - geomProperty = *it; + geomProperty = p; } else { if (name == minimumSizePropertyName) { - minimumSizeProperty = *it; + minimumSizeProperty = p; } else { if (name == maximumSizePropertyName) - maximumSizeProperty = *it; + maximumSizeProperty = p; } } } diff --git a/src/designer/src/lib/shared/zoomwidget.cpp b/src/designer/src/lib/shared/zoomwidget.cpp index 1fff6ed9c..12346955c 100644 --- a/src/designer/src/lib/shared/zoomwidget.cpp +++ b/src/designer/src/lib/shared/zoomwidget.cpp @@ -109,10 +109,11 @@ void ZoomMenu::slotZoomMenu(QAction *a) emit zoomChanged(zoomOf(a)); } -QList<int> ZoomMenu::zoomValues() +QVector<int> ZoomMenu::zoomValues() { - QList<int> rc; + QVector<int> rc; const int nz = sizeof(menuZoomList)/sizeof(int); + rc.reserve(nz); for (int i = 0; i < nz; i++) rc.push_back(menuZoomList[i]); return rc; diff --git a/src/designer/src/lib/shared/zoomwidget_p.h b/src/designer/src/lib/shared/zoomwidget_p.h index 50bbcf6bb..f9724a2ad 100644 --- a/src/designer/src/lib/shared/zoomwidget_p.h +++ b/src/designer/src/lib/shared/zoomwidget_p.h @@ -44,7 +44,7 @@ #include <QtWidgets/QGraphicsView> #include <QtWidgets/QGraphicsProxyWidget> -#include <QtCore/QList> +#include <QtCore/QVector> QT_BEGIN_NAMESPACE @@ -68,7 +68,7 @@ public: int zoom() const; // Return a list of available zoom values. - static QList<int> zoomValues(); + static QVector<int> zoomValues(); public slots: void setZoom(int percent); diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index 6607c9c2a..bc9f2b82e 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -313,18 +313,13 @@ QWidget *QAbstractFormBuilder::create(DomUI *ui, QWidget *parentWidget) void QAbstractFormBuilder::initialize(const DomUI *ui) { - typedef QList<DomCustomWidget*> DomCustomWidgetList; - DomCustomWidgets *domCustomWidgets = ui->elementCustomWidgets(); createCustomWidgets(domCustomWidgets); if (domCustomWidgets) { - const DomCustomWidgetList customWidgets = domCustomWidgets->elementCustomWidget(); - if (!customWidgets.empty()) { - const DomCustomWidgetList::const_iterator cend = customWidgets.constEnd(); - for (DomCustomWidgetList::const_iterator it = customWidgets.constBegin(); it != cend; ++it) - d->storeCustomWidgetData((*it)->elementClass(), *it); - } + const auto &customWidgets = domCustomWidgets->elementCustomWidget(); + for (const DomCustomWidget *w : customWidgets) + d->storeCustomWidgetData(w->elementClass(), w); } } @@ -339,20 +334,20 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge applyProperties(w, ui_widget->elementProperty()); - const QList<DomAction *> &elementAction = ui_widget->elementAction(); + const auto &elementAction = ui_widget->elementAction(); for (DomAction *ui_action : elementAction) { QAction *child_action = create(ui_action, w); Q_UNUSED( child_action ); } - const QList<DomActionGroup *> &elementActionGroup = ui_widget->elementActionGroup(); + const auto &elementActionGroup = ui_widget->elementActionGroup(); for (DomActionGroup *ui_action_group : elementActionGroup) { QActionGroup *child_action_group = create(ui_action_group, w); Q_UNUSED( child_action_group ); } QWidgetList children; - const QList<DomWidget *> &elementWidget = ui_widget->elementWidget(); + const auto &elementWidget = ui_widget->elementWidget(); for (DomWidget *ui_child : elementWidget) { if (QWidget *child = create(ui_child, w)) { children += child; @@ -362,13 +357,13 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge } } - const QList<DomLayout *> &elementLayout = ui_widget->elementLayout(); + const auto &elementLayout = ui_widget->elementLayout(); for (DomLayout *ui_lay : elementLayout) { QLayout *child_lay = create(ui_lay, 0, w); Q_UNUSED( child_lay ); } - const QList<DomActionRef *> addActions = ui_widget->elementAddAction(); + const auto &addActions = ui_widget->elementAddAction(); if (!addActions.empty()) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); for (DomActionRef *ui_action_ref : addActions) { @@ -397,7 +392,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge const QStringList zOrderNames = ui_widget->elementZOrder(); if (!zOrderNames.isEmpty()) { - QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(w->property("_q_zOrder")); + QWidgetList zOrder = qvariant_cast<QWidgetList>(w->property("_q_zOrder")); for (const QString &widgetName : zOrderNames) { if (QWidget *child = w->findChild<QWidget*>(widgetName)) { if (child->parentWidget() == w) { @@ -438,13 +433,13 @@ QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObj d->m_actionGroups.insert(ui_action_group->attributeName(), a); applyProperties(a, ui_action_group->elementProperty()); - const QList<DomAction*> &elementAction = ui_action_group->elementAction(); + const auto &elementAction = ui_action_group->elementAction(); for (DomAction *ui_action : elementAction) { QAction *child_action = create(ui_action, a); Q_UNUSED( child_action ); } - const QList<DomActionGroup *> &elementActionGroup = ui_action_group->elementActionGroup(); + const auto &elementActionGroup = ui_action_group->elementActionGroup(); for (DomActionGroup *g : elementActionGroup) { QActionGroup *child_action_group = create(g, parent); Q_UNUSED( child_action_group ); @@ -680,7 +675,7 @@ void QAbstractFormBuilder::layoutInfo(DomLayout *ui_layout, QObject *parent, int spac = INT_MIN; if (mar == INT_MIN || spac == INT_MIN) { - QList<DomProperty *> properties = ui_layout->elementProperty(); + auto properties = ui_layout->elementProperty(); for (auto it = properties.begin(); it != properties.end(); ) { DomProperty *prop = *it; if ((mar == INT_MIN && prop->attributeName() == strings.marginProperty) @@ -784,7 +779,7 @@ QLayout *QAbstractFormBuilder::create(DomLayout *ui_layout, QLayout *parentLayou applyProperties(layout, ui_layout->elementProperty()); - const QList<DomLayoutItem *> &elementItem = ui_layout->elementItem(); + const auto &elementItem = ui_layout->elementItem(); for (DomLayoutItem *ui_item : elementItem) { if (QLayoutItem *item = create(ui_item, layout, parentWidget)) { addItem(ui_item, item, layout); @@ -951,7 +946,7 @@ QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout bool isVspacer = false; const DomSpacer *ui_spacer = ui_layoutItem->elementSpacer(); - const QList<DomProperty *> spacerProperties = ui_spacer->elementProperty(); + const auto &spacerProperties = ui_spacer->elementProperty(); if (!spacerProperties.empty()) { const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); for (DomProperty *p : spacerProperties) { @@ -991,16 +986,10 @@ QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout */ void QAbstractFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { - typedef QList<DomProperty*> DomPropertyList; - - if (properties.empty()) - return; - - const DomPropertyList::const_iterator cend = properties.constEnd(); - for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) { - const QVariant v = toVariant(o->metaObject(), *it); + for (DomProperty *p : properties) { + const QVariant v = toVariant(o->metaObject(), p); if (!v.isNull()) { - QString attributeName = (*it)->attributeName(); + QString attributeName = p->attributeName(); if (attributeName == QLatin1String("numDigits") && o->inherits("QLCDNumber")) // Deprecated in Qt 4, removed in Qt 5. attributeName = QLatin1String("digitCount"); if (!d->applyPropertyInternally(o, attributeName, v)) @@ -1037,7 +1026,7 @@ void QAbstractFormBuilder::setupColorGroup(QPalette &palette, QPalette::ColorGro DomColorGroup *group) { // old format - const QList<DomColor*> colors = group->elementColor(); + const auto &colors = group->elementColor(); for (int role = 0; role < colors.size(); ++role) { const DomColor *color = colors.at(role); const QColor c(color->elementRed(), color->elementGreen(), color->elementBlue()); @@ -1047,7 +1036,7 @@ void QAbstractFormBuilder::setupColorGroup(QPalette &palette, QPalette::ColorGro // new format const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole"); - const QList<DomColorRole*> colorRoles = group->elementColorRole(); + const auto colorRoles = group->elementColorRole(); for (int role = 0; role < colorRoles.size(); ++role) { const DomColorRole *colorRole = colorRoles.at(role); @@ -1070,7 +1059,7 @@ DomColorGroup *QAbstractFormBuilder::saveColorGroup(const QPalette &palette) const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole"); DomColorGroup *group = new DomColorGroup(); - QList<DomColorRole*> colorRoles; + QVector<DomColorRole *> colorRoles; const uint mask = palette.resolve(); for (int role = QPalette::WindowText; role < QPalette::NColorRoles; ++role) { @@ -1132,7 +1121,7 @@ QBrush QAbstractFormBuilder::setupBrush(DomBrush *brush) const QGradient::CoordinateMode coord = enumKeyToValue<QGradient::CoordinateMode>(gradientCoordinate_enum, gradient->attributeCoordinateMode().toLatin1()); gr->setCoordinateMode(coord); - const QList<DomGradientStop *> stops = gradient->elementGradientStop(); + const auto &stops = gradient->elementGradientStop(); for (const DomGradientStop *stop : stops) { const DomColor *color = stop->elementColor(); gr->setColorAt(stop->attributePosition(), QColor::fromRgb(color->elementRed(), @@ -1177,7 +1166,7 @@ DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br) gradient->setAttributeType(QLatin1String(gradientType_enum.valueToKey(type))); gradient->setAttributeSpread(QLatin1String(gradientSpread_enum.valueToKey(gr->spread()))); gradient->setAttributeCoordinateMode(QLatin1String(gradientCoordinate_enum.valueToKey(gr->coordinateMode()))); - QList<DomGradientStop *> stops; + QVector<DomGradientStop *> stops; const QGradientStops st = gr->stops(); for (const QGradientStop &pair : st) { DomGradientStop *stop = new DomGradientStop(); @@ -1351,7 +1340,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent if (recursive) { if (QLayout *layout = widget->layout()) { if (DomLayout *ui_layout = createDom(layout, 0, ui_parentWidget)) { - QList<DomLayout*> ui_layouts; + QVector<DomLayout *> ui_layouts; ui_layouts.append(ui_layout); ui_widget->setElementLayout(ui_layouts); @@ -1360,11 +1349,11 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } // widgets, actions and action groups - QList<DomWidget*> ui_widgets; - QList<DomAction*> ui_actions; - QList<DomActionGroup*> ui_action_groups; + QVector<DomWidget *> ui_widgets; + QVector<DomAction *> ui_actions; + QVector<DomActionGroup *> ui_action_groups; - QList<QObject*> children; + QObjectList children; // splitters need to store their children in the order specified by child indexes, // not the order of the child list. @@ -1376,9 +1365,9 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } else #endif { - QList<QObject *> childObjects = widget->children(); + QObjectList childObjects = widget->children(); - const QList<QWidget *> list = qvariant_cast<QWidgetList>(widget->property("_q_widgetOrder")); + const QWidgetList list = qvariant_cast<QWidgetList>(widget->property("_q_widgetOrder")); for (QWidget *w : list) { if (childObjects.contains(w)) { children.append(w); @@ -1387,7 +1376,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } children += childObjects; - const QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(widget->property("_q_zOrder")); + const QWidgetList zOrder = qvariant_cast<QWidgetList>(widget->property("_q_zOrder")); if (list != zOrder) { QStringList zOrderList; zOrderList.reserve(zOrder.size()); @@ -1432,8 +1421,9 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } // add-action - QList<DomActionRef*> ui_action_refs; + QVector<DomActionRef *> ui_action_refs; const QList<QAction *> &actions = widget->actions(); + ui_action_refs.reserve(actions.size()); for (QAction *action : actions) { if (DomActionRef *ui_action_ref = createActionRefDom(action)) { ui_action_refs.append(ui_action_ref); @@ -1585,7 +1575,8 @@ DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout newList = saveLayoutEntries(layout); } - QList<DomLayoutItem*> ui_items; + QVector<DomLayoutItem *> ui_items; + ui_items.reserve(newList.size()); for (const FormBuilderSaveLayoutEntry &item : qAsConst(newList)) { if (DomLayoutItem *ui_item = createDom(item.item, lay, ui_parentWidget)) { if (item.row >= 0) @@ -1832,7 +1823,7 @@ DomButtonGroups *QAbstractFormBuilder::saveButtonGroups(const QWidget *mainConta const QObjectList mchildren = mainContainer->children(); if (mchildren.empty()) return 0; - QList<DomButtonGroup*> domGroups; + QVector<DomButtonGroup *> domGroups; const QObjectList::const_iterator cend = mchildren.constEnd(); for (QObjectList::const_iterator it = mchildren.constBegin(); it != cend; ++it) if (QButtonGroup *bg = qobject_cast<QButtonGroup *>(*it)) @@ -1956,7 +1947,7 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW { Q_UNUSED(ui_parentWidget); - QList<DomColumn*> columns; + QVector<DomColumn *> columns; DomProperty *p; QVariant v; const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); @@ -1995,7 +1986,7 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW ui_widget->setElementColumn(columns); - QList<DomItem *> items = ui_widget->elementItem(); + auto items = ui_widget->elementItem(); QQueue<QPair<QTreeWidgetItem *, DomItem *> > pendingQueue; for (int i = 0; i < treeWidget->topLevelItemCount(); i++) @@ -2026,7 +2017,7 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW currentDomItem->setElementProperty(properties); if (parentDomItem) { - QList<DomItem *> childrenItems = parentDomItem->elementItem(); + auto childrenItems = parentDomItem->elementItem(); childrenItems.append(currentDomItem); parentDomItem->setElementItem(childrenItems); } else @@ -2047,7 +2038,7 @@ void QAbstractFormBuilder::saveTableWidgetExtraInfo(QTableWidget *tableWidget, D Q_UNUSED(ui_parentWidget); // save the horizontal header - QList<DomColumn*> columns; + QVector<DomColumn *> columns; for (int c = 0; c < tableWidget->columnCount(); c++) { QList<DomProperty*> properties; QTableWidgetItem *item = tableWidget->horizontalHeaderItem(c); @@ -2061,7 +2052,7 @@ void QAbstractFormBuilder::saveTableWidgetExtraInfo(QTableWidget *tableWidget, D ui_widget->setElementColumn(columns); // save the vertical header - QList<DomRow*> rows; + QVector<DomRow *> rows; for (int r = 0; r < tableWidget->rowCount(); r++) { QList<DomProperty*> properties; QTableWidgetItem *item = tableWidget->verticalHeaderItem(r); @@ -2074,7 +2065,7 @@ void QAbstractFormBuilder::saveTableWidgetExtraInfo(QTableWidget *tableWidget, D } ui_widget->setElementRow(rows); - QList<DomItem *> items = ui_widget->elementItem(); + auto items = ui_widget->elementItem(); for (int r = 0; r < tableWidget->rowCount(); r++) for (int c = 0; c < tableWidget->columnCount(); c++) { QTableWidgetItem *item = tableWidget->item(r, c); @@ -2100,7 +2091,7 @@ void QAbstractFormBuilder::saveListWidgetExtraInfo(QListWidget *listWidget, DomW { Q_UNUSED(ui_parentWidget); - QList<DomItem*> ui_items = ui_widget->elementItem(); + auto ui_items = ui_widget->elementItem(); for (int i=0; i<listWidget->count(); ++i) { QList<DomProperty*> properties; storeItemPropsNFlags(this, listWidget->item(i), &properties); @@ -2119,7 +2110,7 @@ void QAbstractFormBuilder::saveListWidgetExtraInfo(QListWidget *listWidget, DomW void QAbstractFormBuilder::saveComboBoxExtraInfo(QComboBox *comboBox, DomWidget *ui_widget, DomWidget *ui_parentWidget) { Q_UNUSED(ui_parentWidget); - QList<DomItem*> ui_items = ui_widget->elementItem(); + auto ui_items = ui_widget->elementItem(); const int count = comboBox->count(); for (int i=0; i < count; ++i) { @@ -2185,8 +2176,8 @@ void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemVi << QStringLiteral("stretchLastSection")); if (const QTreeView *treeView = qobject_cast<const QTreeView*>(itemView)) { - QList<DomProperty*> viewProperties = ui_widget->elementAttribute(); - const QList<DomProperty*> &headerProperties = computeProperties(treeView->header()); + auto viewProperties = ui_widget->elementAttribute(); + const auto &headerProperties = computeProperties(treeView->header()); for (const QString &realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); @@ -2204,13 +2195,11 @@ void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemVi (QStringList() << QStringLiteral("horizontalHeader") << QStringLiteral("verticalHeader")); - QList<DomProperty*> viewProperties = ui_widget->elementAttribute(); + auto viewProperties = ui_widget->elementAttribute(); for (const QString &headerPrefix : headerPrefixes) { - QList<DomProperty*> headerProperties; - if (headerPrefix == QStringLiteral("horizontalHeader")) - headerProperties = computeProperties(tableView->horizontalHeader()); - else - headerProperties = computeProperties(tableView->verticalHeader()); + const auto &headerProperties = headerPrefix == QStringLiteral("horizontalHeader") + ? computeProperties(tableView->horizontalHeader()) + : computeProperties(tableView->verticalHeader()); for (const QString &realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); @@ -2298,7 +2287,7 @@ void QAbstractFormBuilder::loadListWidgetExtraInfo(DomWidget *ui_widget, QListWi Q_UNUSED(parentWidget); const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - const QList<DomItem *> &elementItem = ui_widget->elementItem(); + const auto &elementItem = ui_widget->elementItem(); for (DomItem *ui_item : elementItem) { const DomPropertyHash properties = propertyMap(ui_item->elementProperty()); QListWidgetItem *item = new QListWidgetItem(listWidget); @@ -2318,7 +2307,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi Q_UNUSED(parentWidget); const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags"); - const QList<DomColumn*> columns = ui_widget->elementColumn(); + const auto &columns = ui_widget->elementColumn(); if (columns.count() > 0) treeWidget->setColumnCount(columns.count()); @@ -2351,7 +2340,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi } QQueue<QPair<DomItem *, QTreeWidgetItem *> > pendingQueue; - const QList<DomItem *> &widgetElementItem = ui_widget->elementItem(); + const auto &widgetElementItem = ui_widget->elementItem(); for (DomItem *ui_item : widgetElementItem) pendingQueue.enqueue(qMakePair(ui_item, nullptr)); @@ -2367,7 +2356,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi else currentItem = new QTreeWidgetItem(treeWidget); - const QList<DomProperty *> properties = domItem->elementProperty(); + const auto &properties = domItem->elementProperty(); int col = -1; for (DomProperty *property : properties) { if (property->attributeName() == strings.flagsAttribute && !property->elementSet().isEmpty()) { @@ -2407,7 +2396,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi } } - const QList<DomItem *> &elementItem = domItem->elementItem(); + const auto &elementItem = domItem->elementItem(); for (DomItem *childItem : elementItem) pendingQueue.enqueue(qMakePair(childItem, currentItem)); @@ -2421,7 +2410,7 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable { Q_UNUSED(parentWidget); - const QList<DomColumn*> columns = ui_widget->elementColumn(); + const auto &columns = ui_widget->elementColumn(); if (columns.count() > 0) tableWidget->setColumnCount(columns.count()); for (int i = 0; i< columns.count(); i++) { @@ -2435,7 +2424,7 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable } } - const QList<DomRow*> rows = ui_widget->elementRow(); + const auto &rows = ui_widget->elementRow(); if (rows.count() > 0) tableWidget->setRowCount(rows.count()); for (int i = 0; i< rows.count(); i++) { @@ -2449,7 +2438,7 @@ void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTable } } - const QList<DomItem *> &elementItem = ui_widget->elementItem(); + const auto &elementItem = ui_widget->elementItem(); for (DomItem *ui_item : elementItem) { if (ui_item->hasAttributeRow() && ui_item->hasAttributeColumn()) { const DomPropertyHash properties = propertyMap(ui_item->elementProperty()); @@ -2467,7 +2456,7 @@ void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox { Q_UNUSED(parentWidget); const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - const QList<DomItem *> &elementItem = ui_widget->elementItem(); + const auto &elementItem = ui_widget->elementItem(); for (DomItem *ui_item : elementItem) { const DomPropertyHash properties = propertyMap(ui_item->elementProperty()); QString text; @@ -2502,15 +2491,14 @@ void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox // Get the button group name out of a widget's attribute list static QString buttonGroupName(const DomWidget *ui_widget) { - typedef QList<DomProperty*> DomPropertyList; - const DomPropertyList attributes = ui_widget->elementAttribute(); + const auto &attributes = ui_widget->elementAttribute(); if (attributes.empty()) return QString(); const QString buttonGroupProperty = QLatin1String(buttonGroupPropertyC); - const DomPropertyList::const_iterator cend = attributes.constEnd(); - for (DomPropertyList::const_iterator it = attributes.constBegin(); it != cend; ++it) - if ( (*it)->attributeName() == buttonGroupProperty) - return (*it)->elementString()->text(); + for (const DomProperty *p : attributes) { + if (p->attributeName() == buttonGroupProperty) + return p->elementString()->text(); + } return QString(); } @@ -2565,8 +2553,8 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract << QStringLiteral("stretchLastSection")); if (QTreeView *treeView = qobject_cast<QTreeView*>(itemView)) { - const QList<DomProperty*> &allAttributes = ui_widget->elementAttribute(); - QList<DomProperty*> headerProperties; + const auto &allAttributes = ui_widget->elementAttribute(); + QList<DomProperty *> headerProperties; for (const QString &realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); @@ -2584,7 +2572,7 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract (QStringList() << QStringLiteral("horizontalHeader") << QStringLiteral("verticalHeader")); - const QList<DomProperty*> allAttributes = ui_widget->elementAttribute(); + const auto &allAttributes = ui_widget->elementAttribute(); for (const QString &headerPrefix : headerPrefixes) { QList<DomProperty*> headerProperties; for (const QString &realPropertyName : realPropertyNames) { @@ -2691,8 +2679,7 @@ DomAction *QAbstractFormBuilder::createDom(QAction *action) DomAction *ui_action = new DomAction; ui_action->setAttributeName(action->objectName()); - const QList<DomProperty*> properties = computeProperties(action); - ui_action->setElementProperty(properties); + ui_action->setElementProperty(computeProperties(action)); return ui_action; } @@ -2709,8 +2696,7 @@ DomButtonGroup *QAbstractFormBuilder::createDom(QButtonGroup *buttonGroup) DomButtonGroup *domButtonGroup = new DomButtonGroup; domButtonGroup->setAttributeName(buttonGroup->objectName()); - QList<DomProperty*> properties = computeProperties(buttonGroup); - domButtonGroup->setElementProperty(properties); + domButtonGroup->setElementProperty(computeProperties(buttonGroup)); return domButtonGroup; } @@ -2722,12 +2708,12 @@ DomActionGroup *QAbstractFormBuilder::createDom(QActionGroup *actionGroup) DomActionGroup *ui_action_group = new DomActionGroup; ui_action_group->setAttributeName(actionGroup->objectName()); - QList<DomProperty*> properties = computeProperties(actionGroup); - ui_action_group->setElementProperty(properties); + ui_action_group->setElementProperty(computeProperties(actionGroup)); - QList<DomAction*> ui_actions; + QVector<DomAction *> ui_actions; const QList<QAction *> &actions = actionGroup->actions(); + ui_actions.reserve(actions.size()); for (QAction *action : actions) { if (DomAction *ui_action = createDom(action)) { ui_actions.append(ui_action); diff --git a/src/designer/src/lib/uilib/formbuilder.cpp b/src/designer/src/lib/uilib/formbuilder.cpp index c90c6b0a1..0ca5f3124 100644 --- a/src/designer/src/lib/uilib/formbuilder.cpp +++ b/src/designer/src/lib/uilib/formbuilder.cpp @@ -314,28 +314,23 @@ static QObject *objectByName(QWidget *topLevel, const QString &name) */ void QFormBuilder::createConnections(DomConnections *ui_connections, QWidget *widget) { - typedef QList<DomConnection*> DomConnectionList; Q_ASSERT(widget != 0); if (ui_connections == 0) return; - const DomConnectionList connections = ui_connections->elementConnection(); - if (!connections.empty()) { - const DomConnectionList::const_iterator cend = connections.constEnd(); - for (DomConnectionList::const_iterator it = connections.constBegin(); it != cend; ++it) { - - QObject *sender = objectByName(widget, (*it)->elementSender()); - QObject *receiver = objectByName(widget, (*it)->elementReceiver()); - if (!sender || !receiver) - continue; + const auto &connections = ui_connections->elementConnection(); + for (const DomConnection *c : connections) { + QObject *sender = objectByName(widget, c->elementSender()); + QObject *receiver = objectByName(widget, c->elementReceiver()); + if (!sender || !receiver) + continue; - QByteArray sig = (*it)->elementSignal().toUtf8(); - sig.prepend("2"); - QByteArray sl = (*it)->elementSlot().toUtf8(); - sl.prepend("1"); - QObject::connect(sender, sig, receiver, sl); - } + QByteArray sig = c->elementSignal().toUtf8(); + sig.prepend("2"); + QByteArray sl = c->elementSlot().toUtf8(); + sl.prepend("1"); + QObject::connect(sender, sig, receiver, sl); } } @@ -514,20 +509,18 @@ QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { - typedef QList<DomProperty*> DomPropertyList; if (properties.empty()) return; const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - const DomPropertyList::const_iterator cend = properties.constEnd(); - for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) { - const QVariant v = toVariant(o->metaObject(), *it); + for (DomProperty *p : properties) { + const QVariant v = toVariant(o->metaObject(), p); if (!v.isValid()) // QTBUG-33130, do not fall for QVariant(QString()).isNull() == true. continue; - const QString attributeName = (*it)->attributeName(); + const QString attributeName = p->attributeName(); const bool isWidget = o->isWidgetType(); if (isWidget && o->parent() == d->parentWidget() && attributeName == strings.geometryProperty) { // apply only the size part of a geometry for the root widget diff --git a/src/designer/src/lib/uilib/formbuilderextra.cpp b/src/designer/src/lib/uilib/formbuilderextra.cpp index 17b00bb7e..b43104d27 100644 --- a/src/designer/src/lib/uilib/formbuilderextra.cpp +++ b/src/designer/src/lib/uilib/formbuilderextra.cpp @@ -250,13 +250,9 @@ void QFormBuilderExtra::clearTextBuilder() void QFormBuilderExtra::registerButtonGroups(const DomButtonGroups *domGroups) { - typedef QList<DomButtonGroup*> DomButtonGroupList; - const DomButtonGroupList domGroupList = domGroups->elementButtonGroup(); - const DomButtonGroupList::const_iterator cend = domGroupList.constEnd(); - for (DomButtonGroupList::const_iterator it = domGroupList.constBegin(); it != cend; ++it) { - DomButtonGroup *domGroup = *it; - m_buttonGroups.insert(domGroup->attributeName(), ButtonGroupEntry(domGroup, 0)); - } + const auto &domGroupList = domGroups->elementButtonGroup(); + for (DomButtonGroup *domGroup : domGroupList) + m_buttonGroups.insert(domGroup->attributeName(), ButtonGroupEntry(domGroup, nullptr)); } // Utilities for parsing per-cell integer properties that have setters and diff --git a/src/designer/src/lib/uilib/ui4.cpp b/src/designer/src/lib/uilib/ui4.cpp index 060385b6f..d0ce3e5d6 100644 --- a/src/designer/src/lib/uilib/ui4.cpp +++ b/src/designer/src/lib/uilib/ui4.cpp @@ -51,71 +51,6 @@ using namespace QFormInternal; ** Implementations */ -void DomUI::clear(bool clear_all) -{ - delete m_widget; - delete m_layoutDefault; - delete m_layoutFunction; - delete m_customWidgets; - delete m_tabStops; - delete m_images; - delete m_includes; - delete m_resources; - delete m_connections; - delete m_designerdata; - delete m_slots; - delete m_buttonGroups; - - if (clear_all) { - m_text.clear(); - m_has_attr_version = false; - m_has_attr_language = false; - m_has_attr_displayname = false; - m_has_attr_stdsetdef = false; - m_attr_stdsetdef = 0; - m_has_attr_stdSetDef = false; - m_attr_stdSetDef = 0; - } - - m_children = 0; - m_widget = 0; - m_layoutDefault = 0; - m_layoutFunction = 0; - m_customWidgets = 0; - m_tabStops = 0; - m_images = 0; - m_includes = 0; - m_resources = 0; - m_connections = 0; - m_designerdata = 0; - m_slots = 0; - m_buttonGroups = 0; -} - -DomUI::DomUI() -{ - m_children = 0; - m_has_attr_version = false; - m_has_attr_language = false; - m_has_attr_displayname = false; - m_has_attr_stdsetdef = false; - m_attr_stdsetdef = 0; - m_has_attr_stdSetDef = false; - m_attr_stdSetDef = 0; - m_widget = 0; - m_layoutDefault = 0; - m_layoutFunction = 0; - m_customWidgets = 0; - m_tabStops = 0; - m_images = 0; - m_includes = 0; - m_resources = 0; - m_connections = 0; - m_designerdata = 0; - m_slots = 0; - m_buttonGroups = 0; -} - DomUI::~DomUI() { delete m_widget; @@ -123,7 +58,6 @@ DomUI::~DomUI() delete m_layoutFunction; delete m_customWidgets; delete m_tabStops; - delete m_images; delete m_includes; delete m_resources; delete m_connections; @@ -134,10 +68,9 @@ DomUI::~DomUI() void DomUI::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("version")) { setAttributeVersion(attribute.value().toString()); continue; @@ -161,97 +94,96 @@ void DomUI::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("author")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("author"), Qt::CaseInsensitive)) { setElementAuthor(reader.readElementText()); continue; } - if (tag == QLatin1String("comment")) { + if (!tag.compare(QLatin1String("comment"), Qt::CaseInsensitive)) { setElementComment(reader.readElementText()); continue; } - if (tag == QLatin1String("exportmacro")) { + if (!tag.compare(QLatin1String("exportmacro"), Qt::CaseInsensitive)) { setElementExportMacro(reader.readElementText()); continue; } - if (tag == QLatin1String("class")) { + if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { setElementClass(reader.readElementText()); continue; } - if (tag == QLatin1String("widget")) { + if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { DomWidget *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } - if (tag == QLatin1String("layoutdefault")) { + if (!tag.compare(QLatin1String("layoutdefault"), Qt::CaseInsensitive)) { DomLayoutDefault *v = new DomLayoutDefault(); v->read(reader); setElementLayoutDefault(v); continue; } - if (tag == QLatin1String("layoutfunction")) { + if (!tag.compare(QLatin1String("layoutfunction"), Qt::CaseInsensitive)) { DomLayoutFunction *v = new DomLayoutFunction(); v->read(reader); setElementLayoutFunction(v); continue; } - if (tag == QLatin1String("pixmapfunction")) { + if (!tag.compare(QLatin1String("pixmapfunction"), Qt::CaseInsensitive)) { setElementPixmapFunction(reader.readElementText()); continue; } - if (tag == QLatin1String("customwidgets")) { + if (!tag.compare(QLatin1String("customwidgets"), Qt::CaseInsensitive)) { DomCustomWidgets *v = new DomCustomWidgets(); v->read(reader); setElementCustomWidgets(v); continue; } - if (tag == QLatin1String("tabstops")) { + if (!tag.compare(QLatin1String("tabstops"), Qt::CaseInsensitive)) { DomTabStops *v = new DomTabStops(); v->read(reader); setElementTabStops(v); continue; } - if (tag == QLatin1String("images")) { - DomImages *v = new DomImages(); - v->read(reader); - setElementImages(v); + if (!tag.compare(QLatin1String("images"), Qt::CaseInsensitive)) { + qWarning("Omitting deprecated element <images>."); + reader.skipCurrentElement(); continue; } - if (tag == QLatin1String("includes")) { + if (!tag.compare(QLatin1String("includes"), Qt::CaseInsensitive)) { DomIncludes *v = new DomIncludes(); v->read(reader); setElementIncludes(v); continue; } - if (tag == QLatin1String("resources")) { + if (!tag.compare(QLatin1String("resources"), Qt::CaseInsensitive)) { DomResources *v = new DomResources(); v->read(reader); setElementResources(v); continue; } - if (tag == QLatin1String("connections")) { + if (!tag.compare(QLatin1String("connections"), Qt::CaseInsensitive)) { DomConnections *v = new DomConnections(); v->read(reader); setElementConnections(v); continue; } - if (tag == QLatin1String("designerdata")) { + if (!tag.compare(QLatin1String("designerdata"), Qt::CaseInsensitive)) { DomDesignerData *v = new DomDesignerData(); v->read(reader); setElementDesignerdata(v); continue; } - if (tag == QLatin1String("slots")) { + if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) { DomSlots *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } - if (tag == QLatin1String("buttongroups")) { + if (!tag.compare(QLatin1String("buttongroups"), Qt::CaseInsensitive)) { DomButtonGroups *v = new DomButtonGroups(); v->read(reader); setElementButtonGroups(v); @@ -261,12 +193,7 @@ void DomUI::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -275,7 +202,7 @@ void DomUI::read(QXmlStreamReader &reader) void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("ui") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("ui") : tagName.toLower()); if (hasAttributeVersion()) writer.writeAttribute(QStringLiteral("version"), attributeVersion()); @@ -292,284 +219,246 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeStdSetDef()) writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdSetDef())); - if (m_children & Author) { + if (m_children & Author) writer.writeTextElement(QStringLiteral("author"), m_author); - } - if (m_children & Comment) { + if (m_children & Comment) writer.writeTextElement(QStringLiteral("comment"), m_comment); - } - if (m_children & ExportMacro) { + if (m_children & ExportMacro) writer.writeTextElement(QStringLiteral("exportmacro"), m_exportMacro); - } - if (m_children & Class) { + if (m_children & Class) writer.writeTextElement(QStringLiteral("class"), m_class); - } - if (m_children & Widget) { + if (m_children & Widget) m_widget->write(writer, QStringLiteral("widget")); - } - if (m_children & LayoutDefault) { + if (m_children & LayoutDefault) m_layoutDefault->write(writer, QStringLiteral("layoutdefault")); - } - if (m_children & LayoutFunction) { + if (m_children & LayoutFunction) m_layoutFunction->write(writer, QStringLiteral("layoutfunction")); - } - if (m_children & PixmapFunction) { + if (m_children & PixmapFunction) writer.writeTextElement(QStringLiteral("pixmapfunction"), m_pixmapFunction); - } - if (m_children & CustomWidgets) { + if (m_children & CustomWidgets) m_customWidgets->write(writer, QStringLiteral("customwidgets")); - } - if (m_children & TabStops) { + if (m_children & TabStops) m_tabStops->write(writer, QStringLiteral("tabstops")); - } - if (m_children & Images) { - m_images->write(writer, QStringLiteral("images")); - } - - if (m_children & Includes) { + if (m_children & Includes) m_includes->write(writer, QStringLiteral("includes")); - } - if (m_children & Resources) { + if (m_children & Resources) m_resources->write(writer, QStringLiteral("resources")); - } - if (m_children & Connections) { + if (m_children & Connections) m_connections->write(writer, QStringLiteral("connections")); - } - if (m_children & Designerdata) { + if (m_children & Designerdata) m_designerdata->write(writer, QStringLiteral("designerdata")); - } - if (m_children & Slots) { + if (m_children & Slots) m_slots->write(writer, QStringLiteral("slots")); - } - if (m_children & ButtonGroups) { + if (m_children & ButtonGroups) m_buttonGroups->write(writer, QStringLiteral("buttongroups")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomUI::setElementAuthor(const QString& a) +void DomUI::setElementAuthor(const QString &a) { m_children |= Author; m_author = a; } -void DomUI::setElementComment(const QString& a) +void DomUI::setElementComment(const QString &a) { m_children |= Comment; m_comment = a; } -void DomUI::setElementExportMacro(const QString& a) +void DomUI::setElementExportMacro(const QString &a) { m_children |= ExportMacro; m_exportMacro = a; } -void DomUI::setElementClass(const QString& a) +void DomUI::setElementClass(const QString &a) { m_children |= Class; m_class = a; } -DomWidget* DomUI::takeElementWidget() +DomWidget *DomUI::takeElementWidget() { - DomWidget* a = m_widget; + DomWidget *a = m_widget; m_widget = 0; m_children ^= Widget; return a; } -void DomUI::setElementWidget(DomWidget* a) +void DomUI::setElementWidget(DomWidget *a) { delete m_widget; m_children |= Widget; m_widget = a; } -DomLayoutDefault* DomUI::takeElementLayoutDefault() +DomLayoutDefault *DomUI::takeElementLayoutDefault() { - DomLayoutDefault* a = m_layoutDefault; + DomLayoutDefault *a = m_layoutDefault; m_layoutDefault = 0; m_children ^= LayoutDefault; return a; } -void DomUI::setElementLayoutDefault(DomLayoutDefault* a) +void DomUI::setElementLayoutDefault(DomLayoutDefault *a) { delete m_layoutDefault; m_children |= LayoutDefault; m_layoutDefault = a; } -DomLayoutFunction* DomUI::takeElementLayoutFunction() +DomLayoutFunction *DomUI::takeElementLayoutFunction() { - DomLayoutFunction* a = m_layoutFunction; + DomLayoutFunction *a = m_layoutFunction; m_layoutFunction = 0; m_children ^= LayoutFunction; return a; } -void DomUI::setElementLayoutFunction(DomLayoutFunction* a) +void DomUI::setElementLayoutFunction(DomLayoutFunction *a) { delete m_layoutFunction; m_children |= LayoutFunction; m_layoutFunction = a; } -void DomUI::setElementPixmapFunction(const QString& a) +void DomUI::setElementPixmapFunction(const QString &a) { m_children |= PixmapFunction; m_pixmapFunction = a; } -DomCustomWidgets* DomUI::takeElementCustomWidgets() +DomCustomWidgets *DomUI::takeElementCustomWidgets() { - DomCustomWidgets* a = m_customWidgets; + DomCustomWidgets *a = m_customWidgets; m_customWidgets = 0; m_children ^= CustomWidgets; return a; } -void DomUI::setElementCustomWidgets(DomCustomWidgets* a) +void DomUI::setElementCustomWidgets(DomCustomWidgets *a) { delete m_customWidgets; m_children |= CustomWidgets; m_customWidgets = a; } -DomTabStops* DomUI::takeElementTabStops() +DomTabStops *DomUI::takeElementTabStops() { - DomTabStops* a = m_tabStops; + DomTabStops *a = m_tabStops; m_tabStops = 0; m_children ^= TabStops; return a; } -void DomUI::setElementTabStops(DomTabStops* a) +void DomUI::setElementTabStops(DomTabStops *a) { delete m_tabStops; m_children |= TabStops; m_tabStops = a; } -DomImages* DomUI::takeElementImages() -{ - DomImages* a = m_images; - m_images = 0; - m_children ^= Images; - return a; -} - -void DomUI::setElementImages(DomImages* a) -{ - delete m_images; - m_children |= Images; - m_images = a; -} - -DomIncludes* DomUI::takeElementIncludes() +DomIncludes *DomUI::takeElementIncludes() { - DomIncludes* a = m_includes; + DomIncludes *a = m_includes; m_includes = 0; m_children ^= Includes; return a; } -void DomUI::setElementIncludes(DomIncludes* a) +void DomUI::setElementIncludes(DomIncludes *a) { delete m_includes; m_children |= Includes; m_includes = a; } -DomResources* DomUI::takeElementResources() +DomResources *DomUI::takeElementResources() { - DomResources* a = m_resources; + DomResources *a = m_resources; m_resources = 0; m_children ^= Resources; return a; } -void DomUI::setElementResources(DomResources* a) +void DomUI::setElementResources(DomResources *a) { delete m_resources; m_children |= Resources; m_resources = a; } -DomConnections* DomUI::takeElementConnections() +DomConnections *DomUI::takeElementConnections() { - DomConnections* a = m_connections; + DomConnections *a = m_connections; m_connections = 0; m_children ^= Connections; return a; } -void DomUI::setElementConnections(DomConnections* a) +void DomUI::setElementConnections(DomConnections *a) { delete m_connections; m_children |= Connections; m_connections = a; } -DomDesignerData* DomUI::takeElementDesignerdata() +DomDesignerData *DomUI::takeElementDesignerdata() { - DomDesignerData* a = m_designerdata; + DomDesignerData *a = m_designerdata; m_designerdata = 0; m_children ^= Designerdata; return a; } -void DomUI::setElementDesignerdata(DomDesignerData* a) +void DomUI::setElementDesignerdata(DomDesignerData *a) { delete m_designerdata; m_children |= Designerdata; m_designerdata = a; } -DomSlots* DomUI::takeElementSlots() +DomSlots *DomUI::takeElementSlots() { - DomSlots* a = m_slots; + DomSlots *a = m_slots; m_slots = 0; m_children ^= Slots; return a; } -void DomUI::setElementSlots(DomSlots* a) +void DomUI::setElementSlots(DomSlots *a) { delete m_slots; m_children |= Slots; m_slots = a; } -DomButtonGroups* DomUI::takeElementButtonGroups() +DomButtonGroups *DomUI::takeElementButtonGroups() { - DomButtonGroups* a = m_buttonGroups; + DomButtonGroups *a = m_buttonGroups; m_buttonGroups = 0; m_children ^= ButtonGroups; return a; } -void DomUI::setElementButtonGroups(DomButtonGroups* a) +void DomUI::setElementButtonGroups(DomButtonGroups *a) { delete m_buttonGroups; m_children |= ButtonGroups; @@ -636,13 +525,6 @@ void DomUI::clearElementTabStops() m_children &= ~TabStops; } -void DomUI::clearElementImages() -{ - delete m_images; - m_images = 0; - m_children &= ~Images; -} - void DomUI::clearElementIncludes() { delete m_includes; @@ -685,23 +567,6 @@ void DomUI::clearElementButtonGroups() m_children &= ~ButtonGroups; } -void DomIncludes::clear(bool clear_all) -{ - qDeleteAll(m_include); - m_include.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomIncludes::DomIncludes() -{ - m_children = 0; -} - DomIncludes::~DomIncludes() { qDeleteAll(m_include); @@ -710,12 +575,11 @@ DomIncludes::~DomIncludes() void DomIncludes::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("include")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { DomInclude *v = new DomInclude(); v->read(reader); m_include.append(v); @@ -725,12 +589,7 @@ void DomIncludes::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -739,54 +598,29 @@ void DomIncludes::read(QXmlStreamReader &reader) void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("includes") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("includes") : tagName.toLower()); - for (int i = 0; i < m_include.size(); ++i) { - DomInclude* v = m_include[i]; + for (DomInclude *v : m_include) v->write(writer, QStringLiteral("include")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomIncludes::setElementInclude(const QList<DomInclude*>& a) +void DomIncludes::setElementInclude(const QVector<DomInclude *> &a) { m_children |= Include; m_include = a; } -void DomInclude::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_location = false; - m_has_attr_impldecl = false; - } - - m_children = 0; -} - -DomInclude::DomInclude() -{ - m_children = 0; - m_has_attr_location = false; - m_has_attr_impldecl = false; - m_text.clear(); -} - DomInclude::~DomInclude() { } void DomInclude::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -798,16 +632,15 @@ void DomInclude::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; + return; case QXmlStreamReader::Characters : if (!reader.isWhitespace()) m_text.append(reader.text().toString()); @@ -820,7 +653,7 @@ void DomInclude::read(QXmlStreamReader &reader) void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("include") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("include") : tagName.toLower()); if (hasAttributeLocation()) writer.writeAttribute(QStringLiteral("location"), attributeLocation()); @@ -834,25 +667,6 @@ void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomResources::clear(bool clear_all) -{ - qDeleteAll(m_include); - m_include.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; -} - -DomResources::DomResources() -{ - m_children = 0; - m_has_attr_name = false; -} - DomResources::~DomResources() { qDeleteAll(m_include); @@ -861,10 +675,9 @@ DomResources::~DomResources() void DomResources::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -872,11 +685,11 @@ void DomResources::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("include")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("include"), Qt::CaseInsensitive)) { DomResource *v = new DomResource(); v->read(reader); m_include.append(v); @@ -886,12 +699,7 @@ void DomResources::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -900,54 +708,32 @@ void DomResources::read(QXmlStreamReader &reader) void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resources") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resources") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); - for (int i = 0; i < m_include.size(); ++i) { - DomResource* v = m_include[i]; + for (DomResource *v : m_include) v->write(writer, QStringLiteral("include")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomResources::setElementInclude(const QList<DomResource*>& a) +void DomResources::setElementInclude(const QVector<DomResource *> &a) { m_children |= Include; m_include = a; } -void DomResource::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_location = false; - } - - m_children = 0; -} - -DomResource::DomResource() -{ - m_children = 0; - m_has_attr_location = false; -} - DomResource::~DomResource() { } void DomResource::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -955,20 +741,15 @@ void DomResource::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -977,42 +758,14 @@ void DomResource::read(QXmlStreamReader &reader) void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resource") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resource") : tagName.toLower()); if (hasAttributeLocation()) writer.writeAttribute(QStringLiteral("location"), attributeLocation()); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomActionGroup::clear(bool clear_all) -{ - qDeleteAll(m_action); - m_action.clear(); - qDeleteAll(m_actionGroup); - m_actionGroup.clear(); - qDeleteAll(m_property); - m_property.clear(); - qDeleteAll(m_attribute); - m_attribute.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; -} - -DomActionGroup::DomActionGroup() -{ - m_children = 0; - m_has_attr_name = false; -} - DomActionGroup::~DomActionGroup() { qDeleteAll(m_action); @@ -1027,10 +780,9 @@ DomActionGroup::~DomActionGroup() void DomActionGroup::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -1038,29 +790,29 @@ void DomActionGroup::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("action")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { DomAction *v = new DomAction(); v->read(reader); m_action.append(v); continue; } - if (tag == QLatin1String("actiongroup")) { + if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) { DomActionGroup *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } - if (tag == QLatin1String("property")) { + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QLatin1String("attribute")) { + if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); @@ -1070,12 +822,7 @@ void DomActionGroup::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -1084,80 +831,50 @@ void DomActionGroup::read(QXmlStreamReader &reader) void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("actiongroup") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actiongroup") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); - for (int i = 0; i < m_action.size(); ++i) { - DomAction* v = m_action[i]; + for (DomAction *v : m_action) v->write(writer, QStringLiteral("action")); - } - for (int i = 0; i < m_actionGroup.size(); ++i) { - DomActionGroup* v = m_actionGroup[i]; + + for (DomActionGroup *v : m_actionGroup) v->write(writer, QStringLiteral("actiongroup")); - } - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - for (int i = 0; i < m_attribute.size(); ++i) { - DomProperty* v = m_attribute[i]; + + for (DomProperty *v : m_attribute) v->write(writer, QStringLiteral("attribute")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomActionGroup::setElementAction(const QList<DomAction*>& a) +void DomActionGroup::setElementAction(const QVector<DomAction *> &a) { m_children |= Action; m_action = a; } -void DomActionGroup::setElementActionGroup(const QList<DomActionGroup*>& a) +void DomActionGroup::setElementActionGroup(const QVector<DomActionGroup *> &a) { m_children |= ActionGroup; m_actionGroup = a; } -void DomActionGroup::setElementProperty(const QList<DomProperty*>& a) +void DomActionGroup::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomActionGroup::setElementAttribute(const QList<DomProperty*>& a) +void DomActionGroup::setElementAttribute(const QList<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; } -void DomAction::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - qDeleteAll(m_attribute); - m_attribute.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - m_has_attr_menu = false; - } - - m_children = 0; -} - -DomAction::DomAction() -{ - m_children = 0; - m_has_attr_name = false; - m_has_attr_menu = false; -} - DomAction::~DomAction() { qDeleteAll(m_property); @@ -1168,10 +885,9 @@ DomAction::~DomAction() void DomAction::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -1183,17 +899,17 @@ void DomAction::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QLatin1String("attribute")) { + if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); @@ -1203,12 +919,7 @@ void DomAction::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -1217,7 +928,7 @@ void DomAction::read(QXmlStreamReader &reader) void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("action") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("action") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); @@ -1225,59 +936,36 @@ void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeMenu()) writer.writeAttribute(QStringLiteral("menu"), attributeMenu()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - for (int i = 0; i < m_attribute.size(); ++i) { - DomProperty* v = m_attribute[i]; + + for (DomProperty *v : m_attribute) v->write(writer, QStringLiteral("attribute")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomAction::setElementProperty(const QList<DomProperty*>& a) +void DomAction::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomAction::setElementAttribute(const QList<DomProperty*>& a) +void DomAction::setElementAttribute(const QList<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; } -void DomActionRef::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; -} - -DomActionRef::DomActionRef() -{ - m_children = 0; - m_has_attr_name = false; -} - DomActionRef::~DomActionRef() { } void DomActionRef::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -1285,20 +973,15 @@ void DomActionRef::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -1307,38 +990,14 @@ void DomActionRef::read(QXmlStreamReader &reader) void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("actionref") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("actionref") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomButtonGroup::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - qDeleteAll(m_attribute); - m_attribute.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; -} - -DomButtonGroup::DomButtonGroup() -{ - m_children = 0; - m_has_attr_name = false; -} - DomButtonGroup::~DomButtonGroup() { qDeleteAll(m_property); @@ -1349,10 +1008,9 @@ DomButtonGroup::~DomButtonGroup() void DomButtonGroup::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -1360,17 +1018,17 @@ void DomButtonGroup::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QLatin1String("attribute")) { + if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); @@ -1380,12 +1038,7 @@ void DomButtonGroup::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -1394,54 +1047,32 @@ void DomButtonGroup::read(QXmlStreamReader &reader) void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("buttongroup") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroup") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - for (int i = 0; i < m_attribute.size(); ++i) { - DomProperty* v = m_attribute[i]; + + for (DomProperty *v : m_attribute) v->write(writer, QStringLiteral("attribute")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomButtonGroup::setElementProperty(const QList<DomProperty*>& a) +void DomButtonGroup::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomButtonGroup::setElementAttribute(const QList<DomProperty*>& a) +void DomButtonGroup::setElementAttribute(const QList<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; } -void DomButtonGroups::clear(bool clear_all) -{ - qDeleteAll(m_buttonGroup); - m_buttonGroup.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomButtonGroups::DomButtonGroups() -{ - m_children = 0; -} - DomButtonGroups::~DomButtonGroups() { qDeleteAll(m_buttonGroup); @@ -1450,12 +1081,11 @@ DomButtonGroups::~DomButtonGroups() void DomButtonGroups::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("buttongroup")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("buttongroup"), Qt::CaseInsensitive)) { DomButtonGroup *v = new DomButtonGroup(); v->read(reader); m_buttonGroup.append(v); @@ -1465,12 +1095,7 @@ void DomButtonGroups::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -1479,295 +1104,20 @@ void DomButtonGroups::read(QXmlStreamReader &reader) void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("buttongroups") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("buttongroups") : tagName.toLower()); - for (int i = 0; i < m_buttonGroup.size(); ++i) { - DomButtonGroup* v = m_buttonGroup[i]; + for (DomButtonGroup *v : m_buttonGroup) v->write(writer, QStringLiteral("buttongroup")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomButtonGroups::setElementButtonGroup(const QList<DomButtonGroup*>& a) +void DomButtonGroups::setElementButtonGroup(const QVector<DomButtonGroup *> &a) { m_children |= ButtonGroup; m_buttonGroup = a; } -void DomImages::clear(bool clear_all) -{ - qDeleteAll(m_image); - m_image.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomImages::DomImages() -{ - m_children = 0; -} - -DomImages::~DomImages() -{ - qDeleteAll(m_image); - m_image.clear(); -} - -void DomImages::read(QXmlStreamReader &reader) -{ - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("image")) { - DomImage *v = new DomImage(); - v->read(reader); - m_image.append(v); - continue; - } - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomImages::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("images") : tagName.toLower()); - - for (int i = 0; i < m_image.size(); ++i) { - DomImage* v = m_image[i]; - v->write(writer, QStringLiteral("image")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomImages::setElementImage(const QList<DomImage*>& a) -{ - m_children |= Image; - m_image = a; -} - -void DomImage::clear(bool clear_all) -{ - delete m_data; - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; - m_data = 0; -} - -DomImage::DomImage() -{ - m_children = 0; - m_has_attr_name = false; - m_data = 0; -} - -DomImage::~DomImage() -{ - delete m_data; -} - -void DomImage::read(QXmlStreamReader &reader) -{ - - const QXmlStreamAttributes attributes = reader.attributes(); - for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); - if (name == QLatin1String("name")) { - setAttributeName(attribute.value().toString()); - continue; - } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); - } - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("data")) { - DomImageData *v = new DomImageData(); - v->read(reader); - setElementData(v); - continue; - } - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomImage::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("image") : tagName.toLower()); - - if (hasAttributeName()) - writer.writeAttribute(QStringLiteral("name"), attributeName()); - - if (m_children & Data) { - m_data->write(writer, QStringLiteral("data")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -DomImageData* DomImage::takeElementData() -{ - DomImageData* a = m_data; - m_data = 0; - m_children ^= Data; - return a; -} - -void DomImage::setElementData(DomImageData* a) -{ - delete m_data; - m_children |= Data; - m_data = a; -} - -void DomImage::clearElementData() -{ - delete m_data; - m_data = 0; - m_children &= ~Data; -} - -void DomImageData::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_format = false; - m_has_attr_length = false; - m_attr_length = 0; - } - - m_children = 0; -} - -DomImageData::DomImageData() -{ - m_children = 0; - m_has_attr_format = false; - m_has_attr_length = false; - m_attr_length = 0; - m_text.clear(); -} - -DomImageData::~DomImageData() -{ -} - -void DomImageData::read(QXmlStreamReader &reader) -{ - - const QXmlStreamAttributes attributes = reader.attributes(); - for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); - if (name == QLatin1String("format")) { - setAttributeFormat(attribute.value().toString()); - continue; - } - if (name == QLatin1String("length")) { - setAttributeLength(attribute.value().toInt()); - continue; - } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); - } - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomImageData::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("imagedata") : tagName.toLower()); - - if (hasAttributeFormat()) - writer.writeAttribute(QStringLiteral("format"), attributeFormat()); - - if (hasAttributeLength()) - writer.writeAttribute(QStringLiteral("length"), QString::number(attributeLength())); - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomCustomWidgets::clear(bool clear_all) -{ - qDeleteAll(m_customWidget); - m_customWidget.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomCustomWidgets::DomCustomWidgets() -{ - m_children = 0; -} - DomCustomWidgets::~DomCustomWidgets() { qDeleteAll(m_customWidget); @@ -1776,12 +1126,11 @@ DomCustomWidgets::~DomCustomWidgets() void DomCustomWidgets::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("customwidget")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("customwidget"), Qt::CaseInsensitive)) { DomCustomWidget *v = new DomCustomWidget(); v->read(reader); m_customWidget.append(v); @@ -1791,12 +1140,7 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -1805,52 +1149,29 @@ void DomCustomWidgets::read(QXmlStreamReader &reader) void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("customwidgets") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidgets") : tagName.toLower()); - for (int i = 0; i < m_customWidget.size(); ++i) { - DomCustomWidget* v = m_customWidget[i]; + for (DomCustomWidget *v : m_customWidget) v->write(writer, QStringLiteral("customwidget")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget*>& a) +void DomCustomWidgets::setElementCustomWidget(const QVector<DomCustomWidget *> &a) { m_children |= CustomWidget; m_customWidget = a; } -void DomHeader::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_location = false; - } - - m_children = 0; -} - -DomHeader::DomHeader() -{ - m_children = 0; - m_has_attr_location = false; - m_text.clear(); -} - DomHeader::~DomHeader() { } void DomHeader::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("location")) { setAttributeLocation(attribute.value().toString()); continue; @@ -1858,16 +1179,15 @@ void DomHeader::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; + return; case QXmlStreamReader::Characters : if (!reader.isWhitespace()) m_text.append(reader.text().toString()); @@ -1880,7 +1200,7 @@ void DomHeader::read(QXmlStreamReader &reader) void DomHeader::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("header") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("header") : tagName.toLower()); if (hasAttributeLocation()) writer.writeAttribute(QStringLiteral("location"), attributeLocation()); @@ -1891,119 +1211,74 @@ void DomHeader::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomCustomWidget::clear(bool clear_all) -{ - delete m_header; - delete m_sizeHint; - delete m_sizePolicy; - delete m_script; - delete m_properties; - delete m_slots; - delete m_propertyspecifications; - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_header = 0; - m_sizeHint = 0; - m_container = 0; - m_sizePolicy = 0; - m_script = 0; - m_properties = 0; - m_slots = 0; - m_propertyspecifications = 0; -} - -DomCustomWidget::DomCustomWidget() -{ - m_children = 0; - m_header = 0; - m_sizeHint = 0; - m_container = 0; - m_sizePolicy = 0; - m_script = 0; - m_properties = 0; - m_slots = 0; - m_propertyspecifications = 0; -} - DomCustomWidget::~DomCustomWidget() { delete m_header; delete m_sizeHint; - delete m_sizePolicy; - delete m_script; - delete m_properties; delete m_slots; delete m_propertyspecifications; } void DomCustomWidget::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("class")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { setElementClass(reader.readElementText()); continue; } - if (tag == QLatin1String("extends")) { + if (!tag.compare(QLatin1String("extends"), Qt::CaseInsensitive)) { setElementExtends(reader.readElementText()); continue; } - if (tag == QLatin1String("header")) { + if (!tag.compare(QLatin1String("header"), Qt::CaseInsensitive)) { DomHeader *v = new DomHeader(); v->read(reader); setElementHeader(v); continue; } - if (tag == QLatin1String("sizehint")) { + if (!tag.compare(QLatin1String("sizehint"), Qt::CaseInsensitive)) { DomSize *v = new DomSize(); v->read(reader); setElementSizeHint(v); continue; } - if (tag == QLatin1String("addpagemethod")) { + if (!tag.compare(QLatin1String("addpagemethod"), Qt::CaseInsensitive)) { setElementAddPageMethod(reader.readElementText()); continue; } - if (tag == QLatin1String("container")) { + if (!tag.compare(QLatin1String("container"), Qt::CaseInsensitive)) { setElementContainer(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("sizepolicy")) { - DomSizePolicyData *v = new DomSizePolicyData(); - v->read(reader); - setElementSizePolicy(v); + if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) { + qWarning("Omitting deprecated element <sizepolicy>."); + reader.skipCurrentElement(); continue; } - if (tag == QLatin1String("pixmap")) { + if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) { setElementPixmap(reader.readElementText()); continue; } - if (tag == QLatin1String("script")) { - DomScript *v = new DomScript(); - v->read(reader); - setElementScript(v); + if (!tag.compare(QLatin1String("script"), Qt::CaseInsensitive)) { + qWarning("Omitting deprecated element <script>."); + reader.skipCurrentElement(); continue; } - if (tag == QLatin1String("properties")) { - DomProperties *v = new DomProperties(); - v->read(reader); - setElementProperties(v); + if (!tag.compare(QLatin1String("properties"), Qt::CaseInsensitive)) { + qWarning("Omitting deprecated element <properties>."); + reader.skipCurrentElement(); continue; } - if (tag == QLatin1String("slots")) { + if (!tag.compare(QLatin1String("slots"), Qt::CaseInsensitive)) { DomSlots *v = new DomSlots(); v->read(reader); setElementSlots(v); continue; } - if (tag == QLatin1String("propertyspecifications")) { + if (!tag.compare(QLatin1String("propertyspecifications"), Qt::CaseInsensitive)) { DomPropertySpecifications *v = new DomPropertySpecifications(); v->read(reader); setElementPropertyspecifications(v); @@ -2013,12 +1288,7 @@ void DomCustomWidget::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -2027,105 +1297,81 @@ void DomCustomWidget::read(QXmlStreamReader &reader) void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("customwidget") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("customwidget") : tagName.toLower()); - if (m_children & Class) { + if (m_children & Class) writer.writeTextElement(QStringLiteral("class"), m_class); - } - if (m_children & Extends) { + if (m_children & Extends) writer.writeTextElement(QStringLiteral("extends"), m_extends); - } - if (m_children & Header) { + if (m_children & Header) m_header->write(writer, QStringLiteral("header")); - } - if (m_children & SizeHint) { + if (m_children & SizeHint) m_sizeHint->write(writer, QStringLiteral("sizehint")); - } - if (m_children & AddPageMethod) { + if (m_children & AddPageMethod) writer.writeTextElement(QStringLiteral("addpagemethod"), m_addPageMethod); - } - if (m_children & Container) { + if (m_children & Container) writer.writeTextElement(QStringLiteral("container"), QString::number(m_container)); - } - - if (m_children & SizePolicy) { - m_sizePolicy->write(writer, QStringLiteral("sizepolicy")); - } - if (m_children & Pixmap) { + if (m_children & Pixmap) writer.writeTextElement(QStringLiteral("pixmap"), m_pixmap); - } - - if (m_children & Script) { - m_script->write(writer, QStringLiteral("script")); - } - if (m_children & Properties) { - m_properties->write(writer, QStringLiteral("properties")); - } - - if (m_children & Slots) { + if (m_children & Slots) m_slots->write(writer, QStringLiteral("slots")); - } - if (m_children & Propertyspecifications) { + if (m_children & Propertyspecifications) m_propertyspecifications->write(writer, QStringLiteral("propertyspecifications")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomCustomWidget::setElementClass(const QString& a) +void DomCustomWidget::setElementClass(const QString &a) { m_children |= Class; m_class = a; } -void DomCustomWidget::setElementExtends(const QString& a) +void DomCustomWidget::setElementExtends(const QString &a) { m_children |= Extends; m_extends = a; } -DomHeader* DomCustomWidget::takeElementHeader() +DomHeader *DomCustomWidget::takeElementHeader() { - DomHeader* a = m_header; + DomHeader *a = m_header; m_header = 0; m_children ^= Header; return a; } -void DomCustomWidget::setElementHeader(DomHeader* a) +void DomCustomWidget::setElementHeader(DomHeader *a) { delete m_header; m_children |= Header; m_header = a; } -DomSize* DomCustomWidget::takeElementSizeHint() +DomSize *DomCustomWidget::takeElementSizeHint() { - DomSize* a = m_sizeHint; + DomSize *a = m_sizeHint; m_sizeHint = 0; m_children ^= SizeHint; return a; } -void DomCustomWidget::setElementSizeHint(DomSize* a) +void DomCustomWidget::setElementSizeHint(DomSize *a) { delete m_sizeHint; m_children |= SizeHint; m_sizeHint = a; } -void DomCustomWidget::setElementAddPageMethod(const QString& a) +void DomCustomWidget::setElementAddPageMethod(const QString &a) { m_children |= AddPageMethod; m_addPageMethod = a; @@ -2137,81 +1383,36 @@ void DomCustomWidget::setElementContainer(int a) m_container = a; } -DomSizePolicyData* DomCustomWidget::takeElementSizePolicy() -{ - DomSizePolicyData* a = m_sizePolicy; - m_sizePolicy = 0; - m_children ^= SizePolicy; - return a; -} - -void DomCustomWidget::setElementSizePolicy(DomSizePolicyData* a) -{ - delete m_sizePolicy; - m_children |= SizePolicy; - m_sizePolicy = a; -} - -void DomCustomWidget::setElementPixmap(const QString& a) +void DomCustomWidget::setElementPixmap(const QString &a) { m_children |= Pixmap; m_pixmap = a; } -DomScript* DomCustomWidget::takeElementScript() -{ - DomScript* a = m_script; - m_script = 0; - m_children ^= Script; - return a; -} - -void DomCustomWidget::setElementScript(DomScript* a) -{ - delete m_script; - m_children |= Script; - m_script = a; -} - -DomProperties* DomCustomWidget::takeElementProperties() +DomSlots *DomCustomWidget::takeElementSlots() { - DomProperties* a = m_properties; - m_properties = 0; - m_children ^= Properties; - return a; -} - -void DomCustomWidget::setElementProperties(DomProperties* a) -{ - delete m_properties; - m_children |= Properties; - m_properties = a; -} - -DomSlots* DomCustomWidget::takeElementSlots() -{ - DomSlots* a = m_slots; + DomSlots *a = m_slots; m_slots = 0; m_children ^= Slots; return a; } -void DomCustomWidget::setElementSlots(DomSlots* a) +void DomCustomWidget::setElementSlots(DomSlots *a) { delete m_slots; m_children |= Slots; m_slots = a; } -DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications() +DomPropertySpecifications *DomCustomWidget::takeElementPropertyspecifications() { - DomPropertySpecifications* a = m_propertyspecifications; + DomPropertySpecifications *a = m_propertyspecifications; m_propertyspecifications = 0; m_children ^= Propertyspecifications; return a; } -void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications* a) +void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications *a) { delete m_propertyspecifications; m_children |= Propertyspecifications; @@ -2252,32 +1453,11 @@ void DomCustomWidget::clearElementContainer() m_children &= ~Container; } -void DomCustomWidget::clearElementSizePolicy() -{ - delete m_sizePolicy; - m_sizePolicy = 0; - m_children &= ~SizePolicy; -} - void DomCustomWidget::clearElementPixmap() { m_children &= ~Pixmap; } -void DomCustomWidget::clearElementScript() -{ - delete m_script; - m_script = 0; - m_children &= ~Script; -} - -void DomCustomWidget::clearElementProperties() -{ - delete m_properties; - m_properties = 0; - m_children &= ~Properties; -} - void DomCustomWidget::clearElementSlots() { delete m_slots; @@ -2292,272 +1472,15 @@ void DomCustomWidget::clearElementPropertyspecifications() m_children &= ~Propertyspecifications; } -void DomProperties::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomProperties::DomProperties() -{ - m_children = 0; -} - -DomProperties::~DomProperties() -{ - qDeleteAll(m_property); - m_property.clear(); -} - -void DomProperties::read(QXmlStreamReader &reader) -{ - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { - DomPropertyData *v = new DomPropertyData(); - v->read(reader); - m_property.append(v); - continue; - } - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomProperties::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("properties") : tagName.toLower()); - - for (int i = 0; i < m_property.size(); ++i) { - DomPropertyData* v = m_property[i]; - v->write(writer, QStringLiteral("property")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomProperties::setElementProperty(const QList<DomPropertyData*>& a) -{ - m_children |= Property; - m_property = a; -} - -void DomPropertyData::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_type = false; - } - - m_children = 0; -} - -DomPropertyData::DomPropertyData() -{ - m_children = 0; - m_has_attr_type = false; -} - -DomPropertyData::~DomPropertyData() -{ -} - -void DomPropertyData::read(QXmlStreamReader &reader) -{ - - const QXmlStreamAttributes attributes = reader.attributes(); - for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); - if (name == QLatin1String("type")) { - setAttributeType(attribute.value().toString()); - continue; - } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); - } - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomPropertyData::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertydata") : tagName.toLower()); - - if (hasAttributeType()) - writer.writeAttribute(QStringLiteral("type"), attributeType()); - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomSizePolicyData::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_horData = 0; - m_verData = 0; -} - -DomSizePolicyData::DomSizePolicyData() -{ - m_children = 0; - m_horData = 0; - m_verData = 0; -} - -DomSizePolicyData::~DomSizePolicyData() -{ -} - -void DomSizePolicyData::read(QXmlStreamReader &reader) -{ - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("hordata")) { - setElementHorData(reader.readElementText().toInt()); - continue; - } - if (tag == QLatin1String("verdata")) { - setElementVerData(reader.readElementText().toInt()); - continue; - } - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomSizePolicyData::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicydata") : tagName.toLower()); - - if (m_children & HorData) { - writer.writeTextElement(QStringLiteral("hordata"), QString::number(m_horData)); - } - - if (m_children & VerData) { - writer.writeTextElement(QStringLiteral("verdata"), QString::number(m_verData)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomSizePolicyData::setElementHorData(int a) -{ - m_children |= HorData; - m_horData = a; -} - -void DomSizePolicyData::setElementVerData(int a) -{ - m_children |= VerData; - m_verData = a; -} - -void DomSizePolicyData::clearElementHorData() -{ - m_children &= ~HorData; -} - -void DomSizePolicyData::clearElementVerData() -{ - m_children &= ~VerData; -} - -void DomLayoutDefault::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_spacing = false; - m_attr_spacing = 0; - m_has_attr_margin = false; - m_attr_margin = 0; - } - - m_children = 0; -} - -DomLayoutDefault::DomLayoutDefault() -{ - m_children = 0; - m_has_attr_spacing = false; - m_attr_spacing = 0; - m_has_attr_margin = false; - m_attr_margin = 0; -} - DomLayoutDefault::~DomLayoutDefault() { } void DomLayoutDefault::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toInt()); continue; @@ -2569,20 +1492,15 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -2591,7 +1509,7 @@ void DomLayoutDefault::read(QXmlStreamReader &reader) void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutdefault") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutdefault") : tagName.toLower()); if (hasAttributeSpacing()) writer.writeAttribute(QStringLiteral("spacing"), QString::number(attributeSpacing())); @@ -2599,41 +1517,18 @@ void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) c if (hasAttributeMargin()) writer.writeAttribute(QStringLiteral("margin"), QString::number(attributeMargin())); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomLayoutFunction::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_spacing = false; - m_has_attr_margin = false; - } - - m_children = 0; -} - -DomLayoutFunction::DomLayoutFunction() -{ - m_children = 0; - m_has_attr_spacing = false; - m_has_attr_margin = false; -} - DomLayoutFunction::~DomLayoutFunction() { } void DomLayoutFunction::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("spacing")) { setAttributeSpacing(attribute.value().toString()); continue; @@ -2645,20 +1540,15 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -2667,7 +1557,7 @@ void DomLayoutFunction::read(QXmlStreamReader &reader) void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutfunction") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutfunction") : tagName.toLower()); if (hasAttributeSpacing()) writer.writeAttribute(QStringLiteral("spacing"), attributeSpacing()); @@ -2675,28 +1565,9 @@ void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) if (hasAttributeMargin()) writer.writeAttribute(QStringLiteral("margin"), attributeMargin()); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomTabStops::clear(bool clear_all) -{ - m_tabStop.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomTabStops::DomTabStops() -{ - m_children = 0; -} - DomTabStops::~DomTabStops() { m_tabStop.clear(); @@ -2704,12 +1575,11 @@ DomTabStops::~DomTabStops() void DomTabStops::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("tabstop")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("tabstop"), Qt::CaseInsensitive)) { m_tabStop.append(reader.readElementText()); continue; } @@ -2717,12 +1587,7 @@ void DomTabStops::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -2731,59 +1596,20 @@ void DomTabStops::read(QXmlStreamReader &reader) void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("tabstops") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("tabstops") : tagName.toLower()); - for (int i = 0; i < m_tabStop.size(); ++i) { - QString v = m_tabStop[i]; + for (const QString &v : m_tabStop) writer.writeTextElement(QStringLiteral("tabstop"), v); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomTabStops::setElementTabStop(const QStringList& a) +void DomTabStops::setElementTabStop(const QStringList &a) { m_children |= TabStop; m_tabStop = a; } -void DomLayout::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - qDeleteAll(m_attribute); - m_attribute.clear(); - qDeleteAll(m_item); - m_item.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_class = false; - m_has_attr_name = false; - m_has_attr_stretch = false; - m_has_attr_rowStretch = false; - m_has_attr_columnStretch = false; - m_has_attr_rowMinimumHeight = false; - m_has_attr_columnMinimumWidth = false; - } - - m_children = 0; -} - -DomLayout::DomLayout() -{ - m_children = 0; - m_has_attr_class = false; - m_has_attr_name = false; - m_has_attr_stretch = false; - m_has_attr_rowStretch = false; - m_has_attr_columnStretch = false; - m_has_attr_rowMinimumHeight = false; - m_has_attr_columnMinimumWidth = false; -} - DomLayout::~DomLayout() { qDeleteAll(m_property); @@ -2796,10 +1622,9 @@ DomLayout::~DomLayout() void DomLayout::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; @@ -2831,23 +1656,23 @@ void DomLayout::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QLatin1String("attribute")) { + if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - if (tag == QLatin1String("item")) { + if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { DomLayoutItem *v = new DomLayoutItem(); v->read(reader); m_item.append(v); @@ -2857,12 +1682,7 @@ void DomLayout::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -2871,7 +1691,7 @@ void DomLayout::read(QXmlStreamReader &reader) void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layout") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layout") : tagName.toLower()); if (hasAttributeClass()) writer.writeAttribute(QStringLiteral("class"), attributeClass()); @@ -2894,99 +1714,61 @@ void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeColumnMinimumWidth()) writer.writeAttribute(QStringLiteral("columnminimumwidth"), attributeColumnMinimumWidth()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - for (int i = 0; i < m_attribute.size(); ++i) { - DomProperty* v = m_attribute[i]; + + for (DomProperty *v : m_attribute) v->write(writer, QStringLiteral("attribute")); - } - for (int i = 0; i < m_item.size(); ++i) { - DomLayoutItem* v = m_item[i]; + + for (DomLayoutItem *v : m_item) v->write(writer, QStringLiteral("item")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomLayout::setElementProperty(const QList<DomProperty*>& a) +void DomLayout::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomLayout::setElementAttribute(const QList<DomProperty*>& a) +void DomLayout::setElementAttribute(const QList<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; } -void DomLayout::setElementItem(const QList<DomLayoutItem*>& a) +void DomLayout::setElementItem(const QVector<DomLayoutItem *> &a) { m_children |= Item; m_item = a; } -void DomLayoutItem::clear(bool clear_all) +DomLayoutItem::~DomLayoutItem() { delete m_widget; delete m_layout; delete m_spacer; - - if (clear_all) { - m_text.clear(); - m_has_attr_row = false; - m_attr_row = 0; - m_has_attr_column = false; - m_attr_column = 0; - m_has_attr_rowSpan = false; - m_attr_rowSpan = 0; - m_has_attr_colSpan = false; - m_attr_colSpan = 0; - m_has_attr_alignment = false; - } - - m_kind = Unknown; - - m_widget = 0; - m_layout = 0; - m_spacer = 0; } -DomLayoutItem::DomLayoutItem() -{ - m_kind = Unknown; - - m_has_attr_row = false; - m_attr_row = 0; - m_has_attr_column = false; - m_attr_column = 0; - m_has_attr_rowSpan = false; - m_attr_rowSpan = 0; - m_has_attr_colSpan = false; - m_attr_colSpan = 0; - m_has_attr_alignment = false; - m_widget = 0; - m_layout = 0; - m_spacer = 0; -} - -DomLayoutItem::~DomLayoutItem() +void DomLayoutItem::clear() { delete m_widget; delete m_layout; delete m_spacer; + + m_kind = Unknown; + + m_widget = nullptr; + m_layout = nullptr; + m_spacer = nullptr; } void DomLayoutItem::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toInt()); continue; @@ -3010,23 +1792,23 @@ void DomLayoutItem::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("widget")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { DomWidget *v = new DomWidget(); v->read(reader); setElementWidget(v); continue; } - if (tag == QLatin1String("layout")) { + if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) { DomLayout *v = new DomLayout(); v->read(reader); setElementLayout(v); continue; } - if (tag == QLatin1String("spacer")) { + if (!tag.compare(QLatin1String("spacer"), Qt::CaseInsensitive)) { DomSpacer *v = new DomSpacer(); v->read(reader); setElementSpacer(v); @@ -3036,12 +1818,7 @@ void DomLayoutItem::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3050,7 +1827,7 @@ void DomLayoutItem::read(QXmlStreamReader &reader) void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutitem") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("layoutitem") : tagName.toLower()); if (hasAttributeRow()) writer.writeAttribute(QStringLiteral("row"), QString::number(attributeRow())); @@ -3068,95 +1845,72 @@ void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) cons writer.writeAttribute(QStringLiteral("alignment"), attributeAlignment()); switch (kind()) { - case Widget: { - DomWidget* v = elementWidget(); - if (v != 0) { - v->write(writer, QStringLiteral("widget")); - } - break; - } - case Layout: { - DomLayout* v = elementLayout(); - if (v != 0) { - v->write(writer, QStringLiteral("layout")); - } - break; - } - case Spacer: { - DomSpacer* v = elementSpacer(); - if (v != 0) { - v->write(writer, QStringLiteral("spacer")); - } - break; - } - default: - break; + case Widget: { + DomWidget *v = elementWidget(); + if (v != 0) + v->write(writer, QStringLiteral("widget")); + break; + } + case Layout: { + DomLayout *v = elementLayout(); + if (v != 0) + v->write(writer, QStringLiteral("layout")); + break; + } + case Spacer: { + DomSpacer *v = elementSpacer(); + if (v != 0) + v->write(writer, QStringLiteral("spacer")); + break; + } + default: + break; } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -DomWidget* DomLayoutItem::takeElementWidget() +DomWidget *DomLayoutItem::takeElementWidget() { - DomWidget* a = m_widget; + DomWidget *a = m_widget; m_widget = 0; return a; } -void DomLayoutItem::setElementWidget(DomWidget* a) +void DomLayoutItem::setElementWidget(DomWidget *a) { - clear(false); + clear(); m_kind = Widget; m_widget = a; } -DomLayout* DomLayoutItem::takeElementLayout() +DomLayout *DomLayoutItem::takeElementLayout() { - DomLayout* a = m_layout; + DomLayout *a = m_layout; m_layout = 0; return a; } -void DomLayoutItem::setElementLayout(DomLayout* a) +void DomLayoutItem::setElementLayout(DomLayout *a) { - clear(false); + clear(); m_kind = Layout; m_layout = a; } -DomSpacer* DomLayoutItem::takeElementSpacer() +DomSpacer *DomLayoutItem::takeElementSpacer() { - DomSpacer* a = m_spacer; + DomSpacer *a = m_spacer; m_spacer = 0; return a; } -void DomLayoutItem::setElementSpacer(DomSpacer* a) +void DomLayoutItem::setElementSpacer(DomSpacer *a) { - clear(false); + clear(); m_kind = Spacer; m_spacer = a; } -void DomRow::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomRow::DomRow() -{ - m_children = 0; -} - DomRow::~DomRow() { qDeleteAll(m_property); @@ -3165,12 +1919,11 @@ DomRow::~DomRow() void DomRow::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -3180,12 +1933,7 @@ void DomRow::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3194,41 +1942,20 @@ void DomRow::read(QXmlStreamReader &reader) void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("row") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("row") : tagName.toLower()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomRow::setElementProperty(const QList<DomProperty*>& a) +void DomRow::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomColumn::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomColumn::DomColumn() -{ - m_children = 0; -} - DomColumn::~DomColumn() { qDeleteAll(m_property); @@ -3237,12 +1964,11 @@ DomColumn::~DomColumn() void DomColumn::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -3252,12 +1978,7 @@ void DomColumn::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3266,51 +1987,20 @@ void DomColumn::read(QXmlStreamReader &reader) void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("column") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("column") : tagName.toLower()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomColumn::setElementProperty(const QList<DomProperty*>& a) +void DomColumn::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomItem::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - qDeleteAll(m_item); - m_item.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_row = false; - m_attr_row = 0; - m_has_attr_column = false; - m_attr_column = 0; - } - - m_children = 0; -} - -DomItem::DomItem() -{ - m_children = 0; - m_has_attr_row = false; - m_attr_row = 0; - m_has_attr_column = false; - m_attr_column = 0; -} - DomItem::~DomItem() { qDeleteAll(m_property); @@ -3321,10 +2011,9 @@ DomItem::~DomItem() void DomItem::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("row")) { setAttributeRow(attribute.value().toInt()); continue; @@ -3336,17 +2025,17 @@ void DomItem::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QLatin1String("item")) { + if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { DomItem *v = new DomItem(); v->read(reader); m_item.append(v); @@ -3356,12 +2045,7 @@ void DomItem::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3370,7 +2054,7 @@ void DomItem::read(QXmlStreamReader &reader) void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("item") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("item") : tagName.toLower()); if (hasAttributeRow()) writer.writeAttribute(QStringLiteral("row"), QString::number(attributeRow())); @@ -3378,90 +2062,32 @@ void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeColumn()) writer.writeAttribute(QStringLiteral("column"), QString::number(attributeColumn())); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - for (int i = 0; i < m_item.size(); ++i) { - DomItem* v = m_item[i]; + + for (DomItem *v : m_item) v->write(writer, QStringLiteral("item")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomItem::setElementProperty(const QList<DomProperty*>& a) +void DomItem::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomItem::setElementItem(const QList<DomItem*>& a) +void DomItem::setElementItem(const QVector<DomItem *> &a) { m_children |= Item; m_item = a; } -void DomWidget::clear(bool clear_all) -{ - m_class.clear(); - qDeleteAll(m_property); - m_property.clear(); - qDeleteAll(m_script); - m_script.clear(); - qDeleteAll(m_widgetData); - m_widgetData.clear(); - qDeleteAll(m_attribute); - m_attribute.clear(); - qDeleteAll(m_row); - m_row.clear(); - qDeleteAll(m_column); - m_column.clear(); - qDeleteAll(m_item); - m_item.clear(); - qDeleteAll(m_layout); - m_layout.clear(); - qDeleteAll(m_widget); - m_widget.clear(); - qDeleteAll(m_action); - m_action.clear(); - qDeleteAll(m_actionGroup); - m_actionGroup.clear(); - qDeleteAll(m_addAction); - m_addAction.clear(); - m_zOrder.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_class = false; - m_has_attr_name = false; - m_has_attr_native = false; - m_attr_native = false; - } - - m_children = 0; -} - -DomWidget::DomWidget() -{ - m_children = 0; - m_has_attr_class = false; - m_has_attr_name = false; - m_has_attr_native = false; - m_attr_native = false; -} - DomWidget::~DomWidget() { m_class.clear(); qDeleteAll(m_property); m_property.clear(); - qDeleteAll(m_script); - m_script.clear(); - qDeleteAll(m_widgetData); - m_widgetData.clear(); qDeleteAll(m_attribute); m_attribute.clear(); qDeleteAll(m_row); @@ -3485,10 +2111,9 @@ DomWidget::~DomWidget() void DomWidget::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("class")) { setAttributeClass(attribute.value().toString()); continue; @@ -3504,87 +2129,85 @@ void DomWidget::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("class")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("class"), Qt::CaseInsensitive)) { m_class.append(reader.readElementText()); continue; } - if (tag == QLatin1String("property")) { + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); continue; } - if (tag == QLatin1String("script")) { - DomScript *v = new DomScript(); - v->read(reader); - m_script.append(v); + if (!tag.compare(QLatin1String("script"), Qt::CaseInsensitive)) { + qWarning("Omitting deprecated element <script>."); + reader.skipCurrentElement(); continue; } - if (tag == QLatin1String("widgetdata")) { - DomWidgetData *v = new DomWidgetData(); - v->read(reader); - m_widgetData.append(v); + if (!tag.compare(QLatin1String("widgetdata"), Qt::CaseInsensitive)) { + qWarning("Omitting deprecated element <widgetdata>."); + reader.skipCurrentElement(); continue; } - if (tag == QLatin1String("attribute")) { + if (!tag.compare(QLatin1String("attribute"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_attribute.append(v); continue; } - if (tag == QLatin1String("row")) { + if (!tag.compare(QLatin1String("row"), Qt::CaseInsensitive)) { DomRow *v = new DomRow(); v->read(reader); m_row.append(v); continue; } - if (tag == QLatin1String("column")) { + if (!tag.compare(QLatin1String("column"), Qt::CaseInsensitive)) { DomColumn *v = new DomColumn(); v->read(reader); m_column.append(v); continue; } - if (tag == QLatin1String("item")) { + if (!tag.compare(QLatin1String("item"), Qt::CaseInsensitive)) { DomItem *v = new DomItem(); v->read(reader); m_item.append(v); continue; } - if (tag == QLatin1String("layout")) { + if (!tag.compare(QLatin1String("layout"), Qt::CaseInsensitive)) { DomLayout *v = new DomLayout(); v->read(reader); m_layout.append(v); continue; } - if (tag == QLatin1String("widget")) { + if (!tag.compare(QLatin1String("widget"), Qt::CaseInsensitive)) { DomWidget *v = new DomWidget(); v->read(reader); m_widget.append(v); continue; } - if (tag == QLatin1String("action")) { + if (!tag.compare(QLatin1String("action"), Qt::CaseInsensitive)) { DomAction *v = new DomAction(); v->read(reader); m_action.append(v); continue; } - if (tag == QLatin1String("actiongroup")) { + if (!tag.compare(QLatin1String("actiongroup"), Qt::CaseInsensitive)) { DomActionGroup *v = new DomActionGroup(); v->read(reader); m_actionGroup.append(v); continue; } - if (tag == QLatin1String("addaction")) { + if (!tag.compare(QLatin1String("addaction"), Qt::CaseInsensitive)) { DomActionRef *v = new DomActionRef(); v->read(reader); m_addAction.append(v); continue; } - if (tag == QLatin1String("zorder")) { + if (!tag.compare(QLatin1String("zorder"), Qt::CaseInsensitive)) { m_zOrder.append(reader.readElementText()); continue; } @@ -3592,12 +2215,7 @@ void DomWidget::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3606,7 +2224,7 @@ void DomWidget::read(QXmlStreamReader &reader) void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("widget") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("widget") : tagName.toLower()); if (hasAttributeClass()) writer.writeAttribute(QStringLiteral("class"), attributeClass()); @@ -3617,171 +2235,117 @@ void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeNative()) writer.writeAttribute(QStringLiteral("native"), (attributeNative() ? QLatin1String("true") : QLatin1String("false"))); - for (int i = 0; i < m_class.size(); ++i) { - QString v = m_class[i]; + for (const QString &v : m_class) writer.writeTextElement(QStringLiteral("class"), v); - } - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - for (int i = 0; i < m_script.size(); ++i) { - DomScript* v = m_script[i]; - v->write(writer, QStringLiteral("script")); - } - for (int i = 0; i < m_widgetData.size(); ++i) { - DomWidgetData* v = m_widgetData[i]; - v->write(writer, QStringLiteral("widgetdata")); - } - for (int i = 0; i < m_attribute.size(); ++i) { - DomProperty* v = m_attribute[i]; + + for (DomProperty *v : m_attribute) v->write(writer, QStringLiteral("attribute")); - } - for (int i = 0; i < m_row.size(); ++i) { - DomRow* v = m_row[i]; + + for (DomRow *v : m_row) v->write(writer, QStringLiteral("row")); - } - for (int i = 0; i < m_column.size(); ++i) { - DomColumn* v = m_column[i]; + + for (DomColumn *v : m_column) v->write(writer, QStringLiteral("column")); - } - for (int i = 0; i < m_item.size(); ++i) { - DomItem* v = m_item[i]; + + for (DomItem *v : m_item) v->write(writer, QStringLiteral("item")); - } - for (int i = 0; i < m_layout.size(); ++i) { - DomLayout* v = m_layout[i]; + + for (DomLayout *v : m_layout) v->write(writer, QStringLiteral("layout")); - } - for (int i = 0; i < m_widget.size(); ++i) { - DomWidget* v = m_widget[i]; + + for (DomWidget *v : m_widget) v->write(writer, QStringLiteral("widget")); - } - for (int i = 0; i < m_action.size(); ++i) { - DomAction* v = m_action[i]; + + for (DomAction *v : m_action) v->write(writer, QStringLiteral("action")); - } - for (int i = 0; i < m_actionGroup.size(); ++i) { - DomActionGroup* v = m_actionGroup[i]; + + for (DomActionGroup *v : m_actionGroup) v->write(writer, QStringLiteral("actiongroup")); - } - for (int i = 0; i < m_addAction.size(); ++i) { - DomActionRef* v = m_addAction[i]; + + for (DomActionRef *v : m_addAction) v->write(writer, QStringLiteral("addaction")); - } - for (int i = 0; i < m_zOrder.size(); ++i) { - QString v = m_zOrder[i]; + + for (const QString &v : m_zOrder) writer.writeTextElement(QStringLiteral("zorder"), v); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomWidget::setElementClass(const QStringList& a) +void DomWidget::setElementClass(const QStringList &a) { m_children |= Class; m_class = a; } -void DomWidget::setElementProperty(const QList<DomProperty*>& a) +void DomWidget::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomWidget::setElementScript(const QList<DomScript*>& a) -{ - m_children |= Script; - m_script = a; -} - -void DomWidget::setElementWidgetData(const QList<DomWidgetData*>& a) -{ - m_children |= WidgetData; - m_widgetData = a; -} - -void DomWidget::setElementAttribute(const QList<DomProperty*>& a) +void DomWidget::setElementAttribute(const QList<DomProperty *> &a) { m_children |= Attribute; m_attribute = a; } -void DomWidget::setElementRow(const QList<DomRow*>& a) +void DomWidget::setElementRow(const QVector<DomRow *> &a) { m_children |= Row; m_row = a; } -void DomWidget::setElementColumn(const QList<DomColumn*>& a) +void DomWidget::setElementColumn(const QVector<DomColumn *> &a) { m_children |= Column; m_column = a; } -void DomWidget::setElementItem(const QList<DomItem*>& a) +void DomWidget::setElementItem(const QVector<DomItem *> &a) { m_children |= Item; m_item = a; } -void DomWidget::setElementLayout(const QList<DomLayout*>& a) +void DomWidget::setElementLayout(const QVector<DomLayout *> &a) { m_children |= Layout; m_layout = a; } -void DomWidget::setElementWidget(const QList<DomWidget*>& a) +void DomWidget::setElementWidget(const QVector<DomWidget *> &a) { m_children |= Widget; m_widget = a; } -void DomWidget::setElementAction(const QList<DomAction*>& a) +void DomWidget::setElementAction(const QVector<DomAction *> &a) { m_children |= Action; m_action = a; } -void DomWidget::setElementActionGroup(const QList<DomActionGroup*>& a) +void DomWidget::setElementActionGroup(const QVector<DomActionGroup *> &a) { m_children |= ActionGroup; m_actionGroup = a; } -void DomWidget::setElementAddAction(const QList<DomActionRef*>& a) +void DomWidget::setElementAddAction(const QVector<DomActionRef *> &a) { m_children |= AddAction; m_addAction = a; } -void DomWidget::setElementZOrder(const QStringList& a) +void DomWidget::setElementZOrder(const QStringList &a) { m_children |= ZOrder; m_zOrder = a; } -void DomSpacer::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; -} - -DomSpacer::DomSpacer() -{ - m_children = 0; - m_has_attr_name = false; -} - DomSpacer::~DomSpacer() { qDeleteAll(m_property); @@ -3790,10 +2354,9 @@ DomSpacer::~DomSpacer() void DomSpacer::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -3801,11 +2364,11 @@ void DomSpacer::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -3815,12 +2378,7 @@ void DomSpacer::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3829,62 +2387,32 @@ void DomSpacer::read(QXmlStreamReader &reader) void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("spacer") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("spacer") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomSpacer::setElementProperty(const QList<DomProperty*>& a) +void DomSpacer::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomColor::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_alpha = false; - m_attr_alpha = 0; - } - - m_children = 0; - m_red = 0; - m_green = 0; - m_blue = 0; -} - -DomColor::DomColor() -{ - m_children = 0; - m_has_attr_alpha = false; - m_attr_alpha = 0; - m_red = 0; - m_green = 0; - m_blue = 0; -} - DomColor::~DomColor() { } void DomColor::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("alpha")) { setAttributeAlpha(attribute.value().toInt()); continue; @@ -3892,19 +2420,19 @@ void DomColor::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("red")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("red"), Qt::CaseInsensitive)) { setElementRed(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("green")) { + if (!tag.compare(QLatin1String("green"), Qt::CaseInsensitive)) { setElementGreen(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("blue")) { + if (!tag.compare(QLatin1String("blue"), Qt::CaseInsensitive)) { setElementBlue(reader.readElementText().toInt()); continue; } @@ -3912,12 +2440,7 @@ void DomColor::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -3926,25 +2449,19 @@ void DomColor::read(QXmlStreamReader &reader) void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("color") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("color") : tagName.toLower()); if (hasAttributeAlpha()) writer.writeAttribute(QStringLiteral("alpha"), QString::number(attributeAlpha())); - if (m_children & Red) { + if (m_children & Red) writer.writeTextElement(QStringLiteral("red"), QString::number(m_red)); - } - if (m_children & Green) { + if (m_children & Green) writer.writeTextElement(QStringLiteral("green"), QString::number(m_green)); - } - if (m_children & Blue) { + if (m_children & Blue) writer.writeTextElement(QStringLiteral("blue"), QString::number(m_blue)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -3982,28 +2499,6 @@ void DomColor::clearElementBlue() m_children &= ~Blue; } -void DomGradientStop::clear(bool clear_all) -{ - delete m_color; - - if (clear_all) { - m_text.clear(); - m_has_attr_position = false; - m_attr_position = 0.0; - } - - m_children = 0; - m_color = 0; -} - -DomGradientStop::DomGradientStop() -{ - m_children = 0; - m_has_attr_position = false; - m_attr_position = 0.0; - m_color = 0; -} - DomGradientStop::~DomGradientStop() { delete m_color; @@ -4011,10 +2506,9 @@ DomGradientStop::~DomGradientStop() void DomGradientStop::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("position")) { setAttributePosition(attribute.value().toDouble()); continue; @@ -4022,11 +2516,11 @@ void DomGradientStop::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("color")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { DomColor *v = new DomColor(); v->read(reader); setElementColor(v); @@ -4036,12 +2530,7 @@ void DomGradientStop::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4050,30 +2539,26 @@ void DomGradientStop::read(QXmlStreamReader &reader) void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("gradientstop") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradientstop") : tagName.toLower()); if (hasAttributePosition()) writer.writeAttribute(QStringLiteral("position"), QString::number(attributePosition(), 'f', 15)); - if (m_children & Color) { + if (m_children & Color) m_color->write(writer, QStringLiteral("color")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -DomColor* DomGradientStop::takeElementColor() +DomColor *DomGradientStop::takeElementColor() { - DomColor* a = m_color; + DomColor *a = m_color; m_color = 0; m_children ^= Color; return a; } -void DomGradientStop::setElementColor(DomColor* a) +void DomGradientStop::setElementColor(DomColor *a) { delete m_color; m_children |= Color; @@ -4087,69 +2572,6 @@ void DomGradientStop::clearElementColor() m_children &= ~Color; } -void DomGradient::clear(bool clear_all) -{ - qDeleteAll(m_gradientStop); - m_gradientStop.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_startX = false; - m_attr_startX = 0.0; - m_has_attr_startY = false; - m_attr_startY = 0.0; - m_has_attr_endX = false; - m_attr_endX = 0.0; - m_has_attr_endY = false; - m_attr_endY = 0.0; - m_has_attr_centralX = false; - m_attr_centralX = 0.0; - m_has_attr_centralY = false; - m_attr_centralY = 0.0; - m_has_attr_focalX = false; - m_attr_focalX = 0.0; - m_has_attr_focalY = false; - m_attr_focalY = 0.0; - m_has_attr_radius = false; - m_attr_radius = 0.0; - m_has_attr_angle = false; - m_attr_angle = 0.0; - m_has_attr_type = false; - m_has_attr_spread = false; - m_has_attr_coordinateMode = false; - } - - m_children = 0; -} - -DomGradient::DomGradient() -{ - m_children = 0; - m_has_attr_startX = false; - m_attr_startX = 0.0; - m_has_attr_startY = false; - m_attr_startY = 0.0; - m_has_attr_endX = false; - m_attr_endX = 0.0; - m_has_attr_endY = false; - m_attr_endY = 0.0; - m_has_attr_centralX = false; - m_attr_centralX = 0.0; - m_has_attr_centralY = false; - m_attr_centralY = 0.0; - m_has_attr_focalX = false; - m_attr_focalX = 0.0; - m_has_attr_focalY = false; - m_attr_focalY = 0.0; - m_has_attr_radius = false; - m_attr_radius = 0.0; - m_has_attr_angle = false; - m_attr_angle = 0.0; - m_has_attr_type = false; - m_has_attr_spread = false; - m_has_attr_coordinateMode = false; -} - DomGradient::~DomGradient() { qDeleteAll(m_gradientStop); @@ -4158,10 +2580,9 @@ DomGradient::~DomGradient() void DomGradient::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("startx")) { setAttributeStartX(attribute.value().toDouble()); continue; @@ -4217,11 +2638,11 @@ void DomGradient::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("gradientstop")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("gradientstop"), Qt::CaseInsensitive)) { DomGradientStop *v = new DomGradientStop(); v->read(reader); m_gradientStop.append(v); @@ -4231,12 +2652,7 @@ void DomGradient::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4245,7 +2661,7 @@ void DomGradient::read(QXmlStreamReader &reader) void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("gradient") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("gradient") : tagName.toLower()); if (hasAttributeStartX()) writer.writeAttribute(QStringLiteral("startx"), QString::number(attributeStartX(), 'f', 15)); @@ -4286,63 +2702,43 @@ void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeCoordinateMode()) writer.writeAttribute(QStringLiteral("coordinatemode"), attributeCoordinateMode()); - for (int i = 0; i < m_gradientStop.size(); ++i) { - DomGradientStop* v = m_gradientStop[i]; + for (DomGradientStop *v : m_gradientStop) v->write(writer, QStringLiteral("gradientstop")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomGradient::setElementGradientStop(const QList<DomGradientStop*>& a) +void DomGradient::setElementGradientStop(const QVector<DomGradientStop *> &a) { m_children |= GradientStop; m_gradientStop = a; } -void DomBrush::clear(bool clear_all) +DomBrush::~DomBrush() { delete m_color; delete m_texture; delete m_gradient; - - if (clear_all) { - m_text.clear(); - m_has_attr_brushStyle = false; - } - - m_kind = Unknown; - - m_color = 0; - m_texture = 0; - m_gradient = 0; } -DomBrush::DomBrush() -{ - m_kind = Unknown; - - m_has_attr_brushStyle = false; - m_color = 0; - m_texture = 0; - m_gradient = 0; -} - -DomBrush::~DomBrush() +void DomBrush::clear() { delete m_color; delete m_texture; delete m_gradient; + + m_kind = Unknown; + + m_color = nullptr; + m_texture = nullptr; + m_gradient = nullptr; } void DomBrush::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("brushstyle")) { setAttributeBrushStyle(attribute.value().toString()); continue; @@ -4350,23 +2746,23 @@ void DomBrush::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("color")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { DomColor *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - if (tag == QLatin1String("texture")) { + if (!tag.compare(QLatin1String("texture"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); setElementTexture(v); continue; } - if (tag == QLatin1String("gradient")) { + if (!tag.compare(QLatin1String("gradient"), Qt::CaseInsensitive)) { DomGradient *v = new DomGradient(); v->read(reader); setElementGradient(v); @@ -4376,12 +2772,7 @@ void DomBrush::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4390,104 +2781,78 @@ void DomBrush::read(QXmlStreamReader &reader) void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("brush") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("brush") : tagName.toLower()); if (hasAttributeBrushStyle()) writer.writeAttribute(QStringLiteral("brushstyle"), attributeBrushStyle()); switch (kind()) { - case Color: { - DomColor* v = elementColor(); - if (v != 0) { - v->write(writer, QStringLiteral("color")); - } - break; - } - case Texture: { - DomProperty* v = elementTexture(); - if (v != 0) { - v->write(writer, QStringLiteral("texture")); - } - break; - } - case Gradient: { - DomGradient* v = elementGradient(); - if (v != 0) { - v->write(writer, QStringLiteral("gradient")); - } - break; - } - default: - break; + case Color: { + DomColor *v = elementColor(); + if (v != 0) + v->write(writer, QStringLiteral("color")); + break; + } + case Texture: { + DomProperty *v = elementTexture(); + if (v != 0) + v->write(writer, QStringLiteral("texture")); + break; + } + case Gradient: { + DomGradient *v = elementGradient(); + if (v != 0) + v->write(writer, QStringLiteral("gradient")); + break; + } + default: + break; } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -DomColor* DomBrush::takeElementColor() +DomColor *DomBrush::takeElementColor() { - DomColor* a = m_color; + DomColor *a = m_color; m_color = 0; return a; } -void DomBrush::setElementColor(DomColor* a) +void DomBrush::setElementColor(DomColor *a) { - clear(false); + clear(); m_kind = Color; m_color = a; } -DomProperty* DomBrush::takeElementTexture() +DomProperty *DomBrush::takeElementTexture() { - DomProperty* a = m_texture; + DomProperty *a = m_texture; m_texture = 0; return a; } -void DomBrush::setElementTexture(DomProperty* a) +void DomBrush::setElementTexture(DomProperty *a) { - clear(false); + clear(); m_kind = Texture; m_texture = a; } -DomGradient* DomBrush::takeElementGradient() +DomGradient *DomBrush::takeElementGradient() { - DomGradient* a = m_gradient; + DomGradient *a = m_gradient; m_gradient = 0; return a; } -void DomBrush::setElementGradient(DomGradient* a) +void DomBrush::setElementGradient(DomGradient *a) { - clear(false); + clear(); m_kind = Gradient; m_gradient = a; } -void DomColorRole::clear(bool clear_all) -{ - delete m_brush; - - if (clear_all) { - m_text.clear(); - m_has_attr_role = false; - } - - m_children = 0; - m_brush = 0; -} - -DomColorRole::DomColorRole() -{ - m_children = 0; - m_has_attr_role = false; - m_brush = 0; -} - DomColorRole::~DomColorRole() { delete m_brush; @@ -4495,10 +2860,9 @@ DomColorRole::~DomColorRole() void DomColorRole::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("role")) { setAttributeRole(attribute.value().toString()); continue; @@ -4506,11 +2870,11 @@ void DomColorRole::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("brush")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { DomBrush *v = new DomBrush(); v->read(reader); setElementBrush(v); @@ -4520,12 +2884,7 @@ void DomColorRole::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4534,30 +2893,26 @@ void DomColorRole::read(QXmlStreamReader &reader) void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("colorrole") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorrole") : tagName.toLower()); if (hasAttributeRole()) writer.writeAttribute(QStringLiteral("role"), attributeRole()); - if (m_children & Brush) { + if (m_children & Brush) m_brush->write(writer, QStringLiteral("brush")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -DomBrush* DomColorRole::takeElementBrush() +DomBrush *DomColorRole::takeElementBrush() { - DomBrush* a = m_brush; + DomBrush *a = m_brush; m_brush = 0; m_children ^= Brush; return a; } -void DomColorRole::setElementBrush(DomBrush* a) +void DomColorRole::setElementBrush(DomBrush *a) { delete m_brush; m_children |= Brush; @@ -4571,25 +2926,6 @@ void DomColorRole::clearElementBrush() m_children &= ~Brush; } -void DomColorGroup::clear(bool clear_all) -{ - qDeleteAll(m_colorRole); - m_colorRole.clear(); - qDeleteAll(m_color); - m_color.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomColorGroup::DomColorGroup() -{ - m_children = 0; -} - DomColorGroup::~DomColorGroup() { qDeleteAll(m_colorRole); @@ -4600,18 +2936,17 @@ DomColorGroup::~DomColorGroup() void DomColorGroup::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("colorrole")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("colorrole"), Qt::CaseInsensitive)) { DomColorRole *v = new DomColorRole(); v->read(reader); m_colorRole.append(v); continue; } - if (tag == QLatin1String("color")) { + if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { DomColor *v = new DomColor(); v->read(reader); m_color.append(v); @@ -4621,12 +2956,7 @@ void DomColorGroup::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4635,58 +2965,29 @@ void DomColorGroup::read(QXmlStreamReader &reader) void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("colorgroup") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("colorgroup") : tagName.toLower()); - for (int i = 0; i < m_colorRole.size(); ++i) { - DomColorRole* v = m_colorRole[i]; + for (DomColorRole *v : m_colorRole) v->write(writer, QStringLiteral("colorrole")); - } - for (int i = 0; i < m_color.size(); ++i) { - DomColor* v = m_color[i]; + + for (DomColor *v : m_color) v->write(writer, QStringLiteral("color")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomColorGroup::setElementColorRole(const QList<DomColorRole*>& a) +void DomColorGroup::setElementColorRole(const QVector<DomColorRole *> &a) { m_children |= ColorRole; m_colorRole = a; } -void DomColorGroup::setElementColor(const QList<DomColor*>& a) +void DomColorGroup::setElementColor(const QVector<DomColor *> &a) { m_children |= Color; m_color = a; } -void DomPalette::clear(bool clear_all) -{ - delete m_active; - delete m_inactive; - delete m_disabled; - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_active = 0; - m_inactive = 0; - m_disabled = 0; -} - -DomPalette::DomPalette() -{ - m_children = 0; - m_active = 0; - m_inactive = 0; - m_disabled = 0; -} - DomPalette::~DomPalette() { delete m_active; @@ -4696,24 +2997,23 @@ DomPalette::~DomPalette() void DomPalette::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("active")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("active"), Qt::CaseInsensitive)) { DomColorGroup *v = new DomColorGroup(); v->read(reader); setElementActive(v); continue; } - if (tag == QLatin1String("inactive")) { + if (!tag.compare(QLatin1String("inactive"), Qt::CaseInsensitive)) { DomColorGroup *v = new DomColorGroup(); v->read(reader); setElementInactive(v); continue; } - if (tag == QLatin1String("disabled")) { + if (!tag.compare(QLatin1String("disabled"), Qt::CaseInsensitive)) { DomColorGroup *v = new DomColorGroup(); v->read(reader); setElementDisabled(v); @@ -4723,12 +3023,7 @@ void DomPalette::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4737,65 +3032,59 @@ void DomPalette::read(QXmlStreamReader &reader) void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("palette") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("palette") : tagName.toLower()); - if (m_children & Active) { + if (m_children & Active) m_active->write(writer, QStringLiteral("active")); - } - if (m_children & Inactive) { + if (m_children & Inactive) m_inactive->write(writer, QStringLiteral("inactive")); - } - if (m_children & Disabled) { + if (m_children & Disabled) m_disabled->write(writer, QStringLiteral("disabled")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -DomColorGroup* DomPalette::takeElementActive() +DomColorGroup *DomPalette::takeElementActive() { - DomColorGroup* a = m_active; + DomColorGroup *a = m_active; m_active = 0; m_children ^= Active; return a; } -void DomPalette::setElementActive(DomColorGroup* a) +void DomPalette::setElementActive(DomColorGroup *a) { delete m_active; m_children |= Active; m_active = a; } -DomColorGroup* DomPalette::takeElementInactive() +DomColorGroup *DomPalette::takeElementInactive() { - DomColorGroup* a = m_inactive; + DomColorGroup *a = m_inactive; m_inactive = 0; m_children ^= Inactive; return a; } -void DomPalette::setElementInactive(DomColorGroup* a) +void DomPalette::setElementInactive(DomColorGroup *a) { delete m_inactive; m_children |= Inactive; m_inactive = a; } -DomColorGroup* DomPalette::takeElementDisabled() +DomColorGroup *DomPalette::takeElementDisabled() { - DomColorGroup* a = m_disabled; + DomColorGroup *a = m_disabled; m_disabled = 0; m_children ^= Disabled; return a; } -void DomPalette::setElementDisabled(DomColorGroup* a) +void DomPalette::setElementDisabled(DomColorGroup *a) { delete m_disabled; m_children |= Disabled; @@ -4823,85 +3112,53 @@ void DomPalette::clearElementDisabled() m_children &= ~Disabled; } -void DomFont::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_pointSize = 0; - m_weight = 0; - m_italic = false; - m_bold = false; - m_underline = false; - m_strikeOut = false; - m_antialiasing = false; - m_kerning = false; -} - -DomFont::DomFont() -{ - m_children = 0; - m_pointSize = 0; - m_weight = 0; - m_italic = false; - m_bold = false; - m_underline = false; - m_strikeOut = false; - m_antialiasing = false; - m_kerning = false; -} - DomFont::~DomFont() { } void DomFont::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("family")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("family"), Qt::CaseInsensitive)) { setElementFamily(reader.readElementText()); continue; } - if (tag == QLatin1String("pointsize")) { + if (!tag.compare(QLatin1String("pointsize"), Qt::CaseInsensitive)) { setElementPointSize(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("weight")) { + if (!tag.compare(QLatin1String("weight"), Qt::CaseInsensitive)) { setElementWeight(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("italic")) { + if (!tag.compare(QLatin1String("italic"), Qt::CaseInsensitive)) { setElementItalic(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QLatin1String("bold")) { + if (!tag.compare(QLatin1String("bold"), Qt::CaseInsensitive)) { setElementBold(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QLatin1String("underline")) { + if (!tag.compare(QLatin1String("underline"), Qt::CaseInsensitive)) { setElementUnderline(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QLatin1String("strikeout")) { + if (!tag.compare(QLatin1String("strikeout"), Qt::CaseInsensitive)) { setElementStrikeOut(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QLatin1String("antialiasing")) { + if (!tag.compare(QLatin1String("antialiasing"), Qt::CaseInsensitive)) { setElementAntialiasing(reader.readElementText() == QLatin1String("true")); continue; } - if (tag == QLatin1String("stylestrategy")) { + if (!tag.compare(QLatin1String("stylestrategy"), Qt::CaseInsensitive)) { setElementStyleStrategy(reader.readElementText()); continue; } - if (tag == QLatin1String("kerning")) { + if (!tag.compare(QLatin1String("kerning"), Qt::CaseInsensitive)) { setElementKerning(reader.readElementText() == QLatin1String("true")); continue; } @@ -4909,12 +3166,7 @@ void DomFont::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -4923,55 +3175,42 @@ void DomFont::read(QXmlStreamReader &reader) void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("font") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("font") : tagName.toLower()); - if (m_children & Family) { + if (m_children & Family) writer.writeTextElement(QStringLiteral("family"), m_family); - } - if (m_children & PointSize) { + if (m_children & PointSize) writer.writeTextElement(QStringLiteral("pointsize"), QString::number(m_pointSize)); - } - if (m_children & Weight) { + if (m_children & Weight) writer.writeTextElement(QStringLiteral("weight"), QString::number(m_weight)); - } - if (m_children & Italic) { + if (m_children & Italic) writer.writeTextElement(QStringLiteral("italic"), (m_italic ? QLatin1String("true") : QLatin1String("false"))); - } - if (m_children & Bold) { + if (m_children & Bold) writer.writeTextElement(QStringLiteral("bold"), (m_bold ? QLatin1String("true") : QLatin1String("false"))); - } - if (m_children & Underline) { + if (m_children & Underline) writer.writeTextElement(QStringLiteral("underline"), (m_underline ? QLatin1String("true") : QLatin1String("false"))); - } - if (m_children & StrikeOut) { + if (m_children & StrikeOut) writer.writeTextElement(QStringLiteral("strikeout"), (m_strikeOut ? QLatin1String("true") : QLatin1String("false"))); - } - if (m_children & Antialiasing) { + if (m_children & Antialiasing) writer.writeTextElement(QStringLiteral("antialiasing"), (m_antialiasing ? QLatin1String("true") : QLatin1String("false"))); - } - if (m_children & StyleStrategy) { + if (m_children & StyleStrategy) writer.writeTextElement(QStringLiteral("stylestrategy"), m_styleStrategy); - } - if (m_children & Kerning) { + if (m_children & Kerning) writer.writeTextElement(QStringLiteral("kerning"), (m_kerning ? QLatin1String("true") : QLatin1String("false"))); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomFont::setElementFamily(const QString& a) +void DomFont::setElementFamily(const QString &a) { m_children |= Family; m_family = a; @@ -5019,7 +3258,7 @@ void DomFont::setElementAntialiasing(bool a) m_antialiasing = a; } -void DomFont::setElementStyleStrategy(const QString& a) +void DomFont::setElementStyleStrategy(const QString &a) { m_children |= StyleStrategy; m_styleStrategy = a; @@ -5081,41 +3320,21 @@ void DomFont::clearElementKerning() m_children &= ~Kerning; } -void DomPoint::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_x = 0; - m_y = 0; -} - -DomPoint::DomPoint() -{ - m_children = 0; - m_x = 0; - m_y = 0; -} - DomPoint::~DomPoint() { } void DomPoint::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("x")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("y")) { + if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { setElementY(reader.readElementText().toInt()); continue; } @@ -5123,12 +3342,7 @@ void DomPoint::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5137,18 +3351,13 @@ void DomPoint::read(QXmlStreamReader &reader) void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("point") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("point") : tagName.toLower()); - if (m_children & X) { + if (m_children & X) writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); - } - if (m_children & Y) { + if (m_children & Y) writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -5175,53 +3384,29 @@ void DomPoint::clearElementY() m_children &= ~Y; } -void DomRect::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_x = 0; - m_y = 0; - m_width = 0; - m_height = 0; -} - -DomRect::DomRect() -{ - m_children = 0; - m_x = 0; - m_y = 0; - m_width = 0; - m_height = 0; -} - DomRect::~DomRect() { } void DomRect::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("x")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("y")) { + if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { setElementY(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("width")) { + if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("height")) { + if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toInt()); continue; } @@ -5229,12 +3414,7 @@ void DomRect::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5243,26 +3423,19 @@ void DomRect::read(QXmlStreamReader &reader) void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("rect") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rect") : tagName.toLower()); - if (m_children & X) { + if (m_children & X) writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); - } - if (m_children & Y) { + if (m_children & Y) writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); - } - if (m_children & Width) { + if (m_children & Width) writer.writeTextElement(QStringLiteral("width"), QString::number(m_width)); - } - if (m_children & Height) { + if (m_children & Height) writer.writeTextElement(QStringLiteral("height"), QString::number(m_height)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -5311,35 +3484,15 @@ void DomRect::clearElementHeight() m_children &= ~Height; } -void DomLocale::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_language = false; - m_has_attr_country = false; - } - - m_children = 0; -} - -DomLocale::DomLocale() -{ - m_children = 0; - m_has_attr_language = false; - m_has_attr_country = false; -} - DomLocale::~DomLocale() { } void DomLocale::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("language")) { setAttributeLanguage(attribute.value().toString()); continue; @@ -5351,20 +3504,15 @@ void DomLocale::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5373,7 +3521,7 @@ void DomLocale::read(QXmlStreamReader &reader) void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("locale") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("locale") : tagName.toLower()); if (hasAttributeLanguage()) writer.writeAttribute(QStringLiteral("language"), attributeLanguage()); @@ -5381,49 +3529,18 @@ void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeCountry()) writer.writeAttribute(QStringLiteral("country"), attributeCountry()); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomSizePolicy::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_hSizeType = false; - m_has_attr_vSizeType = false; - } - - m_children = 0; - m_hSizeType = 0; - m_vSizeType = 0; - m_horStretch = 0; - m_verStretch = 0; -} - -DomSizePolicy::DomSizePolicy() -{ - m_children = 0; - m_has_attr_hSizeType = false; - m_has_attr_vSizeType = false; - m_hSizeType = 0; - m_vSizeType = 0; - m_horStretch = 0; - m_verStretch = 0; -} - DomSizePolicy::~DomSizePolicy() { } void DomSizePolicy::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("hsizetype")) { setAttributeHSizeType(attribute.value().toString()); continue; @@ -5435,23 +3552,23 @@ void DomSizePolicy::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("hsizetype")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("hsizetype"), Qt::CaseInsensitive)) { setElementHSizeType(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("vsizetype")) { + if (!tag.compare(QLatin1String("vsizetype"), Qt::CaseInsensitive)) { setElementVSizeType(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("horstretch")) { + if (!tag.compare(QLatin1String("horstretch"), Qt::CaseInsensitive)) { setElementHorStretch(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("verstretch")) { + if (!tag.compare(QLatin1String("verstretch"), Qt::CaseInsensitive)) { setElementVerStretch(reader.readElementText().toInt()); continue; } @@ -5459,12 +3576,7 @@ void DomSizePolicy::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5473,7 +3585,7 @@ void DomSizePolicy::read(QXmlStreamReader &reader) void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicy") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizepolicy") : tagName.toLower()); if (hasAttributeHSizeType()) writer.writeAttribute(QStringLiteral("hsizetype"), attributeHSizeType()); @@ -5481,24 +3593,17 @@ void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) cons if (hasAttributeVSizeType()) writer.writeAttribute(QStringLiteral("vsizetype"), attributeVSizeType()); - if (m_children & HSizeType) { + if (m_children & HSizeType) writer.writeTextElement(QStringLiteral("hsizetype"), QString::number(m_hSizeType)); - } - if (m_children & VSizeType) { + if (m_children & VSizeType) writer.writeTextElement(QStringLiteral("vsizetype"), QString::number(m_vSizeType)); - } - if (m_children & HorStretch) { + if (m_children & HorStretch) writer.writeTextElement(QStringLiteral("horstretch"), QString::number(m_horStretch)); - } - if (m_children & VerStretch) { + if (m_children & VerStretch) writer.writeTextElement(QStringLiteral("verstretch"), QString::number(m_verStretch)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -5547,41 +3652,21 @@ void DomSizePolicy::clearElementVerStretch() m_children &= ~VerStretch; } -void DomSize::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_width = 0; - m_height = 0; -} - -DomSize::DomSize() -{ - m_children = 0; - m_width = 0; - m_height = 0; -} - DomSize::~DomSize() { } void DomSize::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("width")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("height")) { + if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toInt()); continue; } @@ -5589,12 +3674,7 @@ void DomSize::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5603,18 +3683,13 @@ void DomSize::read(QXmlStreamReader &reader) void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("size") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("size") : tagName.toLower()); - if (m_children & Width) { + if (m_children & Width) writer.writeTextElement(QStringLiteral("width"), QString::number(m_width)); - } - if (m_children & Height) { + if (m_children & Height) writer.writeTextElement(QStringLiteral("height"), QString::number(m_height)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -5641,47 +3716,25 @@ void DomSize::clearElementHeight() m_children &= ~Height; } -void DomDate::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_year = 0; - m_month = 0; - m_day = 0; -} - -DomDate::DomDate() -{ - m_children = 0; - m_year = 0; - m_month = 0; - m_day = 0; -} - DomDate::~DomDate() { } void DomDate::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("year")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) { setElementYear(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("month")) { + if (!tag.compare(QLatin1String("month"), Qt::CaseInsensitive)) { setElementMonth(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("day")) { + if (!tag.compare(QLatin1String("day"), Qt::CaseInsensitive)) { setElementDay(reader.readElementText().toInt()); continue; } @@ -5689,12 +3742,7 @@ void DomDate::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5703,22 +3751,16 @@ void DomDate::read(QXmlStreamReader &reader) void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("date") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("date") : tagName.toLower()); - if (m_children & Year) { + if (m_children & Year) writer.writeTextElement(QStringLiteral("year"), QString::number(m_year)); - } - if (m_children & Month) { + if (m_children & Month) writer.writeTextElement(QStringLiteral("month"), QString::number(m_month)); - } - if (m_children & Day) { + if (m_children & Day) writer.writeTextElement(QStringLiteral("day"), QString::number(m_day)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -5756,47 +3798,25 @@ void DomDate::clearElementDay() m_children &= ~Day; } -void DomTime::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_hour = 0; - m_minute = 0; - m_second = 0; -} - -DomTime::DomTime() -{ - m_children = 0; - m_hour = 0; - m_minute = 0; - m_second = 0; -} - DomTime::~DomTime() { } void DomTime::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("hour")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("minute")) { + if (!tag.compare(QLatin1String("minute"), Qt::CaseInsensitive)) { setElementMinute(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("second")) { + if (!tag.compare(QLatin1String("second"), Qt::CaseInsensitive)) { setElementSecond(reader.readElementText().toInt()); continue; } @@ -5804,12 +3824,7 @@ void DomTime::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5818,22 +3833,16 @@ void DomTime::read(QXmlStreamReader &reader) void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("time") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("time") : tagName.toLower()); - if (m_children & Hour) { + if (m_children & Hour) writer.writeTextElement(QStringLiteral("hour"), QString::number(m_hour)); - } - if (m_children & Minute) { + if (m_children & Minute) writer.writeTextElement(QStringLiteral("minute"), QString::number(m_minute)); - } - if (m_children & Second) { + if (m_children & Second) writer.writeTextElement(QStringLiteral("second"), QString::number(m_second)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -5871,65 +3880,37 @@ void DomTime::clearElementSecond() m_children &= ~Second; } -void DomDateTime::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_hour = 0; - m_minute = 0; - m_second = 0; - m_year = 0; - m_month = 0; - m_day = 0; -} - -DomDateTime::DomDateTime() -{ - m_children = 0; - m_hour = 0; - m_minute = 0; - m_second = 0; - m_year = 0; - m_month = 0; - m_day = 0; -} - DomDateTime::~DomDateTime() { } void DomDateTime::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("hour")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("hour"), Qt::CaseInsensitive)) { setElementHour(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("minute")) { + if (!tag.compare(QLatin1String("minute"), Qt::CaseInsensitive)) { setElementMinute(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("second")) { + if (!tag.compare(QLatin1String("second"), Qt::CaseInsensitive)) { setElementSecond(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("year")) { + if (!tag.compare(QLatin1String("year"), Qt::CaseInsensitive)) { setElementYear(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("month")) { + if (!tag.compare(QLatin1String("month"), Qt::CaseInsensitive)) { setElementMonth(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("day")) { + if (!tag.compare(QLatin1String("day"), Qt::CaseInsensitive)) { setElementDay(reader.readElementText().toInt()); continue; } @@ -5937,12 +3918,7 @@ void DomDateTime::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -5951,34 +3927,25 @@ void DomDateTime::read(QXmlStreamReader &reader) void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("datetime") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("datetime") : tagName.toLower()); - if (m_children & Hour) { + if (m_children & Hour) writer.writeTextElement(QStringLiteral("hour"), QString::number(m_hour)); - } - if (m_children & Minute) { + if (m_children & Minute) writer.writeTextElement(QStringLiteral("minute"), QString::number(m_minute)); - } - if (m_children & Second) { + if (m_children & Second) writer.writeTextElement(QStringLiteral("second"), QString::number(m_second)); - } - if (m_children & Year) { + if (m_children & Year) writer.writeTextElement(QStringLiteral("year"), QString::number(m_year)); - } - if (m_children & Month) { + if (m_children & Month) writer.writeTextElement(QStringLiteral("month"), QString::number(m_month)); - } - if (m_children & Day) { + if (m_children & Day) writer.writeTextElement(QStringLiteral("day"), QString::number(m_day)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -6049,28 +4016,6 @@ void DomDateTime::clearElementDay() m_children &= ~Day; } -void DomStringList::clear(bool clear_all) -{ - m_string.clear(); - - if (clear_all) { - m_text.clear(); - m_has_attr_notr = false; - m_has_attr_comment = false; - m_has_attr_extraComment = false; - } - - m_children = 0; -} - -DomStringList::DomStringList() -{ - m_children = 0; - m_has_attr_notr = false; - m_has_attr_comment = false; - m_has_attr_extraComment = false; -} - DomStringList::~DomStringList() { m_string.clear(); @@ -6078,10 +4023,9 @@ DomStringList::~DomStringList() void DomStringList::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; @@ -6097,11 +4041,11 @@ void DomStringList::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("string")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { m_string.append(reader.readElementText()); continue; } @@ -6109,12 +4053,7 @@ void DomStringList::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -6123,7 +4062,7 @@ void DomStringList::read(QXmlStreamReader &reader) void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringlist") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringlist") : tagName.toLower()); if (hasAttributeNotr()) writer.writeAttribute(QStringLiteral("notr"), attributeNotr()); @@ -6134,52 +4073,27 @@ void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) cons if (hasAttributeExtraComment()) writer.writeAttribute(QStringLiteral("extracomment"), attributeExtraComment()); - for (int i = 0; i < m_string.size(); ++i) { - QString v = m_string[i]; + for (const QString &v : m_string) writer.writeTextElement(QStringLiteral("string"), v); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomStringList::setElementString(const QStringList& a) +void DomStringList::setElementString(const QStringList &a) { m_children |= String; m_string = a; } -void DomResourcePixmap::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_resource = false; - m_has_attr_alias = false; - } - - m_children = 0; -} - -DomResourcePixmap::DomResourcePixmap() -{ - m_children = 0; - m_has_attr_resource = false; - m_has_attr_alias = false; - m_text.clear(); -} - DomResourcePixmap::~DomResourcePixmap() { } void DomResourcePixmap::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("resource")) { setAttributeResource(attribute.value().toString()); continue; @@ -6191,16 +4105,15 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; + return; case QXmlStreamReader::Characters : if (!reader.isWhitespace()) m_text.append(reader.text().toString()); @@ -6213,7 +4126,7 @@ void DomResourcePixmap::read(QXmlStreamReader &reader) void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourcepixmap") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourcepixmap") : tagName.toLower()); if (hasAttributeResource()) writer.writeAttribute(QStringLiteral("resource"), attributeResource()); @@ -6227,50 +4140,6 @@ void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) writer.writeEndElement(); } -void DomResourceIcon::clear(bool clear_all) -{ - delete m_normalOff; - delete m_normalOn; - delete m_disabledOff; - delete m_disabledOn; - delete m_activeOff; - delete m_activeOn; - delete m_selectedOff; - delete m_selectedOn; - - if (clear_all) { - m_text.clear(); - m_has_attr_theme = false; - m_has_attr_resource = false; - } - - m_children = 0; - m_normalOff = 0; - m_normalOn = 0; - m_disabledOff = 0; - m_disabledOn = 0; - m_activeOff = 0; - m_activeOn = 0; - m_selectedOff = 0; - m_selectedOn = 0; -} - -DomResourceIcon::DomResourceIcon() -{ - m_children = 0; - m_has_attr_theme = false; - m_has_attr_resource = false; - m_text.clear(); - m_normalOff = 0; - m_normalOn = 0; - m_disabledOff = 0; - m_disabledOn = 0; - m_activeOff = 0; - m_activeOn = 0; - m_selectedOff = 0; - m_selectedOn = 0; -} - DomResourceIcon::~DomResourceIcon() { delete m_normalOff; @@ -6285,10 +4154,9 @@ DomResourceIcon::~DomResourceIcon() void DomResourceIcon::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("theme")) { setAttributeTheme(attribute.value().toString()); continue; @@ -6300,53 +4168,53 @@ void DomResourceIcon::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("normaloff")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("normaloff"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementNormalOff(v); continue; } - if (tag == QLatin1String("normalon")) { + if (!tag.compare(QLatin1String("normalon"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementNormalOn(v); continue; } - if (tag == QLatin1String("disabledoff")) { + if (!tag.compare(QLatin1String("disabledoff"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOff(v); continue; } - if (tag == QLatin1String("disabledon")) { + if (!tag.compare(QLatin1String("disabledon"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementDisabledOn(v); continue; } - if (tag == QLatin1String("activeoff")) { + if (!tag.compare(QLatin1String("activeoff"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementActiveOff(v); continue; } - if (tag == QLatin1String("activeon")) { + if (!tag.compare(QLatin1String("activeon"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementActiveOn(v); continue; } - if (tag == QLatin1String("selectedoff")) { + if (!tag.compare(QLatin1String("selectedoff"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOff(v); continue; } - if (tag == QLatin1String("selectedon")) { + if (!tag.compare(QLatin1String("selectedon"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementSelectedOn(v); @@ -6356,8 +4224,7 @@ void DomResourceIcon::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; + return; case QXmlStreamReader::Characters : if (!reader.isWhitespace()) m_text.append(reader.text().toString()); @@ -6370,7 +4237,7 @@ void DomResourceIcon::read(QXmlStreamReader &reader) void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("resourceicon") : tagName.toLower()); if (hasAttributeTheme()) writer.writeAttribute(QStringLiteral("theme"), attributeTheme()); @@ -6378,37 +4245,29 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co if (hasAttributeResource()) writer.writeAttribute(QStringLiteral("resource"), attributeResource()); - if (m_children & NormalOff) { + if (m_children & NormalOff) m_normalOff->write(writer, QStringLiteral("normaloff")); - } - if (m_children & NormalOn) { + if (m_children & NormalOn) m_normalOn->write(writer, QStringLiteral("normalon")); - } - if (m_children & DisabledOff) { + if (m_children & DisabledOff) m_disabledOff->write(writer, QStringLiteral("disabledoff")); - } - if (m_children & DisabledOn) { + if (m_children & DisabledOn) m_disabledOn->write(writer, QStringLiteral("disabledon")); - } - if (m_children & ActiveOff) { + if (m_children & ActiveOff) m_activeOff->write(writer, QStringLiteral("activeoff")); - } - if (m_children & ActiveOn) { + if (m_children & ActiveOn) m_activeOn->write(writer, QStringLiteral("activeon")); - } - if (m_children & SelectedOff) { + if (m_children & SelectedOff) m_selectedOff->write(writer, QStringLiteral("selectedoff")); - } - if (m_children & SelectedOn) { + if (m_children & SelectedOn) m_selectedOn->write(writer, QStringLiteral("selectedon")); - } if (!m_text.isEmpty()) writer.writeCharacters(m_text); @@ -6416,120 +4275,120 @@ void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) co writer.writeEndElement(); } -DomResourcePixmap* DomResourceIcon::takeElementNormalOff() +DomResourcePixmap *DomResourceIcon::takeElementNormalOff() { - DomResourcePixmap* a = m_normalOff; + DomResourcePixmap *a = m_normalOff; m_normalOff = 0; m_children ^= NormalOff; return a; } -void DomResourceIcon::setElementNormalOff(DomResourcePixmap* a) +void DomResourceIcon::setElementNormalOff(DomResourcePixmap *a) { delete m_normalOff; m_children |= NormalOff; m_normalOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementNormalOn() +DomResourcePixmap *DomResourceIcon::takeElementNormalOn() { - DomResourcePixmap* a = m_normalOn; + DomResourcePixmap *a = m_normalOn; m_normalOn = 0; m_children ^= NormalOn; return a; } -void DomResourceIcon::setElementNormalOn(DomResourcePixmap* a) +void DomResourceIcon::setElementNormalOn(DomResourcePixmap *a) { delete m_normalOn; m_children |= NormalOn; m_normalOn = a; } -DomResourcePixmap* DomResourceIcon::takeElementDisabledOff() +DomResourcePixmap *DomResourceIcon::takeElementDisabledOff() { - DomResourcePixmap* a = m_disabledOff; + DomResourcePixmap *a = m_disabledOff; m_disabledOff = 0; m_children ^= DisabledOff; return a; } -void DomResourceIcon::setElementDisabledOff(DomResourcePixmap* a) +void DomResourceIcon::setElementDisabledOff(DomResourcePixmap *a) { delete m_disabledOff; m_children |= DisabledOff; m_disabledOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementDisabledOn() +DomResourcePixmap *DomResourceIcon::takeElementDisabledOn() { - DomResourcePixmap* a = m_disabledOn; + DomResourcePixmap *a = m_disabledOn; m_disabledOn = 0; m_children ^= DisabledOn; return a; } -void DomResourceIcon::setElementDisabledOn(DomResourcePixmap* a) +void DomResourceIcon::setElementDisabledOn(DomResourcePixmap *a) { delete m_disabledOn; m_children |= DisabledOn; m_disabledOn = a; } -DomResourcePixmap* DomResourceIcon::takeElementActiveOff() +DomResourcePixmap *DomResourceIcon::takeElementActiveOff() { - DomResourcePixmap* a = m_activeOff; + DomResourcePixmap *a = m_activeOff; m_activeOff = 0; m_children ^= ActiveOff; return a; } -void DomResourceIcon::setElementActiveOff(DomResourcePixmap* a) +void DomResourceIcon::setElementActiveOff(DomResourcePixmap *a) { delete m_activeOff; m_children |= ActiveOff; m_activeOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementActiveOn() +DomResourcePixmap *DomResourceIcon::takeElementActiveOn() { - DomResourcePixmap* a = m_activeOn; + DomResourcePixmap *a = m_activeOn; m_activeOn = 0; m_children ^= ActiveOn; return a; } -void DomResourceIcon::setElementActiveOn(DomResourcePixmap* a) +void DomResourceIcon::setElementActiveOn(DomResourcePixmap *a) { delete m_activeOn; m_children |= ActiveOn; m_activeOn = a; } -DomResourcePixmap* DomResourceIcon::takeElementSelectedOff() +DomResourcePixmap *DomResourceIcon::takeElementSelectedOff() { - DomResourcePixmap* a = m_selectedOff; + DomResourcePixmap *a = m_selectedOff; m_selectedOff = 0; m_children ^= SelectedOff; return a; } -void DomResourceIcon::setElementSelectedOff(DomResourcePixmap* a) +void DomResourceIcon::setElementSelectedOff(DomResourcePixmap *a) { delete m_selectedOff; m_children |= SelectedOff; m_selectedOff = a; } -DomResourcePixmap* DomResourceIcon::takeElementSelectedOn() +DomResourcePixmap *DomResourceIcon::takeElementSelectedOn() { - DomResourcePixmap* a = m_selectedOn; + DomResourcePixmap *a = m_selectedOn; m_selectedOn = 0; m_children ^= SelectedOn; return a; } -void DomResourceIcon::setElementSelectedOn(DomResourcePixmap* a) +void DomResourceIcon::setElementSelectedOn(DomResourcePixmap *a) { delete m_selectedOn; m_children |= SelectedOn; @@ -6592,38 +4451,15 @@ void DomResourceIcon::clearElementSelectedOn() m_children &= ~SelectedOn; } -void DomString::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_notr = false; - m_has_attr_comment = false; - m_has_attr_extraComment = false; - } - - m_children = 0; -} - -DomString::DomString() -{ - m_children = 0; - m_has_attr_notr = false; - m_has_attr_comment = false; - m_has_attr_extraComment = false; - m_text.clear(); -} - DomString::~DomString() { } void DomString::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("notr")) { setAttributeNotr(attribute.value().toString()); continue; @@ -6639,16 +4475,15 @@ void DomString::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; + return; case QXmlStreamReader::Characters : if (!reader.isWhitespace()) m_text.append(reader.text().toString()); @@ -6661,7 +4496,7 @@ void DomString::read(QXmlStreamReader &reader) void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("string") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("string") : tagName.toLower()); if (hasAttributeNotr()) writer.writeAttribute(QStringLiteral("notr"), attributeNotr()); @@ -6678,41 +4513,21 @@ void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeEndElement(); } -void DomPointF::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_x = 0; - m_y = 0; -} - -DomPointF::DomPointF() -{ - m_children = 0; - m_x = 0; - m_y = 0; -} - DomPointF::~DomPointF() { } void DomPointF::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("x")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; } - if (tag == QLatin1String("y")) { + if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { setElementY(reader.readElementText().toDouble()); continue; } @@ -6720,12 +4535,7 @@ void DomPointF::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -6734,18 +4544,13 @@ void DomPointF::read(QXmlStreamReader &reader) void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("pointf") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("pointf") : tagName.toLower()); - if (m_children & X) { + if (m_children & X) writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); - } - if (m_children & Y) { + if (m_children & Y) writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -6772,53 +4577,29 @@ void DomPointF::clearElementY() m_children &= ~Y; } -void DomRectF::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_x = 0; - m_y = 0; - m_width = 0; - m_height = 0; -} - -DomRectF::DomRectF() -{ - m_children = 0; - m_x = 0; - m_y = 0; - m_width = 0; - m_height = 0; -} - DomRectF::~DomRectF() { } void DomRectF::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("x")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toDouble()); continue; } - if (tag == QLatin1String("y")) { + if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { setElementY(reader.readElementText().toDouble()); continue; } - if (tag == QLatin1String("width")) { + if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toDouble()); continue; } - if (tag == QLatin1String("height")) { + if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toDouble()); continue; } @@ -6826,12 +4607,7 @@ void DomRectF::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -6840,26 +4616,19 @@ void DomRectF::read(QXmlStreamReader &reader) void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("rectf") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("rectf") : tagName.toLower()); - if (m_children & X) { + if (m_children & X) writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15)); - } - if (m_children & Y) { + if (m_children & Y) writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15)); - } - if (m_children & Width) { + if (m_children & Width) writer.writeTextElement(QStringLiteral("width"), QString::number(m_width, 'f', 15)); - } - if (m_children & Height) { + if (m_children & Height) writer.writeTextElement(QStringLiteral("height"), QString::number(m_height, 'f', 15)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -6908,41 +4677,21 @@ void DomRectF::clearElementHeight() m_children &= ~Height; } -void DomSizeF::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_width = 0; - m_height = 0; -} - -DomSizeF::DomSizeF() -{ - m_children = 0; - m_width = 0; - m_height = 0; -} - DomSizeF::~DomSizeF() { } void DomSizeF::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("width")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("width"), Qt::CaseInsensitive)) { setElementWidth(reader.readElementText().toDouble()); continue; } - if (tag == QLatin1String("height")) { + if (!tag.compare(QLatin1String("height"), Qt::CaseInsensitive)) { setElementHeight(reader.readElementText().toDouble()); continue; } @@ -6950,12 +4699,7 @@ void DomSizeF::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -6964,18 +4708,13 @@ void DomSizeF::read(QXmlStreamReader &reader) void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizef") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("sizef") : tagName.toLower()); - if (m_children & Width) { + if (m_children & Width) writer.writeTextElement(QStringLiteral("width"), QString::number(m_width, 'f', 15)); - } - if (m_children & Height) { + if (m_children & Height) writer.writeTextElement(QStringLiteral("height"), QString::number(m_height, 'f', 15)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -7002,35 +4741,17 @@ void DomSizeF::clearElementHeight() m_children &= ~Height; } -void DomChar::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_unicode = 0; -} - -DomChar::DomChar() -{ - m_children = 0; - m_unicode = 0; -} - DomChar::~DomChar() { } void DomChar::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("unicode")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("unicode"), Qt::CaseInsensitive)) { setElementUnicode(reader.readElementText().toInt()); continue; } @@ -7038,12 +4759,7 @@ void DomChar::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -7052,14 +4768,10 @@ void DomChar::read(QXmlStreamReader &reader) void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("char") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("char") : tagName.toLower()); - if (m_children & Unicode) { + if (m_children & Unicode) writer.writeTextElement(QStringLiteral("unicode"), QString::number(m_unicode)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -7075,24 +4787,6 @@ void DomChar::clearElementUnicode() m_children &= ~Unicode; } -void DomUrl::clear(bool clear_all) -{ - delete m_string; - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_string = 0; -} - -DomUrl::DomUrl() -{ - m_children = 0; - m_string = 0; -} - DomUrl::~DomUrl() { delete m_string; @@ -7100,12 +4794,11 @@ DomUrl::~DomUrl() void DomUrl::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("string")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { DomString *v = new DomString(); v->read(reader); setElementString(v); @@ -7115,12 +4808,7 @@ void DomUrl::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -7129,27 +4817,23 @@ void DomUrl::read(QXmlStreamReader &reader) void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("url") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("url") : tagName.toLower()); - if (m_children & String) { + if (m_children & String) m_string->write(writer, QStringLiteral("string")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -DomString* DomUrl::takeElementString() +DomString *DomUrl::takeElementString() { - DomString* a = m_string; + DomString *a = m_string; m_string = 0; m_children ^= String; return a; } -void DomUrl::setElementString(DomString* a) +void DomUrl::setElementString(DomString *a) { delete m_string; m_children |= String; @@ -7163,7 +4847,7 @@ void DomUrl::clearElementString() m_children &= ~String; } -void DomProperty::clear(bool clear_all) +DomProperty::~DomProperty() { delete m_color; delete m_font; @@ -7186,84 +4870,9 @@ void DomProperty::clear(bool clear_all) delete m_char; delete m_url; delete m_brush; - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - m_has_attr_stdset = false; - m_attr_stdset = 0; - } - - m_kind = Unknown; - - m_color = 0; - m_cursor = 0; - m_font = 0; - m_iconSet = 0; - m_pixmap = 0; - m_palette = 0; - m_point = 0; - m_rect = 0; - m_locale = 0; - m_sizePolicy = 0; - m_size = 0; - m_string = 0; - m_stringList = 0; - m_number = 0; - m_float = 0.0; - m_double = 0; - m_date = 0; - m_time = 0; - m_dateTime = 0; - m_pointF = 0; - m_rectF = 0; - m_sizeF = 0; - m_longLong = 0; - m_char = 0; - m_url = 0; - m_UInt = 0; - m_uLongLong = 0; - m_brush = 0; } -DomProperty::DomProperty() -{ - m_kind = Unknown; - - m_has_attr_name = false; - m_has_attr_stdset = false; - m_attr_stdset = 0; - m_color = 0; - m_cursor = 0; - m_font = 0; - m_iconSet = 0; - m_pixmap = 0; - m_palette = 0; - m_point = 0; - m_rect = 0; - m_locale = 0; - m_sizePolicy = 0; - m_size = 0; - m_string = 0; - m_stringList = 0; - m_number = 0; - m_float = 0.0; - m_double = 0; - m_date = 0; - m_time = 0; - m_dateTime = 0; - m_pointF = 0; - m_rectF = 0; - m_sizeF = 0; - m_longLong = 0; - m_char = 0; - m_url = 0; - m_UInt = 0; - m_uLongLong = 0; - m_brush = 0; -} - -DomProperty::~DomProperty() +void DomProperty::clear() { delete m_color; delete m_font; @@ -7286,14 +4895,44 @@ DomProperty::~DomProperty() delete m_char; delete m_url; delete m_brush; + + m_kind = Unknown; + + m_color = nullptr; + m_cursor = 0; + m_font = nullptr; + m_iconSet = nullptr; + m_pixmap = nullptr; + m_palette = nullptr; + m_point = nullptr; + m_rect = nullptr; + m_locale = nullptr; + m_sizePolicy = nullptr; + m_size = nullptr; + m_string = nullptr; + m_stringList = nullptr; + m_number = 0; + m_float = 0.0; + m_double = 0.0; + m_date = nullptr; + m_time = nullptr; + m_dateTime = nullptr; + m_pointF = nullptr; + m_rectF = nullptr; + m_sizeF = nullptr; + m_longLong = 0; + m_char = nullptr; + m_url = nullptr; + m_UInt = 0; + m_uLongLong = 0; + m_brush = nullptr; } void DomProperty::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -7305,179 +4944,179 @@ void DomProperty::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("bool")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("bool"), Qt::CaseInsensitive)) { setElementBool(reader.readElementText()); continue; } - if (tag == QLatin1String("color")) { + if (!tag.compare(QLatin1String("color"), Qt::CaseInsensitive)) { DomColor *v = new DomColor(); v->read(reader); setElementColor(v); continue; } - if (tag == QLatin1String("cstring")) { + if (!tag.compare(QLatin1String("cstring"), Qt::CaseInsensitive)) { setElementCstring(reader.readElementText()); continue; } - if (tag == QLatin1String("cursor")) { + if (!tag.compare(QLatin1String("cursor"), Qt::CaseInsensitive)) { setElementCursor(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("cursorshape")) { + if (!tag.compare(QLatin1String("cursorshape"), Qt::CaseInsensitive)) { setElementCursorShape(reader.readElementText()); continue; } - if (tag == QLatin1String("enum")) { + if (!tag.compare(QLatin1String("enum"), Qt::CaseInsensitive)) { setElementEnum(reader.readElementText()); continue; } - if (tag == QLatin1String("font")) { + if (!tag.compare(QLatin1String("font"), Qt::CaseInsensitive)) { DomFont *v = new DomFont(); v->read(reader); setElementFont(v); continue; } - if (tag == QLatin1String("iconset")) { + if (!tag.compare(QLatin1String("iconset"), Qt::CaseInsensitive)) { DomResourceIcon *v = new DomResourceIcon(); v->read(reader); setElementIconSet(v); continue; } - if (tag == QLatin1String("pixmap")) { + if (!tag.compare(QLatin1String("pixmap"), Qt::CaseInsensitive)) { DomResourcePixmap *v = new DomResourcePixmap(); v->read(reader); setElementPixmap(v); continue; } - if (tag == QLatin1String("palette")) { + if (!tag.compare(QLatin1String("palette"), Qt::CaseInsensitive)) { DomPalette *v = new DomPalette(); v->read(reader); setElementPalette(v); continue; } - if (tag == QLatin1String("point")) { + if (!tag.compare(QLatin1String("point"), Qt::CaseInsensitive)) { DomPoint *v = new DomPoint(); v->read(reader); setElementPoint(v); continue; } - if (tag == QLatin1String("rect")) { + if (!tag.compare(QLatin1String("rect"), Qt::CaseInsensitive)) { DomRect *v = new DomRect(); v->read(reader); setElementRect(v); continue; } - if (tag == QLatin1String("set")) { + if (!tag.compare(QLatin1String("set"), Qt::CaseInsensitive)) { setElementSet(reader.readElementText()); continue; } - if (tag == QLatin1String("locale")) { + if (!tag.compare(QLatin1String("locale"), Qt::CaseInsensitive)) { DomLocale *v = new DomLocale(); v->read(reader); setElementLocale(v); continue; } - if (tag == QLatin1String("sizepolicy")) { + if (!tag.compare(QLatin1String("sizepolicy"), Qt::CaseInsensitive)) { DomSizePolicy *v = new DomSizePolicy(); v->read(reader); setElementSizePolicy(v); continue; } - if (tag == QLatin1String("size")) { + if (!tag.compare(QLatin1String("size"), Qt::CaseInsensitive)) { DomSize *v = new DomSize(); v->read(reader); setElementSize(v); continue; } - if (tag == QLatin1String("string")) { + if (!tag.compare(QLatin1String("string"), Qt::CaseInsensitive)) { DomString *v = new DomString(); v->read(reader); setElementString(v); continue; } - if (tag == QLatin1String("stringlist")) { + if (!tag.compare(QLatin1String("stringlist"), Qt::CaseInsensitive)) { DomStringList *v = new DomStringList(); v->read(reader); setElementStringList(v); continue; } - if (tag == QLatin1String("number")) { + if (!tag.compare(QLatin1String("number"), Qt::CaseInsensitive)) { setElementNumber(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("float")) { + if (!tag.compare(QLatin1String("float"), Qt::CaseInsensitive)) { setElementFloat(reader.readElementText().toFloat()); continue; } - if (tag == QLatin1String("double")) { + if (!tag.compare(QLatin1String("double"), Qt::CaseInsensitive)) { setElementDouble(reader.readElementText().toDouble()); continue; } - if (tag == QLatin1String("date")) { + if (!tag.compare(QLatin1String("date"), Qt::CaseInsensitive)) { DomDate *v = new DomDate(); v->read(reader); setElementDate(v); continue; } - if (tag == QLatin1String("time")) { + if (!tag.compare(QLatin1String("time"), Qt::CaseInsensitive)) { DomTime *v = new DomTime(); v->read(reader); setElementTime(v); continue; } - if (tag == QLatin1String("datetime")) { + if (!tag.compare(QLatin1String("datetime"), Qt::CaseInsensitive)) { DomDateTime *v = new DomDateTime(); v->read(reader); setElementDateTime(v); continue; } - if (tag == QLatin1String("pointf")) { + if (!tag.compare(QLatin1String("pointf"), Qt::CaseInsensitive)) { DomPointF *v = new DomPointF(); v->read(reader); setElementPointF(v); continue; } - if (tag == QLatin1String("rectf")) { + if (!tag.compare(QLatin1String("rectf"), Qt::CaseInsensitive)) { DomRectF *v = new DomRectF(); v->read(reader); setElementRectF(v); continue; } - if (tag == QLatin1String("sizef")) { + if (!tag.compare(QLatin1String("sizef"), Qt::CaseInsensitive)) { DomSizeF *v = new DomSizeF(); v->read(reader); setElementSizeF(v); continue; } - if (tag == QLatin1String("longlong")) { + if (!tag.compare(QLatin1String("longlong"), Qt::CaseInsensitive)) { setElementLongLong(reader.readElementText().toLongLong()); continue; } - if (tag == QLatin1String("char")) { + if (!tag.compare(QLatin1String("char"), Qt::CaseInsensitive)) { DomChar *v = new DomChar(); v->read(reader); setElementChar(v); continue; } - if (tag == QLatin1String("url")) { + if (!tag.compare(QLatin1String("url"), Qt::CaseInsensitive)) { DomUrl *v = new DomUrl(); v->read(reader); setElementUrl(v); continue; } - if (tag == QLatin1String("uint")) { + if (!tag.compare(QLatin1String("uint"), Qt::CaseInsensitive)) { setElementUInt(reader.readElementText().toUInt()); continue; } - if (tag == QLatin1String("ulonglong")) { + if (!tag.compare(QLatin1String("ulonglong"), Qt::CaseInsensitive)) { setElementULongLong(reader.readElementText().toULongLong()); continue; } - if (tag == QLatin1String("brush")) { + if (!tag.compare(QLatin1String("brush"), Qt::CaseInsensitive)) { DomBrush *v = new DomBrush(); v->read(reader); setElementBrush(v); @@ -7487,12 +5126,7 @@ void DomProperty::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -7501,7 +5135,7 @@ void DomProperty::read(QXmlStreamReader &reader) void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("property") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("property") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); @@ -7510,605 +5144,564 @@ void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const writer.writeAttribute(QStringLiteral("stdset"), QString::number(attributeStdset())); switch (kind()) { - case Bool: { - writer.writeTextElement(QStringLiteral("bool"), elementBool()); - break; - } - case Color: { - DomColor* v = elementColor(); - if (v != 0) { - v->write(writer, QStringLiteral("color")); - } - break; - } - case Cstring: { - writer.writeTextElement(QStringLiteral("cstring"), elementCstring()); - break; - } - case Cursor: { - writer.writeTextElement(QStringLiteral("cursor"), QString::number(elementCursor())); - break; - } - case CursorShape: { - writer.writeTextElement(QStringLiteral("cursorShape"), elementCursorShape()); - break; - } - case Enum: { - writer.writeTextElement(QStringLiteral("enum"), elementEnum()); - break; - } - case Font: { - DomFont* v = elementFont(); - if (v != 0) { - v->write(writer, QStringLiteral("font")); - } - break; - } - case IconSet: { - DomResourceIcon* v = elementIconSet(); - if (v != 0) { - v->write(writer, QStringLiteral("iconset")); - } - break; - } - case Pixmap: { - DomResourcePixmap* v = elementPixmap(); - if (v != 0) { - v->write(writer, QStringLiteral("pixmap")); - } - break; - } - case Palette: { - DomPalette* v = elementPalette(); - if (v != 0) { - v->write(writer, QStringLiteral("palette")); - } - break; - } - case Point: { - DomPoint* v = elementPoint(); - if (v != 0) { - v->write(writer, QStringLiteral("point")); - } - break; - } - case Rect: { - DomRect* v = elementRect(); - if (v != 0) { - v->write(writer, QStringLiteral("rect")); - } - break; - } - case Set: { - writer.writeTextElement(QStringLiteral("set"), elementSet()); - break; - } - case Locale: { - DomLocale* v = elementLocale(); - if (v != 0) { - v->write(writer, QStringLiteral("locale")); - } - break; - } - case SizePolicy: { - DomSizePolicy* v = elementSizePolicy(); - if (v != 0) { - v->write(writer, QStringLiteral("sizepolicy")); - } - break; - } - case Size: { - DomSize* v = elementSize(); - if (v != 0) { - v->write(writer, QStringLiteral("size")); - } - break; - } - case String: { - DomString* v = elementString(); - if (v != 0) { - v->write(writer, QStringLiteral("string")); - } - break; - } - case StringList: { - DomStringList* v = elementStringList(); - if (v != 0) { - v->write(writer, QStringLiteral("stringlist")); - } - break; - } - case Number: { - writer.writeTextElement(QStringLiteral("number"), QString::number(elementNumber())); - break; - } - case Float: { - writer.writeTextElement(QStringLiteral("float"), QString::number(elementFloat(), 'f', 8)); - break; - } - case Double: { - writer.writeTextElement(QStringLiteral("double"), QString::number(elementDouble(), 'f', 15)); - break; - } - case Date: { - DomDate* v = elementDate(); - if (v != 0) { - v->write(writer, QStringLiteral("date")); - } - break; - } - case Time: { - DomTime* v = elementTime(); - if (v != 0) { - v->write(writer, QStringLiteral("time")); - } - break; - } - case DateTime: { - DomDateTime* v = elementDateTime(); - if (v != 0) { - v->write(writer, QStringLiteral("datetime")); - } - break; - } - case PointF: { - DomPointF* v = elementPointF(); - if (v != 0) { - v->write(writer, QStringLiteral("pointf")); - } - break; - } - case RectF: { - DomRectF* v = elementRectF(); - if (v != 0) { - v->write(writer, QStringLiteral("rectf")); - } - break; - } - case SizeF: { - DomSizeF* v = elementSizeF(); - if (v != 0) { - v->write(writer, QStringLiteral("sizef")); - } - break; - } - case LongLong: { - writer.writeTextElement(QStringLiteral("longLong"), QString::number(elementLongLong())); - break; - } - case Char: { - DomChar* v = elementChar(); - if (v != 0) { - v->write(writer, QStringLiteral("char")); - } - break; - } - case Url: { - DomUrl* v = elementUrl(); - if (v != 0) { - v->write(writer, QStringLiteral("url")); - } - break; - } - case UInt: { - writer.writeTextElement(QStringLiteral("UInt"), QString::number(elementUInt())); - break; - } - case ULongLong: { - writer.writeTextElement(QStringLiteral("uLongLong"), QString::number(elementULongLong())); - break; - } - case Brush: { - DomBrush* v = elementBrush(); - if (v != 0) { - v->write(writer, QStringLiteral("brush")); - } - break; - } - default: - break; + case Bool: { + writer.writeTextElement(QStringLiteral("bool"), elementBool()); + break; + } + case Color: { + DomColor *v = elementColor(); + if (v != 0) + v->write(writer, QStringLiteral("color")); + break; + } + case Cstring: { + writer.writeTextElement(QStringLiteral("cstring"), elementCstring()); + break; + } + case Cursor: { + writer.writeTextElement(QStringLiteral("cursor"), QString::number(elementCursor())); + break; + } + case CursorShape: { + writer.writeTextElement(QStringLiteral("cursorShape"), elementCursorShape()); + break; + } + case Enum: { + writer.writeTextElement(QStringLiteral("enum"), elementEnum()); + break; + } + case Font: { + DomFont *v = elementFont(); + if (v != 0) + v->write(writer, QStringLiteral("font")); + break; + } + case IconSet: { + DomResourceIcon *v = elementIconSet(); + if (v != 0) + v->write(writer, QStringLiteral("iconset")); + break; + } + case Pixmap: { + DomResourcePixmap *v = elementPixmap(); + if (v != 0) + v->write(writer, QStringLiteral("pixmap")); + break; + } + case Palette: { + DomPalette *v = elementPalette(); + if (v != 0) + v->write(writer, QStringLiteral("palette")); + break; + } + case Point: { + DomPoint *v = elementPoint(); + if (v != 0) + v->write(writer, QStringLiteral("point")); + break; + } + case Rect: { + DomRect *v = elementRect(); + if (v != 0) + v->write(writer, QStringLiteral("rect")); + break; + } + case Set: { + writer.writeTextElement(QStringLiteral("set"), elementSet()); + break; + } + case Locale: { + DomLocale *v = elementLocale(); + if (v != 0) + v->write(writer, QStringLiteral("locale")); + break; + } + case SizePolicy: { + DomSizePolicy *v = elementSizePolicy(); + if (v != 0) + v->write(writer, QStringLiteral("sizepolicy")); + break; + } + case Size: { + DomSize *v = elementSize(); + if (v != 0) + v->write(writer, QStringLiteral("size")); + break; + } + case String: { + DomString *v = elementString(); + if (v != 0) + v->write(writer, QStringLiteral("string")); + break; + } + case StringList: { + DomStringList *v = elementStringList(); + if (v != 0) + v->write(writer, QStringLiteral("stringlist")); + break; + } + case Number: { + writer.writeTextElement(QStringLiteral("number"), QString::number(elementNumber())); + break; + } + case Float: { + writer.writeTextElement(QStringLiteral("float"), QString::number(elementFloat(), 'f', 8)); + break; + } + case Double: { + writer.writeTextElement(QStringLiteral("double"), QString::number(elementDouble(), 'f', 15)); + break; + } + case Date: { + DomDate *v = elementDate(); + if (v != 0) + v->write(writer, QStringLiteral("date")); + break; + } + case Time: { + DomTime *v = elementTime(); + if (v != 0) + v->write(writer, QStringLiteral("time")); + break; + } + case DateTime: { + DomDateTime *v = elementDateTime(); + if (v != 0) + v->write(writer, QStringLiteral("datetime")); + break; + } + case PointF: { + DomPointF *v = elementPointF(); + if (v != 0) + v->write(writer, QStringLiteral("pointf")); + break; + } + case RectF: { + DomRectF *v = elementRectF(); + if (v != 0) + v->write(writer, QStringLiteral("rectf")); + break; + } + case SizeF: { + DomSizeF *v = elementSizeF(); + if (v != 0) + v->write(writer, QStringLiteral("sizef")); + break; + } + case LongLong: { + writer.writeTextElement(QStringLiteral("longLong"), QString::number(elementLongLong())); + break; + } + case Char: { + DomChar *v = elementChar(); + if (v != 0) + v->write(writer, QStringLiteral("char")); + break; + } + case Url: { + DomUrl *v = elementUrl(); + if (v != 0) + v->write(writer, QStringLiteral("url")); + break; + } + case UInt: { + writer.writeTextElement(QStringLiteral("UInt"), QString::number(elementUInt())); + break; + } + case ULongLong: { + writer.writeTextElement(QStringLiteral("uLongLong"), QString::number(elementULongLong())); + break; + } + case Brush: { + DomBrush *v = elementBrush(); + if (v != 0) + v->write(writer, QStringLiteral("brush")); + break; + } + default: + break; } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomProperty::setElementBool(const QString& a) +void DomProperty::setElementBool(const QString &a) { - clear(false); + clear(); m_kind = Bool; m_bool = a; } -DomColor* DomProperty::takeElementColor() +DomColor *DomProperty::takeElementColor() { - DomColor* a = m_color; + DomColor *a = m_color; m_color = 0; return a; } -void DomProperty::setElementColor(DomColor* a) +void DomProperty::setElementColor(DomColor *a) { - clear(false); + clear(); m_kind = Color; m_color = a; } -void DomProperty::setElementCstring(const QString& a) +void DomProperty::setElementCstring(const QString &a) { - clear(false); + clear(); m_kind = Cstring; m_cstring = a; } void DomProperty::setElementCursor(int a) { - clear(false); + clear(); m_kind = Cursor; m_cursor = a; } -void DomProperty::setElementCursorShape(const QString& a) +void DomProperty::setElementCursorShape(const QString &a) { - clear(false); + clear(); m_kind = CursorShape; m_cursorShape = a; } -void DomProperty::setElementEnum(const QString& a) +void DomProperty::setElementEnum(const QString &a) { - clear(false); + clear(); m_kind = Enum; m_enum = a; } -DomFont* DomProperty::takeElementFont() +DomFont *DomProperty::takeElementFont() { - DomFont* a = m_font; + DomFont *a = m_font; m_font = 0; return a; } -void DomProperty::setElementFont(DomFont* a) +void DomProperty::setElementFont(DomFont *a) { - clear(false); + clear(); m_kind = Font; m_font = a; } -DomResourceIcon* DomProperty::takeElementIconSet() +DomResourceIcon *DomProperty::takeElementIconSet() { - DomResourceIcon* a = m_iconSet; + DomResourceIcon *a = m_iconSet; m_iconSet = 0; return a; } -void DomProperty::setElementIconSet(DomResourceIcon* a) +void DomProperty::setElementIconSet(DomResourceIcon *a) { - clear(false); + clear(); m_kind = IconSet; m_iconSet = a; } -DomResourcePixmap* DomProperty::takeElementPixmap() +DomResourcePixmap *DomProperty::takeElementPixmap() { - DomResourcePixmap* a = m_pixmap; + DomResourcePixmap *a = m_pixmap; m_pixmap = 0; return a; } -void DomProperty::setElementPixmap(DomResourcePixmap* a) +void DomProperty::setElementPixmap(DomResourcePixmap *a) { - clear(false); + clear(); m_kind = Pixmap; m_pixmap = a; } -DomPalette* DomProperty::takeElementPalette() +DomPalette *DomProperty::takeElementPalette() { - DomPalette* a = m_palette; + DomPalette *a = m_palette; m_palette = 0; return a; } -void DomProperty::setElementPalette(DomPalette* a) +void DomProperty::setElementPalette(DomPalette *a) { - clear(false); + clear(); m_kind = Palette; m_palette = a; } -DomPoint* DomProperty::takeElementPoint() +DomPoint *DomProperty::takeElementPoint() { - DomPoint* a = m_point; + DomPoint *a = m_point; m_point = 0; return a; } -void DomProperty::setElementPoint(DomPoint* a) +void DomProperty::setElementPoint(DomPoint *a) { - clear(false); + clear(); m_kind = Point; m_point = a; } -DomRect* DomProperty::takeElementRect() +DomRect *DomProperty::takeElementRect() { - DomRect* a = m_rect; + DomRect *a = m_rect; m_rect = 0; return a; } -void DomProperty::setElementRect(DomRect* a) +void DomProperty::setElementRect(DomRect *a) { - clear(false); + clear(); m_kind = Rect; m_rect = a; } -void DomProperty::setElementSet(const QString& a) +void DomProperty::setElementSet(const QString &a) { - clear(false); + clear(); m_kind = Set; m_set = a; } -DomLocale* DomProperty::takeElementLocale() +DomLocale *DomProperty::takeElementLocale() { - DomLocale* a = m_locale; + DomLocale *a = m_locale; m_locale = 0; return a; } -void DomProperty::setElementLocale(DomLocale* a) +void DomProperty::setElementLocale(DomLocale *a) { - clear(false); + clear(); m_kind = Locale; m_locale = a; } -DomSizePolicy* DomProperty::takeElementSizePolicy() +DomSizePolicy *DomProperty::takeElementSizePolicy() { - DomSizePolicy* a = m_sizePolicy; + DomSizePolicy *a = m_sizePolicy; m_sizePolicy = 0; return a; } -void DomProperty::setElementSizePolicy(DomSizePolicy* a) +void DomProperty::setElementSizePolicy(DomSizePolicy *a) { - clear(false); + clear(); m_kind = SizePolicy; m_sizePolicy = a; } -DomSize* DomProperty::takeElementSize() +DomSize *DomProperty::takeElementSize() { - DomSize* a = m_size; + DomSize *a = m_size; m_size = 0; return a; } -void DomProperty::setElementSize(DomSize* a) +void DomProperty::setElementSize(DomSize *a) { - clear(false); + clear(); m_kind = Size; m_size = a; } -DomString* DomProperty::takeElementString() +DomString *DomProperty::takeElementString() { - DomString* a = m_string; + DomString *a = m_string; m_string = 0; return a; } -void DomProperty::setElementString(DomString* a) +void DomProperty::setElementString(DomString *a) { - clear(false); + clear(); m_kind = String; m_string = a; } -DomStringList* DomProperty::takeElementStringList() +DomStringList *DomProperty::takeElementStringList() { - DomStringList* a = m_stringList; + DomStringList *a = m_stringList; m_stringList = 0; return a; } -void DomProperty::setElementStringList(DomStringList* a) +void DomProperty::setElementStringList(DomStringList *a) { - clear(false); + clear(); m_kind = StringList; m_stringList = a; } void DomProperty::setElementNumber(int a) { - clear(false); + clear(); m_kind = Number; m_number = a; } void DomProperty::setElementFloat(float a) { - clear(false); + clear(); m_kind = Float; m_float = a; } void DomProperty::setElementDouble(double a) { - clear(false); + clear(); m_kind = Double; m_double = a; } -DomDate* DomProperty::takeElementDate() +DomDate *DomProperty::takeElementDate() { - DomDate* a = m_date; + DomDate *a = m_date; m_date = 0; return a; } -void DomProperty::setElementDate(DomDate* a) +void DomProperty::setElementDate(DomDate *a) { - clear(false); + clear(); m_kind = Date; m_date = a; } -DomTime* DomProperty::takeElementTime() +DomTime *DomProperty::takeElementTime() { - DomTime* a = m_time; + DomTime *a = m_time; m_time = 0; return a; } -void DomProperty::setElementTime(DomTime* a) +void DomProperty::setElementTime(DomTime *a) { - clear(false); + clear(); m_kind = Time; m_time = a; } -DomDateTime* DomProperty::takeElementDateTime() +DomDateTime *DomProperty::takeElementDateTime() { - DomDateTime* a = m_dateTime; + DomDateTime *a = m_dateTime; m_dateTime = 0; return a; } -void DomProperty::setElementDateTime(DomDateTime* a) +void DomProperty::setElementDateTime(DomDateTime *a) { - clear(false); + clear(); m_kind = DateTime; m_dateTime = a; } -DomPointF* DomProperty::takeElementPointF() +DomPointF *DomProperty::takeElementPointF() { - DomPointF* a = m_pointF; + DomPointF *a = m_pointF; m_pointF = 0; return a; } -void DomProperty::setElementPointF(DomPointF* a) +void DomProperty::setElementPointF(DomPointF *a) { - clear(false); + clear(); m_kind = PointF; m_pointF = a; } -DomRectF* DomProperty::takeElementRectF() +DomRectF *DomProperty::takeElementRectF() { - DomRectF* a = m_rectF; + DomRectF *a = m_rectF; m_rectF = 0; return a; } -void DomProperty::setElementRectF(DomRectF* a) +void DomProperty::setElementRectF(DomRectF *a) { - clear(false); + clear(); m_kind = RectF; m_rectF = a; } -DomSizeF* DomProperty::takeElementSizeF() +DomSizeF *DomProperty::takeElementSizeF() { - DomSizeF* a = m_sizeF; + DomSizeF *a = m_sizeF; m_sizeF = 0; return a; } -void DomProperty::setElementSizeF(DomSizeF* a) +void DomProperty::setElementSizeF(DomSizeF *a) { - clear(false); + clear(); m_kind = SizeF; m_sizeF = a; } void DomProperty::setElementLongLong(qlonglong a) { - clear(false); + clear(); m_kind = LongLong; m_longLong = a; } -DomChar* DomProperty::takeElementChar() +DomChar *DomProperty::takeElementChar() { - DomChar* a = m_char; + DomChar *a = m_char; m_char = 0; return a; } -void DomProperty::setElementChar(DomChar* a) +void DomProperty::setElementChar(DomChar *a) { - clear(false); + clear(); m_kind = Char; m_char = a; } -DomUrl* DomProperty::takeElementUrl() +DomUrl *DomProperty::takeElementUrl() { - DomUrl* a = m_url; + DomUrl *a = m_url; m_url = 0; return a; } -void DomProperty::setElementUrl(DomUrl* a) +void DomProperty::setElementUrl(DomUrl *a) { - clear(false); + clear(); m_kind = Url; m_url = a; } void DomProperty::setElementUInt(uint a) { - clear(false); + clear(); m_kind = UInt; m_UInt = a; } void DomProperty::setElementULongLong(qulonglong a) { - clear(false); + clear(); m_kind = ULongLong; m_uLongLong = a; } -DomBrush* DomProperty::takeElementBrush() +DomBrush *DomProperty::takeElementBrush() { - DomBrush* a = m_brush; + DomBrush *a = m_brush; m_brush = 0; return a; } -void DomProperty::setElementBrush(DomBrush* a) +void DomProperty::setElementBrush(DomBrush *a) { - clear(false); + clear(); m_kind = Brush; m_brush = a; } -void DomConnections::clear(bool clear_all) -{ - qDeleteAll(m_connection); - m_connection.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomConnections::DomConnections() -{ - m_children = 0; -} - DomConnections::~DomConnections() { qDeleteAll(m_connection); @@ -8117,12 +5710,11 @@ DomConnections::~DomConnections() void DomConnections::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("connection")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("connection"), Qt::CaseInsensitive)) { DomConnection *v = new DomConnection(); v->read(reader); m_connection.append(v); @@ -8132,12 +5724,7 @@ void DomConnections::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8146,42 +5733,20 @@ void DomConnections::read(QXmlStreamReader &reader) void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connections") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connections") : tagName.toLower()); - for (int i = 0; i < m_connection.size(); ++i) { - DomConnection* v = m_connection[i]; + for (DomConnection *v : m_connection) v->write(writer, QStringLiteral("connection")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomConnections::setElementConnection(const QList<DomConnection*>& a) +void DomConnections::setElementConnection(const QVector<DomConnection *> &a) { m_children |= Connection; m_connection = a; } -void DomConnection::clear(bool clear_all) -{ - delete m_hints; - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; - m_hints = 0; -} - -DomConnection::DomConnection() -{ - m_children = 0; - m_hints = 0; -} - DomConnection::~DomConnection() { delete m_hints; @@ -8189,28 +5754,27 @@ DomConnection::~DomConnection() void DomConnection::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("sender")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("sender"), Qt::CaseInsensitive)) { setElementSender(reader.readElementText()); continue; } - if (tag == QLatin1String("signal")) { + if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) { setElementSignal(reader.readElementText()); continue; } - if (tag == QLatin1String("receiver")) { + if (!tag.compare(QLatin1String("receiver"), Qt::CaseInsensitive)) { setElementReceiver(reader.readElementText()); continue; } - if (tag == QLatin1String("slot")) { + if (!tag.compare(QLatin1String("slot"), Qt::CaseInsensitive)) { setElementSlot(reader.readElementText()); continue; } - if (tag == QLatin1String("hints")) { + if (!tag.compare(QLatin1String("hints"), Qt::CaseInsensitive)) { DomConnectionHints *v = new DomConnectionHints(); v->read(reader); setElementHints(v); @@ -8220,12 +5784,7 @@ void DomConnection::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8234,67 +5793,59 @@ void DomConnection::read(QXmlStreamReader &reader) void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connection") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connection") : tagName.toLower()); - if (m_children & Sender) { + if (m_children & Sender) writer.writeTextElement(QStringLiteral("sender"), m_sender); - } - if (m_children & Signal) { + if (m_children & Signal) writer.writeTextElement(QStringLiteral("signal"), m_signal); - } - if (m_children & Receiver) { + if (m_children & Receiver) writer.writeTextElement(QStringLiteral("receiver"), m_receiver); - } - if (m_children & Slot) { + if (m_children & Slot) writer.writeTextElement(QStringLiteral("slot"), m_slot); - } - if (m_children & Hints) { + if (m_children & Hints) m_hints->write(writer, QStringLiteral("hints")); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomConnection::setElementSender(const QString& a) +void DomConnection::setElementSender(const QString &a) { m_children |= Sender; m_sender = a; } -void DomConnection::setElementSignal(const QString& a) +void DomConnection::setElementSignal(const QString &a) { m_children |= Signal; m_signal = a; } -void DomConnection::setElementReceiver(const QString& a) +void DomConnection::setElementReceiver(const QString &a) { m_children |= Receiver; m_receiver = a; } -void DomConnection::setElementSlot(const QString& a) +void DomConnection::setElementSlot(const QString &a) { m_children |= Slot; m_slot = a; } -DomConnectionHints* DomConnection::takeElementHints() +DomConnectionHints *DomConnection::takeElementHints() { - DomConnectionHints* a = m_hints; + DomConnectionHints *a = m_hints; m_hints = 0; m_children ^= Hints; return a; } -void DomConnection::setElementHints(DomConnectionHints* a) +void DomConnection::setElementHints(DomConnectionHints *a) { delete m_hints; m_children |= Hints; @@ -8328,23 +5879,6 @@ void DomConnection::clearElementHints() m_children &= ~Hints; } -void DomConnectionHints::clear(bool clear_all) -{ - qDeleteAll(m_hint); - m_hint.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomConnectionHints::DomConnectionHints() -{ - m_children = 0; -} - DomConnectionHints::~DomConnectionHints() { qDeleteAll(m_hint); @@ -8353,12 +5887,11 @@ DomConnectionHints::~DomConnectionHints() void DomConnectionHints::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("hint")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("hint"), Qt::CaseInsensitive)) { DomConnectionHint *v = new DomConnectionHint(); v->read(reader); m_hint.append(v); @@ -8368,12 +5901,7 @@ void DomConnectionHints::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8382,55 +5910,29 @@ void DomConnectionHints::read(QXmlStreamReader &reader) void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connectionhints") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhints") : tagName.toLower()); - for (int i = 0; i < m_hint.size(); ++i) { - DomConnectionHint* v = m_hint[i]; + for (DomConnectionHint *v : m_hint) v->write(writer, QStringLiteral("hint")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomConnectionHints::setElementHint(const QList<DomConnectionHint*>& a) +void DomConnectionHints::setElementHint(const QVector<DomConnectionHint *> &a) { m_children |= Hint; m_hint = a; } -void DomConnectionHint::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_type = false; - } - - m_children = 0; - m_x = 0; - m_y = 0; -} - -DomConnectionHint::DomConnectionHint() -{ - m_children = 0; - m_has_attr_type = false; - m_x = 0; - m_y = 0; -} - DomConnectionHint::~DomConnectionHint() { } void DomConnectionHint::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("type")) { setAttributeType(attribute.value().toString()); continue; @@ -8438,15 +5940,15 @@ void DomConnectionHint::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("x")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("x"), Qt::CaseInsensitive)) { setElementX(reader.readElementText().toInt()); continue; } - if (tag == QLatin1String("y")) { + if (!tag.compare(QLatin1String("y"), Qt::CaseInsensitive)) { setElementY(reader.readElementText().toInt()); continue; } @@ -8454,12 +5956,7 @@ void DomConnectionHint::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8468,21 +5965,16 @@ void DomConnectionHint::read(QXmlStreamReader &reader) void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connectionhint") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("connectionhint") : tagName.toLower()); if (hasAttributeType()) writer.writeAttribute(QStringLiteral("type"), attributeType()); - if (m_children & X) { + if (m_children & X) writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x)); - } - if (m_children & Y) { + if (m_children & Y) writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y)); - } - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } @@ -8509,171 +6001,6 @@ void DomConnectionHint::clearElementY() m_children &= ~Y; } -void DomScript::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_source = false; - m_has_attr_language = false; - } - - m_children = 0; -} - -DomScript::DomScript() -{ - m_children = 0; - m_has_attr_source = false; - m_has_attr_language = false; -} - -DomScript::~DomScript() -{ -} - -void DomScript::read(QXmlStreamReader &reader) -{ - - const QXmlStreamAttributes attributes = reader.attributes(); - for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); - if (name == QLatin1String("source")) { - setAttributeSource(attribute.value().toString()); - continue; - } - if (name == QLatin1String("language")) { - setAttributeLanguage(attribute.value().toString()); - continue; - } - reader.raiseError(QLatin1String("Unexpected attribute ") + name); - } - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomScript::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("script") : tagName.toLower()); - - if (hasAttributeSource()) - writer.writeAttribute(QStringLiteral("source"), attributeSource()); - - if (hasAttributeLanguage()) - writer.writeAttribute(QStringLiteral("language"), attributeLanguage()); - - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomWidgetData::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomWidgetData::DomWidgetData() -{ - m_children = 0; -} - -DomWidgetData::~DomWidgetData() -{ - qDeleteAll(m_property); - m_property.clear(); -} - -void DomWidgetData::read(QXmlStreamReader &reader) -{ - - for (bool finished = false; !finished && !reader.hasError();) { - switch (reader.readNext()) { - case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { - DomProperty *v = new DomProperty(); - v->read(reader); - m_property.append(v); - continue; - } - reader.raiseError(QLatin1String("Unexpected element ") + tag); - } - break; - case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; - default : - break; - } - } -} - -void DomWidgetData::write(QXmlStreamWriter &writer, const QString &tagName) const -{ - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("widgetdata") : tagName.toLower()); - - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; - v->write(writer, QStringLiteral("property")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - - writer.writeEndElement(); -} - -void DomWidgetData::setElementProperty(const QList<DomProperty*>& a) -{ - m_children |= Property; - m_property = a; -} - -void DomDesignerData::clear(bool clear_all) -{ - qDeleteAll(m_property); - m_property.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomDesignerData::DomDesignerData() -{ - m_children = 0; -} - DomDesignerData::~DomDesignerData() { qDeleteAll(m_property); @@ -8682,12 +6009,11 @@ DomDesignerData::~DomDesignerData() void DomDesignerData::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("property")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("property"), Qt::CaseInsensitive)) { DomProperty *v = new DomProperty(); v->read(reader); m_property.append(v); @@ -8697,12 +6023,7 @@ void DomDesignerData::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8711,41 +6032,20 @@ void DomDesignerData::read(QXmlStreamReader &reader) void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("designerdata") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("designerdata") : tagName.toLower()); - for (int i = 0; i < m_property.size(); ++i) { - DomProperty* v = m_property[i]; + for (DomProperty *v : m_property) v->write(writer, QStringLiteral("property")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomDesignerData::setElementProperty(const QList<DomProperty*>& a) +void DomDesignerData::setElementProperty(const QList<DomProperty *> &a) { m_children |= Property; m_property = a; } -void DomSlots::clear(bool clear_all) -{ - m_signal.clear(); - m_slot.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomSlots::DomSlots() -{ - m_children = 0; -} - DomSlots::~DomSlots() { m_signal.clear(); @@ -8754,16 +6054,15 @@ DomSlots::~DomSlots() void DomSlots::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("signal")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("signal"), Qt::CaseInsensitive)) { m_signal.append(reader.readElementText()); continue; } - if (tag == QLatin1String("slot")) { + if (!tag.compare(QLatin1String("slot"), Qt::CaseInsensitive)) { m_slot.append(reader.readElementText()); continue; } @@ -8771,12 +6070,7 @@ void DomSlots::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8785,53 +6079,29 @@ void DomSlots::read(QXmlStreamReader &reader) void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("slots") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("slots") : tagName.toLower()); - for (int i = 0; i < m_signal.size(); ++i) { - QString v = m_signal[i]; + for (const QString &v : m_signal) writer.writeTextElement(QStringLiteral("signal"), v); - } - for (int i = 0; i < m_slot.size(); ++i) { - QString v = m_slot[i]; + + for (const QString &v : m_slot) writer.writeTextElement(QStringLiteral("slot"), v); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomSlots::setElementSignal(const QStringList& a) +void DomSlots::setElementSignal(const QStringList &a) { m_children |= Signal; m_signal = a; } -void DomSlots::setElementSlot(const QStringList& a) +void DomSlots::setElementSlot(const QStringList &a) { m_children |= Slot; m_slot = a; } -void DomPropertySpecifications::clear(bool clear_all) -{ - qDeleteAll(m_tooltip); - m_tooltip.clear(); - qDeleteAll(m_stringpropertyspecification); - m_stringpropertyspecification.clear(); - - if (clear_all) { - m_text.clear(); - } - - m_children = 0; -} - -DomPropertySpecifications::DomPropertySpecifications() -{ - m_children = 0; -} - DomPropertySpecifications::~DomPropertySpecifications() { qDeleteAll(m_tooltip); @@ -8842,18 +6112,17 @@ DomPropertySpecifications::~DomPropertySpecifications() void DomPropertySpecifications::read(QXmlStreamReader &reader) { - - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); - if (tag == QLatin1String("tooltip")) { + const QStringRef tag = reader.name(); + if (!tag.compare(QLatin1String("tooltip"), Qt::CaseInsensitive)) { DomPropertyToolTip *v = new DomPropertyToolTip(); v->read(reader); m_tooltip.append(v); continue; } - if (tag == QLatin1String("stringpropertyspecification")) { + if (!tag.compare(QLatin1String("stringpropertyspecification"), Qt::CaseInsensitive)) { DomStringPropertySpecification *v = new DomStringPropertySpecification(); v->read(reader); m_stringpropertyspecification.append(v); @@ -8863,12 +6132,7 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8877,61 +6141,38 @@ void DomPropertySpecifications::read(QXmlStreamReader &reader) void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertyspecifications") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertyspecifications") : tagName.toLower()); - for (int i = 0; i < m_tooltip.size(); ++i) { - DomPropertyToolTip* v = m_tooltip[i]; + for (DomPropertyToolTip *v : m_tooltip) v->write(writer, QStringLiteral("tooltip")); - } - for (int i = 0; i < m_stringpropertyspecification.size(); ++i) { - DomStringPropertySpecification* v = m_stringpropertyspecification[i]; + + for (DomStringPropertySpecification *v : m_stringpropertyspecification) v->write(writer, QStringLiteral("stringpropertyspecification")); - } - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); writer.writeEndElement(); } -void DomPropertySpecifications::setElementTooltip(const QList<DomPropertyToolTip*>& a) +void DomPropertySpecifications::setElementTooltip(const QVector<DomPropertyToolTip *> &a) { m_children |= Tooltip; m_tooltip = a; } -void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a) +void DomPropertySpecifications::setElementStringpropertyspecification(const QVector<DomStringPropertySpecification *> &a) { m_children |= Stringpropertyspecification; m_stringpropertyspecification = a; } -void DomPropertyToolTip::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - } - - m_children = 0; -} - -DomPropertyToolTip::DomPropertyToolTip() -{ - m_children = 0; - m_has_attr_name = false; -} - DomPropertyToolTip::~DomPropertyToolTip() { } void DomPropertyToolTip::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -8939,20 +6180,15 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -8961,48 +6197,23 @@ void DomPropertyToolTip::read(QXmlStreamReader &reader) void DomPropertyToolTip::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertytooltip") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("propertytooltip") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } -void DomStringPropertySpecification::clear(bool clear_all) -{ - - if (clear_all) { - m_text.clear(); - m_has_attr_name = false; - m_has_attr_type = false; - m_has_attr_notr = false; - } - - m_children = 0; -} - -DomStringPropertySpecification::DomStringPropertySpecification() -{ - m_children = 0; - m_has_attr_name = false; - m_has_attr_type = false; - m_has_attr_notr = false; -} - DomStringPropertySpecification::~DomStringPropertySpecification() { } void DomStringPropertySpecification::read(QXmlStreamReader &reader) { - - const QXmlStreamAttributes attributes = reader.attributes(); + const QXmlStreamAttributes &attributes = reader.attributes(); for (const QXmlStreamAttribute &attribute : attributes) { - QStringRef name = attribute.name(); + const QStringRef name = attribute.name(); if (name == QLatin1String("name")) { setAttributeName(attribute.value().toString()); continue; @@ -9018,20 +6229,15 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) reader.raiseError(QLatin1String("Unexpected attribute ") + name); } - for (bool finished = false; !finished && !reader.hasError();) { + while (!reader.hasError()) { switch (reader.readNext()) { case QXmlStreamReader::StartElement : { - const QString tag = reader.name().toString().toLower(); + const QStringRef tag = reader.name(); reader.raiseError(QLatin1String("Unexpected element ") + tag); } break; case QXmlStreamReader::EndElement : - finished = true; - break; - case QXmlStreamReader::Characters : - if (!reader.isWhitespace()) - m_text.append(reader.text().toString()); - break; + return; default : break; } @@ -9040,7 +6246,7 @@ void DomStringPropertySpecification::read(QXmlStreamReader &reader) void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const { - writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringpropertyspecification") : tagName.toLower()); + writer.writeStartElement(tagName.isEmpty() ? QStringLiteral("stringpropertyspecification") : tagName.toLower()); if (hasAttributeName()) writer.writeAttribute(QStringLiteral("name"), attributeName()); @@ -9051,9 +6257,6 @@ void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QStri if (hasAttributeNotr()) writer.writeAttribute(QStringLiteral("notr"), attributeNotr()); - if (!m_text.isEmpty()) - writer.writeCharacters(m_text); - writer.writeEndElement(); } diff --git a/src/designer/src/lib/uilib/ui4_p.h b/src/designer/src/lib/uilib/ui4_p.h index 14d78dc95..e1fd2fb8e 100644 --- a/src/designer/src/lib/uilib/ui4_p.h +++ b/src/designer/src/lib/uilib/ui4_p.h @@ -56,6 +56,7 @@ #include <qlist.h> #include <qstring.h> #include <qstringlist.h> +#include <qvector.h> #include <qxmlstream.h> #include <qglobal.h> @@ -96,15 +97,9 @@ class DomAction; class DomActionRef; class DomButtonGroup; class DomButtonGroups; -class DomImages; -class DomImage; -class DomImageData; class DomCustomWidgets; class DomHeader; class DomCustomWidget; -class DomProperties; -class DomPropertyData; -class DomSizePolicyData; class DomLayoutDefault; class DomLayoutFunction; class DomTabStops; @@ -145,8 +140,6 @@ class DomConnections; class DomConnection; class DomConnectionHints; class DomConnectionHint; -class DomScript; -class DomWidgetData; class DomDesignerData; class DomSlots; class DomPropertySpecifications; @@ -160,28 +153,26 @@ class DomStringPropertySpecification; class QDESIGNER_UILIB_EXPORT DomUI { Q_DISABLE_COPY(DomUI) public: - DomUI(); + DomUI() = default; ~DomUI(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeVersion() const { return m_has_attr_version; } inline QString attributeVersion() const { return m_attr_version; } - inline void setAttributeVersion(const QString& a) { m_attr_version = a; m_has_attr_version = true; } + inline void setAttributeVersion(const QString &a) { m_attr_version = a; m_has_attr_version = true; } inline void clearAttributeVersion() { m_has_attr_version = false; } inline bool hasAttributeLanguage() const { return m_has_attr_language; } inline QString attributeLanguage() const { return m_attr_language; } - inline void setAttributeLanguage(const QString& a) { m_attr_language = a; m_has_attr_language = true; } + inline void setAttributeLanguage(const QString &a) { m_attr_language = a; m_has_attr_language = true; } inline void clearAttributeLanguage() { m_has_attr_language = false; } inline bool hasAttributeDisplayname() const { return m_has_attr_displayname; } inline QString attributeDisplayname() const { return m_attr_displayname; } - inline void setAttributeDisplayname(const QString& a) { m_attr_displayname = a; m_has_attr_displayname = true; } + inline void setAttributeDisplayname(const QString &a) { m_attr_displayname = a; m_has_attr_displayname = true; } inline void clearAttributeDisplayname() { m_has_attr_displayname = false; } inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; } @@ -196,141 +187,132 @@ public: // child element accessors inline QString elementAuthor() const { return m_author; } - void setElementAuthor(const QString& a); + void setElementAuthor(const QString &a); inline bool hasElementAuthor() const { return m_children & Author; } void clearElementAuthor(); inline QString elementComment() const { return m_comment; } - void setElementComment(const QString& a); + void setElementComment(const QString &a); inline bool hasElementComment() const { return m_children & Comment; } void clearElementComment(); inline QString elementExportMacro() const { return m_exportMacro; } - void setElementExportMacro(const QString& a); + void setElementExportMacro(const QString &a); inline bool hasElementExportMacro() const { return m_children & ExportMacro; } void clearElementExportMacro(); inline QString elementClass() const { return m_class; } - void setElementClass(const QString& a); + void setElementClass(const QString &a); inline bool hasElementClass() const { return m_children & Class; } void clearElementClass(); - inline DomWidget* elementWidget() const { return m_widget; } - DomWidget* takeElementWidget(); - void setElementWidget(DomWidget* a); + inline DomWidget *elementWidget() const { return m_widget; } + DomWidget *takeElementWidget(); + void setElementWidget(DomWidget *a); inline bool hasElementWidget() const { return m_children & Widget; } void clearElementWidget(); - inline DomLayoutDefault* elementLayoutDefault() const { return m_layoutDefault; } - DomLayoutDefault* takeElementLayoutDefault(); - void setElementLayoutDefault(DomLayoutDefault* a); + inline DomLayoutDefault *elementLayoutDefault() const { return m_layoutDefault; } + DomLayoutDefault *takeElementLayoutDefault(); + void setElementLayoutDefault(DomLayoutDefault *a); inline bool hasElementLayoutDefault() const { return m_children & LayoutDefault; } void clearElementLayoutDefault(); - inline DomLayoutFunction* elementLayoutFunction() const { return m_layoutFunction; } - DomLayoutFunction* takeElementLayoutFunction(); - void setElementLayoutFunction(DomLayoutFunction* a); + inline DomLayoutFunction *elementLayoutFunction() const { return m_layoutFunction; } + DomLayoutFunction *takeElementLayoutFunction(); + void setElementLayoutFunction(DomLayoutFunction *a); inline bool hasElementLayoutFunction() const { return m_children & LayoutFunction; } void clearElementLayoutFunction(); inline QString elementPixmapFunction() const { return m_pixmapFunction; } - void setElementPixmapFunction(const QString& a); + void setElementPixmapFunction(const QString &a); inline bool hasElementPixmapFunction() const { return m_children & PixmapFunction; } void clearElementPixmapFunction(); - inline DomCustomWidgets* elementCustomWidgets() const { return m_customWidgets; } - DomCustomWidgets* takeElementCustomWidgets(); - void setElementCustomWidgets(DomCustomWidgets* a); + inline DomCustomWidgets *elementCustomWidgets() const { return m_customWidgets; } + DomCustomWidgets *takeElementCustomWidgets(); + void setElementCustomWidgets(DomCustomWidgets *a); inline bool hasElementCustomWidgets() const { return m_children & CustomWidgets; } void clearElementCustomWidgets(); - inline DomTabStops* elementTabStops() const { return m_tabStops; } - DomTabStops* takeElementTabStops(); - void setElementTabStops(DomTabStops* a); + inline DomTabStops *elementTabStops() const { return m_tabStops; } + DomTabStops *takeElementTabStops(); + void setElementTabStops(DomTabStops *a); inline bool hasElementTabStops() const { return m_children & TabStops; } void clearElementTabStops(); - inline DomImages* elementImages() const { return m_images; } - DomImages* takeElementImages(); - void setElementImages(DomImages* a); - inline bool hasElementImages() const { return m_children & Images; } - void clearElementImages(); - - inline DomIncludes* elementIncludes() const { return m_includes; } - DomIncludes* takeElementIncludes(); - void setElementIncludes(DomIncludes* a); + inline DomIncludes *elementIncludes() const { return m_includes; } + DomIncludes *takeElementIncludes(); + void setElementIncludes(DomIncludes *a); inline bool hasElementIncludes() const { return m_children & Includes; } void clearElementIncludes(); - inline DomResources* elementResources() const { return m_resources; } - DomResources* takeElementResources(); - void setElementResources(DomResources* a); + inline DomResources *elementResources() const { return m_resources; } + DomResources *takeElementResources(); + void setElementResources(DomResources *a); inline bool hasElementResources() const { return m_children & Resources; } void clearElementResources(); - inline DomConnections* elementConnections() const { return m_connections; } - DomConnections* takeElementConnections(); - void setElementConnections(DomConnections* a); + inline DomConnections *elementConnections() const { return m_connections; } + DomConnections *takeElementConnections(); + void setElementConnections(DomConnections *a); inline bool hasElementConnections() const { return m_children & Connections; } void clearElementConnections(); - inline DomDesignerData* elementDesignerdata() const { return m_designerdata; } - DomDesignerData* takeElementDesignerdata(); - void setElementDesignerdata(DomDesignerData* a); + inline DomDesignerData *elementDesignerdata() const { return m_designerdata; } + DomDesignerData *takeElementDesignerdata(); + void setElementDesignerdata(DomDesignerData *a); inline bool hasElementDesignerdata() const { return m_children & Designerdata; } void clearElementDesignerdata(); - inline DomSlots* elementSlots() const { return m_slots; } - DomSlots* takeElementSlots(); - void setElementSlots(DomSlots* a); + inline DomSlots *elementSlots() const { return m_slots; } + DomSlots *takeElementSlots(); + void setElementSlots(DomSlots *a); inline bool hasElementSlots() const { return m_children & Slots; } void clearElementSlots(); - inline DomButtonGroups* elementButtonGroups() const { return m_buttonGroups; } - DomButtonGroups* takeElementButtonGroups(); - void setElementButtonGroups(DomButtonGroups* a); + inline DomButtonGroups *elementButtonGroups() const { return m_buttonGroups; } + DomButtonGroups *takeElementButtonGroups(); + void setElementButtonGroups(DomButtonGroups *a); inline bool hasElementButtonGroups() const { return m_children & ButtonGroups; } void clearElementButtonGroups(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_version; - bool m_has_attr_version; + bool m_has_attr_version = false; QString m_attr_language; - bool m_has_attr_language; + bool m_has_attr_language = false; QString m_attr_displayname; - bool m_has_attr_displayname; + bool m_has_attr_displayname = false; - int m_attr_stdsetdef; - bool m_has_attr_stdsetdef; + int m_attr_stdsetdef = 0; + bool m_has_attr_stdsetdef = false; - int m_attr_stdSetDef; - bool m_has_attr_stdSetDef; + int m_attr_stdSetDef = 0; + bool m_has_attr_stdSetDef = false; // child element data - uint m_children; + uint m_children = 0; QString m_author; QString m_comment; QString m_exportMacro; QString m_class; - DomWidget* m_widget; - DomLayoutDefault* m_layoutDefault; - DomLayoutFunction* m_layoutFunction; + DomWidget *m_widget = nullptr; + DomLayoutDefault *m_layoutDefault = nullptr; + DomLayoutFunction *m_layoutFunction = nullptr; QString m_pixmapFunction; - DomCustomWidgets* m_customWidgets; - DomTabStops* m_tabStops; - DomImages* m_images; - DomIncludes* m_includes; - DomResources* m_resources; - DomConnections* m_connections; - DomDesignerData* m_designerdata; - DomSlots* m_slots; - DomButtonGroups* m_buttonGroups; + DomCustomWidgets *m_customWidgets = nullptr; + DomTabStops *m_tabStops = nullptr; + DomIncludes *m_includes = nullptr; + DomResources *m_resources = nullptr; + DomConnections *m_connections = nullptr; + DomDesignerData *m_designerdata = nullptr; + DomSlots *m_slots = nullptr; + DomButtonGroups *m_buttonGroups = nullptr; + enum Child { Author = 1, Comment = 2, @@ -342,40 +324,34 @@ private: PixmapFunction = 128, CustomWidgets = 256, TabStops = 512, - Images = 1024, - Includes = 2048, - Resources = 4096, - Connections = 8192, - Designerdata = 16384, - Slots = 32768, - ButtonGroups = 65536 + Includes = 1024, + Resources = 2048, + Connections = 4096, + Designerdata = 8192, + Slots = 16384, + ButtonGroups = 32768 }; }; class QDESIGNER_UILIB_EXPORT DomIncludes { Q_DISABLE_COPY(DomIncludes) public: - DomIncludes(); + DomIncludes() = default; ~DomIncludes(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomInclude*> elementInclude() const { return m_include; } - void setElementInclude(const QList<DomInclude*>& a); + inline QVector<DomInclude *> elementInclude() const { return m_include; } + void setElementInclude(const QVector<DomInclude *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomInclude*> m_include; + uint m_children = 0; + QVector<DomInclude *> m_include; + enum Child { Include = 1 }; @@ -384,73 +360,65 @@ private: class QDESIGNER_UILIB_EXPORT DomInclude { Q_DISABLE_COPY(DomInclude) public: - DomInclude(); + DomInclude() = default; ~DomInclude(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; + inline QString text() const { return m_text; } inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeLocation() const { return m_has_attr_location; } inline QString attributeLocation() const { return m_attr_location; } - inline void setAttributeLocation(const QString& a) { m_attr_location = a; m_has_attr_location = true; } + inline void setAttributeLocation(const QString &a) { m_attr_location = a; m_has_attr_location = true; } inline void clearAttributeLocation() { m_has_attr_location = false; } inline bool hasAttributeImpldecl() const { return m_has_attr_impldecl; } inline QString attributeImpldecl() const { return m_attr_impldecl; } - inline void setAttributeImpldecl(const QString& a) { m_attr_impldecl = a; m_has_attr_impldecl = true; } + inline void setAttributeImpldecl(const QString &a) { m_attr_impldecl = a; m_has_attr_impldecl = true; } inline void clearAttributeImpldecl() { m_has_attr_impldecl = false; } - // child element accessors private: QString m_text; - void clear(bool clear_all = true); // attribute data QString m_attr_location; - bool m_has_attr_location; + bool m_has_attr_location = false; QString m_attr_impldecl; - bool m_has_attr_impldecl; - - // child element data - uint m_children; + bool m_has_attr_impldecl = false; }; class QDESIGNER_UILIB_EXPORT DomResources { Q_DISABLE_COPY(DomResources) public: - DomResources(); + DomResources() = default; ~DomResources(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } // child element accessors - inline QList<DomResource*> elementInclude() const { return m_include; } - void setElementInclude(const QList<DomResource*>& a); + inline QVector<DomResource *> elementInclude() const { return m_include; } + void setElementInclude(const QVector<DomResource *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; // child element data - uint m_children; - QList<DomResource*> m_include; + uint m_children = 0; + QVector<DomResource *> m_include; + enum Child { Include = 1 }; @@ -459,77 +427,64 @@ private: class QDESIGNER_UILIB_EXPORT DomResource { Q_DISABLE_COPY(DomResource) public: - DomResource(); + DomResource() = default; ~DomResource(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeLocation() const { return m_has_attr_location; } inline QString attributeLocation() const { return m_attr_location; } - inline void setAttributeLocation(const QString& a) { m_attr_location = a; m_has_attr_location = true; } + inline void setAttributeLocation(const QString &a) { m_attr_location = a; m_has_attr_location = true; } inline void clearAttributeLocation() { m_has_attr_location = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_location; - bool m_has_attr_location; - - // child element data - uint m_children; + bool m_has_attr_location = false; }; class QDESIGNER_UILIB_EXPORT DomActionGroup { Q_DISABLE_COPY(DomActionGroup) public: - DomActionGroup(); + DomActionGroup() = default; ~DomActionGroup(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } // child element accessors - inline QList<DomAction*> elementAction() const { return m_action; } - void setElementAction(const QList<DomAction*>& a); + inline QVector<DomAction *> elementAction() const { return m_action; } + void setElementAction(const QVector<DomAction *> &a); - inline QList<DomActionGroup*> elementActionGroup() const { return m_actionGroup; } - void setElementActionGroup(const QList<DomActionGroup*>& a); + inline QVector<DomActionGroup *> elementActionGroup() const { return m_actionGroup; } + void setElementActionGroup(const QVector<DomActionGroup *> &a); inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty*>& a); + void setElementAttribute(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; // child element data - uint m_children; - QList<DomAction*> m_action; - QList<DomActionGroup*> m_actionGroup; + uint m_children = 0; + QVector<DomAction *> m_action; + QVector<DomActionGroup *> m_actionGroup; QList<DomProperty*> m_property; QList<DomProperty*> m_attribute; + enum Child { Action = 1, ActionGroup = 2, @@ -541,47 +496,43 @@ private: class QDESIGNER_UILIB_EXPORT DomAction { Q_DISABLE_COPY(DomAction) public: - DomAction(); + DomAction() = default; ~DomAction(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } inline bool hasAttributeMenu() const { return m_has_attr_menu; } inline QString attributeMenu() const { return m_attr_menu; } - inline void setAttributeMenu(const QString& a) { m_attr_menu = a; m_has_attr_menu = true; } + inline void setAttributeMenu(const QString &a) { m_attr_menu = a; m_has_attr_menu = true; } inline void clearAttributeMenu() { m_has_attr_menu = false; } // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty*>& a); + void setElementAttribute(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; QString m_attr_menu; - bool m_has_attr_menu; + bool m_has_attr_menu = false; // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; QList<DomProperty*> m_attribute; + enum Child { Property = 1, Attribute = 2 @@ -591,69 +542,56 @@ private: class QDESIGNER_UILIB_EXPORT DomActionRef { Q_DISABLE_COPY(DomActionRef) public: - DomActionRef(); + DomActionRef() = default; ~DomActionRef(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; - - // child element data - uint m_children; + bool m_has_attr_name = false; }; class QDESIGNER_UILIB_EXPORT DomButtonGroup { Q_DISABLE_COPY(DomButtonGroup) public: - DomButtonGroup(); + DomButtonGroup() = default; ~DomButtonGroup(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty*>& a); + void setElementAttribute(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; QList<DomProperty*> m_attribute; + enum Child { Property = 1, Attribute = 2 @@ -663,163 +601,46 @@ private: class QDESIGNER_UILIB_EXPORT DomButtonGroups { Q_DISABLE_COPY(DomButtonGroups) public: - DomButtonGroups(); + DomButtonGroups() = default; ~DomButtonGroups(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - // child element accessors - inline QList<DomButtonGroup*> elementButtonGroup() const { return m_buttonGroup; } - void setElementButtonGroup(const QList<DomButtonGroup*>& a); - -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - // child element data - uint m_children; - QList<DomButtonGroup*> m_buttonGroup; - enum Child { - ButtonGroup = 1 - }; -}; - -class QDESIGNER_UILIB_EXPORT DomImages { - Q_DISABLE_COPY(DomImages) -public: - DomImages(); - ~DomImages(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomImage*> elementImage() const { return m_image; } - void setElementImage(const QList<DomImage*>& a); + inline QVector<DomButtonGroup *> elementButtonGroup() const { return m_buttonGroup; } + void setElementButtonGroup(const QVector<DomButtonGroup *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomImage*> m_image; - enum Child { - Image = 1 - }; -}; - -class QDESIGNER_UILIB_EXPORT DomImage { - Q_DISABLE_COPY(DomImage) -public: - DomImage(); - ~DomImage(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - inline bool hasAttributeName() const { return m_has_attr_name; } - inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } - inline void clearAttributeName() { m_has_attr_name = false; } - - // child element accessors - inline DomImageData* elementData() const { return m_data; } - DomImageData* takeElementData(); - void setElementData(DomImageData* a); - inline bool hasElementData() const { return m_children & Data; } - void clearElementData(); - -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - QString m_attr_name; - bool m_has_attr_name; + uint m_children = 0; + QVector<DomButtonGroup *> m_buttonGroup; - // child element data - uint m_children; - DomImageData* m_data; enum Child { - Data = 1 + ButtonGroup = 1 }; }; -class QDESIGNER_UILIB_EXPORT DomImageData { - Q_DISABLE_COPY(DomImageData) -public: - DomImageData(); - ~DomImageData(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - inline bool hasAttributeFormat() const { return m_has_attr_format; } - inline QString attributeFormat() const { return m_attr_format; } - inline void setAttributeFormat(const QString& a) { m_attr_format = a; m_has_attr_format = true; } - inline void clearAttributeFormat() { m_has_attr_format = false; } - - inline bool hasAttributeLength() const { return m_has_attr_length; } - inline int attributeLength() const { return m_attr_length; } - inline void setAttributeLength(int a) { m_attr_length = a; m_has_attr_length = true; } - inline void clearAttributeLength() { m_has_attr_length = false; } - - // child element accessors -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - QString m_attr_format; - bool m_has_attr_format; - - int m_attr_length; - bool m_has_attr_length; - - // child element data - uint m_children; -}; - class QDESIGNER_UILIB_EXPORT DomCustomWidgets { Q_DISABLE_COPY(DomCustomWidgets) public: - DomCustomWidgets(); + DomCustomWidgets() = default; ~DomCustomWidgets(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomCustomWidget*> elementCustomWidget() const { return m_customWidget; } - void setElementCustomWidget(const QList<DomCustomWidget*>& a); + inline QVector<DomCustomWidget *> elementCustomWidget() const { return m_customWidget; } + void setElementCustomWidget(const QVector<DomCustomWidget *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomCustomWidget*> m_customWidget; + uint m_children = 0; + QVector<DomCustomWidget *> m_customWidget; + enum Child { CustomWidget = 1 }; @@ -828,70 +649,63 @@ private: class QDESIGNER_UILIB_EXPORT DomHeader { Q_DISABLE_COPY(DomHeader) public: - DomHeader(); + DomHeader() = default; ~DomHeader(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; + inline QString text() const { return m_text; } inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeLocation() const { return m_has_attr_location; } inline QString attributeLocation() const { return m_attr_location; } - inline void setAttributeLocation(const QString& a) { m_attr_location = a; m_has_attr_location = true; } + inline void setAttributeLocation(const QString &a) { m_attr_location = a; m_has_attr_location = true; } inline void clearAttributeLocation() { m_has_attr_location = false; } - // child element accessors private: QString m_text; - void clear(bool clear_all = true); // attribute data QString m_attr_location; - bool m_has_attr_location; - - // child element data - uint m_children; + bool m_has_attr_location = false; }; class QDESIGNER_UILIB_EXPORT DomCustomWidget { Q_DISABLE_COPY(DomCustomWidget) public: - DomCustomWidget(); + DomCustomWidget() = default; ~DomCustomWidget(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QString elementClass() const { return m_class; } - void setElementClass(const QString& a); + void setElementClass(const QString &a); inline bool hasElementClass() const { return m_children & Class; } void clearElementClass(); inline QString elementExtends() const { return m_extends; } - void setElementExtends(const QString& a); + void setElementExtends(const QString &a); inline bool hasElementExtends() const { return m_children & Extends; } void clearElementExtends(); - inline DomHeader* elementHeader() const { return m_header; } - DomHeader* takeElementHeader(); - void setElementHeader(DomHeader* a); + inline DomHeader *elementHeader() const { return m_header; } + DomHeader *takeElementHeader(); + void setElementHeader(DomHeader *a); inline bool hasElementHeader() const { return m_children & Header; } void clearElementHeader(); - inline DomSize* elementSizeHint() const { return m_sizeHint; } - DomSize* takeElementSizeHint(); - void setElementSizeHint(DomSize* a); + inline DomSize *elementSizeHint() const { return m_sizeHint; } + DomSize *takeElementSizeHint(); + void setElementSizeHint(DomSize *a); inline bool hasElementSizeHint() const { return m_children & SizeHint; } void clearElementSizeHint(); inline QString elementAddPageMethod() const { return m_addPageMethod; } - void setElementAddPageMethod(const QString& a); + void setElementAddPageMethod(const QString &a); inline bool hasElementAddPageMethod() const { return m_children & AddPageMethod; } void clearElementAddPageMethod(); @@ -900,60 +714,37 @@ public: inline bool hasElementContainer() const { return m_children & Container; } void clearElementContainer(); - inline DomSizePolicyData* elementSizePolicy() const { return m_sizePolicy; } - DomSizePolicyData* takeElementSizePolicy(); - void setElementSizePolicy(DomSizePolicyData* a); - inline bool hasElementSizePolicy() const { return m_children & SizePolicy; } - void clearElementSizePolicy(); - inline QString elementPixmap() const { return m_pixmap; } - void setElementPixmap(const QString& a); + void setElementPixmap(const QString &a); inline bool hasElementPixmap() const { return m_children & Pixmap; } void clearElementPixmap(); - inline DomScript* elementScript() const { return m_script; } - DomScript* takeElementScript(); - void setElementScript(DomScript* a); - inline bool hasElementScript() const { return m_children & Script; } - void clearElementScript(); - - inline DomProperties* elementProperties() const { return m_properties; } - DomProperties* takeElementProperties(); - void setElementProperties(DomProperties* a); - inline bool hasElementProperties() const { return m_children & Properties; } - void clearElementProperties(); - - inline DomSlots* elementSlots() const { return m_slots; } - DomSlots* takeElementSlots(); - void setElementSlots(DomSlots* a); + inline DomSlots *elementSlots() const { return m_slots; } + DomSlots *takeElementSlots(); + void setElementSlots(DomSlots *a); inline bool hasElementSlots() const { return m_children & Slots; } void clearElementSlots(); - inline DomPropertySpecifications* elementPropertyspecifications() const { return m_propertyspecifications; } - DomPropertySpecifications* takeElementPropertyspecifications(); - void setElementPropertyspecifications(DomPropertySpecifications* a); + inline DomPropertySpecifications *elementPropertyspecifications() const { return m_propertyspecifications; } + DomPropertySpecifications *takeElementPropertyspecifications(); + void setElementPropertyspecifications(DomPropertySpecifications *a); inline bool hasElementPropertyspecifications() const { return m_children & Propertyspecifications; } void clearElementPropertyspecifications(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QString m_class; QString m_extends; - DomHeader* m_header; - DomSize* m_sizeHint; + DomHeader *m_header = nullptr; + DomSize *m_sizeHint = nullptr; QString m_addPageMethod; - int m_container; - DomSizePolicyData* m_sizePolicy; + int m_container = 0; QString m_pixmap; - DomScript* m_script; - DomProperties* m_properties; - DomSlots* m_slots; - DomPropertySpecifications* m_propertyspecifications; + DomSlots *m_slots = nullptr; + DomPropertySpecifications *m_propertyspecifications = nullptr; + enum Child { Class = 1, Extends = 2, @@ -961,122 +752,20 @@ private: SizeHint = 8, AddPageMethod = 16, Container = 32, - SizePolicy = 64, - Pixmap = 128, - Script = 256, - Properties = 512, - Slots = 1024, - Propertyspecifications = 2048 - }; -}; - -class QDESIGNER_UILIB_EXPORT DomProperties { - Q_DISABLE_COPY(DomProperties) -public: - DomProperties(); - ~DomProperties(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - // child element accessors - inline QList<DomPropertyData*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomPropertyData*>& a); - -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - // child element data - uint m_children; - QList<DomPropertyData*> m_property; - enum Child { - Property = 1 - }; -}; - -class QDESIGNER_UILIB_EXPORT DomPropertyData { - Q_DISABLE_COPY(DomPropertyData) -public: - DomPropertyData(); - ~DomPropertyData(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - inline bool hasAttributeType() const { return m_has_attr_type; } - inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } - inline void clearAttributeType() { m_has_attr_type = false; } - - // child element accessors -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - QString m_attr_type; - bool m_has_attr_type; - - // child element data - uint m_children; -}; - -class QDESIGNER_UILIB_EXPORT DomSizePolicyData { - Q_DISABLE_COPY(DomSizePolicyData) -public: - DomSizePolicyData(); - ~DomSizePolicyData(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - // child element accessors - inline int elementHorData() const { return m_horData; } - void setElementHorData(int a); - inline bool hasElementHorData() const { return m_children & HorData; } - void clearElementHorData(); - - inline int elementVerData() const { return m_verData; } - void setElementVerData(int a); - inline bool hasElementVerData() const { return m_children & VerData; } - void clearElementVerData(); - -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - // child element data - uint m_children; - int m_horData; - int m_verData; - enum Child { - HorData = 1, - VerData = 2 + Pixmap = 64, + Slots = 128, + Propertyspecifications = 256 }; }; class QDESIGNER_UILIB_EXPORT DomLayoutDefault { Q_DISABLE_COPY(DomLayoutDefault) public: - DomLayoutDefault(); + DomLayoutDefault() = default; ~DomLayoutDefault(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeSpacing() const { return m_has_attr_spacing; } @@ -1089,84 +778,63 @@ public: inline void setAttributeMargin(int a) { m_attr_margin = a; m_has_attr_margin = true; } inline void clearAttributeMargin() { m_has_attr_margin = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data - int m_attr_spacing; - bool m_has_attr_spacing; + int m_attr_spacing = 0; + bool m_has_attr_spacing = false; - int m_attr_margin; - bool m_has_attr_margin; - - // child element data - uint m_children; + int m_attr_margin = 0; + bool m_has_attr_margin = false; }; class QDESIGNER_UILIB_EXPORT DomLayoutFunction { Q_DISABLE_COPY(DomLayoutFunction) public: - DomLayoutFunction(); + DomLayoutFunction() = default; ~DomLayoutFunction(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeSpacing() const { return m_has_attr_spacing; } inline QString attributeSpacing() const { return m_attr_spacing; } - inline void setAttributeSpacing(const QString& a) { m_attr_spacing = a; m_has_attr_spacing = true; } + inline void setAttributeSpacing(const QString &a) { m_attr_spacing = a; m_has_attr_spacing = true; } inline void clearAttributeSpacing() { m_has_attr_spacing = false; } inline bool hasAttributeMargin() const { return m_has_attr_margin; } inline QString attributeMargin() const { return m_attr_margin; } - inline void setAttributeMargin(const QString& a) { m_attr_margin = a; m_has_attr_margin = true; } + inline void setAttributeMargin(const QString &a) { m_attr_margin = a; m_has_attr_margin = true; } inline void clearAttributeMargin() { m_has_attr_margin = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_spacing; - bool m_has_attr_spacing; + bool m_has_attr_spacing = false; QString m_attr_margin; - bool m_has_attr_margin; - - // child element data - uint m_children; + bool m_has_attr_margin = false; }; class QDESIGNER_UILIB_EXPORT DomTabStops { Q_DISABLE_COPY(DomTabStops) public: - DomTabStops(); + DomTabStops() = default; ~DomTabStops(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QStringList elementTabStop() const { return m_tabStop; } - void setElementTabStop(const QStringList& a); + void setElementTabStop(const QStringList &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QStringList m_tabStop; + enum Child { TabStop = 1 }; @@ -1175,91 +843,87 @@ private: class QDESIGNER_UILIB_EXPORT DomLayout { Q_DISABLE_COPY(DomLayout) public: - DomLayout(); + DomLayout() = default; ~DomLayout(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeClass() const { return m_has_attr_class; } inline QString attributeClass() const { return m_attr_class; } - inline void setAttributeClass(const QString& a) { m_attr_class = a; m_has_attr_class = true; } + inline void setAttributeClass(const QString &a) { m_attr_class = a; m_has_attr_class = true; } inline void clearAttributeClass() { m_has_attr_class = false; } inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } inline bool hasAttributeStretch() const { return m_has_attr_stretch; } inline QString attributeStretch() const { return m_attr_stretch; } - inline void setAttributeStretch(const QString& a) { m_attr_stretch = a; m_has_attr_stretch = true; } + inline void setAttributeStretch(const QString &a) { m_attr_stretch = a; m_has_attr_stretch = true; } inline void clearAttributeStretch() { m_has_attr_stretch = false; } inline bool hasAttributeRowStretch() const { return m_has_attr_rowStretch; } inline QString attributeRowStretch() const { return m_attr_rowStretch; } - inline void setAttributeRowStretch(const QString& a) { m_attr_rowStretch = a; m_has_attr_rowStretch = true; } + inline void setAttributeRowStretch(const QString &a) { m_attr_rowStretch = a; m_has_attr_rowStretch = true; } inline void clearAttributeRowStretch() { m_has_attr_rowStretch = false; } inline bool hasAttributeColumnStretch() const { return m_has_attr_columnStretch; } inline QString attributeColumnStretch() const { return m_attr_columnStretch; } - inline void setAttributeColumnStretch(const QString& a) { m_attr_columnStretch = a; m_has_attr_columnStretch = true; } + inline void setAttributeColumnStretch(const QString &a) { m_attr_columnStretch = a; m_has_attr_columnStretch = true; } inline void clearAttributeColumnStretch() { m_has_attr_columnStretch = false; } inline bool hasAttributeRowMinimumHeight() const { return m_has_attr_rowMinimumHeight; } inline QString attributeRowMinimumHeight() const { return m_attr_rowMinimumHeight; } - inline void setAttributeRowMinimumHeight(const QString& a) { m_attr_rowMinimumHeight = a; m_has_attr_rowMinimumHeight = true; } + inline void setAttributeRowMinimumHeight(const QString &a) { m_attr_rowMinimumHeight = a; m_has_attr_rowMinimumHeight = true; } inline void clearAttributeRowMinimumHeight() { m_has_attr_rowMinimumHeight = false; } inline bool hasAttributeColumnMinimumWidth() const { return m_has_attr_columnMinimumWidth; } inline QString attributeColumnMinimumWidth() const { return m_attr_columnMinimumWidth; } - inline void setAttributeColumnMinimumWidth(const QString& a) { m_attr_columnMinimumWidth = a; m_has_attr_columnMinimumWidth = true; } + inline void setAttributeColumnMinimumWidth(const QString &a) { m_attr_columnMinimumWidth = a; m_has_attr_columnMinimumWidth = true; } inline void clearAttributeColumnMinimumWidth() { m_has_attr_columnMinimumWidth = false; } // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty*>& a); + void setElementAttribute(const QList<DomProperty *> &a); - inline QList<DomLayoutItem*> elementItem() const { return m_item; } - void setElementItem(const QList<DomLayoutItem*>& a); + inline QVector<DomLayoutItem *> elementItem() const { return m_item; } + void setElementItem(const QVector<DomLayoutItem *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_class; - bool m_has_attr_class; + bool m_has_attr_class = false; QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; QString m_attr_stretch; - bool m_has_attr_stretch; + bool m_has_attr_stretch = false; QString m_attr_rowStretch; - bool m_has_attr_rowStretch; + bool m_has_attr_rowStretch = false; QString m_attr_columnStretch; - bool m_has_attr_columnStretch; + bool m_has_attr_columnStretch = false; QString m_attr_rowMinimumHeight; - bool m_has_attr_rowMinimumHeight; + bool m_has_attr_rowMinimumHeight = false; QString m_attr_columnMinimumWidth; - bool m_has_attr_columnMinimumWidth; + bool m_has_attr_columnMinimumWidth = false; // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; QList<DomProperty*> m_attribute; - QList<DomLayoutItem*> m_item; + QVector<DomLayoutItem *> m_item; + enum Child { Property = 1, Attribute = 2, @@ -1270,13 +934,11 @@ private: class QDESIGNER_UILIB_EXPORT DomLayoutItem { Q_DISABLE_COPY(DomLayoutItem) public: - DomLayoutItem(); + DomLayoutItem() = default; ~DomLayoutItem(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeRow() const { return m_has_attr_row; } @@ -1301,76 +963,70 @@ public: inline bool hasAttributeAlignment() const { return m_has_attr_alignment; } inline QString attributeAlignment() const { return m_attr_alignment; } - inline void setAttributeAlignment(const QString& a) { m_attr_alignment = a; m_has_attr_alignment = true; } + inline void setAttributeAlignment(const QString &a) { m_attr_alignment = a; m_has_attr_alignment = true; } inline void clearAttributeAlignment() { m_has_attr_alignment = false; } // child element accessors enum Kind { Unknown = 0, Widget, Layout, Spacer }; inline Kind kind() const { return m_kind; } - inline DomWidget* elementWidget() const { return m_widget; } - DomWidget* takeElementWidget(); - void setElementWidget(DomWidget* a); + inline DomWidget *elementWidget() const { return m_widget; } + DomWidget *takeElementWidget(); + void setElementWidget(DomWidget *a); - inline DomLayout* elementLayout() const { return m_layout; } - DomLayout* takeElementLayout(); - void setElementLayout(DomLayout* a); + inline DomLayout *elementLayout() const { return m_layout; } + DomLayout *takeElementLayout(); + void setElementLayout(DomLayout *a); - inline DomSpacer* elementSpacer() const { return m_spacer; } - DomSpacer* takeElementSpacer(); - void setElementSpacer(DomSpacer* a); + inline DomSpacer *elementSpacer() const { return m_spacer; } + DomSpacer *takeElementSpacer(); + void setElementSpacer(DomSpacer *a); private: - QString m_text; - void clear(bool clear_all = true); + void clear(); // attribute data - int m_attr_row; - bool m_has_attr_row; + int m_attr_row = 0; + bool m_has_attr_row = false; - int m_attr_column; - bool m_has_attr_column; + int m_attr_column = 0; + bool m_has_attr_column = false; - int m_attr_rowSpan; - bool m_has_attr_rowSpan; + int m_attr_rowSpan = 0; + bool m_has_attr_rowSpan = false; - int m_attr_colSpan; - bool m_has_attr_colSpan; + int m_attr_colSpan = 0; + bool m_has_attr_colSpan = false; QString m_attr_alignment; - bool m_has_attr_alignment; + bool m_has_attr_alignment = false; // child element data - Kind m_kind; - DomWidget* m_widget; - DomLayout* m_layout; - DomSpacer* m_spacer; + Kind m_kind = Unknown; + DomWidget *m_widget = nullptr; + DomLayout *m_layout = nullptr; + DomSpacer *m_spacer = nullptr; }; class QDESIGNER_UILIB_EXPORT DomRow { Q_DISABLE_COPY(DomRow) public: - DomRow(); + DomRow() = default; ~DomRow(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; + enum Child { Property = 1 }; @@ -1379,27 +1035,22 @@ private: class QDESIGNER_UILIB_EXPORT DomColumn { Q_DISABLE_COPY(DomColumn) public: - DomColumn(); + DomColumn() = default; ~DomColumn(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; + enum Child { Property = 1 }; @@ -1408,13 +1059,11 @@ private: class QDESIGNER_UILIB_EXPORT DomItem { Q_DISABLE_COPY(DomItem) public: - DomItem(); + DomItem() = default; ~DomItem(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeRow() const { return m_has_attr_row; } @@ -1429,26 +1078,24 @@ public: // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); - inline QList<DomItem*> elementItem() const { return m_item; } - void setElementItem(const QList<DomItem*>& a); + inline QVector<DomItem *> elementItem() const { return m_item; } + void setElementItem(const QVector<DomItem *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data - int m_attr_row; - bool m_has_attr_row; + int m_attr_row = 0; + bool m_has_attr_row = false; - int m_attr_column; - bool m_has_attr_column; + int m_attr_column = 0; + bool m_has_attr_column = false; // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; - QList<DomItem*> m_item; + QVector<DomItem *> m_item; + enum Child { Property = 1, Item = 2 @@ -1458,23 +1105,21 @@ private: class QDESIGNER_UILIB_EXPORT DomWidget { Q_DISABLE_COPY(DomWidget) public: - DomWidget(); + DomWidget() = default; ~DomWidget(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeClass() const { return m_has_attr_class; } inline QString attributeClass() const { return m_attr_class; } - inline void setAttributeClass(const QString& a) { m_attr_class = a; m_has_attr_class = true; } + inline void setAttributeClass(const QString &a) { m_attr_class = a; m_has_attr_class = true; } inline void clearAttributeClass() { m_has_attr_class = false; } inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } inline bool hasAttributeNative() const { return m_has_attr_native; } @@ -1484,127 +1129,111 @@ public: // child element accessors inline QStringList elementClass() const { return m_class; } - void setElementClass(const QStringList& a); + void setElementClass(const QStringList &a); inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); - - inline QList<DomScript*> elementScript() const { return m_script; } - void setElementScript(const QList<DomScript*>& a); - - inline QList<DomWidgetData*> elementWidgetData() const { return m_widgetData; } - void setElementWidgetData(const QList<DomWidgetData*>& a); + void setElementProperty(const QList<DomProperty *> &a); inline QList<DomProperty*> elementAttribute() const { return m_attribute; } - void setElementAttribute(const QList<DomProperty*>& a); + void setElementAttribute(const QList<DomProperty *> &a); - inline QList<DomRow*> elementRow() const { return m_row; } - void setElementRow(const QList<DomRow*>& a); + inline QVector<DomRow *> elementRow() const { return m_row; } + void setElementRow(const QVector<DomRow *> &a); - inline QList<DomColumn*> elementColumn() const { return m_column; } - void setElementColumn(const QList<DomColumn*>& a); + inline QVector<DomColumn *> elementColumn() const { return m_column; } + void setElementColumn(const QVector<DomColumn *> &a); - inline QList<DomItem*> elementItem() const { return m_item; } - void setElementItem(const QList<DomItem*>& a); + inline QVector<DomItem *> elementItem() const { return m_item; } + void setElementItem(const QVector<DomItem *> &a); - inline QList<DomLayout*> elementLayout() const { return m_layout; } - void setElementLayout(const QList<DomLayout*>& a); + inline QVector<DomLayout *> elementLayout() const { return m_layout; } + void setElementLayout(const QVector<DomLayout *> &a); - inline QList<DomWidget*> elementWidget() const { return m_widget; } - void setElementWidget(const QList<DomWidget*>& a); + inline QVector<DomWidget *> elementWidget() const { return m_widget; } + void setElementWidget(const QVector<DomWidget *> &a); - inline QList<DomAction*> elementAction() const { return m_action; } - void setElementAction(const QList<DomAction*>& a); + inline QVector<DomAction *> elementAction() const { return m_action; } + void setElementAction(const QVector<DomAction *> &a); - inline QList<DomActionGroup*> elementActionGroup() const { return m_actionGroup; } - void setElementActionGroup(const QList<DomActionGroup*>& a); + inline QVector<DomActionGroup *> elementActionGroup() const { return m_actionGroup; } + void setElementActionGroup(const QVector<DomActionGroup *> &a); - inline QList<DomActionRef*> elementAddAction() const { return m_addAction; } - void setElementAddAction(const QList<DomActionRef*>& a); + inline QVector<DomActionRef *> elementAddAction() const { return m_addAction; } + void setElementAddAction(const QVector<DomActionRef *> &a); inline QStringList elementZOrder() const { return m_zOrder; } - void setElementZOrder(const QStringList& a); + void setElementZOrder(const QStringList &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_class; - bool m_has_attr_class; + bool m_has_attr_class = false; QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; - bool m_attr_native; - bool m_has_attr_native; + bool m_attr_native = false; + bool m_has_attr_native = false; // child element data - uint m_children; + uint m_children = 0; QStringList m_class; QList<DomProperty*> m_property; - QList<DomScript*> m_script; - QList<DomWidgetData*> m_widgetData; QList<DomProperty*> m_attribute; - QList<DomRow*> m_row; - QList<DomColumn*> m_column; - QList<DomItem*> m_item; - QList<DomLayout*> m_layout; - QList<DomWidget*> m_widget; - QList<DomAction*> m_action; - QList<DomActionGroup*> m_actionGroup; - QList<DomActionRef*> m_addAction; + QVector<DomRow *> m_row; + QVector<DomColumn *> m_column; + QVector<DomItem *> m_item; + QVector<DomLayout *> m_layout; + QVector<DomWidget *> m_widget; + QVector<DomAction *> m_action; + QVector<DomActionGroup *> m_actionGroup; + QVector<DomActionRef *> m_addAction; QStringList m_zOrder; + enum Child { Class = 1, Property = 2, - Script = 4, - WidgetData = 8, - Attribute = 16, - Row = 32, - Column = 64, - Item = 128, - Layout = 256, - Widget = 512, - Action = 1024, - ActionGroup = 2048, - AddAction = 4096, - ZOrder = 8192 + Attribute = 4, + Row = 8, + Column = 16, + Item = 32, + Layout = 64, + Widget = 128, + Action = 256, + ActionGroup = 512, + AddAction = 1024, + ZOrder = 2048 }; }; class QDESIGNER_UILIB_EXPORT DomSpacer { Q_DISABLE_COPY(DomSpacer) public: - DomSpacer(); + DomSpacer() = default; ~DomSpacer(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; + enum Child { Property = 1 }; @@ -1613,13 +1242,11 @@ private: class QDESIGNER_UILIB_EXPORT DomColor { Q_DISABLE_COPY(DomColor) public: - DomColor(); + DomColor() = default; ~DomColor(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeAlpha() const { return m_has_attr_alpha; } @@ -1644,18 +1271,16 @@ public: void clearElementBlue(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data - int m_attr_alpha; - bool m_has_attr_alpha; + int m_attr_alpha = 0; + bool m_has_attr_alpha = false; // child element data - uint m_children; - int m_red; - int m_green; - int m_blue; + uint m_children = 0; + int m_red = 0; + int m_green = 0; + int m_blue = 0; + enum Child { Red = 1, Green = 2, @@ -1666,13 +1291,11 @@ private: class QDESIGNER_UILIB_EXPORT DomGradientStop { Q_DISABLE_COPY(DomGradientStop) public: - DomGradientStop(); + DomGradientStop() = default; ~DomGradientStop(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributePosition() const { return m_has_attr_position; } @@ -1681,23 +1304,21 @@ public: inline void clearAttributePosition() { m_has_attr_position = false; } // child element accessors - inline DomColor* elementColor() const { return m_color; } - DomColor* takeElementColor(); - void setElementColor(DomColor* a); + inline DomColor *elementColor() const { return m_color; } + DomColor *takeElementColor(); + void setElementColor(DomColor *a); inline bool hasElementColor() const { return m_children & Color; } void clearElementColor(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data - double m_attr_position; - bool m_has_attr_position; + double m_attr_position = 0.0; + bool m_has_attr_position = false; // child element data - uint m_children; - DomColor* m_color; + uint m_children = 0; + DomColor *m_color = nullptr; + enum Child { Color = 1 }; @@ -1706,13 +1327,11 @@ private: class QDESIGNER_UILIB_EXPORT DomGradient { Q_DISABLE_COPY(DomGradient) public: - DomGradient(); + DomGradient() = default; ~DomGradient(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeStartX() const { return m_has_attr_startX; } @@ -1767,70 +1386,68 @@ public: inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } + inline void setAttributeType(const QString &a) { m_attr_type = a; m_has_attr_type = true; } inline void clearAttributeType() { m_has_attr_type = false; } inline bool hasAttributeSpread() const { return m_has_attr_spread; } inline QString attributeSpread() const { return m_attr_spread; } - inline void setAttributeSpread(const QString& a) { m_attr_spread = a; m_has_attr_spread = true; } + inline void setAttributeSpread(const QString &a) { m_attr_spread = a; m_has_attr_spread = true; } inline void clearAttributeSpread() { m_has_attr_spread = false; } inline bool hasAttributeCoordinateMode() const { return m_has_attr_coordinateMode; } inline QString attributeCoordinateMode() const { return m_attr_coordinateMode; } - inline void setAttributeCoordinateMode(const QString& a) { m_attr_coordinateMode = a; m_has_attr_coordinateMode = true; } + inline void setAttributeCoordinateMode(const QString &a) { m_attr_coordinateMode = a; m_has_attr_coordinateMode = true; } inline void clearAttributeCoordinateMode() { m_has_attr_coordinateMode = false; } // child element accessors - inline QList<DomGradientStop*> elementGradientStop() const { return m_gradientStop; } - void setElementGradientStop(const QList<DomGradientStop*>& a); + inline QVector<DomGradientStop *> elementGradientStop() const { return m_gradientStop; } + void setElementGradientStop(const QVector<DomGradientStop *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data - double m_attr_startX; - bool m_has_attr_startX; + double m_attr_startX = 0.0; + bool m_has_attr_startX = false; - double m_attr_startY; - bool m_has_attr_startY; + double m_attr_startY = 0.0; + bool m_has_attr_startY = false; - double m_attr_endX; - bool m_has_attr_endX; + double m_attr_endX = 0.0; + bool m_has_attr_endX = false; - double m_attr_endY; - bool m_has_attr_endY; + double m_attr_endY = 0.0; + bool m_has_attr_endY = false; - double m_attr_centralX; - bool m_has_attr_centralX; + double m_attr_centralX = 0.0; + bool m_has_attr_centralX = false; - double m_attr_centralY; - bool m_has_attr_centralY; + double m_attr_centralY = 0.0; + bool m_has_attr_centralY = false; - double m_attr_focalX; - bool m_has_attr_focalX; + double m_attr_focalX = 0.0; + bool m_has_attr_focalX = false; - double m_attr_focalY; - bool m_has_attr_focalY; + double m_attr_focalY = 0.0; + bool m_has_attr_focalY = false; - double m_attr_radius; - bool m_has_attr_radius; + double m_attr_radius = 0.0; + bool m_has_attr_radius = false; - double m_attr_angle; - bool m_has_attr_angle; + double m_attr_angle = 0.0; + bool m_has_attr_angle = false; QString m_attr_type; - bool m_has_attr_type; + bool m_has_attr_type = false; QString m_attr_spread; - bool m_has_attr_spread; + bool m_has_attr_spread = false; QString m_attr_coordinateMode; - bool m_has_attr_coordinateMode; + bool m_has_attr_coordinateMode = false; // child element data - uint m_children; - QList<DomGradientStop*> m_gradientStop; + uint m_children = 0; + QVector<DomGradientStop *> m_gradientStop; + enum Child { GradientStop = 1 }; @@ -1839,86 +1456,79 @@ private: class QDESIGNER_UILIB_EXPORT DomBrush { Q_DISABLE_COPY(DomBrush) public: - DomBrush(); + DomBrush() = default; ~DomBrush(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeBrushStyle() const { return m_has_attr_brushStyle; } inline QString attributeBrushStyle() const { return m_attr_brushStyle; } - inline void setAttributeBrushStyle(const QString& a) { m_attr_brushStyle = a; m_has_attr_brushStyle = true; } + inline void setAttributeBrushStyle(const QString &a) { m_attr_brushStyle = a; m_has_attr_brushStyle = true; } inline void clearAttributeBrushStyle() { m_has_attr_brushStyle = false; } // child element accessors enum Kind { Unknown = 0, Color, Texture, Gradient }; inline Kind kind() const { return m_kind; } - inline DomColor* elementColor() const { return m_color; } - DomColor* takeElementColor(); - void setElementColor(DomColor* a); + inline DomColor *elementColor() const { return m_color; } + DomColor *takeElementColor(); + void setElementColor(DomColor *a); - inline DomProperty* elementTexture() const { return m_texture; } - DomProperty* takeElementTexture(); - void setElementTexture(DomProperty* a); + inline DomProperty *elementTexture() const { return m_texture; } + DomProperty *takeElementTexture(); + void setElementTexture(DomProperty *a); - inline DomGradient* elementGradient() const { return m_gradient; } - DomGradient* takeElementGradient(); - void setElementGradient(DomGradient* a); + inline DomGradient *elementGradient() const { return m_gradient; } + DomGradient *takeElementGradient(); + void setElementGradient(DomGradient *a); private: - QString m_text; - void clear(bool clear_all = true); + void clear(); // attribute data QString m_attr_brushStyle; - bool m_has_attr_brushStyle; + bool m_has_attr_brushStyle = false; // child element data - Kind m_kind; - DomColor* m_color; - DomProperty* m_texture; - DomGradient* m_gradient; + Kind m_kind = Unknown; + DomColor *m_color = nullptr; + DomProperty *m_texture = nullptr; + DomGradient *m_gradient = nullptr; }; class QDESIGNER_UILIB_EXPORT DomColorRole { Q_DISABLE_COPY(DomColorRole) public: - DomColorRole(); + DomColorRole() = default; ~DomColorRole(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeRole() const { return m_has_attr_role; } inline QString attributeRole() const { return m_attr_role; } - inline void setAttributeRole(const QString& a) { m_attr_role = a; m_has_attr_role = true; } + inline void setAttributeRole(const QString &a) { m_attr_role = a; m_has_attr_role = true; } inline void clearAttributeRole() { m_has_attr_role = false; } // child element accessors - inline DomBrush* elementBrush() const { return m_brush; } - DomBrush* takeElementBrush(); - void setElementBrush(DomBrush* a); + inline DomBrush *elementBrush() const { return m_brush; } + DomBrush *takeElementBrush(); + void setElementBrush(DomBrush *a); inline bool hasElementBrush() const { return m_children & Brush; } void clearElementBrush(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_role; - bool m_has_attr_role; + bool m_has_attr_role = false; // child element data - uint m_children; - DomBrush* m_brush; + uint m_children = 0; + DomBrush *m_brush = nullptr; + enum Child { Brush = 1 }; @@ -1927,31 +1537,26 @@ private: class QDESIGNER_UILIB_EXPORT DomColorGroup { Q_DISABLE_COPY(DomColorGroup) public: - DomColorGroup(); + DomColorGroup() = default; ~DomColorGroup(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomColorRole*> elementColorRole() const { return m_colorRole; } - void setElementColorRole(const QList<DomColorRole*>& a); + inline QVector<DomColorRole *> elementColorRole() const { return m_colorRole; } + void setElementColorRole(const QVector<DomColorRole *> &a); - inline QList<DomColor*> elementColor() const { return m_color; } - void setElementColor(const QList<DomColor*>& a); + inline QVector<DomColor *> elementColor() const { return m_color; } + void setElementColor(const QVector<DomColor *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomColorRole*> m_colorRole; - QList<DomColor*> m_color; + uint m_children = 0; + QVector<DomColorRole *> m_colorRole; + QVector<DomColor *> m_color; + enum Child { ColorRole = 1, Color = 2 @@ -1961,44 +1566,39 @@ private: class QDESIGNER_UILIB_EXPORT DomPalette { Q_DISABLE_COPY(DomPalette) public: - DomPalette(); + DomPalette() = default; ~DomPalette(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline DomColorGroup* elementActive() const { return m_active; } - DomColorGroup* takeElementActive(); - void setElementActive(DomColorGroup* a); + inline DomColorGroup *elementActive() const { return m_active; } + DomColorGroup *takeElementActive(); + void setElementActive(DomColorGroup *a); inline bool hasElementActive() const { return m_children & Active; } void clearElementActive(); - inline DomColorGroup* elementInactive() const { return m_inactive; } - DomColorGroup* takeElementInactive(); - void setElementInactive(DomColorGroup* a); + inline DomColorGroup *elementInactive() const { return m_inactive; } + DomColorGroup *takeElementInactive(); + void setElementInactive(DomColorGroup *a); inline bool hasElementInactive() const { return m_children & Inactive; } void clearElementInactive(); - inline DomColorGroup* elementDisabled() const { return m_disabled; } - DomColorGroup* takeElementDisabled(); - void setElementDisabled(DomColorGroup* a); + inline DomColorGroup *elementDisabled() const { return m_disabled; } + DomColorGroup *takeElementDisabled(); + void setElementDisabled(DomColorGroup *a); inline bool hasElementDisabled() const { return m_children & Disabled; } void clearElementDisabled(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - DomColorGroup* m_active; - DomColorGroup* m_inactive; - DomColorGroup* m_disabled; + uint m_children = 0; + DomColorGroup *m_active = nullptr; + DomColorGroup *m_inactive = nullptr; + DomColorGroup *m_disabled = nullptr; + enum Child { Active = 1, Inactive = 2, @@ -2009,18 +1609,15 @@ private: class QDESIGNER_UILIB_EXPORT DomFont { Q_DISABLE_COPY(DomFont) public: - DomFont(); + DomFont() = default; ~DomFont(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QString elementFamily() const { return m_family; } - void setElementFamily(const QString& a); + void setElementFamily(const QString &a); inline bool hasElementFamily() const { return m_children & Family; } void clearElementFamily(); @@ -2060,7 +1657,7 @@ public: void clearElementAntialiasing(); inline QString elementStyleStrategy() const { return m_styleStrategy; } - void setElementStyleStrategy(const QString& a); + void setElementStyleStrategy(const QString &a); inline bool hasElementStyleStrategy() const { return m_children & StyleStrategy; } void clearElementStyleStrategy(); @@ -2070,22 +1667,20 @@ public: void clearElementKerning(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QString m_family; - int m_pointSize; - int m_weight; - bool m_italic; - bool m_bold; - bool m_underline; - bool m_strikeOut; - bool m_antialiasing; + int m_pointSize = 0; + int m_weight = 0; + bool m_italic = false; + bool m_bold = false; + bool m_underline = false; + bool m_strikeOut = false; + bool m_antialiasing = false; QString m_styleStrategy; - bool m_kerning; + bool m_kerning = false; + enum Child { Family = 1, PointSize = 2, @@ -2103,15 +1698,12 @@ private: class QDESIGNER_UILIB_EXPORT DomPoint { Q_DISABLE_COPY(DomPoint) public: - DomPoint(); + DomPoint() = default; ~DomPoint(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementX() const { return m_x; } void setElementX(int a); @@ -2124,14 +1716,12 @@ public: void clearElementY(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_x; - int m_y; + uint m_children = 0; + int m_x = 0; + int m_y = 0; + enum Child { X = 1, Y = 2 @@ -2141,15 +1731,12 @@ private: class QDESIGNER_UILIB_EXPORT DomRect { Q_DISABLE_COPY(DomRect) public: - DomRect(); + DomRect() = default; ~DomRect(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementX() const { return m_x; } void setElementX(int a); @@ -2172,16 +1759,14 @@ public: void clearElementHeight(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_x; - int m_y; - int m_width; - int m_height; + uint m_children = 0; + int m_x = 0; + int m_y = 0; + int m_width = 0; + int m_height = 0; + enum Child { X = 1, Y = 2, @@ -2193,61 +1778,50 @@ private: class QDESIGNER_UILIB_EXPORT DomLocale { Q_DISABLE_COPY(DomLocale) public: - DomLocale(); + DomLocale() = default; ~DomLocale(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeLanguage() const { return m_has_attr_language; } inline QString attributeLanguage() const { return m_attr_language; } - inline void setAttributeLanguage(const QString& a) { m_attr_language = a; m_has_attr_language = true; } + inline void setAttributeLanguage(const QString &a) { m_attr_language = a; m_has_attr_language = true; } inline void clearAttributeLanguage() { m_has_attr_language = false; } inline bool hasAttributeCountry() const { return m_has_attr_country; } inline QString attributeCountry() const { return m_attr_country; } - inline void setAttributeCountry(const QString& a) { m_attr_country = a; m_has_attr_country = true; } + inline void setAttributeCountry(const QString &a) { m_attr_country = a; m_has_attr_country = true; } inline void clearAttributeCountry() { m_has_attr_country = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_language; - bool m_has_attr_language; + bool m_has_attr_language = false; QString m_attr_country; - bool m_has_attr_country; - - // child element data - uint m_children; + bool m_has_attr_country = false; }; class QDESIGNER_UILIB_EXPORT DomSizePolicy { Q_DISABLE_COPY(DomSizePolicy) public: - DomSizePolicy(); + DomSizePolicy() = default; ~DomSizePolicy(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeHSizeType() const { return m_has_attr_hSizeType; } inline QString attributeHSizeType() const { return m_attr_hSizeType; } - inline void setAttributeHSizeType(const QString& a) { m_attr_hSizeType = a; m_has_attr_hSizeType = true; } + inline void setAttributeHSizeType(const QString &a) { m_attr_hSizeType = a; m_has_attr_hSizeType = true; } inline void clearAttributeHSizeType() { m_has_attr_hSizeType = false; } inline bool hasAttributeVSizeType() const { return m_has_attr_vSizeType; } inline QString attributeVSizeType() const { return m_attr_vSizeType; } - inline void setAttributeVSizeType(const QString& a) { m_attr_vSizeType = a; m_has_attr_vSizeType = true; } + inline void setAttributeVSizeType(const QString &a) { m_attr_vSizeType = a; m_has_attr_vSizeType = true; } inline void clearAttributeVSizeType() { m_has_attr_vSizeType = false; } // child element accessors @@ -2272,22 +1846,20 @@ public: void clearElementVerStretch(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_hSizeType; - bool m_has_attr_hSizeType; + bool m_has_attr_hSizeType = false; QString m_attr_vSizeType; - bool m_has_attr_vSizeType; + bool m_has_attr_vSizeType = false; // child element data - uint m_children; - int m_hSizeType; - int m_vSizeType; - int m_horStretch; - int m_verStretch; + uint m_children = 0; + int m_hSizeType = 0; + int m_vSizeType = 0; + int m_horStretch = 0; + int m_verStretch = 0; + enum Child { HSizeType = 1, VSizeType = 2, @@ -2299,15 +1871,12 @@ private: class QDESIGNER_UILIB_EXPORT DomSize { Q_DISABLE_COPY(DomSize) public: - DomSize(); + DomSize() = default; ~DomSize(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementWidth() const { return m_width; } void setElementWidth(int a); @@ -2320,14 +1889,12 @@ public: void clearElementHeight(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_width; - int m_height; + uint m_children = 0; + int m_width = 0; + int m_height = 0; + enum Child { Width = 1, Height = 2 @@ -2337,15 +1904,12 @@ private: class QDESIGNER_UILIB_EXPORT DomDate { Q_DISABLE_COPY(DomDate) public: - DomDate(); + DomDate() = default; ~DomDate(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementYear() const { return m_year; } void setElementYear(int a); @@ -2363,15 +1927,13 @@ public: void clearElementDay(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_year; - int m_month; - int m_day; + uint m_children = 0; + int m_year = 0; + int m_month = 0; + int m_day = 0; + enum Child { Year = 1, Month = 2, @@ -2382,15 +1944,12 @@ private: class QDESIGNER_UILIB_EXPORT DomTime { Q_DISABLE_COPY(DomTime) public: - DomTime(); + DomTime() = default; ~DomTime(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementHour() const { return m_hour; } void setElementHour(int a); @@ -2408,15 +1967,13 @@ public: void clearElementSecond(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_hour; - int m_minute; - int m_second; + uint m_children = 0; + int m_hour = 0; + int m_minute = 0; + int m_second = 0; + enum Child { Hour = 1, Minute = 2, @@ -2427,15 +1984,12 @@ private: class QDESIGNER_UILIB_EXPORT DomDateTime { Q_DISABLE_COPY(DomDateTime) public: - DomDateTime(); + DomDateTime() = default; ~DomDateTime(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementHour() const { return m_hour; } void setElementHour(int a); @@ -2468,18 +2022,16 @@ public: void clearElementDay(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_hour; - int m_minute; - int m_second; - int m_year; - int m_month; - int m_day; + uint m_children = 0; + int m_hour = 0; + int m_minute = 0; + int m_second = 0; + int m_year = 0; + int m_month = 0; + int m_day = 0; + enum Child { Hour = 1, Minute = 2, @@ -2493,51 +2045,47 @@ private: class QDESIGNER_UILIB_EXPORT DomStringList { Q_DISABLE_COPY(DomStringList) public: - DomStringList(); + DomStringList() = default; ~DomStringList(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeNotr() const { return m_has_attr_notr; } inline QString attributeNotr() const { return m_attr_notr; } - inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; } + inline void setAttributeNotr(const QString &a) { m_attr_notr = a; m_has_attr_notr = true; } inline void clearAttributeNotr() { m_has_attr_notr = false; } inline bool hasAttributeComment() const { return m_has_attr_comment; } inline QString attributeComment() const { return m_attr_comment; } - inline void setAttributeComment(const QString& a) { m_attr_comment = a; m_has_attr_comment = true; } + inline void setAttributeComment(const QString &a) { m_attr_comment = a; m_has_attr_comment = true; } inline void clearAttributeComment() { m_has_attr_comment = false; } inline bool hasAttributeExtraComment() const { return m_has_attr_extraComment; } inline QString attributeExtraComment() const { return m_attr_extraComment; } - inline void setAttributeExtraComment(const QString& a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } + inline void setAttributeExtraComment(const QString &a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } inline void clearAttributeExtraComment() { m_has_attr_extraComment = false; } // child element accessors inline QStringList elementString() const { return m_string; } - void setElementString(const QStringList& a); + void setElementString(const QStringList &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_notr; - bool m_has_attr_notr; + bool m_has_attr_notr = false; QString m_attr_comment; - bool m_has_attr_comment; + bool m_has_attr_comment = false; QString m_attr_extraComment; - bool m_has_attr_extraComment; + bool m_has_attr_extraComment = false; // child element data - uint m_children; + uint m_children = 0; QStringList m_string; + enum Child { String = 1 }; @@ -2546,133 +2094,130 @@ private: class QDESIGNER_UILIB_EXPORT DomResourcePixmap { Q_DISABLE_COPY(DomResourcePixmap) public: - DomResourcePixmap(); + DomResourcePixmap() = default; ~DomResourcePixmap(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; + inline QString text() const { return m_text; } inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeResource() const { return m_has_attr_resource; } inline QString attributeResource() const { return m_attr_resource; } - inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; } + inline void setAttributeResource(const QString &a) { m_attr_resource = a; m_has_attr_resource = true; } inline void clearAttributeResource() { m_has_attr_resource = false; } inline bool hasAttributeAlias() const { return m_has_attr_alias; } inline QString attributeAlias() const { return m_attr_alias; } - inline void setAttributeAlias(const QString& a) { m_attr_alias = a; m_has_attr_alias = true; } + inline void setAttributeAlias(const QString &a) { m_attr_alias = a; m_has_attr_alias = true; } inline void clearAttributeAlias() { m_has_attr_alias = false; } - // child element accessors private: QString m_text; - void clear(bool clear_all = true); // attribute data QString m_attr_resource; - bool m_has_attr_resource; + bool m_has_attr_resource = false; QString m_attr_alias; - bool m_has_attr_alias; - - // child element data - uint m_children; + bool m_has_attr_alias = false; }; class QDESIGNER_UILIB_EXPORT DomResourceIcon { Q_DISABLE_COPY(DomResourceIcon) public: - DomResourceIcon(); + DomResourceIcon() = default; ~DomResourceIcon(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; + inline QString text() const { return m_text; } inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeTheme() const { return m_has_attr_theme; } inline QString attributeTheme() const { return m_attr_theme; } - inline void setAttributeTheme(const QString& a) { m_attr_theme = a; m_has_attr_theme = true; } + inline void setAttributeTheme(const QString &a) { m_attr_theme = a; m_has_attr_theme = true; } inline void clearAttributeTheme() { m_has_attr_theme = false; } inline bool hasAttributeResource() const { return m_has_attr_resource; } inline QString attributeResource() const { return m_attr_resource; } - inline void setAttributeResource(const QString& a) { m_attr_resource = a; m_has_attr_resource = true; } + inline void setAttributeResource(const QString &a) { m_attr_resource = a; m_has_attr_resource = true; } inline void clearAttributeResource() { m_has_attr_resource = false; } // child element accessors - inline DomResourcePixmap* elementNormalOff() const { return m_normalOff; } - DomResourcePixmap* takeElementNormalOff(); - void setElementNormalOff(DomResourcePixmap* a); + inline DomResourcePixmap *elementNormalOff() const { return m_normalOff; } + DomResourcePixmap *takeElementNormalOff(); + void setElementNormalOff(DomResourcePixmap *a); inline bool hasElementNormalOff() const { return m_children & NormalOff; } void clearElementNormalOff(); - inline DomResourcePixmap* elementNormalOn() const { return m_normalOn; } - DomResourcePixmap* takeElementNormalOn(); - void setElementNormalOn(DomResourcePixmap* a); + inline DomResourcePixmap *elementNormalOn() const { return m_normalOn; } + DomResourcePixmap *takeElementNormalOn(); + void setElementNormalOn(DomResourcePixmap *a); inline bool hasElementNormalOn() const { return m_children & NormalOn; } void clearElementNormalOn(); - inline DomResourcePixmap* elementDisabledOff() const { return m_disabledOff; } - DomResourcePixmap* takeElementDisabledOff(); - void setElementDisabledOff(DomResourcePixmap* a); + inline DomResourcePixmap *elementDisabledOff() const { return m_disabledOff; } + DomResourcePixmap *takeElementDisabledOff(); + void setElementDisabledOff(DomResourcePixmap *a); inline bool hasElementDisabledOff() const { return m_children & DisabledOff; } void clearElementDisabledOff(); - inline DomResourcePixmap* elementDisabledOn() const { return m_disabledOn; } - DomResourcePixmap* takeElementDisabledOn(); - void setElementDisabledOn(DomResourcePixmap* a); + inline DomResourcePixmap *elementDisabledOn() const { return m_disabledOn; } + DomResourcePixmap *takeElementDisabledOn(); + void setElementDisabledOn(DomResourcePixmap *a); inline bool hasElementDisabledOn() const { return m_children & DisabledOn; } void clearElementDisabledOn(); - inline DomResourcePixmap* elementActiveOff() const { return m_activeOff; } - DomResourcePixmap* takeElementActiveOff(); - void setElementActiveOff(DomResourcePixmap* a); + inline DomResourcePixmap *elementActiveOff() const { return m_activeOff; } + DomResourcePixmap *takeElementActiveOff(); + void setElementActiveOff(DomResourcePixmap *a); inline bool hasElementActiveOff() const { return m_children & ActiveOff; } void clearElementActiveOff(); - inline DomResourcePixmap* elementActiveOn() const { return m_activeOn; } - DomResourcePixmap* takeElementActiveOn(); - void setElementActiveOn(DomResourcePixmap* a); + inline DomResourcePixmap *elementActiveOn() const { return m_activeOn; } + DomResourcePixmap *takeElementActiveOn(); + void setElementActiveOn(DomResourcePixmap *a); inline bool hasElementActiveOn() const { return m_children & ActiveOn; } void clearElementActiveOn(); - inline DomResourcePixmap* elementSelectedOff() const { return m_selectedOff; } - DomResourcePixmap* takeElementSelectedOff(); - void setElementSelectedOff(DomResourcePixmap* a); + inline DomResourcePixmap *elementSelectedOff() const { return m_selectedOff; } + DomResourcePixmap *takeElementSelectedOff(); + void setElementSelectedOff(DomResourcePixmap *a); inline bool hasElementSelectedOff() const { return m_children & SelectedOff; } void clearElementSelectedOff(); - inline DomResourcePixmap* elementSelectedOn() const { return m_selectedOn; } - DomResourcePixmap* takeElementSelectedOn(); - void setElementSelectedOn(DomResourcePixmap* a); + inline DomResourcePixmap *elementSelectedOn() const { return m_selectedOn; } + DomResourcePixmap *takeElementSelectedOn(); + void setElementSelectedOn(DomResourcePixmap *a); inline bool hasElementSelectedOn() const { return m_children & SelectedOn; } void clearElementSelectedOn(); private: QString m_text; - void clear(bool clear_all = true); // attribute data QString m_attr_theme; - bool m_has_attr_theme; + bool m_has_attr_theme = false; QString m_attr_resource; - bool m_has_attr_resource; + bool m_has_attr_resource = false; // child element data - uint m_children; - DomResourcePixmap* m_normalOff; - DomResourcePixmap* m_normalOn; - DomResourcePixmap* m_disabledOff; - DomResourcePixmap* m_disabledOn; - DomResourcePixmap* m_activeOff; - DomResourcePixmap* m_activeOn; - DomResourcePixmap* m_selectedOff; - DomResourcePixmap* m_selectedOn; + uint m_children = 0; + DomResourcePixmap *m_normalOff = nullptr; + DomResourcePixmap *m_normalOn = nullptr; + DomResourcePixmap *m_disabledOff = nullptr; + DomResourcePixmap *m_disabledOn = nullptr; + DomResourcePixmap *m_activeOff = nullptr; + DomResourcePixmap *m_activeOn = nullptr; + DomResourcePixmap *m_selectedOff = nullptr; + DomResourcePixmap *m_selectedOn = nullptr; + enum Child { NormalOff = 1, NormalOn = 2, @@ -2688,61 +2233,54 @@ private: class QDESIGNER_UILIB_EXPORT DomString { Q_DISABLE_COPY(DomString) public: - DomString(); + DomString() = default; ~DomString(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; + inline QString text() const { return m_text; } inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeNotr() const { return m_has_attr_notr; } inline QString attributeNotr() const { return m_attr_notr; } - inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; } + inline void setAttributeNotr(const QString &a) { m_attr_notr = a; m_has_attr_notr = true; } inline void clearAttributeNotr() { m_has_attr_notr = false; } inline bool hasAttributeComment() const { return m_has_attr_comment; } inline QString attributeComment() const { return m_attr_comment; } - inline void setAttributeComment(const QString& a) { m_attr_comment = a; m_has_attr_comment = true; } + inline void setAttributeComment(const QString &a) { m_attr_comment = a; m_has_attr_comment = true; } inline void clearAttributeComment() { m_has_attr_comment = false; } inline bool hasAttributeExtraComment() const { return m_has_attr_extraComment; } inline QString attributeExtraComment() const { return m_attr_extraComment; } - inline void setAttributeExtraComment(const QString& a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } + inline void setAttributeExtraComment(const QString &a) { m_attr_extraComment = a; m_has_attr_extraComment = true; } inline void clearAttributeExtraComment() { m_has_attr_extraComment = false; } - // child element accessors private: QString m_text; - void clear(bool clear_all = true); // attribute data QString m_attr_notr; - bool m_has_attr_notr; + bool m_has_attr_notr = false; QString m_attr_comment; - bool m_has_attr_comment; + bool m_has_attr_comment = false; QString m_attr_extraComment; - bool m_has_attr_extraComment; - - // child element data - uint m_children; + bool m_has_attr_extraComment = false; }; class QDESIGNER_UILIB_EXPORT DomPointF { Q_DISABLE_COPY(DomPointF) public: - DomPointF(); + DomPointF() = default; ~DomPointF(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline double elementX() const { return m_x; } void setElementX(double a); @@ -2755,14 +2293,12 @@ public: void clearElementY(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - double m_x; - double m_y; + uint m_children = 0; + double m_x = 0.0; + double m_y = 0.0; + enum Child { X = 1, Y = 2 @@ -2772,15 +2308,12 @@ private: class QDESIGNER_UILIB_EXPORT DomRectF { Q_DISABLE_COPY(DomRectF) public: - DomRectF(); + DomRectF() = default; ~DomRectF(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline double elementX() const { return m_x; } void setElementX(double a); @@ -2803,16 +2336,14 @@ public: void clearElementHeight(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - double m_x; - double m_y; - double m_width; - double m_height; + uint m_children = 0; + double m_x = 0.0; + double m_y = 0.0; + double m_width = 0.0; + double m_height = 0.0; + enum Child { X = 1, Y = 2, @@ -2824,15 +2355,12 @@ private: class QDESIGNER_UILIB_EXPORT DomSizeF { Q_DISABLE_COPY(DomSizeF) public: - DomSizeF(); + DomSizeF() = default; ~DomSizeF(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline double elementWidth() const { return m_width; } void setElementWidth(double a); @@ -2845,14 +2373,12 @@ public: void clearElementHeight(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - double m_width; - double m_height; + uint m_children = 0; + double m_width = 0.0; + double m_height = 0.0; + enum Child { Width = 1, Height = 2 @@ -2862,15 +2388,12 @@ private: class QDESIGNER_UILIB_EXPORT DomChar { Q_DISABLE_COPY(DomChar) public: - DomChar(); + DomChar() = default; ~DomChar(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline int elementUnicode() const { return m_unicode; } void setElementUnicode(int a); @@ -2878,13 +2401,11 @@ public: void clearElementUnicode(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - int m_unicode; + uint m_children = 0; + int m_unicode = 0; + enum Child { Unicode = 1 }; @@ -2893,30 +2414,25 @@ private: class QDESIGNER_UILIB_EXPORT DomUrl { Q_DISABLE_COPY(DomUrl) public: - DomUrl(); + DomUrl() = default; ~DomUrl(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline DomString* elementString() const { return m_string; } - DomString* takeElementString(); - void setElementString(DomString* a); + inline DomString *elementString() const { return m_string; } + DomString *takeElementString(); + void setElementString(DomString *a); inline bool hasElementString() const { return m_children & String; } void clearElementString(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - DomString* m_string; + uint m_children = 0; + DomString *m_string = nullptr; + enum Child { String = 1 }; @@ -2925,18 +2441,16 @@ private: class QDESIGNER_UILIB_EXPORT DomProperty { Q_DISABLE_COPY(DomProperty) public: - DomProperty(); + DomProperty() = default; ~DomProperty(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } inline bool hasAttributeStdset() const { return m_has_attr_stdset; } @@ -2949,70 +2463,70 @@ public: inline Kind kind() const { return m_kind; } inline QString elementBool() const { return m_bool; } - void setElementBool(const QString& a); + void setElementBool(const QString &a); - inline DomColor* elementColor() const { return m_color; } - DomColor* takeElementColor(); - void setElementColor(DomColor* a); + inline DomColor *elementColor() const { return m_color; } + DomColor *takeElementColor(); + void setElementColor(DomColor *a); inline QString elementCstring() const { return m_cstring; } - void setElementCstring(const QString& a); + void setElementCstring(const QString &a); inline int elementCursor() const { return m_cursor; } void setElementCursor(int a); inline QString elementCursorShape() const { return m_cursorShape; } - void setElementCursorShape(const QString& a); + void setElementCursorShape(const QString &a); inline QString elementEnum() const { return m_enum; } - void setElementEnum(const QString& a); + void setElementEnum(const QString &a); - inline DomFont* elementFont() const { return m_font; } - DomFont* takeElementFont(); - void setElementFont(DomFont* a); + inline DomFont *elementFont() const { return m_font; } + DomFont *takeElementFont(); + void setElementFont(DomFont *a); - inline DomResourceIcon* elementIconSet() const { return m_iconSet; } - DomResourceIcon* takeElementIconSet(); - void setElementIconSet(DomResourceIcon* a); + inline DomResourceIcon *elementIconSet() const { return m_iconSet; } + DomResourceIcon *takeElementIconSet(); + void setElementIconSet(DomResourceIcon *a); - inline DomResourcePixmap* elementPixmap() const { return m_pixmap; } - DomResourcePixmap* takeElementPixmap(); - void setElementPixmap(DomResourcePixmap* a); + inline DomResourcePixmap *elementPixmap() const { return m_pixmap; } + DomResourcePixmap *takeElementPixmap(); + void setElementPixmap(DomResourcePixmap *a); - inline DomPalette* elementPalette() const { return m_palette; } - DomPalette* takeElementPalette(); - void setElementPalette(DomPalette* a); + inline DomPalette *elementPalette() const { return m_palette; } + DomPalette *takeElementPalette(); + void setElementPalette(DomPalette *a); - inline DomPoint* elementPoint() const { return m_point; } - DomPoint* takeElementPoint(); - void setElementPoint(DomPoint* a); + inline DomPoint *elementPoint() const { return m_point; } + DomPoint *takeElementPoint(); + void setElementPoint(DomPoint *a); - inline DomRect* elementRect() const { return m_rect; } - DomRect* takeElementRect(); - void setElementRect(DomRect* a); + inline DomRect *elementRect() const { return m_rect; } + DomRect *takeElementRect(); + void setElementRect(DomRect *a); inline QString elementSet() const { return m_set; } - void setElementSet(const QString& a); + void setElementSet(const QString &a); - inline DomLocale* elementLocale() const { return m_locale; } - DomLocale* takeElementLocale(); - void setElementLocale(DomLocale* a); + inline DomLocale *elementLocale() const { return m_locale; } + DomLocale *takeElementLocale(); + void setElementLocale(DomLocale *a); - inline DomSizePolicy* elementSizePolicy() const { return m_sizePolicy; } - DomSizePolicy* takeElementSizePolicy(); - void setElementSizePolicy(DomSizePolicy* a); + inline DomSizePolicy *elementSizePolicy() const { return m_sizePolicy; } + DomSizePolicy *takeElementSizePolicy(); + void setElementSizePolicy(DomSizePolicy *a); - inline DomSize* elementSize() const { return m_size; } - DomSize* takeElementSize(); - void setElementSize(DomSize* a); + inline DomSize *elementSize() const { return m_size; } + DomSize *takeElementSize(); + void setElementSize(DomSize *a); - inline DomString* elementString() const { return m_string; } - DomString* takeElementString(); - void setElementString(DomString* a); + inline DomString *elementString() const { return m_string; } + DomString *takeElementString(); + void setElementString(DomString *a); - inline DomStringList* elementStringList() const { return m_stringList; } - DomStringList* takeElementStringList(); - void setElementStringList(DomStringList* a); + inline DomStringList *elementStringList() const { return m_stringList; } + DomStringList *takeElementStringList(); + void setElementStringList(DomStringList *a); inline int elementNumber() const { return m_number; } void setElementNumber(int a); @@ -3023,40 +2537,40 @@ public: inline double elementDouble() const { return m_double; } void setElementDouble(double a); - inline DomDate* elementDate() const { return m_date; } - DomDate* takeElementDate(); - void setElementDate(DomDate* a); + inline DomDate *elementDate() const { return m_date; } + DomDate *takeElementDate(); + void setElementDate(DomDate *a); - inline DomTime* elementTime() const { return m_time; } - DomTime* takeElementTime(); - void setElementTime(DomTime* a); + inline DomTime *elementTime() const { return m_time; } + DomTime *takeElementTime(); + void setElementTime(DomTime *a); - inline DomDateTime* elementDateTime() const { return m_dateTime; } - DomDateTime* takeElementDateTime(); - void setElementDateTime(DomDateTime* a); + inline DomDateTime *elementDateTime() const { return m_dateTime; } + DomDateTime *takeElementDateTime(); + void setElementDateTime(DomDateTime *a); - inline DomPointF* elementPointF() const { return m_pointF; } - DomPointF* takeElementPointF(); - void setElementPointF(DomPointF* a); + inline DomPointF *elementPointF() const { return m_pointF; } + DomPointF *takeElementPointF(); + void setElementPointF(DomPointF *a); - inline DomRectF* elementRectF() const { return m_rectF; } - DomRectF* takeElementRectF(); - void setElementRectF(DomRectF* a); + inline DomRectF *elementRectF() const { return m_rectF; } + DomRectF *takeElementRectF(); + void setElementRectF(DomRectF *a); - inline DomSizeF* elementSizeF() const { return m_sizeF; } - DomSizeF* takeElementSizeF(); - void setElementSizeF(DomSizeF* a); + inline DomSizeF *elementSizeF() const { return m_sizeF; } + DomSizeF *takeElementSizeF(); + void setElementSizeF(DomSizeF *a); inline qlonglong elementLongLong() const { return m_longLong; } void setElementLongLong(qlonglong a); - inline DomChar* elementChar() const { return m_char; } - DomChar* takeElementChar(); - void setElementChar(DomChar* a); + inline DomChar *elementChar() const { return m_char; } + DomChar *takeElementChar(); + void setElementChar(DomChar *a); - inline DomUrl* elementUrl() const { return m_url; } - DomUrl* takeElementUrl(); - void setElementUrl(DomUrl* a); + inline DomUrl *elementUrl() const { return m_url; } + DomUrl *takeElementUrl(); + void setElementUrl(DomUrl *a); inline uint elementUInt() const { return m_UInt; } void setElementUInt(uint a); @@ -3064,82 +2578,76 @@ public: inline qulonglong elementULongLong() const { return m_uLongLong; } void setElementULongLong(qulonglong a); - inline DomBrush* elementBrush() const { return m_brush; } - DomBrush* takeElementBrush(); - void setElementBrush(DomBrush* a); + inline DomBrush *elementBrush() const { return m_brush; } + DomBrush *takeElementBrush(); + void setElementBrush(DomBrush *a); private: - QString m_text; - void clear(bool clear_all = true); + void clear(); // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; - int m_attr_stdset; - bool m_has_attr_stdset; + int m_attr_stdset = 0; + bool m_has_attr_stdset = false; // child element data - Kind m_kind; + Kind m_kind = Unknown; QString m_bool; - DomColor* m_color; + DomColor *m_color = nullptr; QString m_cstring; - int m_cursor; + int m_cursor = 0; QString m_cursorShape; QString m_enum; - DomFont* m_font; - DomResourceIcon* m_iconSet; - DomResourcePixmap* m_pixmap; - DomPalette* m_palette; - DomPoint* m_point; - DomRect* m_rect; + DomFont *m_font = nullptr; + DomResourceIcon *m_iconSet = nullptr; + DomResourcePixmap *m_pixmap = nullptr; + DomPalette *m_palette = nullptr; + DomPoint *m_point = nullptr; + DomRect *m_rect = nullptr; QString m_set; - DomLocale* m_locale; - DomSizePolicy* m_sizePolicy; - DomSize* m_size; - DomString* m_string; - DomStringList* m_stringList; - int m_number; - float m_float; - double m_double; - DomDate* m_date; - DomTime* m_time; - DomDateTime* m_dateTime; - DomPointF* m_pointF; - DomRectF* m_rectF; - DomSizeF* m_sizeF; - qlonglong m_longLong; - DomChar* m_char; - DomUrl* m_url; - uint m_UInt; - qulonglong m_uLongLong; - DomBrush* m_brush; + DomLocale *m_locale = nullptr; + DomSizePolicy *m_sizePolicy = nullptr; + DomSize *m_size = nullptr; + DomString *m_string = nullptr; + DomStringList *m_stringList = nullptr; + int m_number = 0; + float m_float = 0.0; + double m_double = 0.0; + DomDate *m_date = nullptr; + DomTime *m_time = nullptr; + DomDateTime *m_dateTime = nullptr; + DomPointF *m_pointF = nullptr; + DomRectF *m_rectF = nullptr; + DomSizeF *m_sizeF = nullptr; + qlonglong m_longLong = 0; + DomChar *m_char = nullptr; + DomUrl *m_url = nullptr; + uint m_UInt = 0; + qulonglong m_uLongLong = 0; + DomBrush *m_brush = nullptr; }; class QDESIGNER_UILIB_EXPORT DomConnections { Q_DISABLE_COPY(DomConnections) public: - DomConnections(); + DomConnections() = default; ~DomConnections(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomConnection*> elementConnection() const { return m_connection; } - void setElementConnection(const QList<DomConnection*>& a); + inline QVector<DomConnection *> elementConnection() const { return m_connection; } + void setElementConnection(const QVector<DomConnection *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomConnection*> m_connection; + uint m_children = 0; + QVector<DomConnection *> m_connection; + enum Child { Connection = 1 }; @@ -3148,54 +2656,49 @@ private: class QDESIGNER_UILIB_EXPORT DomConnection { Q_DISABLE_COPY(DomConnection) public: - DomConnection(); + DomConnection() = default; ~DomConnection(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QString elementSender() const { return m_sender; } - void setElementSender(const QString& a); + void setElementSender(const QString &a); inline bool hasElementSender() const { return m_children & Sender; } void clearElementSender(); inline QString elementSignal() const { return m_signal; } - void setElementSignal(const QString& a); + void setElementSignal(const QString &a); inline bool hasElementSignal() const { return m_children & Signal; } void clearElementSignal(); inline QString elementReceiver() const { return m_receiver; } - void setElementReceiver(const QString& a); + void setElementReceiver(const QString &a); inline bool hasElementReceiver() const { return m_children & Receiver; } void clearElementReceiver(); inline QString elementSlot() const { return m_slot; } - void setElementSlot(const QString& a); + void setElementSlot(const QString &a); inline bool hasElementSlot() const { return m_children & Slot; } void clearElementSlot(); - inline DomConnectionHints* elementHints() const { return m_hints; } - DomConnectionHints* takeElementHints(); - void setElementHints(DomConnectionHints* a); + inline DomConnectionHints *elementHints() const { return m_hints; } + DomConnectionHints *takeElementHints(); + void setElementHints(DomConnectionHints *a); inline bool hasElementHints() const { return m_children & Hints; } void clearElementHints(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QString m_sender; QString m_signal; QString m_receiver; QString m_slot; - DomConnectionHints* m_hints; + DomConnectionHints *m_hints = nullptr; + enum Child { Sender = 1, Signal = 2, @@ -3208,27 +2711,22 @@ private: class QDESIGNER_UILIB_EXPORT DomConnectionHints { Q_DISABLE_COPY(DomConnectionHints) public: - DomConnectionHints(); + DomConnectionHints() = default; ~DomConnectionHints(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomConnectionHint*> elementHint() const { return m_hint; } - void setElementHint(const QList<DomConnectionHint*>& a); + inline QVector<DomConnectionHint *> elementHint() const { return m_hint; } + void setElementHint(const QVector<DomConnectionHint *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomConnectionHint*> m_hint; + uint m_children = 0; + QVector<DomConnectionHint *> m_hint; + enum Child { Hint = 1 }; @@ -3237,18 +2735,16 @@ private: class QDESIGNER_UILIB_EXPORT DomConnectionHint { Q_DISABLE_COPY(DomConnectionHint) public: - DomConnectionHint(); + DomConnectionHint() = default; ~DomConnectionHint(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } + inline void setAttributeType(const QString &a) { m_attr_type = a; m_has_attr_type = true; } inline void clearAttributeType() { m_has_attr_type = false; } // child element accessors @@ -3263,114 +2759,40 @@ public: void clearElementY(); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_type; - bool m_has_attr_type; + bool m_has_attr_type = false; // child element data - uint m_children; - int m_x; - int m_y; + uint m_children = 0; + int m_x = 0; + int m_y = 0; + enum Child { X = 1, Y = 2 }; }; -class QDESIGNER_UILIB_EXPORT DomScript { - Q_DISABLE_COPY(DomScript) -public: - DomScript(); - ~DomScript(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - inline bool hasAttributeSource() const { return m_has_attr_source; } - inline QString attributeSource() const { return m_attr_source; } - inline void setAttributeSource(const QString& a) { m_attr_source = a; m_has_attr_source = true; } - inline void clearAttributeSource() { m_has_attr_source = false; } - - inline bool hasAttributeLanguage() const { return m_has_attr_language; } - inline QString attributeLanguage() const { return m_attr_language; } - inline void setAttributeLanguage(const QString& a) { m_attr_language = a; m_has_attr_language = true; } - inline void clearAttributeLanguage() { m_has_attr_language = false; } - - // child element accessors -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - QString m_attr_source; - bool m_has_attr_source; - - QString m_attr_language; - bool m_has_attr_language; - - // child element data - uint m_children; -}; - -class QDESIGNER_UILIB_EXPORT DomWidgetData { - Q_DISABLE_COPY(DomWidgetData) -public: - DomWidgetData(); - ~DomWidgetData(); - - void read(QXmlStreamReader &reader); - void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - - // attribute accessors - // child element accessors - inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); - -private: - QString m_text; - void clear(bool clear_all = true); - - // attribute data - // child element data - uint m_children; - QList<DomProperty*> m_property; - enum Child { - Property = 1 - }; -}; - class QDESIGNER_UILIB_EXPORT DomDesignerData { Q_DISABLE_COPY(DomDesignerData) public: - DomDesignerData(); + DomDesignerData() = default; ~DomDesignerData(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QList<DomProperty*> elementProperty() const { return m_property; } - void setElementProperty(const QList<DomProperty*>& a); + void setElementProperty(const QList<DomProperty *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QList<DomProperty*> m_property; + enum Child { Property = 1 }; @@ -3379,31 +2801,26 @@ private: class QDESIGNER_UILIB_EXPORT DomSlots { Q_DISABLE_COPY(DomSlots) public: - DomSlots(); + DomSlots() = default; ~DomSlots(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors inline QStringList elementSignal() const { return m_signal; } - void setElementSignal(const QStringList& a); + void setElementSignal(const QStringList &a); inline QStringList elementSlot() const { return m_slot; } - void setElementSlot(const QStringList& a); + void setElementSlot(const QStringList &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; + uint m_children = 0; QStringList m_signal; QStringList m_slot; + enum Child { Signal = 1, Slot = 2 @@ -3413,31 +2830,26 @@ private: class QDESIGNER_UILIB_EXPORT DomPropertySpecifications { Q_DISABLE_COPY(DomPropertySpecifications) public: - DomPropertySpecifications(); + DomPropertySpecifications() = default; ~DomPropertySpecifications(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } - // attribute accessors // child element accessors - inline QList<DomPropertyToolTip*> elementTooltip() const { return m_tooltip; } - void setElementTooltip(const QList<DomPropertyToolTip*>& a); + inline QVector<DomPropertyToolTip *> elementTooltip() const { return m_tooltip; } + void setElementTooltip(const QVector<DomPropertyToolTip *> &a); - inline QList<DomStringPropertySpecification*> elementStringpropertyspecification() const { return m_stringpropertyspecification; } - void setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a); + inline QVector<DomStringPropertySpecification *> elementStringpropertyspecification() const { return m_stringpropertyspecification; } + void setElementStringpropertyspecification(const QVector<DomStringPropertySpecification *> &a); private: - QString m_text; - void clear(bool clear_all = true); - // attribute data // child element data - uint m_children; - QList<DomPropertyToolTip*> m_tooltip; - QList<DomStringPropertySpecification*> m_stringpropertyspecification; + uint m_children = 0; + QVector<DomPropertyToolTip *> m_tooltip; + QVector<DomStringPropertySpecification *> m_stringpropertyspecification; + enum Child { Tooltip = 1, Stringpropertyspecification = 2 @@ -3447,77 +2859,59 @@ private: class QDESIGNER_UILIB_EXPORT DomPropertyToolTip { Q_DISABLE_COPY(DomPropertyToolTip) public: - DomPropertyToolTip(); + DomPropertyToolTip() = default; ~DomPropertyToolTip(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; - - // child element data - uint m_children; + bool m_has_attr_name = false; }; class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification { Q_DISABLE_COPY(DomStringPropertySpecification) public: - DomStringPropertySpecification(); + DomStringPropertySpecification() = default; ~DomStringPropertySpecification(); void read(QXmlStreamReader &reader); void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const; - inline QString text() const { return m_text; } - inline void setText(const QString &s) { m_text = s; } // attribute accessors inline bool hasAttributeName() const { return m_has_attr_name; } inline QString attributeName() const { return m_attr_name; } - inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; } + inline void setAttributeName(const QString &a) { m_attr_name = a; m_has_attr_name = true; } inline void clearAttributeName() { m_has_attr_name = false; } inline bool hasAttributeType() const { return m_has_attr_type; } inline QString attributeType() const { return m_attr_type; } - inline void setAttributeType(const QString& a) { m_attr_type = a; m_has_attr_type = true; } + inline void setAttributeType(const QString &a) { m_attr_type = a; m_has_attr_type = true; } inline void clearAttributeType() { m_has_attr_type = false; } inline bool hasAttributeNotr() const { return m_has_attr_notr; } inline QString attributeNotr() const { return m_attr_notr; } - inline void setAttributeNotr(const QString& a) { m_attr_notr = a; m_has_attr_notr = true; } + inline void setAttributeNotr(const QString &a) { m_attr_notr = a; m_has_attr_notr = true; } inline void clearAttributeNotr() { m_has_attr_notr = false; } - // child element accessors private: - QString m_text; - void clear(bool clear_all = true); - // attribute data QString m_attr_name; - bool m_has_attr_name; + bool m_has_attr_name = false; QString m_attr_type; - bool m_has_attr_type; + bool m_has_attr_type = false; QString m_attr_notr; - bool m_has_attr_notr; - - // child element data - uint m_children; + bool m_has_attr_notr = false; }; diff --git a/src/designer/src/src.pro b/src/designer/src/src.pro index 6915e34e9..79e9e64ee 100644 --- a/src/designer/src/src.pro +++ b/src/designer/src/src.pro @@ -2,18 +2,23 @@ TEMPLATE = subdirs SUBDIRS = \ uiplugin \ - uitools \ - lib \ - components \ - designer + uitools + +qtConfig(process) { + SUBDIRS += \ + lib \ + components \ + designer + + lib.depends = uiplugin + components.depends = lib + designer.depends = components + plugins.depends = lib -contains(QT_CONFIG, shared): SUBDIRS += plugins + contains(QT_CONFIG, shared): SUBDIRS += plugins +} uitools.depends = uiplugin -lib.depends = uiplugin -components.depends = lib -designer.depends = components -plugins.depends = lib qtNomakeTools( \ lib \ diff --git a/src/linguist/lconvert/lconvert.pro b/src/linguist/lconvert/lconvert.pro index e52e8d729..d1e49bc20 100644 --- a/src/linguist/lconvert/lconvert.pro +++ b/src/linguist/lconvert/lconvert.pro @@ -6,4 +6,5 @@ SOURCES += main.cpp include(../shared/formats.pri) +QMAKE_TARGET_DESCRIPTION = "Qt Translation File Converter" load(qt_tool) diff --git a/src/linguist/lconvert/main.cpp b/src/linguist/lconvert/main.cpp index 4e26adbbb..2dc07db51 100644 --- a/src/linguist/lconvert/main.cpp +++ b/src/linguist/lconvert/main.cpp @@ -94,6 +94,8 @@ static int usage(const QStringList &args) " Drop obsolete messages.\n\n" " -no-finished\n" " Drop finished messages.\n\n" + " -no-untranslated\n" + " Drop untranslated messages.\n\n" " -sort-contexts\n" " Sort contexts in output TS file alphabetically.\n\n" " -locations {absolute|relative|none}\n" @@ -145,6 +147,7 @@ int main(int argc, char *argv[]) bool dropTranslations = false; bool noObsolete = false; bool noFinished = false; + bool noUntranslated = false; bool verbose = false; bool noUiLines = false; Translator::LocationsType locations = Translator::DefaultLocations; @@ -199,6 +202,8 @@ int main(int argc, char *argv[]) noObsolete = true; } else if (args[i] == QLatin1String("-no-finished")) { noFinished = true; + } else if (args[i] == QLatin1String("-no-untranslated")) { + noUntranslated = true; } else if (args[i] == QLatin1String("-sort-contexts")) { cd.m_sortContexts = true; } else if (args[i] == QLatin1String("-locations")) { @@ -256,6 +261,8 @@ int main(int argc, char *argv[]) tr.stripObsoleteMessages(); if (noFinished) tr.stripFinishedMessages(); + if (noUntranslated) + tr.stripUntranslatedMessages(); if (dropTranslations) tr.dropTranslations(); if (noUiLines) diff --git a/src/linguist/linguist.pro b/src/linguist/linguist.pro index 3a70580f6..103336daf 100644 --- a/src/linguist/linguist.pro +++ b/src/linguist/linguist.pro @@ -3,7 +3,7 @@ SUBDIRS = \ lrelease \ lupdate \ lconvert -!no-png:qtHaveModule(widgets): SUBDIRS += linguist +!no-png:qtHaveModule(widgets):qtConfig(process): SUBDIRS += linguist qtNomakeTools( \ linguist \ diff --git a/src/linguist/linguist/errorsview.cpp b/src/linguist/linguist/errorsview.cpp index 685bb0289..5d56fd5ac 100644 --- a/src/linguist/linguist/errorsview.cpp +++ b/src/linguist/linguist/errorsview.cpp @@ -57,7 +57,6 @@ void ErrorsView::clear() void ErrorsView::addError(int model, const ErrorType type, const QString &arg) { - QString error; switch (type) { case SuperfluousAccelerator: addError(model, tr("Accelerator possibly superfluous in translation.")); diff --git a/src/linguist/linguist/linguist.pro b/src/linguist/linguist/linguist.pro index c3de1c6a8..7b02bc324 100644 --- a/src/linguist/linguist/linguist.pro +++ b/src/linguist/linguist/linguist.pro @@ -59,8 +59,7 @@ contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE DEFINES += QT_KEYWORDS TARGET = linguist -QMAKE_TARGET_PRODUCT = Qt Linguist -QMAKE_TARGET_DESCRIPTION = Tool for adding translations to Qt applications +QMAKE_TARGET_DESCRIPTION = Qt Linguist win32 { RC_ICONS = linguist.ico diff --git a/src/linguist/linguist/main.cpp b/src/linguist/linguist/main.cpp index 4d3df2294..3b92dfe1b 100644 --- a/src/linguist/linguist/main.cpp +++ b/src/linguist/linguist/main.cpp @@ -92,6 +92,9 @@ int main(int argc, char **argv) { Q_INIT_RESOURCE(linguist); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication app(argc, argv); QApplication::setOverrideCursor(Qt::WaitCursor); diff --git a/src/linguist/linguist/mainwindow.cpp b/src/linguist/linguist/mainwindow.cpp index 27600d0f8..92aed394e 100644 --- a/src/linguist/linguist/mainwindow.cpp +++ b/src/linguist/linguist/mainwindow.cpp @@ -2590,7 +2590,6 @@ void MainWindow::readConfig() { QSettings config; - QRect r(pos(), size()); restoreGeometry(config.value(settingPath("Geometry/WindowGeometry")).toByteArray()); restoreState(config.value(settingPath("MainWindowState")).toByteArray()); diff --git a/src/linguist/lrelease/lrelease.pro b/src/linguist/lrelease/lrelease.pro index df026fe48..c2416dc9a 100644 --- a/src/linguist/lrelease/lrelease.pro +++ b/src/linguist/lrelease/lrelease.pro @@ -11,4 +11,5 @@ qmake.name = QMAKE qmake.value = $$shell_path($$QMAKE_QMAKE) QT_TOOL_ENV += qmake +QMAKE_TARGET_DESCRIPTION = "Qt Translation File Compiler" load(qt_tool) diff --git a/src/linguist/lupdate/lupdate.pro b/src/linguist/lupdate/lupdate.pro index 710fd9b1d..3aef95c8d 100644 --- a/src/linguist/lupdate/lupdate.pro +++ b/src/linguist/lupdate/lupdate.pro @@ -37,4 +37,5 @@ qmake.name = QMAKE qmake.value = $$shell_path($$QMAKE_QMAKE) QT_TOOL_ENV += qmake +QMAKE_TARGET_DESCRIPTION = "Qt Translation File Update Tool" load(qt_tool) diff --git a/src/linguist/shared/qmakebuiltins.cpp b/src/linguist/shared/qmakebuiltins.cpp index 19fc6d639..dde02544d 100644 --- a/src/linguist/shared/qmakebuiltins.cpp +++ b/src/linguist/shared/qmakebuiltins.cpp @@ -435,7 +435,7 @@ QMakeEvaluator::writeFile(const QString &ctx, const QString &fn, QIODevice::Open return ReturnTrue; } -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) void QMakeEvaluator::runProcess(QProcess *proc, const QString &command) const { proc->setWorkingDirectory(currentDirectory()); @@ -456,7 +456,7 @@ void QMakeEvaluator::runProcess(QProcess *proc, const QString &command) const QByteArray QMakeEvaluator::getCommandOutput(const QString &args, int *exitCode) const { QByteArray out; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) QProcess proc; runProcess(&proc, args); *exitCode = (proc.exitStatus() == QProcess::NormalExit) ? proc.exitCode() : -1; @@ -1653,7 +1653,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( #ifdef PROEVALUATOR_FULL if (m_cumulative) // Anything else would be insanity return ReturnFalse; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) QProcess proc; proc.setProcessChannelMode(QProcess::ForwardedChannels); runProcess(&proc, args.at(0).toQString(m_tmp2)); diff --git a/src/linguist/shared/qmakeevaluator.h b/src/linguist/shared/qmakeevaluator.h index 5a430c14b..d68543482 100644 --- a/src/linguist/shared/qmakeevaluator.h +++ b/src/linguist/shared/qmakeevaluator.h @@ -44,7 +44,7 @@ #include <qstring.h> #include <qstringlist.h> #include <qshareddata.h> -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) # include <qprocess.h> #else # include <qiodevice.h> @@ -237,7 +237,7 @@ public: VisitReturn writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode, bool exe, const QString &contents); -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) void runProcess(QProcess *proc, const QString &command) const; #endif QByteArray getCommandOutput(const QString &args, int *exitCode) const; diff --git a/src/linguist/shared/qmakeglobals.cpp b/src/linguist/shared/qmakeglobals.cpp index 0b2a1ffce..471d42fce 100644 --- a/src/linguist/shared/qmakeglobals.cpp +++ b/src/linguist/shared/qmakeglobals.cpp @@ -312,7 +312,7 @@ QString QMakeGlobals::expandEnvVars(const QString &str) const bool QMakeGlobals::initProperties() { QByteArray data; -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) QProcess proc; proc.start(qmake_abslocation, QStringList() << QLatin1String("-query")); if (!proc.waitForFinished()) diff --git a/src/linguist/shared/qmakeglobals.h b/src/linguist/shared/qmakeglobals.h index 756f69dd9..0f7082fd1 100644 --- a/src/linguist/shared/qmakeglobals.h +++ b/src/linguist/shared/qmakeglobals.h @@ -38,7 +38,7 @@ #include <qhash.h> #include <qstringlist.h> -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(process) # include <qprocess.h> #endif #ifdef PROEVALUATOR_THREAD_SAFE diff --git a/src/linguist/shared/qph.cpp b/src/linguist/shared/qph.cpp index 9bfd8833d..f29b3789b 100644 --- a/src/linguist/shared/qph.cpp +++ b/src/linguist/shared/qph.cpp @@ -63,7 +63,6 @@ private: bool QPHReader::read(Translator &translator) { m_currentField = NoField; - QString result; while (!atEnd()) { readNext(); if (isStartElement()) { diff --git a/src/linguist/shared/translator.cpp b/src/linguist/shared/translator.cpp index 9ef717426..5b0538d4e 100644 --- a/src/linguist/shared/translator.cpp +++ b/src/linguist/shared/translator.cpp @@ -420,6 +420,16 @@ void Translator::stripFinishedMessages() m_indexOk = false; } +void Translator::stripUntranslatedMessages() +{ + for (TMM::Iterator it = m_messages.begin(); it != m_messages.end(); ) + if (!it->isTranslated()) + it = m_messages.erase(it); + else + ++it; + m_indexOk = false; +} + void Translator::stripEmptyContexts() { for (TMM::Iterator it = m_messages.begin(); it != m_messages.end();) diff --git a/src/linguist/shared/translator.h b/src/linguist/shared/translator.h index 57a154008..8919a13df 100644 --- a/src/linguist/shared/translator.h +++ b/src/linguist/shared/translator.h @@ -128,6 +128,7 @@ public: void stripObsoleteMessages(); void stripFinishedMessages(); + void stripUntranslatedMessages(); void stripEmptyContexts(); void stripNonPluralForms(); void stripIdenticalSourceTranslations(); diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp index ee75fc277..5c8bcc129 100644 --- a/src/linguist/shared/ts.cpp +++ b/src/linguist/shared/ts.cpp @@ -188,7 +188,6 @@ QString TSReader::readTransContents() bool TSReader::read(Translator &translator) { - STRING(byte); STRING(catalog); STRING(comment); STRING(context); @@ -216,13 +215,11 @@ bool TSReader::read(Translator &translator) STRING(type); STRING(unfinished); STRING(userdata); - STRING(value); STRING(vanished); //STRING(version); STRING(yes); static const QString strextrans(QLatin1String("extra-")); - static const QString strUtf8(QLatin1String("UTF-8")); while (!atEnd()) { readNext(); diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp index 49dbe5426..7dafe63aa 100644 --- a/src/macdeployqt/shared/shared.cpp +++ b/src/macdeployqt/shared/shared.cpp @@ -821,6 +821,12 @@ void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework deployedInstallName = framework.deployedInstallName; } changeInstallName(framework.installName, deployedInstallName, binary); + // Workaround for the case when the library ID name is a symlink, while the dependencies + // specified using the canonical path to the library (QTBUG-56814) + QString canonicalInstallName = QFileInfo(framework.installName).canonicalFilePath(); + if (canonicalInstallName != framework.installName) { + changeInstallName(canonicalInstallName, deployedInstallName, binary); + } } } @@ -1023,74 +1029,71 @@ void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pl // Plugin white list: QStringList pluginList; + const auto addPlugins = [&pluginSourcePath,&pluginList](const QString &subDirectory, + const std::function<bool(QString)> &predicate = std::function<bool(QString)>()) { + const QStringList libs = QDir(pluginSourcePath + QLatin1Char('/') + subDirectory) + .entryList({QStringLiteral("*.dylib")}); + for (const QString &lib : libs) { + if (!lib.endsWith(QStringLiteral("_debug.dylib")) && (!predicate || predicate(lib))) + pluginList.append(subDirectory + QLatin1Char('/') + lib); + } + }; + // Platform plugin: pluginList.append("platforms/libqcocoa.dylib"); // Cocoa print support pluginList.append("printsupport/libcocoaprintersupport.dylib"); + // Styles + addPlugins(QStringLiteral("styles")); + // Check if Qt was configured with -libinfix const QString libInfixWithFramework = getLibInfix(deploymentInfo.deployedFrameworks) + QStringLiteral(".framework"); // Network - if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtNetwork") + libInfixWithFramework)) { - QStringList bearerPlugins = QDir(pluginSourcePath + QStringLiteral("/bearer")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, bearerPlugins) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) - pluginList.append(QStringLiteral("bearer/") + plugin); - } - } + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtNetwork") + libInfixWithFramework)) + addPlugins(QStringLiteral("bearer")); // All image formats (svg if QtSvg.framework is used) - QStringList imagePlugins = QDir(pluginSourcePath + QStringLiteral("/imageformats")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, imagePlugins) { - if (plugin.contains(QStringLiteral("qsvg"))) { - if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSvg") + libInfixWithFramework)) - pluginList.append(QStringLiteral("imageformats/") + plugin); - } else if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) { - pluginList.append(QStringLiteral("imageformats/") + plugin); - } - } + const bool usesSvg = deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSvg") + libInfixWithFramework); + addPlugins(QStringLiteral("imageformats"), [usesSvg](const QString &lib) { + if (lib.contains(QStringLiteral("qsvg")) && !usesSvg) + return false; + return true; + }); - QStringList iconEngines = QDir(pluginSourcePath + QStringLiteral("/iconengines")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, iconEngines) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) { - pluginList.append(QStringLiteral("iconengines/") + plugin); - } - } + addPlugins(QStringLiteral("iconengines")); // Sql plugins if QtSql.framework is in use if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSql") + libInfixWithFramework)) { - QStringList sqlPlugins = QDir(pluginSourcePath + QStringLiteral("/sqldrivers")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, sqlPlugins) { - if (plugin.endsWith(QStringLiteral("_debug.dylib"))) - continue; - - // Some sql plugins are known to cause app store rejections. Skip or warn for these plugins. - if (plugin.startsWith(QStringLiteral("libqsqlodbc")) || plugin.startsWith(QStringLiteral("libqsqlpsql"))) { - LogWarning() << "Plugin" << plugin << "uses private API and is not Mac App store compliant."; + addPlugins(QStringLiteral("sqldrivers"), [](const QString &lib) { + if (lib.startsWith(QStringLiteral("libqsqlodbc")) || lib.startsWith(QStringLiteral("libqsqlpsql"))) { + LogWarning() << "Plugin" << lib << "uses private API and is not Mac App store compliant."; if (appstoreCompliant) { - LogWarning() << "Skip plugin" << plugin; - continue; + LogWarning() << "Skip plugin" << lib; + return false; } } - - pluginList.append(QStringLiteral("sqldrivers/") + plugin); - } + return true; + }); } // multimedia plugins if QtMultimedia.framework is in use if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtMultimedia") + libInfixWithFramework)) { - QStringList plugins = QDir(pluginSourcePath + QStringLiteral("/mediaservice")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, plugins) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) - pluginList.append(QStringLiteral("mediaservice/") + plugin); - } - plugins = QDir(pluginSourcePath + QStringLiteral("/audio")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, plugins) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) - pluginList.append(QStringLiteral("audio/") + plugin); - } + addPlugins(QStringLiteral("mediaservice")); + addPlugins(QStringLiteral("audio")); + } + + // render related plugins if Qt3DRender.framework is in use + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("Qt3DRender") + libInfixWithFramework)) { + addPlugins(QStringLiteral("sceneparsers")); + addPlugins(QStringLiteral("geometryloaders")); + } + + // scene related plugins if Qt3DQuickRender.framework is in use + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("Qt3DQuickRender") + libInfixWithFramework)) { + addPlugins(QStringLiteral("renderplugins")); } foreach (const QString &plugin, pluginList) { diff --git a/src/macdeployqt/tests/deployment_mac.pro b/src/macdeployqt/tests/deployment_mac.pro deleted file mode 100644 index 59f6071d6..000000000 --- a/src/macdeployqt/tests/deployment_mac.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = app -INCLUDEPATH += . ../shared/ -TARGET=tst_deployment_mac -CONFIG += qtestlib - -SOURCES += tst_deployment_mac.cpp ../shared/shared.cpp -HEADERS += ../shared/shared.h diff --git a/src/macdeployqt/tests/tst_deployment_mac.cpp b/src/macdeployqt/tests/tst_deployment_mac.cpp deleted file mode 100644 index ffbe974e6..000000000 --- a/src/macdeployqt/tests/tst_deployment_mac.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -#include <QtCore> -#include <QtTest/QTest> -#include <shared.h> - -class tst_deployment_mac : public QObject -{ -Q_OBJECT -private slots: - void testParseOtoolLibraryLine(); - void testgetQtFrameworks(); - void testFindAppBinarty(); -}; - -void tst_deployment_mac::testParseOtoolLibraryLine() -{ -{ - QString line = " /Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.4.0, current version 4.4.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/Users/foo/build/qt-4.4/lib/")); - QCOMPARE(info.frameworkName, QLatin1String("QtGui.framework")); - QCOMPARE(info.frameworkPath, QLatin1String("/Users/foo/build/qt-4.4/lib/QtGui.framework")); - QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4")); - QCOMPARE(info.binaryName, QLatin1String("QtGui")); - QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/QtGui")); - QCOMPARE(info.version, QLatin1String("4")); - QCOMPARE(info.installName, QLatin1String("/Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui")); - QCOMPARE(info.sourceFilePath, QLatin1String("/Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/QtGui.framework/Versions/4")); -} -{ - QString line = " /Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon (compatibility version 4.1.0, current version 4.1.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/Users/foo/build/qt-4.4/lib/")); - QCOMPARE(info.frameworkName, QLatin1String("phonon.framework")); - QCOMPARE(info.frameworkPath, QLatin1String("/Users/foo/build/qt-4.4/lib/phonon.framework")); - QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4")); - QCOMPARE(info.binaryName, QLatin1String("phonon")); - QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/phonon")); - QCOMPARE(info.version, QLatin1String("4")); - QCOMPARE(info.installName, QLatin1String("/Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.sourceFilePath, QLatin1String("/Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/phonon.framework/Versions/4")); -} - -{ - QString line = " /usr/local/Qt-4.4.0/lib/phonon.framework/Versions/4/phonon (compatibility version 4.1.0, current version 4.1.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/usr/local/Qt-4.4.0/lib/")); - QCOMPARE(info.frameworkName, QLatin1String("phonon.framework")); - QCOMPARE(info.frameworkPath, QLatin1String("/usr/local/Qt-4.4.0/lib/phonon.framework")); - QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4")); - QCOMPARE(info.binaryName, QLatin1String("phonon")); - QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/phonon")); - QCOMPARE(info.version, QLatin1String("4")); - QCOMPARE(info.installName, QLatin1String("/usr/local/Qt-4.4.0/lib/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.sourceFilePath, QLatin1String("/usr/local/Qt-4.4.0/lib/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/phonon.framework/Versions/4")); -} - -{ - QString line = " QtGui.framework/Versions/4/QtGui (compatibility version 4.1.0, current version 4.1.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/Library/Frameworks/")); - QCOMPARE(info.frameworkName, QLatin1String("QtGui.framework")); - QCOMPARE(info.frameworkPath, QLatin1String("/Library/Frameworks/QtGui.framework")); - QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4")); - QCOMPARE(info.binaryName, QLatin1String("QtGui")); - QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/QtGui")); - QCOMPARE(info.version, QLatin1String("4")); - QCOMPARE(info.installName, QLatin1String("QtGui.framework/Versions/4/QtGui")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui")); - QCOMPARE(info.sourceFilePath, QLatin1String("/Library/Frameworks/QtGui.framework/Versions/4/QtGui")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/QtGui.framework/Versions/4")); -} - -{ - QString line = " phonon.framework/Versions/4/QtGui (compatibility version 4.1.0, current version 4.1.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/Library/Frameworks/")); - QCOMPARE(info.frameworkName, QLatin1String("phonon.framework")); - QCOMPARE(info.frameworkPath, QLatin1String("/Library/Frameworks/phonon.framework")); - QCOMPARE(info.binaryDirectory, QLatin1String("Versions/4")); - QCOMPARE(info.binaryName, QLatin1String("phonon")); - QCOMPARE(info.binaryPath, QLatin1String("/Versions/4/phonon")); - QCOMPARE(info.version, QLatin1String("4")); - QCOMPARE(info.installName, QLatin1String("phonon.framework/Versions/4/phonon")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.sourceFilePath, QLatin1String("/Library/Frameworks/phonon.framework/Versions/4/phonon")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/phonon.framework/Versions/4")); -} - -{ - QString line = " /Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib (compatibility version 4.4.0, current version 4.4.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/Users/foo/build/qt-4.4/lib/")); - QCOMPARE(info.binaryName, QLatin1String("libQtCLucene.4.dylib")); - QCOMPARE(info.frameworkName, QLatin1String("libQtCLucene.4.dylib")); - QCOMPARE(info.frameworkPath, QLatin1String("/Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib")); - QCOMPARE(info.installName, QLatin1String("/Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/libQtCLucene.4.dylib")); - QCOMPARE(info.sourceFilePath, QLatin1String("/Users/foo/build/qt-4.4/lib/libQtCLucene.4.dylib")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/")); -} -{ - QString line = "libQtCLucene.4.dylib (compatibility version 4.4.0, current version 4.4.0)"; - FrameworkInfo info = parseOtoolLibraryLine(line, false); -// qDebug() << info; - QCOMPARE(info.frameworkDirectory, QLatin1String("/usr/lib/")); - QCOMPARE(info.binaryName, QLatin1String("libQtCLucene.4.dylib")); - QCOMPARE(info.frameworkName, QLatin1String("libQtCLucene.4.dylib")); - QCOMPARE(info.frameworkPath, QLatin1String("/usr/lib/libQtCLucene.4.dylib")); - QCOMPARE(info.installName, QLatin1String("libQtCLucene.4.dylib")); - QCOMPARE(info.deployedInstallName, QLatin1String("@executable_path/../Frameworks/libQtCLucene.4.dylib")); - QCOMPARE(info.sourceFilePath, QLatin1String("/usr/lib/libQtCLucene.4.dylib")); - QCOMPARE(info.destinationDirectory, QLatin1String("Contents/Frameworks/")); -} -{ - QString line = "/foo"; //invalid - FrameworkInfo info = parseOtoolLibraryLine(line, false); - QCOMPARE(info.frameworkName, QString()); -} - -} - -void tst_deployment_mac::testgetQtFrameworks() -{ -{ - QStringList otool = QStringList() - << "/Users/foo/build/qt-4.4/lib/phonon.framework/Versions/4/phonon (compatibility version 4.1.0, current version 4.1.0)" - << "/Users/foo/build/qt-4.4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.4.0, current version 4.4.0)" - << "/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 136.0.0)" - << "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 949.27.0)" - << "/Users/foo/build/qt-4.4/lib/QtCore.framework/Versions/4/QtCore (compatibility version 4.4.0, current version 4.4.0)" - << "/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)" - << "/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)" - << "/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)" - << "/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)" - << " " - ; - - QList<FrameworkInfo> frameworks = getQtFrameworks(otool, false); - QCOMPARE(frameworks.count(), 3); - QCOMPARE(frameworks.at(0).binaryName, QLatin1String("phonon")); - QCOMPARE(frameworks.at(1).binaryName, QLatin1String("QtGui")); - QCOMPARE(frameworks.at(2).binaryName, QLatin1String("QtCore")); -} -{ - QStringList otool = QStringList() - << "QtHelp.framework/Versions/4/QtHelp (compatibility version 4.4.0, current version 4.4.0)" - << "libQtCLucene.4.dylib (compatibility version 4.4.0, current version 4.4.0)" - << "QtSql.framework/Versions/4/QtSql (compatibility version 4.4.0, current version 4.4.0)" - << "QtXml.framework/Versions/4/QtXml (compatibility version 4.4.0, current version 4.4.0)" - << "QtGui.framework/Versions/4/QtGui (compatibility version 4.4.0, current version 4.4.0)" - << "/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 128.0.0)" - << "/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 824.42.0)" - << "QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.4.0, current version 4.4.0)" - << "QtCore.framework/Versions/4/QtCore (compatibility version 4.4.0, current version 4.4.0)" - << "/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3)" - << "/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.6)" - << "/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)" - << "/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)" - ; - - QList<FrameworkInfo> frameworks = getQtFrameworks(otool, false); - QCOMPARE(frameworks.count(), 7); - QCOMPARE(frameworks.at(0).binaryName, QLatin1String("QtHelp")); - QCOMPARE(frameworks.at(1).binaryName, QLatin1String("libQtCLucene.4.dylib")); - QCOMPARE(frameworks.at(2).binaryName, QLatin1String("QtSql")); - QCOMPARE(frameworks.at(3).binaryName, QLatin1String("QtXml")); - QCOMPARE(frameworks.at(4).binaryName, QLatin1String("QtGui")); - QCOMPARE(frameworks.at(5).binaryName, QLatin1String("QtNetwork")); - QCOMPARE(frameworks.at(6).binaryName, QLatin1String("QtCore")); -} - -} - -void tst_deployment_mac::testFindAppBinarty() -{ - QCOMPARE(findAppBinary("tst_deployment_mac.app"), QLatin1String("tst_deployment_mac.app/Contents/MacOS/tst_deployment_mac")); -} - -QTEST_MAIN(tst_deployment_mac) - -#include "tst_deployment_mac.moc" diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index a819026d8..7298d1ec2 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -2651,8 +2651,10 @@ void CppCodeParser::createExampleFileNodes(DocumentNode *dn) fullPath.truncate(fullPath.lastIndexOf('/')); QStringList exampleFiles = Config::getFilesHere(fullPath, exampleNameFilter, Location(), excludeDirs, excludeFiles); - QString imagesPath = fullPath + "/images"; - QStringList imageFiles = Config::getFilesHere(imagesPath, exampleImageFilter, Location(), excludeDirs, excludeFiles); + // Search for all image files under the example project, excluding doc/images directory. + QSet<QString> excludeDocDirs(excludeDirs); + excludeDocDirs.insert(QDir(fullPath).canonicalPath() + "/doc/images"); + QStringList imageFiles = Config::getFilesHere(fullPath, exampleImageFilter, Location(), excludeDocDirs, excludeFiles); if (!exampleFiles.isEmpty()) { // move main.cpp and to the end, if it exists QString mainCpp; diff --git a/src/qdoc/doc/qdoc-manual-markupcmds.qdoc b/src/qdoc/doc/qdoc-manual-markupcmds.qdoc index b7e854375..6e1951666 100644 --- a/src/qdoc/doc/qdoc-manual-markupcmds.qdoc +++ b/src/qdoc/doc/qdoc-manual-markupcmds.qdoc @@ -3544,6 +3544,30 @@ A support class is identified in the \\class comment with the \l {compat-command} {\\compat} command. + \section2 \c {examplefiles [regular_expression]} + + The \c examplefiles argument lists the files that are part of + an example project. The optional second argument is a regular + expression; if provided, only the files whose path matches with + the regular expression are listed. + + The \c examplefiles argument can be only used within example + documentation (see \l {example-command}{\\example}), and is + typically used together with the \l {noautolist-command}{\\noautolist} + command. + + \section2 \c {exampleimages [regular_expression]} + + The \c exampleimages argument lists the images that are part of + an example project. The optional second argument is a regular + expression; if provided, only the image files whose path matches + with the regular expression are listed. + + The \c exampleimages argument can be only used within example + documentation (see \l {example-command}{\\example}), and is + typically used together with the \l {noautolist-command}{\\noautolist} + command. + \section2 \c functionindex The \c functionindex argument provides a complete alphabetical @@ -3953,6 +3977,10 @@ This command was introduced in QDoc 5.6. + Since Qt 5.10, this command can be applied also to \l{example-command} + {\\example} documentation, where it causes the automatically generated + list of files and images belonging to an example project to be omitted. + \target omit-command \section1 \\omit diff --git a/src/qdoc/doc/qdoc-manual-topiccmds.qdoc b/src/qdoc/doc/qdoc-manual-topiccmds.qdoc index d1a605b4e..53fe85684 100644 --- a/src/qdoc/doc/qdoc-manual-topiccmds.qdoc +++ b/src/qdoc/doc/qdoc-manual-topiccmds.qdoc @@ -364,9 +364,9 @@ \l {exampledirs-variable} {exampledirs} variable in the QDoc configuration file. - The documentation page will be output to \c {path-to-example}.html. - QDoc will add a list of all the example's source files at the top - of the page. + The documentation page will be output to \c {modulename-path-to-example}.html. + QDoc will add a list of all the example's source and images files at the end + of the page, unless \l {noautolist-command}{\\noautolist} command is used. For example, if \l {exampledirs-variable} {exampledirs} contains \c $QTDIR/examples/widgets/imageviewer, then @@ -391,6 +391,9 @@ <center><h1>Image Viewer Example</h1></center> \endraw + The example shows how to combine QLabel and QScrollArea + to display an image. + Files: \list \li \l{http://doc.qt.io/qt-5/qtwidgets-widgets-imageviewer-imageviewer-cpp.html} @@ -401,12 +404,13 @@ {widgets/imageviewer/main.cpp} \endlist - The example shows how to combine QLabel and QScrollArea - to display an image. ... \endquotation + \b {See also:} \l {generatelist-command}{\\generatelist examplefiles}, + \l {noautolist-command}{\\noautolist} + \target externalpage-command \section1 \\externalpage diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index 88e2a1b36..bef912013 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -960,7 +960,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) if (node->isDocumentNode()) { const DocumentNode *dn = static_cast<const DocumentNode *>(node); - if (dn->isExample()) { + if (dn->isExample() && !dn->noAutoList()) { generateExampleFiles(dn, marker); } else if (dn->docSubtype() == Node::File) { @@ -983,8 +983,8 @@ void Generator::generateExampleFiles(const DocumentNode *dn, CodeMarker *marker) { if (dn->childNodes().isEmpty()) return; - generateFileList(dn, marker, Node::File, QString("Files:")); - generateFileList(dn, marker, Node::Image, QString("Images:")); + generateFileList(dn, marker, Node::File); + generateFileList(dn, marker, Node::Image); } void Generator::generateDocumentNode(DocumentNode* /* dn */, CodeMarker* /* marker */) @@ -1005,16 +1005,39 @@ void Generator::generateCollectionNode(CollectionNode* , CodeMarker* ) void Generator::generateFileList(const DocumentNode* dn, CodeMarker* marker, Node::DocSubtype subtype, - const QString& tag) + const QString& regExp) { int count = 0; Text text; OpenedList openedList(OpenedList::Bullet); + QString tag; + + NodeList children(dn->childNodes()); + std::sort(children.begin(), children.end(), Generator::compareNodes); + if (!regExp.isEmpty()) { + QRegExp re(regExp); + QMutableListIterator<Node*> i(children); + while (i.hasNext()) { + if (!re.exactMatch(i.next()->name())) + i.remove(); + } + } + if (children.size() > 1) { + switch (subtype) { + default: + case Node::File: + tag = "Files:"; + break; + case Node::Image: + tag = "Images:"; + break; + } + text << Atom::ParaLeft << tag << Atom::ParaRight; + } - text << Atom::ParaLeft << tag << Atom::ParaRight - << Atom(Atom::ListLeft, openedList.styleString()); + text << Atom(Atom::ListLeft, openedList.styleString()); - foreach (const Node* child, dn->childNodes()) { + foreach (const Node* child, children) { if (child->docSubtype() == subtype) { ++count; QString file = child->name(); @@ -1609,10 +1632,11 @@ void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker) objectName[0] = objectName[0].toLower(); } - - // We have an overloaded signal, show an example - QString code = "connect(" + objectName + ", static_cast<" + func->returnType() - + QLatin1Char('(') + func->parent()->name() + "::*)("; + // We have an overloaded signal, show an example. Note, for const + // overloaded signals one should use Q{Const,NonConst}Overload, but + // it is very unlikely that we will ever have public API overloading + // signals by const. + QString code = "connect(" + objectName + ", QOverload<"; for (int i = 0; i < func->parameters().size(); ++i) { if (i != 0) code += ", "; @@ -1620,10 +1644,7 @@ void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker) code += p.dataType() + p.rightType(); } - code += QLatin1Char(')'); - if (func->isConst()) - code += " const"; - code += ">(&" + func->parent()->name() + "::" + func->name() + "),\n [=]("; + code += ">::of(&" + func->parent()->name() + "::" + func->name() + "),\n [=]("; for (int i = 0; i < func->parameters().size(); ++i) { if (i != 0) @@ -1647,8 +1668,9 @@ void Generator::generateOverloadedSignal(const Node* node, CodeMarker* marker) << node->name() << Atom(Atom::FormattingRight,ATOM_FORMATTING_ITALIC) << " is overloaded in this class. " - "To connect to this one using the function pointer syntax, you must " - "specify the signal type in a static cast, as shown in this example:" + "To connect to this signal by using the function pointer syntax, Qt " + "provides a convenient helper for obtaining the function pointer as " + "shown in this example:" << Atom(Atom::Code, marker->markedUpCode(code, node, func->location())); generateText(text, node, marker); diff --git a/src/qdoc/generator.h b/src/qdoc/generator.h index a3c34eaba..4709ad129 100644 --- a/src/qdoc/generator.h +++ b/src/qdoc/generator.h @@ -153,7 +153,7 @@ protected: void generateFileList(const DocumentNode* dn, CodeMarker* marker, Node::DocSubtype subtype, - const QString& tag); + const QString& regExp = QString()); void generateSince(const Node *node, CodeMarker *marker); void generateStatus(const Node *node, CodeMarker *marker); void generatePrivateSignalNote(const Node* node, CodeMarker* marker); @@ -230,6 +230,7 @@ private: static QmlTypeNode* qmlTypeContext_; void generateReimplementedFrom(const FunctionNode *func, CodeMarker *marker); + static bool compareNodes(Node *a, Node *b) { return (a->name() < b->name()); } protected: const Config* config_; diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index be6617501..a0f8eacde 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -709,6 +709,19 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark generateAnnotatedList(relative, marker, cn->members()); } } + else if (atom->string().startsWith("examplefiles") || + atom->string().startsWith("exampleimages")) { + if (relative->isExample()) { + Node::DocSubtype subType = (atom->string().mid(7,5) == "image") ? Node::Image : Node::File; + QString regExp; + int secondArg = atom->string().indexOf(" "); + if (secondArg != -1) + regExp = atom->string().mid(++secondArg); + generateFileList(static_cast<const DocumentNode*>(relative), marker, subType, regExp); + } + else + relative->location().warning(QString("'\\generatelist \1' can only be used with '\\example' topic command").arg(atom->string())); + } else if (atom->string() == QLatin1String("classhierarchy")) { generateClassHierarchy(relative, qdb_->getCppClasses()); } diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 6d83ba631..9919317f2 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -1213,7 +1213,7 @@ NodeList Aggregate::overloads(const QString &funcName) const given \a type and having the given \a parent and \a name. */ Aggregate::Aggregate(NodeType type, Aggregate *parent, const QString& name) - : Node(type, parent, name) + : Node(type, parent, name), noAutoList_(false) { switch (type) { case Class: diff --git a/src/qdoc/node.h b/src/qdoc/node.h index 2de9e2e5b..33cdd3c1a 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -423,7 +423,8 @@ public: void setOutputSubdirectory(const QString& t) Q_DECL_OVERRIDE; const NodeMap& primaryFunctionMap() { return primaryFunctionMap_; } const QMap<QString, NodeList>& secondaryFunctionMap() { return secondaryFunctionMap_; } - + bool noAutoList() const { return noAutoList_; } + virtual void setNoAutoList(bool b) Q_DECL_OVERRIDE { noAutoList_ = b; } protected: Aggregate(NodeType type, Aggregate* parent, const QString& name); @@ -444,6 +445,7 @@ private: NodeMap childMap_; NodeMap primaryFunctionMap_; QMap<QString, NodeList> secondaryFunctionMap_; + bool noAutoList_; }; class LeafNode : public Node @@ -1151,7 +1153,7 @@ class CollectionNode : public Aggregate Aggregate* parent, const QString& name, Genus genus) - : Aggregate(type, parent, name), seen_(false), noAutoList_(false) + : Aggregate(type, parent, name), seen_(false) { setPageType(Node::OverviewPage); setGenus(genus); @@ -1194,12 +1196,10 @@ class CollectionNode : public Aggregate void markSeen() { seen_ = true; } void markNotSeen() { seen_ = false; } - bool noAutoList() const { return noAutoList_; } - virtual void setNoAutoList(bool b) Q_DECL_OVERRIDE { noAutoList_ = b; } + private: bool seen_; - bool noAutoList_; QString title_; QString subtitle_; NodeList members_; diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro index 8cf4b44dd..a49ddc555 100644 --- a/src/qdoc/qdoc.pro +++ b/src/qdoc/qdoc.pro @@ -95,6 +95,7 @@ qtPrepareTool(QHELPGENERATOR, qhelpgenerator) QMAKE_DOCS = $$PWD/doc/config/qdoc.qdocconf +QMAKE_TARGET_DESCRIPTION = "Qt Documentation Compiler" load(qt_tool) TR_EXCLUDE += $$PWD/* diff --git a/src/qtattributionsscanner/main.cpp b/src/qtattributionsscanner/main.cpp index 908b24ca4..ddb942a9d 100644 --- a/src/qtattributionsscanner/main.cpp +++ b/src/qtattributionsscanner/main.cpp @@ -44,12 +44,13 @@ int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); a.setApplicationName(QStringLiteral("Qt Attributions Scanner")); - a.setApplicationVersion(QStringLiteral("1.0")); + a.setApplicationVersion(QStringLiteral("1.1")); QCommandLineParser parser; - parser.setApplicationDescription(tr("Searches and processes qt_attribution.json files in Qt sources.")); - parser.addPositionalArgument(QStringLiteral("directory"), - tr("The directory to scan recursively.")); + parser.setApplicationDescription(tr("Processes qt_attribution.json files in Qt sources.")); + parser.addPositionalArgument(QStringLiteral("path"), + tr("Path to a qt_attribution.json file, " + "or a directory to be scannned recursively.")); parser.addHelpOption(); parser.addVersionOption(); @@ -60,6 +61,10 @@ int main(int argc, char *argv[]) QCommandLineOption filterOption(QStringLiteral("filter"), tr("Filter packages according to <filter> (e.g. QDocModule=qtcore)"), QStringLiteral("expression")); + QCommandLineOption baseDirOption(QStringLiteral("basedir"), + tr("Paths in documentation are made relative to this " + "directory."), + QStringLiteral("directory")); QCommandLineOption outputOption({ QStringLiteral("o"), QStringLiteral("output") }, tr("Write generated data to <file>."), QStringLiteral("file")); @@ -70,6 +75,7 @@ int main(int argc, char *argv[]) parser.addOption(generatorOption); parser.addOption(filterOption); + parser.addOption(baseDirOption); parser.addOption(outputOption); parser.addOption(verboseOption); parser.addOption(silentOption); @@ -90,13 +96,22 @@ int main(int argc, char *argv[]) if (parser.positionalArguments().size() != 1) parser.showHelp(2); - const QString directory = parser.positionalArguments().constLast(); - - if (logLevel == VerboseLog) - std::cerr << qPrintable(tr("Recursively scanning %1 for qt_attribution.json files...").arg( - QDir::toNativeSeparators(directory))) << std::endl; - - QVector<Package> packages = Scanner::scanDirectory(directory, logLevel); + const QString path = parser.positionalArguments().constLast(); + + QVector<Package> packages; + const QFileInfo pathInfo(path); + if (pathInfo.isDir()) { + if (logLevel == VerboseLog) + std::cerr << qPrintable(tr("Recursively scanning %1 for qt_attribution.json files...").arg( + QDir::toNativeSeparators(path))) << std::endl; + packages = Scanner::scanDirectory(path, logLevel); + } else if (pathInfo.isFile()) { + packages = Scanner::readFile(path, logLevel); + } else { + std::cerr << qPrintable(tr("%1 is not a valid file or directory.").arg( + QDir::toNativeSeparators(path))) << std::endl << std::endl; + parser.showHelp(7); + } if (parser.isSet(filterOption)) { PackageFilter filter(parser.value(filterOption)); @@ -124,8 +139,16 @@ int main(int argc, char *argv[]) QString generator = parser.value(generatorOption); if (generator == QLatin1String("qdoc")) { - // include top level module name in printed paths - QString baseDirectory = QDir(directory).absoluteFilePath(QStringLiteral("..")); + QString baseDirectory = parser.value(baseDirOption); + if (baseDirectory.isEmpty()) { + if (pathInfo.isDir()) { + // include top level module name in printed paths + baseDirectory = pathInfo.dir().absoluteFilePath(QStringLiteral("..")); + } else { + baseDirectory = pathInfo.absoluteDir().absoluteFilePath(QStringLiteral("..")); + } + } + QDocGenerator::generate(out, packages, baseDirectory, logLevel); } else if (generator == QLatin1String("json")) { JsonGenerator::generate(out, packages, logLevel); diff --git a/src/qtattributionsscanner/qtattributionsscanner.pro b/src/qtattributionsscanner/qtattributionsscanner.pro index 827e5f5cf..c3c57b35d 100644 --- a/src/qtattributionsscanner/qtattributionsscanner.pro +++ b/src/qtattributionsscanner/qtattributionsscanner.pro @@ -18,4 +18,5 @@ HEADERS += \ DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII +QMAKE_TARGET_DESCRIPTION = "Qt Source Code Attribution Scanner" load(qt_tool) diff --git a/src/qtattributionsscanner/scanner.cpp b/src/qtattributionsscanner/scanner.cpp index 488417e89..d7d958138 100644 --- a/src/qtattributionsscanner/scanner.cpp +++ b/src/qtattributionsscanner/scanner.cpp @@ -140,7 +140,7 @@ static Package readPackage(const QJsonObject &object, const QString &filePath, L return p; } -static QVector<Package> readFile(const QString &filePath, LogLevel logLevel) +QVector<Package> readFile(const QString &filePath, LogLevel logLevel) { if (logLevel == VerboseLog) { std::cerr << qPrintable(tr("Reading file %1...").arg( diff --git a/src/qtattributionsscanner/scanner.h b/src/qtattributionsscanner/scanner.h index 47d4aa6d9..f3ae9f0ea 100644 --- a/src/qtattributionsscanner/scanner.h +++ b/src/qtattributionsscanner/scanner.h @@ -37,7 +37,7 @@ namespace Scanner { -QVector<Package> readDirectory(const QString &packageDirectory, LogLevel logLevel); +QVector<Package> readFile(const QString &filePath, LogLevel logLevel); QVector<Package> scanDirectory(const QString &directory, LogLevel logLevel); } diff --git a/src/qtdiag/main.cpp b/src/qtdiag/main.cpp index 14eae6be4..2f5e2e9ee 100644 --- a/src/qtdiag/main.cpp +++ b/src/qtdiag/main.cpp @@ -49,10 +49,12 @@ int main(int argc, char **argv) const QCommandLineOption noGlOption(QStringLiteral("no-gl"), QStringLiteral("Do not output GL information")); const QCommandLineOption glExtensionOption(QStringLiteral("gl-extensions"), QStringLiteral("List GL extensions")); const QCommandLineOption fontOption(QStringLiteral("fonts"), QStringLiteral("Output list of fonts")); + const QCommandLineOption noVkOption(QStringLiteral("no-vulkan"), QStringLiteral("Do not output Vulkan information")); commandLineParser.setApplicationDescription(QStringLiteral("Prints diagnostic output about the Qt library.")); commandLineParser.addOption(noGlOption); commandLineParser.addOption(glExtensionOption); commandLineParser.addOption(fontOption); + commandLineParser.addOption(noVkOption); commandLineParser.addHelpOption(); commandLineParser.process(app); unsigned flags = commandLineParser.isSet(noGlOption) ? 0u : unsigned(QtDiagGl); @@ -60,6 +62,8 @@ int main(int argc, char **argv) flags |= QtDiagGlExtensions; if (commandLineParser.isSet(fontOption)) flags |= QtDiagFonts; + if (!commandLineParser.isSet(noVkOption)) + flags |= QtDiagVk; std::wcout << qtDiag(flags).toStdWString(); return 0; diff --git a/src/qtdiag/qtdiag.cpp b/src/qtdiag/qtdiag.cpp index 437f11ce9..d07921d07 100644 --- a/src/qtdiag/qtdiag.cpp +++ b/src/qtdiag/qtdiag.cpp @@ -37,7 +37,12 @@ #ifndef QT_NO_OPENGL # include <QtGui/QOpenGLContext> # include <QtGui/QOpenGLFunctions> +# include <QtGui/QOpenGLVersionProfile> #endif // QT_NO_OPENGL +#if QT_CONFIG(vulkan) +# include <QtGui/QVulkanInstance> +# include <QtGui/QVulkanWindow> +#endif // vulkan #include <QtGui/QWindow> #include <QtGui/QTouchDevice> @@ -58,6 +63,7 @@ #include <QtCore/QDir> #include <QtCore/QFileSelector> #include <QtCore/QDebug> +#include <QtCore/QVersionNumber> #include <private/qsimd_p.h> #include <private/qguiapplication_p.h> @@ -176,7 +182,30 @@ void dumpGlInfo(QTextStream &str, bool listExtensions) << "\nVersion: " << reinterpret_cast<const char *>(functions.glGetString(GL_VERSION)) << "\nShading language: " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION)) << "\nFormat: " << context.format(); - +# ifndef QT_OPENGL_ES_2 + GLint majorVersion; + functions.glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); + GLint minorVersion; + functions.glGetIntegerv(GL_MINOR_VERSION, &minorVersion); + const QByteArray openGlVersionFunctionsName = "QOpenGLFunctions_" + + QByteArray::number(majorVersion) + '_' + QByteArray::number(minorVersion); + str << "\nProfile: None (" << openGlVersionFunctionsName << ')'; + if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 1)) { + QOpenGLVersionProfile profile; + profile.setVersion(majorVersion, minorVersion); + profile.setProfile(QSurfaceFormat::CoreProfile); + if (QAbstractOpenGLFunctions *f = context.versionFunctions(profile)) { + if (f->initializeOpenGLFunctions()) + str << ", Core (" << openGlVersionFunctionsName << "_Core)"; + } + profile.setProfile(QSurfaceFormat::CompatibilityProfile); + if (QAbstractOpenGLFunctions *f = context.versionFunctions(profile)) { + if (f->initializeOpenGLFunctions()) + str << ", Compatibility (" << openGlVersionFunctionsName << "_Compatibility)"; + } + } + str << '\n'; +# endif // !QT_OPENGL_ES_2 if (listExtensions) { QList<QByteArray> extensionList = context.extensions().toList(); std::sort(extensionList.begin(), extensionList.end()); @@ -191,6 +220,44 @@ void dumpGlInfo(QTextStream &str, bool listExtensions) #endif // !QT_NO_OPENGL +#if QT_CONFIG(vulkan) +QVersionNumber vulkanVersion(uint32_t v) +{ + return QVersionNumber(VK_VERSION_MAJOR(v), VK_VERSION_MINOR(v), VK_VERSION_PATCH(v)); +} + +void dumpVkInfo(QTextStream &str) +{ + QVulkanInstance inst; + if (inst.create()) { + str << "Vulkan instance available\n"; + str << "Supported instance extensions:\n"; + for (const QVulkanExtension &ext : inst.supportedExtensions()) + str << " " << ext.name << ", version " << ext.version << "\n"; + str << "Supported layers:\n"; + for (const QVulkanLayer &layer : inst.supportedLayers()) + str << " " << layer.name << ", version " << layer.version + << ", spec version " << layer.specVersion.toString() + << ", " << layer.description << "\n"; + // Show at least the available physical devices. Anything additional + // needs lots of initialization, or, if done through QVulkanWindow, an + // exposed window. None of these are very tempting right now. + str << "Available physical devices:\n"; + QVulkanWindow window; + window.setVulkanInstance(&inst); + for (const VkPhysicalDeviceProperties &props : window.availablePhysicalDevices()) { + str << " API version " << vulkanVersion(props.apiVersion).toString() + << hex << ", vendor 0x" << props.vendorID + << ", device 0x" << props.deviceID << ", " << props.deviceName + << dec << ", type " << props.deviceType + << ", driver version " << vulkanVersion(props.driverVersion).toString(); + } + } else { + str << "Unable to create a Vulkan instance, error code is" << inst.errorCode() << "\n"; + } +} +#endif // vulkan + #define DUMP_CAPABILITY(str, integration, capability) \ if (platformIntegration->hasCapability(QPlatformIntegration::capability)) \ str << ' ' << #capability; @@ -351,7 +418,7 @@ QString qtDiag(unsigned flags) #endif str << '\n'; -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); str << "\nEnvironment:\n"; const QStringList keys = systemEnvironment.keys(); @@ -359,7 +426,7 @@ QString qtDiag(unsigned flags) if (key.startsWith(QLatin1Char('Q'))) str << " " << key << "=\"" << systemEnvironment.value(key) << "\"\n"; } -#endif // !QT_NO_PROCESS +#endif // QT_CONFIG(process) const QByteArrayList features = qtFeatures(); if (!features.isEmpty()) @@ -603,6 +670,13 @@ QString qtDiag(unsigned flags) Q_UNUSED(flags) #endif // !QT_NO_OPENGL +#if QT_CONFIG(vulkan) + if (flags & QtDiagVk) { + dumpVkInfo(str); + str << "\n\n"; + } +#endif // vulkan + // On Windows, this will provide addition GPU info similar to the output of dxdiag. if (const QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface()) { const QVariant gpuInfoV = ni->property("gpu"); diff --git a/src/qtdiag/qtdiag.h b/src/qtdiag/qtdiag.h index b073297ef..359840647 100644 --- a/src/qtdiag/qtdiag.h +++ b/src/qtdiag/qtdiag.h @@ -36,7 +36,8 @@ QT_BEGIN_NAMESPACE enum QtDiagFlags { QtDiagGl = 0x1, QtDiagGlExtensions = 0x2, - QtDiagFonts = 0x4 + QtDiagFonts = 0x4, + QtDiagVk = 0x8 }; QString qtDiag(unsigned flags = 0); diff --git a/src/shared/deviceskin/deviceskin.cpp b/src/shared/deviceskin/deviceskin.cpp index 603834dc6..b8649b9b3 100644 --- a/src/shared/deviceskin/deviceskin.cpp +++ b/src/shared/deviceskin/deviceskin.cpp @@ -50,7 +50,7 @@ #include <QtGui/QImage> #include <QtCore/QTimer> #include <QtCore/QDir> -#include <QtCore/QRegExp> +#include <QtCore/QRegularExpression> #include <QtGui/QMouseEvent> #include <QtCore/QDebug> @@ -285,12 +285,14 @@ bool DeviceSkinParameters::read(QTextStream &ts, ReadMode rm, QString *errorMess ts.readLine(); // eol joystick = -1; const QString Joystick = QLatin1String("Joystick"); + const QRegularExpression splitRe(QLatin1String("[ \t][ \t]*")); + Q_ASSERT(splitRe.isValid()); while (i < nareas && !ts.atEnd() ) { buttonAreas.push_back(DeviceSkinButtonArea()); DeviceSkinButtonArea &area = buttonAreas.back(); const QString line = ts.readLine(); if ( !line.isEmpty() && line[0] != QLatin1Char('#') ) { - const QStringList tok = line.split(QRegExp(QLatin1String("[ \t][ \t]*"))); + const QStringList tok = line.split(splitRe); if ( tok.count()<6 ) { *errorMessage = DeviceSkin::tr("Syntax error in area definition: %1").arg(line); return false; diff --git a/src/shared/qtgradienteditor/qtcolorline.h b/src/shared/qtgradienteditor/qtcolorline.h index 606d0fa84..6d19ed4d9 100644 --- a/src/shared/qtgradienteditor/qtcolorline.h +++ b/src/shared/qtgradienteditor/qtcolorline.h @@ -54,7 +54,6 @@ class QtColorLine : public QWidget Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered) Q_PROPERTY(ColorComponent colorComponent READ colorComponent WRITE setColorComponent) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_ENUMS(ColorComponent) public: enum ColorComponent { @@ -66,6 +65,7 @@ public: Value, Alpha }; + Q_ENUM(ColorComponent) QSize minimumSizeHint() const; QSize sizeHint() const; diff --git a/src/shared/qtgradienteditor/qtgradientwidget.cpp b/src/shared/qtgradienteditor/qtgradientwidget.cpp index 73c448578..24226384a 100644 --- a/src/shared/qtgradienteditor/qtgradientwidget.cpp +++ b/src/shared/qtgradienteditor/qtgradientwidget.cpp @@ -49,12 +49,7 @@ #define _USE_MATH_DEFINES #endif - -#include "math.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include "qmath.h" QT_BEGIN_NAMESPACE @@ -343,7 +338,7 @@ void QtGradientWidget::mousePressEvent(QMouseEvent *e) if (r1.contains(pF) || r2.contains(pF) || r3.contains(pF)) { x = pF.x() / size().width() - d_ptr->m_centralRadial.x(); y = pF.y() / size().height() - d_ptr->m_centralRadial.y(); - double clickRadius = sqrt(x * x + y * y); + const double clickRadius = hypot(x, y); //d_ptr->m_radiusOffset = d_ptr->m_radiusRadial - clickRadius; d_ptr->m_radiusFactor = d_ptr->m_radiusRadial / clickRadius; if (d_ptr->m_radiusFactor == 0) @@ -382,7 +377,7 @@ void QtGradientWidget::mousePressEvent(QMouseEvent *e) y = current.y() - central.y(); x /= size().width() / 2; y /= size().height() / 2; - double angle = atan2(-y, x) * 180 / M_PI; + const double angle = qRadiansToDegrees(atan2(-y, x)); d_ptr->m_angleOffset = d_ptr->m_angleConical - angle; d_ptr->m_dragAngle = d_ptr->m_angleConical; @@ -442,7 +437,7 @@ void QtGradientWidget::mouseMoveEvent(QMouseEvent *e) } else { x = pF.x() / size().width() - d_ptr->m_centralRadial.x(); y = pF.y() / size().height() - d_ptr->m_centralRadial.y(); - double moveRadius = sqrt(x * x + y * y); + const double moveRadius = hypot(x, y); //double newRadius = moveRadius + d_ptr->m_radiusOffset; double newRadius = moveRadius * d_ptr->m_radiusFactor; if (newRadius > 2) @@ -472,7 +467,7 @@ void QtGradientWidget::mouseMoveEvent(QMouseEvent *e) x /= size().width() / 2; y /= size().height() / 2; - double angle = atan2(-y, x) * 180 / M_PI + d_ptr->m_angleOffset; + const double angle = qRadiansToDegrees(atan2(-y, x)) + d_ptr->m_angleOffset; d_ptr->setAngleConical(angle); } } @@ -619,28 +614,30 @@ void QtGradientWidget::paintEvent(QPaintEvent *e) p.setBrush(Qt::NoBrush); int pointCount = 2; for (int i = 0; i < pointCount; i++) { - QPointF ang(cos(M_PI * (i * 180.0 / pointCount + d_ptr->m_angleConical) / 180) * size().width() / 2, - -sin(M_PI * (i * 180.0 / pointCount + d_ptr->m_angleConical) / 180) * size().height() / 2); - double mod = sqrt(ang.x() * ang.x() + ang.y() * ang.y()); - p.drawLine(QPointF(central.x() + ang.x() * (radius - corr) / mod, - central.y() + ang.y() * (radius - corr) / mod), - QPointF(central.x() + ang.x() * (radius + corr) / mod, - central.y() + ang.y() * (radius + corr) / mod)); - p.drawLine(QPointF(central.x() - ang.x() * (radius - corr) / mod, - central.y() - ang.y() * (radius - corr) / mod), - QPointF(central.x() - ang.x() * (radius + corr) / mod, - central.y() - ang.y() * (radius + corr) / mod)); + const qreal angle = qDegreesToRadians(i * 180.0 / pointCount + d_ptr->m_angleConical); + const QPointF ray(cos(angle) * size().width() / 2, + -sin(angle) * size().height() / 2); + const double mod = hypot(ray.x(), ray.y()); + p.drawLine(QPointF(central.x() + ray.x() * (radius - corr) / mod, + central.y() + ray.y() * (radius - corr) / mod), + QPointF(central.x() + ray.x() * (radius + corr) / mod, + central.y() + ray.y() * (radius + corr) / mod)); + p.drawLine(QPointF(central.x() - ray.x() * (radius - corr) / mod, + central.y() - ray.y() * (radius - corr) / mod), + QPointF(central.x() - ray.x() * (radius + corr) / mod, + central.y() - ray.y() * (radius + corr) / mod)); } if (d_ptr->m_dragHandle == QtGradientWidgetPrivate::AngleConicalHandle) { p.save(); p.setPen(dragPen); - QPointF ang(cos(M_PI * (d_ptr->m_angleConical - d_ptr->m_angleOffset) / 180) * size().width() / 2, - -sin(M_PI * (d_ptr->m_angleConical - d_ptr->m_angleOffset) / 180) * size().height() / 2); - double mod = sqrt(ang.x() * ang.x() + ang.y() * ang.y()); - p.drawLine(QPointF(central.x() + ang.x() * (radius - corr) / mod, - central.y() + ang.y() * (radius - corr) / mod), - QPointF(central.x() + ang.x() * (radius + corr) / mod, - central.y() + ang.y() * (radius + corr) / mod)); + const qreal angle = qDegreesToRadians(d_ptr->m_angleConical - d_ptr->m_angleOffset); + const QPointF ray(cos(angle) * size().width() / 2, + -sin(angle) * size().height() / 2); + const double mod = hypot(ray.x(), ray.y()); + p.drawLine(QPointF(central.x() + ray.x() * (radius - corr) / mod, + central.y() + ray.y() * (radius - corr) / mod), + QPointF(central.x() + ray.x() * (radius + corr) / mod, + central.y() + ray.y() * (radius + corr) / mod)); p.restore(); } diff --git a/src/shared/qtpropertybrowser/qteditorfactory.cpp b/src/shared/qtpropertybrowser/qteditorfactory.cpp index a87449faf..de852a740 100644 --- a/src/shared/qtpropertybrowser/qteditorfactory.cpp +++ b/src/shared/qtpropertybrowser/qteditorfactory.cpp @@ -1965,7 +1965,7 @@ public: QMap<QtProperty *, QtProperty *> m_propertyToEnum; QMap<QtProperty *, QtProperty *> m_enumToProperty; - QMap<QtProperty *, QList<QWidget *> > m_enumToEditors; + QMap<QtProperty *, QWidgetList > m_enumToEditors; QMap<QWidget *, QtProperty *> m_editorToEnum; bool m_updatingEnum; }; diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp index 6c1338c77..9bc5e4f21 100644 --- a/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp +++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.cpp @@ -402,7 +402,6 @@ static QIcon drawIndicatorIcon(const QPalette &palette, QStyle *style) QPixmap pix(14, 14); pix.fill(Qt::transparent); QStyleOption branchOption; - QRect r(QPoint(0, 0), pix.size()); branchOption.rect = QRect(2, 2, 9, 9); // ### hardcoded in qcommonstyle.cpp branchOption.palette = palette; branchOption.state = QStyle::State_Children; diff --git a/src/shared/qtpropertybrowser/qttreepropertybrowser.h b/src/shared/qtpropertybrowser/qttreepropertybrowser.h index a2ea777f6..9ff4d5f50 100644 --- a/src/shared/qtpropertybrowser/qttreepropertybrowser.h +++ b/src/shared/qtpropertybrowser/qttreepropertybrowser.h @@ -50,7 +50,6 @@ class QtTreePropertyBrowserPrivate; class QtTreePropertyBrowser : public QtAbstractPropertyBrowser { Q_OBJECT - Q_ENUMS(ResizeMode) Q_PROPERTY(int indentation READ indentation WRITE setIndentation) Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated) Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors) @@ -67,6 +66,7 @@ public: Fixed, ResizeToContents }; + Q_ENUM(ResizeMode) QtTreePropertyBrowser(QWidget *parent = 0); ~QtTreePropertyBrowser(); diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp index fd21a6949..f574bd25e 100644 --- a/src/windeployqt/main.cpp +++ b/src/windeployqt/main.cpp @@ -816,6 +816,7 @@ static const PluginModuleMapping pluginModuleMappings[] = {"sqldrivers", QtSqlModule}, {"texttospeech", QtTextToSpeechModule}, {"qtwebengine", QtWebEngineModule | QtWebEngineCoreModule | QtWebEngineWidgetsModule}, + {"styles", QtWidgetsModule}, {"sceneparsers", Qt3DRendererModule}, {"renderplugins", Qt3DRendererModule}, {"geometryloaders", Qt3DRendererModule} diff --git a/src/windeployqt/windeployqt.pro b/src/windeployqt/windeployqt.pro index b6c843e15..fc8c74fd5 100644 --- a/src/windeployqt/windeployqt.pro +++ b/src/windeployqt/windeployqt.pro @@ -9,4 +9,5 @@ CONFIG += force_bootstrap win32: LIBS += -lshlwapi +QMAKE_TARGET_DESCRIPTION = "Qt Windows Deployment Tool" load(qt_tool) diff --git a/src/winrtrunner/winrtrunner.pro b/src/winrtrunner/winrtrunner.pro index 21f2c8310..e633e0f0d 100644 --- a/src/winrtrunner/winrtrunner.pro +++ b/src/winrtrunner/winrtrunner.pro @@ -22,4 +22,5 @@ LIBS += -lruntimeobject -lwsclient -lShlwapi -lurlmon -lxmllite -lcrypt32 include(../shared/corecon/corecon.pri) +QMAKE_TARGET_DESCRIPTION = "Qt WinRT Runner" load(qt_tool) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 53466702f..15a7cf569 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -25,5 +25,6 @@ cross_compile:SUBDIRS -= linguist qhelpindexmodel \ qhelpprojectdata \ -android|ios|qnx|winrt: SUBDIRS -= qtdiag +!qtConfig(process): SUBDIRS -= qtattributionsscanner linguist qtdiag windeployqt +android|qnx: SUBDIRS -= qtdiag !win32|winrt: SUBDIRS -= windeployqt diff --git a/tests/auto/linguist/lconvert/data/untranslated.ts b/tests/auto/linguist/lconvert/data/untranslated.ts new file mode 100644 index 000000000..89007df26 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/untranslated.ts @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>a</name> + <message> + <location filename="a.cpp" line="93"/> + <source>One string</source> + <translation>Ein Gesimsband</translation> + </message> + <message> + <location filename="a.cpp" line="380"/> + <source>Untranslated String</source> + <translation></translation> + </message> + <message numerus="yes"> + <location filename="a.cpp" line="456"/> + <source>%n things</source> + <translation> + <numerusform></numerusform> + <numerusform>%n Dinger</numerusform> + </translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lconvert/data/untranslated.ts.out b/tests/auto/linguist/lconvert/data/untranslated.ts.out new file mode 100644 index 000000000..6244f9db8 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/untranslated.ts.out @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>a</name> + <message> + <location filename="a.cpp" line="93"/> + <source>One string</source> + <translation>Ein Gesimsband</translation> + </message> + <message numerus="yes"> + <location filename="a.cpp" line="456"/> + <source>%n things</source> + <translation> + <numerusform></numerusform> + <numerusform>%n Dinger</numerusform> + </translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp index bf4ca9510..2ff8ea508 100644 --- a/tests/auto/linguist/lconvert/tst_lconvert.cpp +++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp @@ -46,10 +46,8 @@ private slots: void converts(); void roundtrips_data(); void roundtrips(); -#if 0 void chains_data(); void chains(); -#endif void merge(); private: @@ -247,7 +245,6 @@ void tst_lconvert::converts() Q_DECLARE_METATYPE(QList<QStringList>); -#if 0 void tst_lconvert::chains_data() { QTest::addColumn<QString>("inFileName"); @@ -255,6 +252,9 @@ void tst_lconvert::chains_data() QTest::addColumn<QStringList>("stations"); QTest::addColumn<QList<QStringList> >("args"); + QTest::newRow("no-untranslated") << "untranslated.ts" << "untranslated.ts.out" + << QStringList({"ts", "ts"}) + << QList<QStringList>({QStringList("-no-untranslated")}); } void tst_lconvert::chains() @@ -266,7 +266,6 @@ void tst_lconvert::chains() convertChain(inFileName, outFileName, stations, args); } -#endif void tst_lconvert::roundtrips_data() { diff --git a/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp b/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp index da7e03779..10cfff9ac 100644 --- a/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp +++ b/tests/auto/qhelpgenerator/tst_qhelpgenerator.cpp @@ -137,12 +137,6 @@ void tst_QHelpGenerator::checkIndices() || m_query->value(1).toString() != QLatin1String("foo")) QFAIL("Index Error!"); - /* - m_query->exec("SELECT COUNT(DISTINCT Id) FROM IndexItemTable"); - if (!m_query->next() || m_query->value(0).toInt() != 7) - QFAIL("Index Error!"); - */ - m_query->exec("SELECT COUNT(a.Id) FROM IndexTable a, " "IndexFilterTable b, FilterAttributeTable c WHERE a.Id=b.IndexId " "AND b.FilterAttributeId=c.Id AND c.Name=\'filter2\'"); diff --git a/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.error b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.error new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.error diff --git a/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json new file mode 100644 index 000000000..6a75269c0 --- /dev/null +++ b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json @@ -0,0 +1,21 @@ +[ + { + "Copyright": "Copyright", + "Description": "", + "Homepage": "", + "Id": "minimal", + "License": "License", + "LicenseFile": "", + "LicenseId": "", + "Name": "Minimal", + "Path": "%{PWD}", + "Files": "", + "QDocModule": "qtest", + "QtParts": [ + "libs" + ], + "QtUsage": "Usage", + "Version": "", + "DownloadLocation": "" + } +] diff --git a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp index c3e8bb9b6..7740fde9b 100644 --- a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp +++ b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp @@ -47,6 +47,8 @@ private slots: void test(); private: + void readExpectedFile(const QString &baseDir, const QString &fileName, QByteArray *content); + QString m_cmd; QString m_basePath; }; @@ -62,25 +64,45 @@ tst_qtattributionsscanner::tst_qtattributionsscanner() void tst_qtattributionsscanner::test_data() { - QTest::addColumn<QString>("directory"); - QTest::newRow("good") << QStringLiteral("good"); - QTest::newRow("warnings (incomplete)") << QStringLiteral("warnings/incomplete"); - QTest::newRow("warnings (unknown attribute)") << QStringLiteral("warnings/unknown"); + QTest::addColumn<QString>("input"); + QTest::addColumn<QString>("stdout_file"); + QTest::addColumn<QString>("stderr_file"); + + QTest::newRow("good") + << QStringLiteral("good") + << QStringLiteral("good/expected.json") + << QStringLiteral("good/expected.error"); + QTest::newRow("warnings (incomplete)") + << QStringLiteral("warnings/incomplete") + << QStringLiteral("warnings/incomplete/expected.json") + << QStringLiteral("warnings/incomplete/expected.error"); + QTest::newRow("warnings (unknown attribute)") + << QStringLiteral("warnings/unknown") + << QStringLiteral("warnings/unknown/expected.json") + << QStringLiteral("warnings/unknown/expected.error"); + QTest::newRow("singlefile") + << QStringLiteral("good/minimal/qt_attribution.json") + << QStringLiteral("good/minimal/expected.json") + << QStringLiteral("good/minimal/expected.error"); } -static void readExpectedFile(const QString &dir, const QString &fileName, QByteArray *content) +void tst_qtattributionsscanner::readExpectedFile(const QString &baseDir, const QString &fileName, QByteArray *content) { - QFile file(QDir(dir).absoluteFilePath(fileName)); + QFile file(QDir(m_basePath).absoluteFilePath(fileName)); QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), "Could not open " + file.fileName().toLocal8Bit()); *content = file.readAll(); - content->replace("%{PWD}", dir.toUtf8()); + content->replace("%{PWD}", baseDir.toUtf8()); } void tst_qtattributionsscanner::test() { - QFETCH(QString, directory); + QFETCH(QString, input); + QFETCH(QString, stdout_file); + QFETCH(QString, stderr_file); - QString dir = QDir(m_basePath).absoluteFilePath(directory); + QString dir = QDir(m_basePath).absoluteFilePath(input); + if (QFileInfo(dir).isFile()) + dir = QFileInfo(dir).absolutePath(); QProcess proc; QString command = m_cmd + " " + dir + " --output-format json"; @@ -100,7 +122,7 @@ void tst_qtattributionsscanner::test() stdErr.replace(QDir::separator(), "/"); QByteArray expectedErrorOutput; - readExpectedFile(dir, "expected.error", &expectedErrorOutput); + readExpectedFile(dir, stderr_file, &expectedErrorOutput); QCOMPARE(stdErr, expectedErrorOutput); } @@ -113,7 +135,7 @@ void tst_qtattributionsscanner::test() QVERIFY2(!actualJson.isNull(), "Invalid output: " + jsonError.errorString().toLatin1()); QByteArray expectedOutput; - readExpectedFile(dir, "expected.json", &expectedOutput); + readExpectedFile(dir, stdout_file, &expectedOutput); QJsonDocument expectedJson = QJsonDocument::fromJson(expectedOutput); if (!QTest::qCompare(actualJson, expectedJson, "actualJson", "expectedJson", __FILE__, __LINE__)) { diff --git a/tests/auto/qtdiag/tst_qtdiag.cpp b/tests/auto/qtdiag/tst_qtdiag.cpp index 96c33abab..207c450c2 100644 --- a/tests/auto/qtdiag/tst_qtdiag.cpp +++ b/tests/auto/qtdiag/tst_qtdiag.cpp @@ -46,9 +46,6 @@ private: void tst_QtDiag::initTestCase() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else QString binary = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QStringLiteral("/qtdiag"); # ifdef Q_OS_WIN binary += QStringLiteral(".exe"); @@ -62,14 +59,10 @@ void tst_QtDiag::initTestCase() + QByteArrayLiteral("' does not exist."); QSKIP(message.constData()); } -#endif // !QT_NO_PROCESS } void tst_QtDiag::run() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else if (m_binary.isEmpty()) QSKIP("Binary could not be found"); QProcess process; @@ -83,7 +76,6 @@ void tst_QtDiag::run() QVERIFY(!output.isEmpty()); output.replace('\r', ""); qDebug("\n%s", output.constData()); -#endif // !QT_NO_PROCESS } QTEST_MAIN(tst_QtDiag) diff --git a/tests/auto/windeployqt/tst_windeployqt.cpp b/tests/auto/windeployqt/tst_windeployqt.cpp index 30da829e7..f20e59180 100644 --- a/tests/auto/windeployqt/tst_windeployqt.cpp +++ b/tests/auto/windeployqt/tst_windeployqt.cpp @@ -37,7 +37,6 @@ #include <QtCore/QTextStream> #include <QtTest/QtTest> -#ifndef QT_NO_PROCESS static const QString msgProcessError(const QProcess &process, const QString &what, const QByteArray &stdOut = QByteArray(), const QByteArray &stdErr = QByteArray()) @@ -98,8 +97,6 @@ static bool runProcess(const QString &binary, return true; } -#endif // !QT_NO_PROCESS - class tst_windeployqt : public QObject { Q_OBJECT @@ -116,9 +113,6 @@ private: void tst_windeployqt::initTestCase() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else m_windeployqtBinary = QStandardPaths::findExecutable("windeployqt"); QVERIFY(!m_windeployqtBinary.isEmpty()); m_testApp = QFINDTESTDATA("testapp"); @@ -126,14 +120,10 @@ void tst_windeployqt::initTestCase() const QFileInfo testAppBinary(m_testApp + QLatin1String("/testapp.exe")); QVERIFY2(testAppBinary.isFile(), qPrintable(testAppBinary.absoluteFilePath())); m_testAppBinary = testAppBinary.absoluteFilePath(); -#endif // QT_NO_PROCESS } void tst_windeployqt::help() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else QString errorMessage; QByteArray stdOut; QByteArray stdErr; @@ -141,7 +131,6 @@ void tst_windeployqt::help() QString(), QProcessEnvironment(), 5000, &stdOut, &stdErr), qPrintable(errorMessage)); QVERIFY2(!stdOut.isEmpty(), stdErr); -#endif // QT_NO_PROCESS } // deploy(): Deploys the test application and launches it with Qt removed from the environment @@ -149,9 +138,6 @@ void tst_windeployqt::help() void tst_windeployqt::deploy() { -#ifdef QT_NO_PROCESS - QSKIP("This test requires QProcess support"); -#else QString errorMessage; // Deploy application QStringList deployArguments; @@ -189,7 +175,6 @@ void tst_windeployqt::deploy() // Verify that application still runs QVERIFY2(runProcess(m_testAppBinary, QStringList(), &errorMessage, QString(), env, 10000), qPrintable(errorMessage)); -#endif // QT_NO_PROCESS } QTEST_MAIN(tst_windeployqt) |