diff options
Diffstat (limited to 'src/tools/uic')
28 files changed, 2064 insertions, 6589 deletions
diff --git a/src/tools/uic/cpp/cpp.pri b/src/tools/uic/cpp/cpp.pri index 49c71a6dfa..a6b6188117 100644 --- a/src/tools/uic/cpp/cpp.pri +++ b/src/tools/uic/cpp/cpp.pri @@ -3,18 +3,10 @@ INCLUDEPATH += $$PWD $$QT_BUILD_TREE/src/tools/uic DEFINES += QT_UIC_CPP_GENERATOR # Input -HEADERS += $$PWD/cppextractimages.h \ - $$PWD/cppwritedeclaration.h \ - $$PWD/cppwriteicondata.h \ - $$PWD/cppwriteicondeclaration.h \ - $$PWD/cppwriteiconinitialization.h \ +HEADERS += $$PWD/cppwritedeclaration.h \ $$PWD/cppwriteincludes.h \ $$PWD/cppwriteinitialization.h -SOURCES += $$PWD/cppextractimages.cpp \ - $$PWD/cppwritedeclaration.cpp \ - $$PWD/cppwriteicondata.cpp \ - $$PWD/cppwriteicondeclaration.cpp \ - $$PWD/cppwriteiconinitialization.cpp \ +SOURCES += $$PWD/cppwritedeclaration.cpp \ $$PWD/cppwriteincludes.cpp \ $$PWD/cppwriteinitialization.cpp diff --git a/src/tools/uic/cpp/cppextractimages.cpp b/src/tools/uic/cpp/cppextractimages.cpp deleted file mode 100644 index 4d06d08dae..0000000000 --- a/src/tools/uic/cpp/cppextractimages.cpp +++ /dev/null @@ -1,140 +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 "cppextractimages.h" -#include "cppwriteicondata.h" -#include "driver.h" -#include "ui4.h" -#include "utils.h" -#include "uic.h" - -#include <qtextstream.h> -#include <qtextcodec.h> -#include <qdir.h> -#include <qfile.h> -#include <qfileinfo.h> - -QT_BEGIN_NAMESPACE - -namespace CPP { - -ExtractImages::ExtractImages(const Option &opt) - : m_output(0), m_option(opt) -{ -} - -void ExtractImages::acceptUI(DomUI *node) -{ - if (!m_option.extractImages) - return; - - if (node->elementImages() == 0) - return; - - QString className = node->elementClass() + m_option.postfix; - - QFile f; - if (m_option.qrcOutputFile.size()) { - f.setFileName(m_option.qrcOutputFile); - if (!f.open(QIODevice::WriteOnly | QFile::Text)) { - fprintf(stderr, "%s: Error: Could not create resource file\n", qPrintable(m_option.messagePrefix())); - return; - } - - QFileInfo fi(m_option.qrcOutputFile); - QDir dir = fi.absoluteDir(); - if (!dir.exists(QLatin1String("images")) && !dir.mkdir(QLatin1String("images"))) { - fprintf(stderr, "%s: Error: Could not create image dir\n", qPrintable(m_option.messagePrefix())); - return; - } - dir.cd(QLatin1String("images")); - m_imagesDir = dir; - - m_output = new QTextStream(&f); -#ifndef QT_NO_TEXTCODEC - m_output->setCodec(QTextCodec::codecForName("UTF-8")); -#endif - - QTextStream &out = *m_output; - - out << "<RCC>\n"; - out << " <qresource prefix=\"/" << className << "\" >\n"; - TreeWalker::acceptUI(node); - out << " </qresource>\n"; - out << "</RCC>\n"; - - f.close(); - delete m_output; - m_output = 0; - } -} - -void ExtractImages::acceptImages(DomImages *images) -{ - TreeWalker::acceptImages(images); -} - -void ExtractImages::acceptImage(DomImage *image) -{ - QString format = image->elementData()->attributeFormat(); - QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower(); - QString fname = m_imagesDir.absoluteFilePath(image->attributeName() + QLatin1Char('.') + extension); - - *m_output << " <file>images/" << image->attributeName() << QLatin1Char('.') + extension << "</file>\n"; - - QFile f; - f.setFileName(fname); - const bool isXPM_GZ = format == QLatin1String("XPM.GZ"); - QIODevice::OpenMode openMode = QIODevice::WriteOnly; - if (isXPM_GZ) - openMode |= QIODevice::Text; - if (!f.open(openMode)) { - fprintf(stderr, "%s: Error: Could not create image file %s: %s", - qPrintable(m_option.messagePrefix()), - qPrintable(fname), qPrintable(f.errorString())); - return; - } - - if (isXPM_GZ) { - QTextStream *imageOut = new QTextStream(&f); -#ifndef QT_NO_TEXTCODEC - imageOut->setCodec(QTextCodec::codecForName("UTF-8")); -#endif - - CPP::WriteIconData::writeImage(*imageOut, QString(), m_option.limitXPM_LineLength, image); - delete imageOut; - } else { - CPP::WriteIconData::writeImage(f, image); - } - - f.close(); -} - -} // namespace CPP - -QT_END_NAMESPACE diff --git a/src/tools/uic/cpp/cppextractimages.h b/src/tools/uic/cpp/cppextractimages.h deleted file mode 100644 index d012de8d0a..0000000000 --- a/src/tools/uic/cpp/cppextractimages.h +++ /dev/null @@ -1,64 +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$ -** -****************************************************************************/ - -#ifndef CPPEXTRACTIMAGES_H -#define CPPEXTRACTIMAGES_H - -#include "treewalker.h" -#include <qdir.h> - -QT_BEGIN_NAMESPACE - -class QTextStream; -class Driver; -class Uic; - -struct Option; - -namespace CPP { - -class ExtractImages : public TreeWalker -{ -public: - ExtractImages(const Option &opt); - - void acceptUI(DomUI *node) Q_DECL_OVERRIDE; - void acceptImages(DomImages *images) Q_DECL_OVERRIDE; - void acceptImage(DomImage *image) Q_DECL_OVERRIDE; - -private: - QTextStream *m_output; - const Option &m_option; - QDir m_imagesDir; -}; - -} // namespace CPP - -QT_END_NAMESPACE - -#endif // CPPEXTRACTIMAGES_H diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp index 6ebef1cc41..9e774ad07b 100644 --- a/src/tools/uic/cpp/cppwritedeclaration.cpp +++ b/src/tools/uic/cpp/cppwritedeclaration.cpp @@ -27,10 +27,7 @@ ****************************************************************************/ #include "cppwritedeclaration.h" -#include "cppwriteicondeclaration.h" #include "cppwriteinitialization.h" -#include "cppwriteiconinitialization.h" -#include "cppextractimages.h" #include "driver.h" #include "ui4.h" #include "uic.h" @@ -56,47 +53,15 @@ namespace { output << "} // namespace " << *it << "\n"; } } - - void writeScriptContextClass(const QString &indent, QTextStream &str) { - str << indent << "class ScriptContext\n" - << indent << "{\n" - << indent << "public:\n" - << indent << " void run(const QString &script, QWidget *widget, const QWidgetList &childWidgets)\n" - << indent << " {\n" - << indent << " QScriptValue widgetObject = scriptEngine.newQObject(widget);\n" - << indent << " QScriptValue childWidgetArray = scriptEngine.newArray (childWidgets.size());\n" - << indent << " for (int i = 0; i < childWidgets.size(); i++)\n" - << indent << " childWidgetArray.setProperty(i, scriptEngine.newQObject(childWidgets[i]));\n" - << indent << " QScriptContext *ctx = scriptEngine.pushContext();\n" - << indent << " ctx ->activationObject().setProperty(QLatin1String(\"widget\"), widgetObject);\n" - << indent << " ctx ->activationObject().setProperty(QLatin1String(\"childWidgets\"), childWidgetArray);\n\n" - << indent << " scriptEngine.evaluate(script);\n" - << indent << " if (scriptEngine.hasUncaughtException ()) {\n" - << indent << " qWarning() << \"An exception occurred at line \" << scriptEngine.uncaughtExceptionLineNumber()\n" - << indent << " << \" of the script for \" << widget->objectName() << \": \" << engineError() << '\\n'\n" - << indent << " << script;\n" - << indent << " }\n\n" - << indent << " scriptEngine.popContext();\n" - << indent << " }\n\n" - << indent << "private:\n" - << indent << " QString engineError()\n" - << indent << " {\n" - << indent << " QScriptValue error = scriptEngine.evaluate(\"Error\");\n" - << indent << " return error.toString();\n" - << indent << " }\n\n" - << indent << " QScriptEngine scriptEngine;\n" - << indent << "};\n\n"; - } } namespace CPP { -WriteDeclaration::WriteDeclaration(Uic *uic, bool activateScripts) : +WriteDeclaration::WriteDeclaration(Uic *uic) : m_uic(uic), m_driver(uic->driver()), m_output(uic->output()), - m_option(uic->option()), - m_activateScripts(activateScripts) + m_option(uic->option()) { } @@ -106,7 +71,6 @@ void WriteDeclaration::acceptUI(DomUI *node) QString className = qualifiedClassName; m_driver->findOrInsertWidget(node->elementWidget()); - QString widgetClassName = node->elementWidget()->attributeClass(); QString exportMacro = node->elementExportMacro(); if (!exportMacro.isEmpty()) @@ -154,29 +118,7 @@ void WriteDeclaration::acceptUI(DomUI *node) m_output << "\n"; - WriteInitialization(m_uic, m_activateScripts).acceptUI(node); - - if (node->elementImages()) { - if (m_option.extractImages) { - ExtractImages(m_uic->option()).acceptUI(node); - } else { - m_output << "\n" - << "protected:\n" - << m_option.indent << "enum IconID\n" - << m_option.indent << "{\n"; - WriteIconDeclaration(m_uic).acceptUI(node); - - m_output << m_option.indent << m_option.indent << "unknown_ID\n" - << m_option.indent << "};\n"; - - WriteIconInitialization(m_uic).acceptUI(node); - } - } - - if (m_activateScripts) { - m_output << "\nprivate:\n\n"; - writeScriptContextClass(m_option.indent, m_output); - } + WriteInitialization(m_uic).acceptUI(node); m_output << "};\n\n"; diff --git a/src/tools/uic/cpp/cppwritedeclaration.h b/src/tools/uic/cpp/cppwritedeclaration.h index baa57c5978..ca2122293c 100644 --- a/src/tools/uic/cpp/cppwritedeclaration.h +++ b/src/tools/uic/cpp/cppwritedeclaration.h @@ -43,7 +43,7 @@ namespace CPP { struct WriteDeclaration : public TreeWalker { - WriteDeclaration(Uic *uic, bool activateScripts); + WriteDeclaration(Uic *uic); void acceptUI(DomUI *node) Q_DECL_OVERRIDE; void acceptWidget(DomWidget *node) Q_DECL_OVERRIDE; @@ -58,7 +58,6 @@ private: Driver *m_driver; QTextStream &m_output; const Option &m_option; - const bool m_activateScripts; }; } // namespace CPP diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp deleted file mode 100644 index 4601a4c5e9..0000000000 --- a/src/tools/uic/cpp/cppwriteicondata.cpp +++ /dev/null @@ -1,172 +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 "cppwriteicondata.h" -#include "driver.h" -#include "ui4.h" -#include "uic.h" - -#include <qtextstream.h> - -QT_BEGIN_NAMESPACE - -namespace CPP { - -static QByteArray transformImageData(const QString &data) -{ - int baSize = data.length() / 2; - uchar *ba = new uchar[baSize]; - for (int i = 0; i < baSize; ++i) { - char h = data[2 * (i)].toLatin1(); - char l = data[2 * (i) + 1].toLatin1(); - uchar r = 0; - if (h <= '9') - r += h - '0'; - else - r += h - 'a' + 10; - r = r << 4; - if (l <= '9') - r += l - '0'; - else - r += l - 'a' + 10; - ba[i] = r; - } - QByteArray ret(reinterpret_cast<const char *>(ba), baSize); - delete [] ba; - return ret; -} - -static QByteArray unzipXPM(const QString &data, ulong &length) -{ -#ifndef QT_NO_COMPRESS - const int lengthOffset = 4; - QByteArray ba(lengthOffset, ' '); - - // qUncompress() expects the first 4 bytes to be the expected length of the - // uncompressed data - ba[0] = (length & 0xff000000) >> 24; - ba[1] = (length & 0x00ff0000) >> 16; - ba[2] = (length & 0x0000ff00) >> 8; - ba[3] = (length & 0x000000ff); - ba.append(transformImageData(data)); - QByteArray baunzip = qUncompress(ba); - return baunzip; -#else - Q_UNUSED(data); - Q_UNUSED(length); - return QByteArray(); -#endif -} - - -WriteIconData::WriteIconData(Uic *uic) - : driver(uic->driver()), output(uic->output()), option(uic->option()) -{ -} - -void WriteIconData::acceptUI(DomUI *node) -{ - TreeWalker::acceptUI(node); -} - -void WriteIconData::acceptImages(DomImages *images) -{ - TreeWalker::acceptImages(images); -} - -void WriteIconData::acceptImage(DomImage *image) -{ - // Limit line length when writing code. - writeImage(output, option.indent, true, image); -} - -void WriteIconData::writeImage(QTextStream &output, const QString &indent, - bool limitXPM_LineLength, const DomImage *image) -{ - QString img = image->attributeName() + QLatin1String("_data"); - QString data = image->elementData()->text(); - QString fmt = image->elementData()->attributeFormat(); - int size = image->elementData()->attributeLength(); - - if (fmt == QLatin1String("XPM.GZ")) { - ulong length = size; - QByteArray baunzip = unzipXPM(data, length); - length = baunzip.size(); - // shouldn't we test the initial 'length' against the - // resulting 'length' to catch corrupt UIC files? - int a = 0; - int column = 0; - bool inQuote = false; - output << indent << "/* XPM */\n" - << indent << "static const char* const " << img << "[] = { \n"; - while (baunzip[a] != '\"') - a++; - for (; a < (int) length; a++) { - output << baunzip[a]; - if (baunzip[a] == '\n') { - column = 0; - } else if (baunzip[a] == '"') { - inQuote = !inQuote; - } - - column++; - if (limitXPM_LineLength && column >= 512 && inQuote) { - output << "\"\n\""; // be nice with MSVC & Co. - column = 1; - } - } - - if (! baunzip.trimmed ().endsWith ("};")) - output << "};"; - - output << "\n\n"; - } else { - output << indent << "static const unsigned char " << img << "[] = { \n"; - output << indent; - int a ; - for (a = 0; a < (int) (data.length()/2)-1; a++) { - output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << ','; - if (a % 12 == 11) - output << '\n' << indent; - else - output << ' '; - } - output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << '\n'; - output << "};\n\n"; - } -} - -void WriteIconData::writeImage(QIODevice &output, DomImage *image) -{ - const QByteArray array = transformImageData(image->elementData()->text()); - output.write(array.constData(), array.size()); -} - -} // namespace CPP - -QT_END_NAMESPACE diff --git a/src/tools/uic/cpp/cppwriteicondata.h b/src/tools/uic/cpp/cppwriteicondata.h deleted file mode 100644 index c496d5a85b..0000000000 --- a/src/tools/uic/cpp/cppwriteicondata.h +++ /dev/null @@ -1,68 +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$ -** -****************************************************************************/ - -#ifndef CPPWRITEICONDATA_H -#define CPPWRITEICONDATA_H - -#include "treewalker.h" - -QT_BEGIN_NAMESPACE - -class QTextStream; -class QIODevice; -class Driver; -class Uic; - -struct Option; - -namespace CPP { - -class WriteIconData : public TreeWalker -{ -public: - WriteIconData(Uic *uic); - - void acceptUI(DomUI *node) Q_DECL_OVERRIDE; - void acceptImages(DomImages *images) Q_DECL_OVERRIDE; - void acceptImage(DomImage *image) Q_DECL_OVERRIDE; - - static void writeImage(QTextStream &output, const QString &indent, - bool limitXPM_LineLength, const DomImage *image); - static void writeImage(QIODevice &output, DomImage *image); - -private: - Driver *driver; - QTextStream &output; - const Option &option; -}; - -} // namespace CPP - -QT_END_NAMESPACE - -#endif // CPPWRITEICONDATA_H diff --git a/src/tools/uic/cpp/cppwriteicondeclaration.cpp b/src/tools/uic/cpp/cppwriteicondeclaration.cpp deleted file mode 100644 index 5264e3de54..0000000000 --- a/src/tools/uic/cpp/cppwriteicondeclaration.cpp +++ /dev/null @@ -1,67 +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 "cppwriteicondeclaration.h" -#include "driver.h" -#include "ui4.h" -#include "uic.h" - -#include <qtextstream.h> - -QT_BEGIN_NAMESPACE - -namespace CPP { - -WriteIconDeclaration::WriteIconDeclaration(Uic *uic) - : driver(uic->driver()), output(uic->output()), option(uic->option()) -{ -} - -void WriteIconDeclaration::acceptUI(DomUI *node) -{ - TreeWalker::acceptUI(node); -} - -void WriteIconDeclaration::acceptImages(DomImages *images) -{ - TreeWalker::acceptImages(images); -} - -void WriteIconDeclaration::acceptImage(DomImage *image) -{ - QString name = image->attributeName(); - if (name.isEmpty()) - return; - - driver->insertPixmap(name); - output << option.indent << option.indent << name << "_ID,\n"; -} - -} // namespace CPP - -QT_END_NAMESPACE diff --git a/src/tools/uic/cpp/cppwriteicondeclaration.h b/src/tools/uic/cpp/cppwriteicondeclaration.h deleted file mode 100644 index 6483b8bf4a..0000000000 --- a/src/tools/uic/cpp/cppwriteicondeclaration.h +++ /dev/null @@ -1,63 +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$ -** -****************************************************************************/ - -#ifndef CPPWRITEICONDECLARATION_H -#define CPPWRITEICONDECLARATION_H - -#include "treewalker.h" - -QT_BEGIN_NAMESPACE - -class QTextStream; -class Driver; -class Uic; - -struct Option; - -namespace CPP { - -class WriteIconDeclaration : public TreeWalker -{ -public: - WriteIconDeclaration(Uic *uic); - - void acceptUI(DomUI *node) Q_DECL_OVERRIDE; - void acceptImages(DomImages *images) Q_DECL_OVERRIDE; - void acceptImage(DomImage *image) Q_DECL_OVERRIDE; - -private: - Driver *driver; - QTextStream &output; - const Option &option; -}; - -} // namespace CPP - -QT_END_NAMESPACE - -#endif // CPPWRITEICONDECLARATION_H diff --git a/src/tools/uic/cpp/cppwriteiconinitialization.cpp b/src/tools/uic/cpp/cppwriteiconinitialization.cpp deleted file mode 100644 index 33d1c8402e..0000000000 --- a/src/tools/uic/cpp/cppwriteiconinitialization.cpp +++ /dev/null @@ -1,102 +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 "cppwriteiconinitialization.h" -#include "cppwriteicondata.h" -#include "driver.h" -#include "ui4.h" -#include "utils.h" -#include "uic.h" - -#include <qtextstream.h> -#include <qstring.h> - -QT_BEGIN_NAMESPACE - -namespace CPP { - -WriteIconInitialization::WriteIconInitialization(Uic *uic) - : driver(uic->driver()), output(uic->output()), option(uic->option()) -{ - this->uic = uic; -} - -void WriteIconInitialization::acceptUI(DomUI *node) -{ - if (node->elementImages() == 0) - return; - - QString className = node->elementClass() + option.postfix; - - output << option.indent << "static QPixmap " << iconFromDataFunction() << "(IconID id)\n" - << option.indent << "{\n"; - - WriteIconData(uic).acceptUI(node); - - output << option.indent << "switch (id) {\n"; - - TreeWalker::acceptUI(node); - - output << option.indent << option.indent << "default: return QPixmap();\n"; - - output << option.indent << "} // switch\n" - << option.indent << "} // icon\n\n"; -} - -QString WriteIconInitialization::iconFromDataFunction() -{ - return QLatin1String("qt_get_icon"); -} - -void WriteIconInitialization::acceptImages(DomImages *images) -{ - TreeWalker::acceptImages(images); -} - -void WriteIconInitialization::acceptImage(DomImage *image) -{ - QString img = image->attributeName() + QLatin1String("_data"); - QString data = image->elementData()->text(); - QString fmt = image->elementData()->attributeFormat(); - - QString imageId = image->attributeName() + QLatin1String("_ID"); - QString imageData = image->attributeName() + QLatin1String("_data"); - QString ind = option.indent + option.indent; - - output << ind << "case " << imageId << ": "; - - if (fmt == QLatin1String("XPM.GZ")) { - output << "return " << "QPixmap((const char**)" << imageData << ");\n"; - } else { - output << " { QImage img; img.loadFromData(" << imageData << ", sizeof(" << imageData << "), " << fixString(fmt, ind) << "); return QPixmap::fromImage(img); }\n"; - } -} - -} // namespace CPP - -QT_END_NAMESPACE diff --git a/src/tools/uic/cpp/cppwriteiconinitialization.h b/src/tools/uic/cpp/cppwriteiconinitialization.h deleted file mode 100644 index 588cb1bc67..0000000000 --- a/src/tools/uic/cpp/cppwriteiconinitialization.h +++ /dev/null @@ -1,68 +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$ -** -****************************************************************************/ - -#ifndef CPPWRITEICONINITIALIZATION_H -#define CPPWRITEICONINITIALIZATION_H - -#include "treewalker.h" - -class QString; - -QT_BEGIN_NAMESPACE - -class QTextStream; -class Driver; -class Uic; - -struct Option; - -namespace CPP { - -class WriteIconInitialization : public TreeWalker -{ -public: - WriteIconInitialization(Uic *uic); - - void acceptUI(DomUI *node) Q_DECL_OVERRIDE; - void acceptImages(DomImages *images) Q_DECL_OVERRIDE; - void acceptImage(DomImage *image) Q_DECL_OVERRIDE; - - static QString iconFromDataFunction(); - -private: - Uic *uic; - Driver *driver; - QTextStream &output; - const Option &option; -}; - -} // namespace CPP - -QT_END_NAMESPACE - -#endif // CPPWRITEICONINITIALIZATION_H diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index dcbe400224..de64b85219 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -69,7 +69,7 @@ static inline QString moduleHeader(const QString &module, const QString &header) namespace CPP { WriteIncludes::WriteIncludes(Uic *uic) - : m_uic(uic), m_output(uic->output()), m_scriptsActivated(false), m_laidOut(false) + : m_uic(uic), m_output(uic->output()), m_laidOut(false) { // When possible (no namespace) use the "QtModule/QClass" convention // and create a re-mapping of the old header "qclass.h" to it. Do not do this @@ -92,7 +92,6 @@ WriteIncludes::WriteIncludes(Uic *uic) void WriteIncludes::acceptUI(DomUI *node) { - m_scriptsActivated = false; m_laidOut = false; m_localIncludes.clear(); m_globalIncludes.clear(); @@ -231,10 +230,6 @@ void WriteIncludes::acceptCustomWidget(DomCustomWidget *node) if (className.isEmpty()) return; - if (const DomScript *domScript = node->elementScript()) - if (!domScript->text().isEmpty()) - activateScripts(); - if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) { add(className, false); // no header specified } else { @@ -296,21 +291,6 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global) } } -void WriteIncludes::acceptWidgetScripts(const DomScripts &scripts, DomWidget *, const DomWidgets &) -{ - if (!scripts.empty()) { - activateScripts(); - } -} - -void WriteIncludes::activateScripts() -{ - if (!m_scriptsActivated) { - add(QLatin1String("QScriptEngine")); - add(QLatin1String("QDebug")); - m_scriptsActivated = true; - } -} } // namespace CPP QT_END_NAMESPACE diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index 7a6a499536..0d9c293efc 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -54,7 +54,6 @@ struct WriteIncludes : public TreeWalker void acceptLayout(DomLayout *node) Q_DECL_OVERRIDE; void acceptSpacer(DomSpacer *node) Q_DECL_OVERRIDE; void acceptProperty(DomProperty *node) Q_DECL_OVERRIDE; - void acceptWidgetScripts(const DomScripts &, DomWidget *, const DomWidgets &) Q_DECL_OVERRIDE; // // custom widgets @@ -68,8 +67,6 @@ struct WriteIncludes : public TreeWalker void acceptIncludes(DomIncludes *node) Q_DECL_OVERRIDE; void acceptInclude(DomInclude *node) Q_DECL_OVERRIDE; - bool scriptsActivated() const { return m_scriptsActivated; } - private: void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false); @@ -79,7 +76,6 @@ private: void insertInclude(const QString &header, bool global); void writeHeaders(const OrderedSet &headers, bool global); QString headerForClassName(const QString &className) const; - void activateScripts(); const Uic *m_uic; QTextStream &m_output; @@ -94,7 +90,6 @@ private: StringMap m_classToHeader; StringMap m_oldHeaderToNewHeader; - bool m_scriptsActivated; bool m_laidOut; }; diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index d208ec6718..86908147d8 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -27,7 +27,6 @@ ****************************************************************************/ #include "cppwriteinitialization.h" -#include "cppwriteiconinitialization.h" #include "driver.h" #include "ui4.h" #include "utils.h" @@ -83,8 +82,8 @@ namespace { int w = 0; int h = 0; - if (properties.contains(QLatin1String("sizeHint"))) { - if (const DomSize *sizeHint = properties.value(QLatin1String("sizeHint"))->elementSize()) { + if (const DomProperty *sh = properties.value(QLatin1String("sizeHint"))) { + if (const DomSize *sizeHint = sh->elementSize()) { w = sizeHint->elementWidth(); h = sizeHint->elementHeight(); } @@ -92,17 +91,23 @@ namespace { output << w << ", " << h << ", "; // size type - QString sizeType = properties.contains(QLatin1String("sizeType")) ? - properties.value(QLatin1String("sizeType"))->elementEnum() : - QString::fromLatin1("Expanding"); + QString sizeType; + if (const DomProperty *st = properties.value(QLatin1String("sizeType"))) { + const QString value = st->elementEnum(); + if (value.startsWith(QLatin1String("QSizePolicy::"))) + sizeType = value; + else + sizeType = QLatin1String("QSizePolicy::") + value; + } else { + sizeType = QStringLiteral("QSizePolicy::Expanding"); + } - if (!sizeType.startsWith(QLatin1String("QSizePolicy::"))) - sizeType.prepend(QLatin1String("QSizePolicy::")); // orientation bool isVspacer = false; - if (properties.contains(QLatin1String("orientation"))) { - const QString orientation = properties.value(QLatin1String("orientation"))->elementEnum(); - if (orientation == QLatin1String("Qt::Vertical") || orientation == QLatin1String("Vertical")) isVspacer = true; + if (const DomProperty *o = properties.value(QLatin1String("orientation"))) { + const QString orientation = o->elementEnum(); + if (orientation == QLatin1String("Qt::Vertical") || orientation == QLatin1String("Vertical")) + isVspacer = true; } if (isVspacer) @@ -125,11 +130,6 @@ namespace { str << indent << varName << "->" << setter << '(' << v << ");\n"; } - void writeSetupUIScriptVariableDeclarations(const QString &indent, QTextStream &str) { - str << indent << "ScriptContext scriptContext;\n" - << indent << "QWidgetList childWidgets;\n"; - } - static inline bool iconHasStatePixmaps(const DomResourceIcon *i) { return i->hasElementNormalOff() || i->hasElementNormalOn() || i->hasElementDisabledOff() || i->hasElementDisabledOn() || @@ -396,10 +396,8 @@ void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QStri int defaultStyleValue, bool suppressDefault, QTextStream &str) const { // User value - const DomPropertyMap::const_iterator mit = properties.constFind(propertyName); - const bool found = mit != properties.constEnd(); - if (found) { - const int value = mit.value()->elementNumber(); + if (const DomProperty *prop = properties.value(propertyName)) { + const int value = prop->elementNumber(); // Emulate the pre 4.3 behaviour: The value form default value was only used to determine // the default value, layout properties were always written const bool useLayoutFunctionPre43 = !suppressDefault && (m_state[p] == (HasDefaultFunction|HasDefaultValue)) && value == m_defaultValues[p]; @@ -461,7 +459,7 @@ static bool needsTranslation(const DomElement *element) } // --- WriteInitialization -WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) : +WriteInitialization::WriteInitialization(Uic *uic) : m_uic(uic), m_driver(uic->driver()), m_output(uic->output()), m_option(uic->option()), m_indent(m_option.indent + m_option.indent), @@ -472,14 +470,28 @@ WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) : m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly), m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly), m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly), - m_activateScripts(activateScripts), m_layoutWidget(false), + m_layoutWidget(false), m_firstThemeIcon(true) { } +QString WriteInitialization::writeString(const QString &s, const QString &indent) const +{ + unsigned flags = 0; + const QString ret = fixString(s, indent, &flags); + if (flags & Utf8String) + return QLatin1String("QString::fromUtf8(") + ret + QLatin1Char(')'); + // MSVC cannot concat L"foo" "bar" (C2308: concatenating mismatched strings), + // use QLatin1String instead (all platforms to avoid cross-compiling issues). + if (flags & MultiLineString) + return QLatin1String("QLatin1String(") + ret + QLatin1Char(')'); + const QLatin1String stringWrapper = m_uic->option().stringLiteral ? + QLatin1String("QStringLiteral(") : QLatin1String("QLatin1String("); + return stringWrapper + ret + QLatin1Char(')'); +} + void WriteInitialization::acceptUI(DomUI *node) { - m_registeredImages.clear(); m_actionGroupChain.push(0); m_widgetChain.push(0); m_layoutChain.push(0); @@ -490,9 +502,6 @@ void WriteInitialization::acceptUI(DomUI *node) if (node->elementCustomWidgets()) TreeWalker::acceptCustomWidgets(node->elementCustomWidgets()); - if (node->elementImages()) - TreeWalker::acceptImages(node->elementImages()); - if (m_option.generateImplemetation) m_output << "#include <" << m_driver->headerFileName() << ">\n\n"; @@ -512,9 +521,6 @@ void WriteInitialization::acceptUI(DomUI *node) m_output << m_option.indent << "void " << "setupUi(" << widgetClassName << " *" << varName << ")\n" << m_option.indent << "{\n"; - if (m_activateScripts) - writeSetupUIScriptVariableDeclarations(m_indent, m_output); - const QStringList connections = m_uic->databaseInfo()->connections(); for (int i=0; i<connections.size(); ++i) { QString connection = connections.at(i); @@ -591,15 +597,15 @@ void WriteInitialization::addWizardPage(const QString &pageVarName, const DomWid /* If the node has a (free-format) string "pageId" attribute (which could * an integer or an enumeration value), use setPage(), else addPage(). */ QString id; - const DomPropertyList attributes = page->elementAttribute(); + const auto &attributes = page->elementAttribute(); if (!attributes.empty()) { - const DomPropertyList::const_iterator acend = attributes.constEnd(); - for (DomPropertyList::const_iterator it = attributes.constBegin(); it != acend; ++it) - if ((*it)->attributeName() == QLatin1String("pageId")) { - if (const DomString *ds = (*it)->elementString()) + for (const DomProperty *p : attributes) { + if (p->attributeName() == QLatin1String("pageId")) { + if (const DomString *ds = p->elementString()) id = ds->text(); break; } + } } if (id.isEmpty()) { m_output << m_indent << parentWidget << "->addPage(" << pageVarName << ");\n"; @@ -884,7 +890,7 @@ void WriteInitialization::acceptLayout(DomLayout *node) const QString varName = m_driver->findOrInsertLayout(node); const DomPropertyMap properties = propertyMap(node->elementProperty()); - const bool oldLayoutProperties = properties.constFind(QLatin1String("margin")) != properties.constEnd(); + const bool oldLayoutProperties = properties.value(QLatin1String("margin")) != nullptr; bool isGroupBox = false; @@ -1149,9 +1155,7 @@ void WriteInitialization::writeProperties(const QString &varName, if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) { DomPropertyMap properties = propertyMap(lst); - if (properties.contains(QLatin1String("control"))) { - DomProperty *p = properties.value(QLatin1String("control")); - Q_ASSERT( p ); + if (DomProperty *p = properties.value(QLatin1String("control"))) { m_output << m_indent << varName << "->setControl(" << writeString(toString(p->elementString()), m_dindent) << ");\n"; } @@ -1261,7 +1265,7 @@ void WriteInitialization::writeProperties(const QString &varName, if (stdset) { setFunction = QLatin1String("->set") - + propertyName.left(1).toUpper() + + propertyName.at(0).toUpper() + propertyName.midRef(1) + QLatin1Char('('); } else { @@ -1612,10 +1616,10 @@ QString WriteInitialization::writeFontProperties(const DomFont *f) } // Post 4.4 write resource icon -static void writeResourceIcon(QTextStream &output, - const QString &iconName, - const QString &indent, - const DomResourceIcon *i) +void WriteInitialization::writeResourceIcon(QTextStream &output, + const QString &iconName, + const QString &indent, + const DomResourceIcon *i) const { if (i->hasElementNormalOff()) output << indent << iconName << ".addFile(" << writeString(i->elementNormalOff()->text(), indent) << ", QSize(), QIcon::Normal, QIcon::Off);\n"; @@ -1708,7 +1712,7 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri return; // old format - const QList<DomColor*> colors = colorGroup->elementColor(); + const auto &colors = colorGroup->elementColor(); for (int i=0; i<colors.size(); ++i) { const DomColor *color = colors.at(i); @@ -1719,7 +1723,7 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri } // new format - const QList<DomColorRole *> colorRoles = colorGroup->elementColorRole(); + const auto &colorRoles = colorGroup->elementColorRole(); for (const DomColorRole *colorRole : colorRoles) { if (colorRole->hasAttributeRole()) { const QString brushName = writeBrushInitialization(colorRole->elementBrush()); @@ -1796,7 +1800,7 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush << gradient->attributeCoordinateMode() << ");\n"; } - const QList<DomGradientStop *> stops = gradient->elementGradientStop(); + const auto &stops = gradient->elementGradientStop(); for (const DomGradientStop *stop : stops) { const DomColor *color = stop->elementColor(); m_output << m_indent << gradientName << ".setColorAt(" @@ -1894,23 +1898,6 @@ QString WriteInitialization::pixCall(const QString &t, const QString &text) cons type += QLatin1String("()"); return type; } - if (const DomImage *image = findImage(text)) { - if (m_option.extractImages) { - const QString format = image->elementData()->attributeFormat(); - const QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower(); - return QLatin1String("QPixmap(QString::fromUtf8(\":/") - + m_generatedClass - + QLatin1String("/images/") - + text - + QLatin1Char('.') - + extension - + QLatin1String("\"))"); - } - return WriteIconInitialization::iconFromDataFunction() - + QLatin1Char('(') - + text - + QLatin1String("_ID)"); - } QString pixFunc = m_uic->pixmapFunction(); if (pixFunc.isEmpty()) @@ -1927,63 +1914,34 @@ QString WriteInitialization::pixCall(const QString &t, const QString &text) cons void WriteInitialization::initializeComboBox(DomWidget *w) { const QString varName = m_driver->findOrInsertWidget(w); - const QString className = w->attributeClass(); - const QList<DomItem*> items = w->elementItem(); + const auto &items = w->elementItem(); if (items.isEmpty()) return; - // If possible use qcombobox's addItems() which is much faster then a bunch of addItem() calls - bool makeStringListCall = true; - bool translatable = false; - QStringList list; - for (int i=0; i<items.size(); ++i) { + for (int i = 0; i < items.size(); ++i) { const DomItem *item = items.at(i); const DomPropertyMap properties = propertyMap(item->elementProperty()); const DomProperty *text = properties.value(QLatin1String("text")); - const DomProperty *pixmap = properties.value(QLatin1String("icon")); - bool needsTr = needsTranslation(text->elementString()); - if (pixmap != 0 || (i > 0 && translatable != needsTr)) { - makeStringListCall = false; - break; - } - translatable = needsTr; - list.append(autoTrCall(text->elementString())); // fix me here - } + const DomProperty *icon = properties.value(QLatin1String("icon")); - if (makeStringListCall) { - QTextStream &o = translatable ? m_refreshOut : m_output; - if (translatable) - o << m_indent << varName << "->clear();\n"; - o << m_indent << varName << "->insertItems(0, QStringList()" << '\n'; - for (int i = 0; i < list.size(); ++i) - o << m_indent << " << " << list.at(i) << "\n"; - o << m_indent << ");\n"; - } else { - for (int i = 0; i < items.size(); ++i) { - const DomItem *item = items.at(i); - const DomPropertyMap properties = propertyMap(item->elementProperty()); - const DomProperty *text = properties.value(QLatin1String("text")); - const DomProperty *icon = properties.value(QLatin1String("icon")); - - QString iconValue; - if (icon) - iconValue = iconCall(icon); - - m_output << m_indent << varName << "->addItem("; - if (icon) - m_output << iconValue << ", "; - - if (needsTranslation(text->elementString())) { - m_output << "QString());\n"; - m_refreshOut << m_indent << varName << "->setItemText(" << i << ", " << trCall(text->elementString()) << ");\n"; - } else { - m_output << noTrCall(text->elementString()) << ");\n"; - } + QString iconValue; + if (icon) + iconValue = iconCall(icon); + + m_output << m_indent << varName << "->addItem("; + if (icon) + m_output << iconValue << ", "; + + if (needsTranslation(text->elementString())) { + m_output << "QString());\n"; + m_refreshOut << m_indent << varName << "->setItemText(" << i << ", " << trCall(text->elementString()) << ");\n"; + } else { + m_output << noTrCall(text->elementString()) << ");\n"; } - m_refreshOut << "\n"; } + m_refreshOut << "\n"; } QString WriteInitialization::disableSorting(DomWidget *w, const QString &varName) @@ -2118,9 +2076,8 @@ void WriteInitialization::addCommonInitializers(Item *item, void WriteInitialization::initializeListWidget(DomWidget *w) { const QString varName = m_driver->findOrInsertWidget(w); - const QString className = w->attributeClass(); - const QList<DomItem*> items = w->elementItem(); + const auto &items = w->elementItem(); if (items.isEmpty()) return; @@ -2150,7 +2107,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) // columns Item item(QLatin1String("QTreeWidgetItem"), m_indent, m_output, m_refreshOut, m_driver); - const QList<DomColumn*> columns = w->elementColumn(); + const auto &columns = w->elementColumn(); for (int i = 0; i < columns.size(); ++i) { const DomColumn *column = columns.at(i); @@ -2193,7 +2150,7 @@ void WriteInitialization::initializeTreeWidget(DomWidget *w) conditions an item is needed needs to be done bottom-up, the whole process makes two passes, storing the intermediate result in a recursive StringInitializerListMap. */ -QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItems(const QList<DomItem *> &domItems) +QList<WriteInitialization::Item *> WriteInitialization::initializeTreeWidgetItems(const QVector<DomItem *> &domItems) { // items QList<Item *> items; @@ -2237,7 +2194,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) const QString varName = m_driver->findOrInsertWidget(w); // columns - const QList<DomColumn *> columns = w->elementColumn(); + const auto &columns = w->elementColumn(); if (columns.size() != 0) { m_output << m_indent << "if (" << varName << "->columnCount() < " << columns.size() << ")\n" @@ -2259,7 +2216,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) } // rows - const QList<DomRow *> rows = w->elementRow(); + const auto &rows = w->elementRow(); if (rows.size() != 0) { m_output << m_indent << "if (" << varName << "->rowCount() < " << rows.size() << ")\n" @@ -2283,7 +2240,7 @@ void WriteInitialization::initializeTableWidget(DomWidget *w) // items QString tempName = disableSorting(w, varName); - const QList<DomItem *> items = w->elementItem(); + const auto &items = w->elementItem(); for (int i = 0; i < items.size(); ++i) { const DomItem *cell = items.at(i); @@ -2310,7 +2267,7 @@ QString WriteInitialization::trCall(const QString &str, const QString &commentHi return QLatin1String("QString()"); QString result; - const QString comment = commentHint.isEmpty() ? QString(QLatin1String("Q_NULLPTR")) : fixString(commentHint, m_dindent); + const QString comment = commentHint.isEmpty() ? QString(QLatin1String("nullptr")) : fixString(commentHint, m_dindent); if (m_option.translateFunction.isEmpty()) { if (m_option.idBased) { @@ -2428,11 +2385,6 @@ void WriteInitialization::acceptConnection(DomConnection *connection) << ");\n"; } -DomImage *WriteInitialization::findImage(const QString &name) const -{ - return m_registeredImages.value(name); -} - DomWidget *WriteInitialization::findWidget(QLatin1String widgetClass) { for (int i = m_widgetChain.count() - 1; i >= 0; --i) { @@ -2445,49 +2397,6 @@ DomWidget *WriteInitialization::findWidget(QLatin1String widgetClass) return 0; } -void WriteInitialization::acceptImage(DomImage *image) -{ - if (!image->hasAttributeName()) - return; - - m_registeredImages.insert(image->attributeName(), image); -} - -void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, DomWidget *node, const DomWidgets &childWidgets) -{ - // Add the per-class custom scripts to the per-widget ones. - DomScripts scripts(widgetScripts); - - if (DomScript *customWidgetScript = m_uic->customWidgetsInfo()->customWidgetScript(node->attributeClass())) - scripts.push_front(customWidgetScript); - - if (scripts.empty()) - return; - - // concatenate script snippets - QString script; - for (const DomScript *domScript : qAsConst(scripts)) { - const QString snippet = domScript->text(); - if (!snippet.isEmpty()) - script += QStringRef(&snippet).trimmed() + QLatin1Char('\n'); - } - if (script.isEmpty()) - return; - - // Build the list of children and insert call - m_output << m_indent << "childWidgets.clear();\n"; - if (!childWidgets.empty()) { - m_output << m_indent << "childWidgets"; - for (DomWidget *child : childWidgets) - m_output << " << " << m_driver->findOrInsertWidget(child); - m_output << ";\n"; - } - m_output << m_indent << "scriptContext.run(" - << writeString(script, m_dindent) << ", " - << m_driver->findOrInsertWidget(node) << ", childWidgets);\n"; -} - - static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet<QString> &directives) { if (directives.isEmpty()) diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index a9691e1de4..b26f51875d 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -88,14 +88,13 @@ struct WriteInitialization : public TreeWalker typedef QList<DomProperty*> DomPropertyList; typedef QHash<QString, DomProperty*> DomPropertyMap; - WriteInitialization(Uic *uic, bool activateScripts); + WriteInitialization(Uic *uic); // // widgets // void acceptUI(DomUI *node) Q_DECL_OVERRIDE; void acceptWidget(DomWidget *node) Q_DECL_OVERRIDE; - void acceptWidgetScripts(const DomScripts &, DomWidget *node, const DomWidgets &childWidgets) Q_DECL_OVERRIDE; void acceptLayout(DomLayout *node) Q_DECL_OVERRIDE; void acceptSpacer(DomSpacer *node) Q_DECL_OVERRIDE; @@ -130,11 +129,6 @@ struct WriteInitialization : public TreeWalker // void acceptConnection(DomConnection *connection) Q_DECL_OVERRIDE; -// -// images -// - void acceptImage(DomImage *image) Q_DECL_OVERRIDE; - enum { Use43UiFile = 0, TopLevelMargin, @@ -145,6 +139,8 @@ struct WriteInitialization : public TreeWalker private: static QString domColor2QString(const DomColor *c); + QString writeString(const QString &s, const QString &indent) const; + QString iconCall(const DomProperty *prop); QString pixCall(const DomProperty *prop) const; QString pixCall(const QString &type, const QString &text) const; @@ -221,7 +217,7 @@ private: void initializeComboBox(DomWidget *w); void initializeListWidget(DomWidget *w); void initializeTreeWidget(DomWidget *w); - QList<Item *> initializeTreeWidgetItems(const QList<DomItem *> &domItems); + QList<Item *> initializeTreeWidgetItems(const QVector<DomItem *> &domItems); void initializeTableWidget(DomWidget *w); QString disableSorting(DomWidget *w, const QString &varName); @@ -229,12 +225,12 @@ private: QString findDeclaration(const QString &name); DomWidget *findWidget(QLatin1String widgetClass); - DomImage *findImage(const QString &name) const; bool isValidObject(const QString &name) const; private: QString writeFontProperties(const DomFont *f); + void writeResourceIcon(QTextStream &output, const QString &iconName, const QString &indent, const DomResourceIcon *i) const; QString writeIconProperties(const DomResourceIcon *i); QString writeSizePolicy(const DomSizePolicy *sp); QString writeBrushInitialization(const DomBrush *brush); @@ -263,7 +259,6 @@ private: QSet<QString> m_buttonGroups; QHash<QString, DomWidget*> m_registeredWidgets; - QHash<QString, DomImage*> m_registeredImages; QHash<QString, DomAction*> m_registeredActions; typedef QHash<uint, QString> ColorBrushHash; ColorBrushHash m_colorBrushHash; @@ -314,7 +309,6 @@ private: QString m_delayedActionInitialization; QTextStream m_actionOut; - const bool m_activateScripts; bool m_layoutWidget; bool m_firstThemeIcon; diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp index 662a249d71..6883b715ae 100644 --- a/src/tools/uic/customwidgetsinfo.cpp +++ b/src/tools/uic/customwidgetsinfo.cpp @@ -91,18 +91,6 @@ QString CustomWidgetsInfo::realClassName(const QString &className) const return className; } -DomScript *CustomWidgetsInfo::customWidgetScript(const QString &name) const -{ - if (m_customWidgets.empty()) - return 0; - - const NameCustomWidgetMap::const_iterator it = m_customWidgets.constFind(name); - if (it == m_customWidgets.constEnd()) - return 0; - - return it.value()->elementScript(); -} - QString CustomWidgetsInfo::customWidgetAddPageMethod(const QString &name) const { if (DomCustomWidget *dcw = m_customWidgets.value(name, 0)) diff --git a/src/tools/uic/customwidgetsinfo.h b/src/tools/uic/customwidgetsinfo.h index 7bc2b62619..3ce27d546c 100644 --- a/src/tools/uic/customwidgetsinfo.h +++ b/src/tools/uic/customwidgetsinfo.h @@ -57,8 +57,6 @@ public: inline DomCustomWidget *customWidget(const QString &name) const { return m_customWidgets.value(name); } - DomScript *customWidgetScript(const QString &name) const; - QString customWidgetAddPageMethod(const QString &name) const; QString realClassName(const QString &className) const; diff --git a/src/tools/uic/databaseinfo.cpp b/src/tools/uic/databaseinfo.cpp index 73fcf06c54..fa5d5f5df0 100644 --- a/src/tools/uic/databaseinfo.cpp +++ b/src/tools/uic/databaseinfo.cpp @@ -52,11 +52,11 @@ void DatabaseInfo::acceptWidget(DomWidget *node) { QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty()); - DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"), 0); + DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode")); if (frameworkCode && toBool(frameworkCode->elementBool()) == false) return; - DomProperty *db = properties.value(QLatin1String("database"), 0); + DomProperty *db = properties.value(QLatin1String("database")); if (db && db->elementStringList()) { QStringList info = db->elementStringList()->elementString(); diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index 3599470403..46a1e66bcc 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -75,6 +75,10 @@ int runUic(int argc, char *argv[]) noImplicitIncludesOption.setDescription(QStringLiteral("Disable generation of #include-directives.")); parser.addOption(noImplicitIncludesOption); + QCommandLineOption noStringLiteralOption(QStringList() << QStringLiteral("s") << QStringLiteral("no-stringliteral")); + noStringLiteralOption.setDescription(QStringLiteral("Use QLatin1String instead of QStringLiteral in generated code.")); + parser.addOption(noStringLiteralOption); + QCommandLineOption postfixOption(QStringLiteral("postfix")); postfixOption.setDescription(QStringLiteral("Postfix to add to all generated classnames.")); postfixOption.setValueName(QStringLiteral("postfix")); @@ -107,6 +111,7 @@ int runUic(int argc, char *argv[]) driver.option().outputFile = parser.value(outputOption); driver.option().headerProtection = !parser.isSet(noProtOption); driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption); + driver.option().stringLiteral = !parser.isSet(noStringLiteralOption); driver.option().idBased = parser.isSet(idBasedOption); driver.option().postfix = parser.value(postfixOption); driver.option().translateFunction = parser.value(translateOption); diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h index 1483d94c07..c7278393fb 100644 --- a/src/tools/uic/option.h +++ b/src/tools/uic/option.h @@ -48,10 +48,10 @@ struct Option unsigned int generateNamespace : 1; unsigned int autoConnection : 1; unsigned int dependencies : 1; - unsigned int extractImages : 1; unsigned int limitXPM_LineLength : 1; unsigned int implicitIncludes: 1; unsigned int idBased: 1; + unsigned int stringLiteral: 1; Generator generator; QString inputFile; @@ -74,10 +74,10 @@ struct Option generateNamespace(1), autoConnection(1), dependencies(0), - extractImages(0), limitXPM_LineLength(0), implicitIncludes(1), idBased(0), + stringLiteral(1), generator(CppGenerator), prefix(QLatin1String("Ui_")) { indent.fill(QLatin1Char(' '), 4); } diff --git a/src/tools/uic/treewalker.cpp b/src/tools/uic/treewalker.cpp index eb9f1c02f8..4c9981580b 100644 --- a/src/tools/uic/treewalker.cpp +++ b/src/tools/uic/treewalker.cpp @@ -38,9 +38,6 @@ void TreeWalker::acceptUI(DomUI *ui) acceptButtonGroups(domButtonGroups); acceptTabStops(ui->elementTabStops()); - - if (ui->elementImages()) - acceptImages(ui->elementImages()); } void TreeWalker::acceptLayoutDefault(DomLayoutDefault *layoutDefault) @@ -112,9 +109,6 @@ void TreeWalker::acceptWidget(DomWidget *widget) if (!widget->elementLayout().isEmpty()) acceptLayout(widget->elementLayout().at(0)); - - const DomScripts scripts(widget->elementScript()); - acceptWidgetScripts(scripts, widget, childWidgets); } void TreeWalker::acceptSpacer(DomSpacer *spacer) @@ -251,17 +245,6 @@ void TreeWalker::acceptActionRef(DomActionRef *actionRef) Q_UNUSED(actionRef); } -void TreeWalker::acceptImages(DomImages *images) -{ - for (int i=0; i<images->elementImage().size(); ++i) - acceptImage(images->elementImage().at(i)); -} - -void TreeWalker::acceptImage(DomImage *image) -{ - Q_UNUSED(image); -} - void TreeWalker::acceptIncludes(DomIncludes *includes) { for (int i=0; i<includes->elementInclude().size(); ++i) @@ -295,17 +278,11 @@ void TreeWalker::acceptConnectionHint(DomConnectionHint *connectionHint) Q_UNUSED(connectionHint); } -void TreeWalker::acceptWidgetScripts(const DomScripts &, DomWidget *, const DomWidgets &) -{ -} - void TreeWalker::acceptButtonGroups(const DomButtonGroups *domButtonGroups) { - typedef QList<DomButtonGroup*> DomButtonGroupList; - const DomButtonGroupList domGroups = domButtonGroups->elementButtonGroup(); - const DomButtonGroupList::const_iterator cend = domGroups.constEnd(); - for (DomButtonGroupList::const_iterator it = domGroups.constBegin(); it != cend; ++it) - acceptButtonGroup(*it); + const auto &domGroups = domButtonGroups->elementButtonGroup(); + for (const DomButtonGroup *g : domGroups) + acceptButtonGroup(g); } void TreeWalker::acceptButtonGroup(const DomButtonGroup *) diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h index 0739f5138c..78da17d628 100644 --- a/src/tools/uic/treewalker.h +++ b/src/tools/uic/treewalker.h @@ -101,11 +101,8 @@ struct TreeWalker virtual void acceptTime(DomTime *time); virtual void acceptDateTime(DomDateTime *dateTime); virtual void acceptProperty(DomProperty *property); - typedef QList<DomScript *> DomScripts; - typedef QList<DomWidget *> DomWidgets; - virtual void acceptWidgetScripts(const DomScripts &, DomWidget *node, const DomWidgets &childWidgets); - virtual void acceptImages(DomImages *images); - virtual void acceptImage(DomImage *image); + typedef QVector<DomScript *> DomScripts; + typedef QVector<DomWidget *> DomWidgets; virtual void acceptIncludes(DomIncludes *includes); virtual void acceptInclude(DomInclude *incl); virtual void acceptAction(DomAction *action); diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 5a609ef42b..bc1039871e 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -40,71 +40,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; @@ -112,7 +47,6 @@ DomUI::~DomUI() delete m_layoutFunction; delete m_customWidgets; delete m_tabStops; - delete m_images; delete m_includes; delete m_resources; delete m_connections; @@ -123,10 +57,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; @@ -150,97 +83,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); @@ -250,12 +182,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; } @@ -264,7 +191,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()); @@ -281,284 +208,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; @@ -625,13 +514,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; @@ -674,23 +556,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); @@ -699,12 +564,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); @@ -714,12 +578,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; } @@ -728,54 +587,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; @@ -787,16 +621,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()); @@ -809,7 +642,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()); @@ -823,25 +656,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); @@ -850,10 +664,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; @@ -861,11 +674,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); @@ -875,12 +688,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; } @@ -889,54 +697,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; @@ -944,20 +730,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; } @@ -966,42 +747,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); @@ -1016,10 +769,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; @@ -1027,29 +779,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); @@ -1059,12 +811,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; } @@ -1073,80 +820,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); @@ -1157,10 +874,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; @@ -1172,17 +888,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); @@ -1192,12 +908,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; } @@ -1206,7 +917,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()); @@ -1214,59 +925,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; @@ -1274,20 +962,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; } @@ -1296,38 +979,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); @@ -1338,10 +997,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; @@ -1349,17 +1007,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); @@ -1369,12 +1027,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; } @@ -1383,54 +1036,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); @@ -1439,12 +1070,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); @@ -1454,12 +1084,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; } @@ -1468,295 +1093,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); @@ -1765,12 +1115,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); @@ -1780,12 +1129,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; } @@ -1794,52 +1138,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; @@ -1847,16 +1168,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()); @@ -1869,7 +1189,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()); @@ -1880,119 +1200,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); @@ -2002,12 +1277,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; } @@ -2016,105 +1286,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; @@ -2126,81 +1372,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; @@ -2241,32 +1442,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; @@ -2281,272 +1461,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; @@ -2558,20 +1481,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; } @@ -2580,7 +1498,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())); @@ -2588,41 +1506,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; @@ -2634,20 +1529,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; } @@ -2656,7 +1546,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()); @@ -2664,28 +1554,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(); @@ -2693,12 +1564,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; } @@ -2706,12 +1576,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; } @@ -2720,59 +1585,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); @@ -2785,10 +1611,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; @@ -2820,23 +1645,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); @@ -2846,12 +1671,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; } @@ -2860,7 +1680,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()); @@ -2883,99 +1703,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; @@ -2999,23 +1781,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); @@ -3025,12 +1807,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; } @@ -3039,7 +1816,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())); @@ -3057,95 +1834,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); @@ -3154,12 +1908,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); @@ -3169,12 +1922,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; } @@ -3183,41 +1931,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); @@ -3226,12 +1953,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); @@ -3241,12 +1967,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; } @@ -3255,51 +1976,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); @@ -3310,10 +2000,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; @@ -3325,17 +2014,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); @@ -3345,12 +2034,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; } @@ -3359,7 +2043,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())); @@ -3367,90 +2051,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); @@ -3474,10 +2100,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; @@ -3493,87 +2118,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; } @@ -3581,12 +2204,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; } @@ -3595,7 +2213,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()); @@ -3606,171 +2224,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); @@ -3779,10 +2343,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; @@ -3790,11 +2353,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); @@ -3804,12 +2367,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; } @@ -3818,62 +2376,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; @@ -3881,19 +2409,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; } @@ -3901,12 +2429,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; } @@ -3915,25 +2438,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(); } @@ -3971,28 +2488,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; @@ -4000,10 +2495,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; @@ -4011,11 +2505,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); @@ -4025,12 +2519,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; } @@ -4039,30 +2528,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; @@ -4076,69 +2561,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); @@ -4147,10 +2569,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; @@ -4206,11 +2627,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); @@ -4220,12 +2641,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; } @@ -4234,7 +2650,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)); @@ -4275,63 +2691,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; @@ -4339,23 +2735,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); @@ -4365,12 +2761,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; } @@ -4379,104 +2770,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; @@ -4484,10 +2849,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; @@ -4495,11 +2859,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); @@ -4509,12 +2873,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; } @@ -4523,30 +2882,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; @@ -4560,25 +2915,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); @@ -4589,18 +2925,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); @@ -4610,12 +2945,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; } @@ -4624,58 +2954,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; @@ -4685,24 +2986,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); @@ -4712,12 +3012,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; } @@ -4726,65 +3021,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; @@ -4812,85 +3101,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; } @@ -4898,12 +3155,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; } @@ -4912,55 +3164,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; @@ -5008,7 +3247,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; @@ -5070,41 +3309,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; } @@ -5112,12 +3331,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; } @@ -5126,18 +3340,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(); } @@ -5164,53 +3373,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; } @@ -5218,12 +3403,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; } @@ -5232,26 +3412,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(); } @@ -5300,35 +3473,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; @@ -5340,20 +3493,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; } @@ -5362,7 +3510,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()); @@ -5370,49 +3518,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; @@ -5424,23 +3541,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; } @@ -5448,12 +3565,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; } @@ -5462,7 +3574,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()); @@ -5470,24 +3582,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(); } @@ -5536,41 +3641,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; } @@ -5578,12 +3663,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; } @@ -5592,18 +3672,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(); } @@ -5630,47 +3705,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; } @@ -5678,12 +3731,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; } @@ -5692,22 +3740,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(); } @@ -5745,47 +3787,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; } @@ -5793,12 +3813,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; } @@ -5807,22 +3822,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(); } @@ -5860,65 +3869,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; } @@ -5926,12 +3907,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; } @@ -5940,34 +3916,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(); } @@ -6038,28 +4005,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(); @@ -6067,10 +4012,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; @@ -6086,11 +4030,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; } @@ -6098,12 +4042,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; } @@ -6112,7 +4051,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()); @@ -6123,52 +4062,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; @@ -6180,16 +4094,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()); @@ -6202,7 +4115,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()); @@ -6216,50 +4129,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; @@ -6274,10 +4143,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; @@ -6289,53 +4157,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); @@ -6345,8 +4213,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()); @@ -6359,7 +4226,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()); @@ -6367,37 +4234,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); @@ -6405,120 +4264,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; @@ -6581,38 +4440,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; @@ -6628,16 +4464,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()); @@ -6650,7 +4485,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()); @@ -6667,41 +4502,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; } @@ -6709,12 +4524,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; } @@ -6723,18 +4533,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(); } @@ -6761,53 +4566,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; } @@ -6815,12 +4596,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; } @@ -6829,26 +4605,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(); } @@ -6897,41 +4666,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; } @@ -6939,12 +4688,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; } @@ -6953,18 +4697,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(); } @@ -6991,35 +4730,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; } @@ -7027,12 +4748,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; } @@ -7041,14 +4757,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(); } @@ -7064,24 +4776,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; @@ -7089,12 +4783,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); @@ -7104,12 +4797,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; } @@ -7118,27 +4806,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; @@ -7152,7 +4836,7 @@ void DomUrl::clearElementString() m_children &= ~String; } -void DomProperty::clear(bool clear_all) +DomProperty::~DomProperty() { delete m_color; delete m_font; @@ -7175,84 +4859,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; @@ -7275,14 +4884,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; @@ -7294,179 +4933,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); @@ -7476,12 +5115,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; } @@ -7490,7 +5124,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()); @@ -7499,605 +5133,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); @@ -8106,12 +5699,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); @@ -8121,12 +5713,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; } @@ -8135,42 +5722,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; @@ -8178,28 +5743,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); @@ -8209,12 +5773,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; } @@ -8223,67 +5782,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; @@ -8317,23 +5868,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); @@ -8342,12 +5876,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); @@ -8357,12 +5890,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; } @@ -8371,55 +5899,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; @@ -8427,15 +5929,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; } @@ -8443,12 +5945,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; } @@ -8457,21 +5954,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(); } @@ -8498,171 +5990,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); @@ -8671,12 +5998,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); @@ -8686,12 +6012,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; } @@ -8700,41 +6021,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(); @@ -8743,16 +6043,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; } @@ -8760,12 +6059,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; } @@ -8774,53 +6068,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); @@ -8831,18 +6101,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); @@ -8852,12 +6121,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; } @@ -8866,61 +6130,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; @@ -8928,20 +6169,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; } @@ -8950,48 +6186,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; @@ -9007,20 +6218,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; } @@ -9029,7 +6235,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()); @@ -9040,9 +6246,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/tools/uic/ui4.h b/src/tools/uic/ui4.h index 820d2c5f8c..08a5ed01d5 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -45,6 +45,7 @@ #include <qlist.h> #include <qstring.h> #include <qstringlist.h> +#include <qvector.h> #include <qxmlstream.h> #include <qglobal.h> @@ -85,15 +86,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; @@ -134,8 +129,6 @@ class DomConnections; class DomConnection; class DomConnectionHints; class DomConnectionHint; -class DomScript; -class DomWidgetData; class DomDesignerData; class DomSlots; class DomPropertySpecifications; @@ -147,29 +140,28 @@ 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; } @@ -184,141 +176,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, @@ -330,586 +313,388 @@ 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 }; - - DomUI(const DomUI &other); - void operator = (const DomUI&other); }; 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 }; - - DomIncludes(const DomIncludes &other); - void operator = (const DomIncludes&other); }; 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; - - DomInclude(const DomInclude &other); - void operator = (const DomInclude&other); + 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 }; - - DomResources(const DomResources &other); - void operator = (const DomResources&other); }; 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; - - DomResource(const DomResource &other); - void operator = (const DomResource&other); + 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, Property = 4, Attribute = 8 }; - - DomActionGroup(const DomActionGroup &other); - void operator = (const DomActionGroup&other); }; 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 }; - - DomAction(const DomAction &other); - void operator = (const DomAction&other); }; 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; - - DomActionRef(const DomActionRef &other); - void operator = (const DomActionRef&other); + 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 }; - - DomButtonGroup(const DomButtonGroup &other); - void operator = (const DomButtonGroup&other); }; 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 - }; - - DomButtonGroups(const DomButtonGroups &other); - void operator = (const DomButtonGroups&other); -}; - -class QDESIGNER_UILIB_EXPORT 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 - }; - - DomImages(const DomImages &other); - void operator = (const DomImages&other); -}; - -class QDESIGNER_UILIB_EXPORT 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); + uint m_children = 0; + QVector<DomButtonGroup *> m_buttonGroup; - // attribute data - QString m_attr_name; - bool m_has_attr_name; - - // child element data - uint m_children; - DomImageData* m_data; enum Child { - Data = 1 + ButtonGroup = 1 }; - - DomImage(const DomImage &other); - void operator = (const DomImage&other); -}; - -class QDESIGNER_UILIB_EXPORT 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; - - DomImageData(const DomImageData &other); - void operator = (const DomImageData&other); }; 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 }; - - DomCustomWidgets(const DomCustomWidgets &other); - void operator = (const DomCustomWidgets&other); }; 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; - - DomHeader(const DomHeader &other); - void operator = (const DomHeader&other); + 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(); @@ -918,60 +703,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, @@ -979,130 +741,20 @@ private: SizeHint = 8, AddPageMethod = 16, Container = 32, - SizePolicy = 64, - Pixmap = 128, - Script = 256, - Properties = 512, - Slots = 1024, - Propertyspecifications = 2048 - }; - - DomCustomWidget(const DomCustomWidget &other); - void operator = (const DomCustomWidget&other); -}; - -class QDESIGNER_UILIB_EXPORT 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 - }; - - DomProperties(const DomProperties &other); - void operator = (const DomProperties&other); -}; - -class QDESIGNER_UILIB_EXPORT 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; - - DomPropertyData(const DomPropertyData &other); - void operator = (const DomPropertyData&other); -}; - -class QDESIGNER_UILIB_EXPORT 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 }; - - DomSizePolicyData(const DomSizePolicyData &other); - void operator = (const DomSizePolicyData&other); }; 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; } @@ -1115,202 +767,167 @@ 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_margin; - bool m_has_attr_margin; + int m_attr_spacing = 0; + bool m_has_attr_spacing = false; - // child element data - uint m_children; - - DomLayoutDefault(const DomLayoutDefault &other); - void operator = (const DomLayoutDefault&other); + 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; - - DomLayoutFunction(const DomLayoutFunction &other); - void operator = (const DomLayoutFunction&other); + 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 }; - - DomTabStops(const DomTabStops &other); - void operator = (const DomTabStops&other); }; 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, Item = 4 }; - - DomLayout(const DomLayout &other); - void operator = (const DomLayout&other); }; 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; } @@ -1335,126 +952,107 @@ 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; - - DomLayoutItem(const DomLayoutItem &other); - void operator = (const DomLayoutItem&other); + 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 }; - - DomRow(const DomRow &other); - void operator = (const DomRow&other); }; 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 }; - - DomColumn(const DomColumn &other); - void operator = (const DomColumn&other); }; 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; } @@ -1469,54 +1067,48 @@ 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 }; - - DomItem(const DomItem &other); - void operator = (const DomItem&other); }; 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; } @@ -1526,146 +1118,124 @@ 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 }; - - DomWidget(const DomWidget &other); - void operator = (const DomWidget&other); }; 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 }; - - DomSpacer(const DomSpacer &other); - void operator = (const DomSpacer&other); }; 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; } @@ -1690,37 +1260,31 @@ 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, Blue = 4 }; - - DomColor(const DomColor &other); - void operator = (const DomColor&other); }; 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; } @@ -1729,40 +1293,34 @@ 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 }; - - DomGradientStop(const DomGradientStop &other); - void operator = (const DomGradientStop&other); }; 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; } @@ -1817,270 +1375,238 @@ 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 }; - - DomGradient(const DomGradient &other); - void operator = (const DomGradient&other); }; 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; - - DomBrush(const DomBrush &other); - void operator = (const DomBrush&other); + 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 }; - - DomColorRole(const DomColorRole &other); - void operator = (const DomColorRole&other); }; 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 }; - - DomColorGroup(const DomColorGroup &other); - void operator = (const DomColorGroup&other); }; 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, Disabled = 4 }; - - DomPalette(const DomPalette &other); - void operator = (const DomPalette&other); }; 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(); @@ -2120,7 +1646,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(); @@ -2130,22 +1656,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, @@ -2158,22 +1682,17 @@ private: StyleStrategy = 256, Kerning = 512 }; - - DomFont(const DomFont &other); - void operator = (const DomFont&other); }; 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); @@ -2186,34 +1705,27 @@ 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 }; - - DomPoint(const DomPoint &other); - void operator = (const DomPoint&other); }; 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); @@ -2236,86 +1748,69 @@ 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, Width = 4, Height = 8 }; - - DomRect(const DomRect &other); - void operator = (const DomRect&other); }; 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; - - DomLocale(const DomLocale &other); - void operator = (const DomLocale&other); + 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 @@ -2340,44 +1835,37 @@ 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, HorStretch = 4, VerStretch = 8 }; - - DomSizePolicy(const DomSizePolicy &other); - void operator = (const DomSizePolicy&other); }; 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); @@ -2390,34 +1878,27 @@ 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 }; - - DomSize(const DomSize &other); - void operator = (const DomSize&other); }; 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); @@ -2435,36 +1916,29 @@ 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, Day = 4 }; - - DomDate(const DomDate &other); - void operator = (const DomDate&other); }; 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); @@ -2482,36 +1956,29 @@ 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, Second = 4 }; - - DomTime(const DomTime &other); - void operator = (const DomTime&other); }; 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); @@ -2544,18 +2011,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, @@ -2564,197 +2029,184 @@ private: Month = 16, Day = 32 }; - - DomDateTime(const DomDateTime &other); - void operator = (const DomDateTime&other); }; 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 }; - - DomStringList(const DomStringList &other); - void operator = (const DomStringList&other); }; 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; - - DomResourcePixmap(const DomResourcePixmap &other); - void operator = (const DomResourcePixmap&other); + 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, @@ -2765,70 +2217,59 @@ private: SelectedOff = 64, SelectedOn = 128 }; - - DomResourceIcon(const DomResourceIcon &other); - void operator = (const DomResourceIcon&other); }; 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; - - DomString(const DomString &other); - void operator = (const DomString&other); + 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); @@ -2841,34 +2282,27 @@ 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 }; - - DomPointF(const DomPointF &other); - void operator = (const DomPointF&other); }; 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); @@ -2891,38 +2325,31 @@ 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, Width = 4, Height = 8 }; - - DomRectF(const DomRectF &other); - void operator = (const DomRectF&other); }; 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); @@ -2935,34 +2362,27 @@ 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 }; - - DomSizeF(const DomSizeF &other); - void operator = (const DomSizeF&other); }; 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); @@ -2970,69 +2390,56 @@ 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 }; - - DomChar(const DomChar &other); - void operator = (const DomChar&other); }; 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 }; - - DomUrl(const DomUrl &other); - void operator = (const DomUrl&other); }; 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; } @@ -3045,70 +2452,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); @@ -3119,40 +2526,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); @@ -3160,142 +2567,127 @@ 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; - - DomProperty(const DomProperty &other); - void operator = (const DomProperty&other); + 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 }; - - DomConnections(const DomConnections &other); - void operator = (const DomConnections&other); }; 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, @@ -3303,56 +2695,45 @@ private: Slot = 8, Hints = 16 }; - - DomConnection(const DomConnection &other); - void operator = (const DomConnection&other); }; 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 }; - - DomConnectionHints(const DomConnectionHints &other); - void operator = (const DomConnectionHints&other); }; 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 @@ -3367,278 +2748,159 @@ 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 }; - - DomConnectionHint(const DomConnectionHint &other); - void operator = (const DomConnectionHint&other); -}; - -class QDESIGNER_UILIB_EXPORT 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; - - DomScript(const DomScript &other); - void operator = (const DomScript&other); -}; - -class QDESIGNER_UILIB_EXPORT 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 - }; - - DomWidgetData(const DomWidgetData &other); - void operator = (const DomWidgetData&other); }; 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 }; - - DomDesignerData(const DomDesignerData &other); - void operator = (const DomDesignerData&other); }; 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 }; - - DomSlots(const DomSlots &other); - void operator = (const DomSlots&other); }; 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 }; - - DomPropertySpecifications(const DomPropertySpecifications &other); - void operator = (const DomPropertySpecifications&other); }; 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; - - DomPropertyToolTip(const DomPropertyToolTip &other); - void operator = (const DomPropertyToolTip&other); + 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; - - DomStringPropertySpecification(const DomStringPropertySpecification &other); - void operator = (const DomStringPropertySpecification&other); + bool m_has_attr_notr = false; }; diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index fa775161e5..48756db651 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -52,8 +52,7 @@ QT_BEGIN_NAMESPACE Uic::Uic(Driver *d) : drv(d), out(d->output()), - opt(d->option()), - externalPix(true) + opt(d->option()) { } @@ -253,15 +252,13 @@ bool Uic::write(DomUI *ui) if (pixFunction == QLatin1String("QPixmap::fromMimeSource")) pixFunction = QLatin1String("qPixmapFromMimeSource"); - externalPix = ui->elementImages() == 0; - info.acceptUI(ui); cWidgetsInfo.acceptUI(ui); WriteIncludes writeIncludes(this); writeIncludes.acceptUI(ui); Validator(this).acceptUI(ui); - WriteDeclaration(this, writeIncludes.scriptsActivated()).acceptUI(ui); + WriteDeclaration(this).acceptUI(ui); if (opt.headerProtection) writeHeaderProtectionEnd(); diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h index 10404d3370..e00dc595bc 100644 --- a/src/tools/uic/uic.h +++ b/src/tools/uic/uic.h @@ -74,12 +74,6 @@ public: inline void setPixmapFunction(const QString &f) { pixFunction = f; } - inline bool hasExternalPixmap() const - { return externalPix; } - - inline void setExternalPixmap(bool b) - { externalPix = b; } - inline const DatabaseInfo *databaseInfo() const { return &info; } @@ -123,7 +117,6 @@ private: DatabaseInfo info; CustomWidgetsInfo cWidgetsInfo; QString pixFunction; - bool externalPix; }; QT_END_NAMESPACE diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro index 02469cdd1b..18511395d9 100644 --- a/src/tools/uic/uic.pro +++ b/src/tools/uic/uic.pro @@ -12,4 +12,5 @@ HEADERS += uic.h SOURCES += main.cpp \ uic.cpp +QMAKE_TARGET_DESCRIPTION = "Qt User Interface Compiler" load(qt_tool) diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h index 7c5918cab9..18b361fb81 100644 --- a/src/tools/uic/utils.h +++ b/src/tools/uic/utils.h @@ -107,19 +107,6 @@ inline QString fixString(const QString &str, const QString &indent, return rc; } -inline QString writeString(const QString &s, const QString &indent) -{ - unsigned flags = 0; - const QString ret = fixString(s, indent, &flags); - if (flags & Utf8String) - return QLatin1String("QString::fromUtf8(") + ret + QLatin1Char(')'); - // MSVC cannot concat L"foo" "bar" (C2308: concatenating mismatched strings), - // use QLatin1String instead (all platforms to avoid cross-compiling issues). - if (flags & MultiLineString) - return QLatin1String("QLatin1String(") + ret + QLatin1Char(')'); - return QLatin1String("QStringLiteral(") + ret + QLatin1Char(')'); -} - inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties) { QHash<QString, DomProperty *> map; |