summaryrefslogtreecommitdiffstats
path: root/src/tools/uic
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/uic')
-rw-r--r--src/tools/uic/cpp/cpp.pri20
-rw-r--r--src/tools/uic/cpp/cppextractimages.cpp150
-rw-r--r--src/tools/uic/cpp/cppextractimages.h77
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.cpp279
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.h81
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.cpp185
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.h81
-rw-r--r--src/tools/uic/cpp/cppwriteicondeclaration.cpp80
-rw-r--r--src/tools/uic/cpp/cppwriteicondeclaration.h76
-rw-r--r--src/tools/uic/cpp/cppwriteiconinitialization.cpp115
-rw-r--r--src/tools/uic/cpp/cppwriteiconinitialization.h81
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.cpp342
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.h116
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp3012
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.h373
-rw-r--r--src/tools/uic/customwidgetsinfo.cpp127
-rw-r--r--src/tools/uic/customwidgetsinfo.h91
-rw-r--r--src/tools/uic/databaseinfo.cpp96
-rw-r--r--src/tools/uic/databaseinfo.h79
-rw-r--r--src/tools/uic/driver.cpp381
-rw-r--r--src/tools/uic/driver.h140
-rw-r--r--src/tools/uic/globaldefs.h54
-rw-r--r--src/tools/uic/main.cpp182
-rw-r--r--src/tools/uic/option.h106
-rw-r--r--src/tools/uic/treewalker.cpp328
-rw-r--r--src/tools/uic/treewalker.h137
-rw-r--r--src/tools/uic/ui4.cpp11154
-rw-r--r--src/tools/uic/ui4.h3807
-rw-r--r--src/tools/uic/uic.cpp387
-rw-r--r--src/tools/uic/uic.h145
-rw-r--r--src/tools/uic/uic.pri21
-rw-r--r--src/tools/uic/uic.pro23
-rw-r--r--src/tools/uic/utils.h128
-rw-r--r--src/tools/uic/validator.cpp94
-rw-r--r--src/tools/uic/validator.h74
35 files changed, 22622 insertions, 0 deletions
diff --git a/src/tools/uic/cpp/cpp.pri b/src/tools/uic/cpp/cpp.pri
new file mode 100644
index 0000000000..49c71a6dfa
--- /dev/null
+++ b/src/tools/uic/cpp/cpp.pri
@@ -0,0 +1,20 @@
+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 \
+ $$PWD/cppwriteincludes.h \
+ $$PWD/cppwriteinitialization.h
+
+SOURCES += $$PWD/cppextractimages.cpp \
+ $$PWD/cppwritedeclaration.cpp \
+ $$PWD/cppwriteicondata.cpp \
+ $$PWD/cppwriteicondeclaration.cpp \
+ $$PWD/cppwriteiconinitialization.cpp \
+ $$PWD/cppwriteincludes.cpp \
+ $$PWD/cppwriteinitialization.cpp
diff --git a/src/tools/uic/cpp/cppextractimages.cpp b/src/tools/uic/cpp/cppextractimages.cpp
new file mode 100644
index 0000000000..0b1391d343
--- /dev/null
+++ b/src/tools/uic/cpp/cppextractimages.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppextractimages.h"
+#include "cppwriteicondata.h"
+#include "driver.h"
+#include "ui4.h"
+#include "utils.h"
+#include "uic.h"
+
+#include <QtCore/QDataStream>
+#include <QtCore/QTextStream>
+#include <QtCore/QTextCodec>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+
+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);
+ m_output->setCodec(QTextCodec::codecForName("UTF-8"));
+
+ 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);
+ imageOut->setCodec(QTextCodec::codecForName("UTF-8"));
+
+ 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
new file mode 100644
index 0000000000..ce8cdc1d72
--- /dev/null
+++ b/src/tools/uic/cpp/cppextractimages.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CPPEXTRACTIMAGES_H
+#define CPPEXTRACTIMAGES_H
+
+#include "treewalker.h"
+#include <QtCore/QDir>
+
+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);
+ void acceptImages(DomImages *images);
+ void acceptImage(DomImage *image);
+
+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
new file mode 100644
index 0000000000..d5ae0beef7
--- /dev/null
+++ b/src/tools/uic/cpp/cppwritedeclaration.cpp
@@ -0,0 +1,279 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppwritedeclaration.h"
+#include "cppwriteicondeclaration.h"
+#include "cppwriteinitialization.h"
+#include "cppwriteiconinitialization.h"
+#include "cppextractimages.h"
+#include "driver.h"
+#include "ui4.h"
+#include "uic.h"
+#include "databaseinfo.h"
+#include "customwidgetsinfo.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+ void openNameSpaces(const QStringList &namespaceList, QTextStream &output) {
+ if (namespaceList.empty())
+ return;
+ const QStringList::const_iterator cend = namespaceList.constEnd();
+ for (QStringList::const_iterator it = namespaceList.constBegin(); it != cend; ++it) {
+ if (!it->isEmpty()) {
+ output << "namespace " << *it << " {\n";
+ }
+ }
+ }
+
+ void closeNameSpaces(const QStringList &namespaceList, QTextStream &output) {
+ if (namespaceList.empty())
+ return;
+
+ QListIterator<QString> it(namespaceList);
+ it.toBack();
+ while (it.hasPrevious()) {
+ const QString ns = it.previous();
+ if (!ns.isEmpty()) {
+ output << "} // namespace " << ns << "\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) :
+ m_uic(uic),
+ m_driver(uic->driver()),
+ m_output(uic->output()),
+ m_option(uic->option()),
+ m_activateScripts(activateScripts)
+{
+}
+
+void WriteDeclaration::acceptUI(DomUI *node)
+{
+ QString qualifiedClassName = node->elementClass() + m_option.postfix;
+ QString className = qualifiedClassName;
+
+ QString varName = m_driver->findOrInsertWidget(node->elementWidget());
+ QString widgetClassName = node->elementWidget()->attributeClass();
+
+ QString exportMacro = node->elementExportMacro();
+ if (!exportMacro.isEmpty())
+ exportMacro.append(QLatin1Char(' '));
+
+ QStringList namespaceList = qualifiedClassName.split(QLatin1String("::"));
+ if (namespaceList.count()) {
+ className = namespaceList.last();
+ namespaceList.removeLast();
+ }
+
+ // This is a bit of the hack but covers the cases Qt in/without namespaces
+ // and User defined classes in/without namespaces. The "strange" case
+ // is a User using Qt-in-namespace having his own classes not in a namespace.
+ // In this case the generated Ui helper classes will also end up in
+ // the Qt namespace (which is harmless, but not "pretty")
+ const bool needsMacro = namespaceList.count() == 0
+ || namespaceList[0] == QLatin1String("qdesigner_internal");
+
+ if (needsMacro)
+ m_output << "QT_BEGIN_NAMESPACE\n\n";
+
+ openNameSpaces(namespaceList, m_output);
+
+ if (namespaceList.count())
+ m_output << "\n";
+
+ m_output << "class " << exportMacro << m_option.prefix << className << "\n"
+ << "{\n"
+ << "public:\n";
+
+ const QStringList connections = m_uic->databaseInfo()->connections();
+ for (int i=0; i<connections.size(); ++i) {
+ const QString connection = connections.at(i);
+
+ if (connection == QLatin1String("(default)"))
+ continue;
+
+ m_output << m_option.indent << "QSqlDatabase " << connection << "Connection;\n";
+ }
+
+ TreeWalker::acceptWidget(node->elementWidget());
+ if (const DomButtonGroups *domButtonGroups = node->elementButtonGroups())
+ acceptButtonGroups(domButtonGroups);
+
+ 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);
+ }
+
+ m_output << "};\n\n";
+
+ closeNameSpaces(namespaceList, m_output);
+
+ if (namespaceList.count())
+ m_output << "\n";
+
+ if (m_option.generateNamespace && !m_option.prefix.isEmpty()) {
+ namespaceList.append(QLatin1String("Ui"));
+
+ openNameSpaces(namespaceList, m_output);
+
+ m_output << m_option.indent << "class " << exportMacro << className << ": public " << m_option.prefix << className << " {};\n";
+
+ closeNameSpaces(namespaceList, m_output);
+
+ if (namespaceList.count())
+ m_output << "\n";
+ }
+
+ if (needsMacro)
+ m_output << "QT_END_NAMESPACE\n\n";
+}
+
+void WriteDeclaration::acceptWidget(DomWidget *node)
+{
+ QString className = QLatin1String("QWidget");
+ if (node->hasAttributeClass())
+ className = node->attributeClass();
+
+ m_output << m_option.indent << m_uic->customWidgetsInfo()->realClassName(className) << " *" << m_driver->findOrInsertWidget(node) << ";\n";
+
+ TreeWalker::acceptWidget(node);
+}
+
+void WriteDeclaration::acceptSpacer(DomSpacer *node)
+{
+ m_output << m_option.indent << "QSpacerItem *" << m_driver->findOrInsertSpacer(node) << ";\n";
+ TreeWalker::acceptSpacer(node);
+}
+
+void WriteDeclaration::acceptLayout(DomLayout *node)
+{
+ QString className = QLatin1String("QLayout");
+ if (node->hasAttributeClass())
+ className = node->attributeClass();
+
+ m_output << m_option.indent << className << " *" << m_driver->findOrInsertLayout(node) << ";\n";
+
+ TreeWalker::acceptLayout(node);
+}
+
+void WriteDeclaration::acceptActionGroup(DomActionGroup *node)
+{
+ m_output << m_option.indent << "QActionGroup *" << m_driver->findOrInsertActionGroup(node) << ";\n";
+
+ TreeWalker::acceptActionGroup(node);
+}
+
+void WriteDeclaration::acceptAction(DomAction *node)
+{
+ m_output << m_option.indent << "QAction *" << m_driver->findOrInsertAction(node) << ";\n";
+
+ TreeWalker::acceptAction(node);
+}
+
+void WriteDeclaration::acceptButtonGroup(const DomButtonGroup *buttonGroup)
+{
+ m_output << m_option.indent << "QButtonGroup *" << m_driver->findOrInsertButtonGroup(buttonGroup) << ";\n";
+ TreeWalker::acceptButtonGroup(buttonGroup);
+}
+
+} // namespace CPP
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwritedeclaration.h b/src/tools/uic/cpp/cppwritedeclaration.h
new file mode 100644
index 0000000000..7900e01203
--- /dev/null
+++ b/src/tools/uic/cpp/cppwritedeclaration.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CPPWRITEDECLARATION_H
+#define CPPWRITEDECLARATION_H
+
+#include "treewalker.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTextStream;
+class Driver;
+class Uic;
+
+struct Option;
+
+namespace CPP {
+
+struct WriteDeclaration : public TreeWalker
+{
+ WriteDeclaration(Uic *uic, bool activateScripts);
+
+ void acceptUI(DomUI *node);
+ void acceptWidget(DomWidget *node);
+ void acceptSpacer(DomSpacer *node);
+ void acceptLayout(DomLayout *node);
+ void acceptActionGroup(DomActionGroup *node);
+ void acceptAction(DomAction *node);
+ void acceptButtonGroup(const DomButtonGroup *buttonGroup);
+
+private:
+ Uic *m_uic;
+ Driver *m_driver;
+ QTextStream &m_output;
+ const Option &m_option;
+ const bool m_activateScripts;
+};
+
+} // namespace CPP
+
+QT_END_NAMESPACE
+
+#endif // CPPWRITEDECLARATION_H
diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp
new file mode 100644
index 0000000000..e09b081b8f
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondata.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppwriteicondata.h"
+#include "driver.h"
+#include "ui4.h"
+#include "uic.h"
+
+#include <QtCore/QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+namespace CPP {
+
+static QByteArray transformImageData(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(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)
+{
+ QByteArray array = transformImageData(image->elementData()->text());
+ output.write(array, array.size());
+}
+
+} // namespace CPP
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwriteicondata.h b/src/tools/uic/cpp/cppwriteicondata.h
new file mode 100644
index 0000000000..c971e17914
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondata.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $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);
+ void acceptImages(DomImages *images);
+ void acceptImage(DomImage *image);
+
+ 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
new file mode 100644
index 0000000000..21f88c3bd6
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondeclaration.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppwriteicondeclaration.h"
+#include "driver.h"
+#include "ui4.h"
+#include "uic.h"
+
+#include <QtCore/QTextStream>
+
+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
new file mode 100644
index 0000000000..5ad2a6f6ba
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondeclaration.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $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);
+ void acceptImages(DomImages *images);
+ void acceptImage(DomImage *image);
+
+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
new file mode 100644
index 0000000000..d9d24c1bc7
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteiconinitialization.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppwriteiconinitialization.h"
+#include "cppwriteicondata.h"
+#include "driver.h"
+#include "ui4.h"
+#include "utils.h"
+#include "uic.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QString>
+
+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
new file mode 100644
index 0000000000..b3cf270838
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteiconinitialization.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $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);
+ void acceptImages(DomImages *images);
+ void acceptImage(DomImage *image);
+
+ 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
new file mode 100644
index 0000000000..d09c712b7b
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -0,0 +1,342 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppwriteincludes.h"
+#include "driver.h"
+#include "ui4.h"
+#include "uic.h"
+#include "databaseinfo.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QFileInfo>
+#include <QtCore/QTextStream>
+
+#include <stdio.h>
+
+QT_BEGIN_NAMESPACE
+
+enum { debugWriteIncludes = 0 };
+enum { warnHeaderGeneration = 0 };
+
+struct ClassInfoEntry
+{
+ const char *klass;
+ const char *module;
+ const char *header;
+};
+
+static const ClassInfoEntry qclass_lib_map[] = {
+#define QT_CLASS_LIB(klass, module, header) { #klass, #module, #header },
+#include "qclass_lib_map.h"
+
+#undef QT_CLASS_LIB
+};
+
+// Format a module header as 'QtCore/QObject'
+static inline QString moduleHeader(const QString &module, const QString &header)
+{
+ QString rc = module;
+ rc += QLatin1Char('/');
+ rc += header;
+ return rc;
+}
+
+namespace CPP {
+
+WriteIncludes::WriteIncludes(Uic *uic)
+ : m_uic(uic), m_output(uic->output()), m_scriptsActivated(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
+ // for the "Phonon::Someclass" classes, however.
+ const QString namespaceDelimiter = QLatin1String("::");
+ const ClassInfoEntry *classLibEnd = qclass_lib_map + sizeof(qclass_lib_map)/sizeof(ClassInfoEntry);
+ for(const ClassInfoEntry *it = qclass_lib_map; it < classLibEnd; ++it) {
+ const QString klass = QLatin1String(it->klass);
+ const QString module = QLatin1String(it->module);
+ QLatin1String header = QLatin1String(it->header);
+ if (klass.contains(namespaceDelimiter)) {
+ m_classToHeader.insert(klass, moduleHeader(module, header));
+ } else {
+ const QString newHeader = moduleHeader(module, klass);
+ m_classToHeader.insert(klass, newHeader);
+ m_oldHeaderToNewHeader.insert(header, newHeader);
+ }
+ }
+}
+
+void WriteIncludes::acceptUI(DomUI *node)
+{
+ m_scriptsActivated = false;
+ m_localIncludes.clear();
+ m_globalIncludes.clear();
+ m_knownClasses.clear();
+ m_includeBaseNames.clear();
+
+ if (node->elementIncludes())
+ acceptIncludes(node->elementIncludes());
+
+ if (node->elementCustomWidgets())
+ TreeWalker::acceptCustomWidgets(node->elementCustomWidgets());
+
+ add(QLatin1String("QApplication"));
+ add(QLatin1String("QVariant"));
+ add(QLatin1String("QAction"));
+
+ add(QLatin1String("QButtonGroup")); // ### only if it is really necessary
+ add(QLatin1String("QHeaderView"));
+
+ if (m_uic->hasExternalPixmap() && m_uic->pixmapFunction() == QLatin1String("qPixmapFromMimeSource")) {
+#ifdef QT_NO_QT3_SUPPORT
+ qWarning("%s: Warning: The form file has external pixmaps or qPixmapFromMimeSource() set as a pixmap function. "
+ "This requires Qt 3 support, which is disabled. The resulting code will not compile.",
+ qPrintable(m_uic->option().messagePrefix()));
+#endif
+ add(QLatin1String("Q3MimeSourceFactory"));
+ }
+
+ if (m_uic->databaseInfo()->connections().size()) {
+ add(QLatin1String("QSqlDatabase"));
+ add(QLatin1String("Q3SqlCursor"));
+ add(QLatin1String("QSqlRecord"));
+ add(QLatin1String("Q3SqlForm"));
+ }
+
+ TreeWalker::acceptUI(node);
+
+ writeHeaders(m_globalIncludes, true);
+ writeHeaders(m_localIncludes, false);
+
+ m_output << QLatin1Char('\n');
+}
+
+void WriteIncludes::acceptWidget(DomWidget *node)
+{
+ if (debugWriteIncludes)
+ fprintf(stderr, "%s '%s'\n", Q_FUNC_INFO, qPrintable(node->attributeClass()));
+
+ add(node->attributeClass());
+ TreeWalker::acceptWidget(node);
+}
+
+void WriteIncludes::acceptLayout(DomLayout *node)
+{
+ add(node->attributeClass());
+ TreeWalker::acceptLayout(node);
+}
+
+void WriteIncludes::acceptSpacer(DomSpacer *node)
+{
+ add(QLatin1String("QSpacerItem"));
+ TreeWalker::acceptSpacer(node);
+}
+
+void WriteIncludes::acceptProperty(DomProperty *node)
+{
+ if (node->kind() == DomProperty::Date)
+ add(QLatin1String("QDate"));
+ if (node->kind() == DomProperty::Locale)
+ add(QLatin1String("QLocale"));
+ TreeWalker::acceptProperty(node);
+}
+
+void WriteIncludes::insertIncludeForClass(const QString &className, QString header, bool global)
+{
+ if (debugWriteIncludes)
+ fprintf(stderr, "%s %s '%s' %d\n", Q_FUNC_INFO, qPrintable(className), qPrintable(header), global);
+
+ do {
+ if (!header.isEmpty())
+ break;
+
+ // Known class
+ const StringMap::const_iterator it = m_classToHeader.constFind(className);
+ if (it != m_classToHeader.constEnd()) {
+ header = it.value();
+ global = true;
+ break;
+ }
+
+ // Quick check by class name to detect includehints provided for custom widgets.
+ // Remove namespaces
+ QString lowerClassName = className.toLower();
+ static const QString namespaceSeparator = QLatin1String("::");
+ const int namespaceIndex = lowerClassName.lastIndexOf(namespaceSeparator);
+ if (namespaceIndex != -1)
+ lowerClassName.remove(0, namespaceIndex + namespaceSeparator.size());
+ if (m_includeBaseNames.contains(lowerClassName)) {
+ header.clear();
+ break;
+ }
+
+ // Last resort: Create default header
+ if (!m_uic->option().implicitIncludes)
+ break;
+ header = lowerClassName;
+ header += QLatin1String(".h");
+ if (warnHeaderGeneration) {
+ qWarning("%s: Warning: generated header '%s' for class '%s'.",
+ qPrintable(m_uic->option().messagePrefix()),
+ qPrintable(header), qPrintable(className));
+
+ }
+
+ global = true;
+ } while (false);
+
+ if (!header.isEmpty())
+ insertInclude(header, global);
+}
+
+void WriteIncludes::add(const QString &className, bool determineHeader, const QString &header, bool global)
+{
+ if (debugWriteIncludes)
+ fprintf(stderr, "%s %s '%s' %d\n", Q_FUNC_INFO, qPrintable(className), qPrintable(header), global);
+
+ if (className.isEmpty() || m_knownClasses.contains(className))
+ return;
+
+ m_knownClasses.insert(className);
+
+ if (className == QLatin1String("Line")) { // ### hmm, deprecate me!
+ add(QLatin1String("QFrame"));
+ return;
+ }
+
+ if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3ListView")) ||
+ m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3Table"))) {
+ add(QLatin1String("Q3Header"));
+ }
+ if (determineHeader)
+ insertIncludeForClass(className, header, global);
+}
+
+void WriteIncludes::acceptCustomWidget(DomCustomWidget *node)
+{
+ const QString className = node->elementClass();
+ 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 {
+ // custom header unless it is a built-in qt class
+ QString header;
+ bool global = false;
+ if (!m_classToHeader.contains(className)) {
+ global = node->elementHeader()->attributeLocation().toLower() == QLatin1String("global");
+ header = node->elementHeader()->text();
+ }
+ add(className, true, header, global);
+ }
+}
+
+void WriteIncludes::acceptCustomWidgets(DomCustomWidgets *node)
+{
+ Q_UNUSED(node);
+}
+
+void WriteIncludes::acceptIncludes(DomIncludes *node)
+{
+ TreeWalker::acceptIncludes(node);
+}
+
+void WriteIncludes::acceptInclude(DomInclude *node)
+{
+ bool global = true;
+ if (node->hasAttributeLocation())
+ global = node->attributeLocation() == QLatin1String("global");
+ insertInclude(node->text(), global);
+}
+
+void WriteIncludes::insertInclude(const QString &header, bool global)
+{
+ if (debugWriteIncludes)
+ fprintf(stderr, "%s %s %d\n", Q_FUNC_INFO, qPrintable(header), global);
+
+ OrderedSet &includes = global ? m_globalIncludes : m_localIncludes;
+ if (includes.contains(header))
+ return;
+ // Insert. Also remember base name for quick check of suspicious custom plugins
+ includes.insert(header, false);
+ const QString lowerBaseName = QFileInfo(header).completeBaseName ().toLower();
+ m_includeBaseNames.insert(lowerBaseName);
+}
+
+void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
+{
+ const QChar openingQuote = global ? QLatin1Char('<') : QLatin1Char('"');
+ const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"');
+
+ // Check for the old headers 'qslider.h' and replace by 'QtGui/QSlider'
+ const OrderedSet::const_iterator cend = headers.constEnd();
+ for (OrderedSet::const_iterator sit = headers.constBegin(); sit != cend; ++sit) {
+ const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key());
+ const bool mapped = hit != m_oldHeaderToNewHeader.constEnd();
+ const QString header = mapped ? hit.value() : sit.key();
+ if (!header.trimmed().isEmpty()) {
+ m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n');
+ }
+ }
+}
+
+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
new file mode 100644
index 0000000000..2b98fe9616
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteincludes.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CPPWRITEINCLUDES_H
+#define CPPWRITEINCLUDES_H
+
+#include "treewalker.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QMap>
+#include <QtCore/QSet>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class QTextStream;
+class Driver;
+class Uic;
+
+namespace CPP {
+
+struct WriteIncludes : public TreeWalker
+{
+ WriteIncludes(Uic *uic);
+
+ void acceptUI(DomUI *node);
+ void acceptWidget(DomWidget *node);
+ void acceptLayout(DomLayout *node);
+ void acceptSpacer(DomSpacer *node);
+ void acceptProperty(DomProperty *node);
+ void acceptWidgetScripts(const DomScripts &, DomWidget *, const DomWidgets &);
+
+//
+// custom widgets
+//
+ void acceptCustomWidgets(DomCustomWidgets *node);
+ void acceptCustomWidget(DomCustomWidget *node);
+
+//
+// include hints
+//
+ void acceptIncludes(DomIncludes *node);
+ void acceptInclude(DomInclude *node);
+
+ bool scriptsActivated() const { return m_scriptsActivated; }
+
+private:
+ void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false);
+
+private:
+ typedef QMap<QString, bool> OrderedSet;
+ void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false);
+ void insertInclude(const QString &header, bool global);
+ void writeHeaders(const OrderedSet &headers, bool global);
+ QString headerForClassName(const QString &className) const;
+ void activateScripts();
+
+ const Uic *m_uic;
+ QTextStream &m_output;
+
+ OrderedSet m_localIncludes;
+ OrderedSet m_globalIncludes;
+ QSet<QString> m_includeBaseNames;
+
+ QSet<QString> m_knownClasses;
+
+ typedef QMap<QString, QString> StringMap;
+ StringMap m_classToHeader;
+ StringMap m_oldHeaderToNewHeader;
+
+ bool m_scriptsActivated;
+};
+
+} // namespace CPP
+
+QT_END_NAMESPACE
+
+#endif // CPPWRITEINCLUDES_H
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
new file mode 100644
index 0000000000..37d012c109
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -0,0 +1,3012 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cppwriteinitialization.h"
+#include "cppwriteiconinitialization.h"
+#include "driver.h"
+#include "ui4.h"
+#include "utils.h"
+#include "uic.h"
+#include "databaseinfo.h"
+#include "globaldefs.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QDebug>
+
+#include <ctype.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+ // Fixup an enumeration name from class Qt.
+ // They are currently stored as "BottomToolBarArea" instead of "Qt::BottomToolBarArea".
+ // due to MO issues. This might be fixed in the future.
+ void fixQtEnumerationName(QString& name) {
+ static const QLatin1String prefix("Qt::");
+ if (name.indexOf(prefix) != 0)
+ name.prepend(prefix);
+ }
+ // figure out the toolbar area of a DOM attrib list.
+ // By legacy, it is stored as an integer. As of 4.3.0, it is the enumeration value.
+ QString toolBarAreaStringFromDOMAttributes(const CPP::WriteInitialization::DomPropertyMap &attributes) {
+ const DomProperty *pstyle = attributes.value(QLatin1String("toolBarArea"));
+ if (!pstyle)
+ return QString();
+
+ switch (pstyle->kind()) {
+ case DomProperty::Number: {
+ QString area = QLatin1String("static_cast<Qt::ToolBarArea>(");
+ area += QString::number(pstyle->elementNumber());
+ area += QLatin1String("), ");
+ return area;
+ }
+ case DomProperty::Enum: {
+ QString area = pstyle->elementEnum();
+ fixQtEnumerationName(area);
+ area += QLatin1String(", ");
+ return area;
+ }
+ default:
+ break;
+ }
+ return QString();
+ }
+
+ // Write a statement to create a spacer item.
+ void writeSpacerItem(const DomSpacer *node, QTextStream &output) {
+ const QHash<QString, DomProperty *> properties = propertyMap(node->elementProperty());
+ output << "new QSpacerItem(";
+
+ if (properties.contains(QLatin1String("sizeHint"))) {
+ const DomSize *sizeHint = properties.value(QLatin1String("sizeHint"))->elementSize();
+ output << sizeHint->elementWidth() << ", " << sizeHint->elementHeight() << ", ";
+ }
+
+ // size type
+ QString sizeType = properties.contains(QLatin1String("sizeType")) ?
+ properties.value(QLatin1String("sizeType"))->elementEnum() :
+ QString::fromLatin1("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 (isVspacer)
+ output << "QSizePolicy::Minimum, " << sizeType << ')';
+ else
+ output << sizeType << ", QSizePolicy::Minimum)";
+ }
+
+
+ // Helper for implementing comparison functions for integers.
+ int compareInt(int i1, int i2) {
+ if (i1 < i2) return -1;
+ if (i1 > i2) return 1;
+ return 0;
+ }
+
+ // Write object->setFoo(x);
+ template <class Value>
+ void writeSetter(const QString &indent, const QString &varName,const QString &setter, Value v, QTextStream &str) {
+ 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() ||
+ i->hasElementActiveOff() || i->hasElementActiveOn() ||
+ i->hasElementSelectedOff() || i->hasElementSelectedOn();
+ }
+
+ static inline bool isIconFormat44(const DomResourceIcon *i) {
+ return iconHasStatePixmaps(i) || !i->attributeTheme().isEmpty();
+ }
+
+ // Check on properties. Filter out empty legacy pixmap/icon properties
+ // as Designer pre 4.4 used to remove missing resource references.
+ // This can no longer be handled by the code as we have 'setIcon(QIcon())' as well as 'QIcon icon'
+ static bool checkProperty(const QString &fileName, const DomProperty *p) {
+ switch (p->kind()) {
+ case DomProperty::IconSet:
+ if (const DomResourceIcon *dri = p->elementIconSet()) {
+ if (!isIconFormat44(dri)) {
+ if (dri->text().isEmpty()) {
+ const QString msg = QString::fromUtf8("%1: Warning: An invalid icon property '%2' was encountered.").arg(fileName).arg(p->attributeName());
+ qWarning("%s", qPrintable(msg));
+ return false;
+ }
+ }
+ }
+ break;
+ case DomProperty::Pixmap:
+ if (const DomResourcePixmap *drp = p->elementPixmap())
+ if (drp->text().isEmpty()) {
+ const QString msg = QString::fromUtf8("%1: Warning: An invalid pixmap property '%2' was encountered.").arg(fileName).arg(p->attributeName());
+ qWarning("%s", qPrintable(msg));
+ return false;
+ }
+ break;
+ default:
+ break;
+ }
+ return true;
+ }
+
+ inline void openIfndef(QTextStream &str, const QString &symbol) { if (!symbol.isEmpty()) str << QLatin1String("#ifndef ") << symbol << endl; }
+ inline void closeIfndef(QTextStream &str, const QString &symbol) { if (!symbol.isEmpty()) str << QLatin1String("#endif // ") << symbol << endl; }
+
+ const char *accessibilityDefineC = "QT_NO_ACCESSIBILITY";
+ const char *toolTipDefineC = "QT_NO_TOOLTIP";
+ const char *whatsThisDefineC = "QT_NO_WHATSTHIS";
+ const char *statusTipDefineC = "QT_NO_STATUSTIP";
+ const char *shortcutDefineC = "QT_NO_SHORTCUT";
+}
+
+namespace CPP {
+
+FontHandle::FontHandle(const DomFont *domFont) :
+ m_domFont(domFont)
+{
+}
+
+int FontHandle::compare(const FontHandle &rhs) const
+{
+ const QString family = m_domFont->hasElementFamily() ? m_domFont->elementFamily() : QString();
+ const QString rhsFamily = rhs.m_domFont->hasElementFamily() ? rhs.m_domFont->elementFamily() : QString();
+
+ if (const int frc = family.compare(rhsFamily))
+ return frc;
+
+ const int pointSize = m_domFont->hasElementPointSize() ? m_domFont->elementPointSize() : -1;
+ const int rhsPointSize = rhs.m_domFont->hasElementPointSize() ? rhs.m_domFont->elementPointSize() : -1;
+
+ if (const int crc = compareInt(pointSize, rhsPointSize))
+ return crc;
+
+ const int bold = m_domFont->hasElementBold() ? (m_domFont->elementBold() ? 1 : 0) : -1;
+ const int rhsBold = rhs.m_domFont->hasElementBold() ? (rhs.m_domFont->elementBold() ? 1 : 0) : -1;
+ if (const int crc = compareInt(bold, rhsBold))
+ return crc;
+
+ const int italic = m_domFont->hasElementItalic() ? (m_domFont->elementItalic() ? 1 : 0) : -1;
+ const int rhsItalic = rhs.m_domFont->hasElementItalic() ? (rhs.m_domFont->elementItalic() ? 1 : 0) : -1;
+ if (const int crc = compareInt(italic, rhsItalic))
+ return crc;
+
+ const int underline = m_domFont->hasElementUnderline() ? (m_domFont->elementUnderline() ? 1 : 0) : -1;
+ const int rhsUnderline = rhs.m_domFont->hasElementUnderline() ? (rhs.m_domFont->elementUnderline() ? 1 : 0) : -1;
+ if (const int crc = compareInt(underline, rhsUnderline))
+ return crc;
+
+ const int weight = m_domFont->hasElementWeight() ? m_domFont->elementWeight() : -1;
+ const int rhsWeight = rhs.m_domFont->hasElementWeight() ? rhs.m_domFont->elementWeight() : -1;
+ if (const int crc = compareInt(weight, rhsWeight))
+ return crc;
+
+ const int strikeOut = m_domFont->hasElementStrikeOut() ? (m_domFont->elementStrikeOut() ? 1 : 0) : -1;
+ const int rhsStrikeOut = rhs.m_domFont->hasElementStrikeOut() ? (rhs.m_domFont->elementStrikeOut() ? 1 : 0) : -1;
+ if (const int crc = compareInt(strikeOut, rhsStrikeOut))
+ return crc;
+
+ const int kerning = m_domFont->hasElementKerning() ? (m_domFont->elementKerning() ? 1 : 0) : -1;
+ const int rhsKerning = rhs.m_domFont->hasElementKerning() ? (rhs.m_domFont->elementKerning() ? 1 : 0) : -1;
+ if (const int crc = compareInt(kerning, rhsKerning))
+ return crc;
+
+ const int antialiasing = m_domFont->hasElementAntialiasing() ? (m_domFont->elementAntialiasing() ? 1 : 0) : -1;
+ const int rhsAntialiasing = rhs.m_domFont->hasElementAntialiasing() ? (rhs.m_domFont->elementAntialiasing() ? 1 : 0) : -1;
+ if (const int crc = compareInt(antialiasing, rhsAntialiasing))
+ return crc;
+
+ const QString styleStrategy = m_domFont->hasElementStyleStrategy() ? m_domFont->elementStyleStrategy() : QString();
+ const QString rhsStyleStrategy = rhs.m_domFont->hasElementStyleStrategy() ? rhs.m_domFont->elementStyleStrategy() : QString();
+
+ if (const int src = styleStrategy.compare(rhsStyleStrategy))
+ return src;
+
+ return 0;
+}
+
+IconHandle::IconHandle(const DomResourceIcon *domIcon) :
+ m_domIcon(domIcon)
+{
+}
+
+int IconHandle::compare(const IconHandle &rhs) const
+{
+ if (const int comp = m_domIcon->attributeTheme().compare(rhs.m_domIcon->attributeTheme()))
+ return comp;
+
+ const QString normalOff = m_domIcon->hasElementNormalOff() ? m_domIcon->elementNormalOff()->text() : QString();
+ const QString rhsNormalOff = rhs.m_domIcon->hasElementNormalOff() ? rhs.m_domIcon->elementNormalOff()->text() : QString();
+ if (const int comp = normalOff.compare(rhsNormalOff))
+ return comp;
+
+ const QString normalOn = m_domIcon->hasElementNormalOn() ? m_domIcon->elementNormalOn()->text() : QString();
+ const QString rhsNormalOn = rhs.m_domIcon->hasElementNormalOn() ? rhs.m_domIcon->elementNormalOn()->text() : QString();
+ if (const int comp = normalOn.compare(rhsNormalOn))
+ return comp;
+
+ const QString disabledOff = m_domIcon->hasElementDisabledOff() ? m_domIcon->elementDisabledOff()->text() : QString();
+ const QString rhsDisabledOff = rhs.m_domIcon->hasElementDisabledOff() ? rhs.m_domIcon->elementDisabledOff()->text() : QString();
+ if (const int comp = disabledOff.compare(rhsDisabledOff))
+ return comp;
+
+ const QString disabledOn = m_domIcon->hasElementDisabledOn() ? m_domIcon->elementDisabledOn()->text() : QString();
+ const QString rhsDisabledOn = rhs.m_domIcon->hasElementDisabledOn() ? rhs.m_domIcon->elementDisabledOn()->text() : QString();
+ if (const int comp = disabledOn.compare(rhsDisabledOn))
+ return comp;
+
+ const QString activeOff = m_domIcon->hasElementActiveOff() ? m_domIcon->elementActiveOff()->text() : QString();
+ const QString rhsActiveOff = rhs.m_domIcon->hasElementActiveOff() ? rhs.m_domIcon->elementActiveOff()->text() : QString();
+ if (const int comp = activeOff.compare(rhsActiveOff))
+ return comp;
+
+ const QString activeOn = m_domIcon->hasElementActiveOn() ? m_domIcon->elementActiveOn()->text() : QString();
+ const QString rhsActiveOn = rhs.m_domIcon->hasElementActiveOn() ? rhs.m_domIcon->elementActiveOn()->text() : QString();
+ if (const int comp = activeOn.compare(rhsActiveOn))
+ return comp;
+
+ const QString selectedOff = m_domIcon->hasElementSelectedOff() ? m_domIcon->elementSelectedOff()->text() : QString();
+ const QString rhsSelectedOff = rhs.m_domIcon->hasElementSelectedOff() ? rhs.m_domIcon->elementSelectedOff()->text() : QString();
+ if (const int comp = selectedOff.compare(rhsSelectedOff))
+ return comp;
+
+ const QString selectedOn = m_domIcon->hasElementSelectedOn() ? m_domIcon->elementSelectedOn()->text() : QString();
+ const QString rhsSelectedOn = rhs.m_domIcon->hasElementSelectedOn() ? rhs.m_domIcon->elementSelectedOn()->text() : QString();
+ if (const int comp = selectedOn.compare(rhsSelectedOn))
+ return comp;
+ // Pre 4.4 Legacy
+ if (const int comp = m_domIcon->text().compare(rhs.m_domIcon->text()))
+ return comp;
+
+ return 0;
+}
+
+
+#if defined(Q_OS_MAC) && defined(Q_CC_GNU) && (__GNUC__ == 3 && __GNUC_MINOR__ == 3)
+inline uint qHash(const SizePolicyHandle &handle) { return qHash(handle.m_domSizePolicy); }
+inline uint qHash(const FontHandle &handle) { return qHash(handle.m_domFont); }
+inline uint qHash(const IconHandle &handle) { return qHash(handle.m_domIcon); }
+#endif
+
+SizePolicyHandle::SizePolicyHandle(const DomSizePolicy *domSizePolicy) :
+ m_domSizePolicy(domSizePolicy)
+{
+}
+
+int SizePolicyHandle::compare(const SizePolicyHandle &rhs) const
+{
+
+ const int hSizeType = m_domSizePolicy->hasElementHSizeType() ? m_domSizePolicy->elementHSizeType() : -1;
+ const int rhsHSizeType = rhs.m_domSizePolicy->hasElementHSizeType() ? rhs.m_domSizePolicy->elementHSizeType() : -1;
+ if (const int crc = compareInt(hSizeType, rhsHSizeType))
+ return crc;
+
+ const int vSizeType = m_domSizePolicy->hasElementVSizeType() ? m_domSizePolicy->elementVSizeType() : -1;
+ const int rhsVSizeType = rhs.m_domSizePolicy->hasElementVSizeType() ? rhs.m_domSizePolicy->elementVSizeType() : -1;
+ if (const int crc = compareInt(vSizeType, rhsVSizeType))
+ return crc;
+
+ const int hStretch = m_domSizePolicy->hasElementHorStretch() ? m_domSizePolicy->elementHorStretch() : -1;
+ const int rhsHStretch = rhs.m_domSizePolicy->hasElementHorStretch() ? rhs.m_domSizePolicy->elementHorStretch() : -1;
+ if (const int crc = compareInt(hStretch, rhsHStretch))
+ return crc;
+
+ const int vStretch = m_domSizePolicy->hasElementVerStretch() ? m_domSizePolicy->elementVerStretch() : -1;
+ const int rhsVStretch = rhs.m_domSizePolicy->hasElementVerStretch() ? rhs.m_domSizePolicy->elementVerStretch() : -1;
+ if (const int crc = compareInt(vStretch, rhsVStretch))
+ return crc;
+
+ const QString attributeHSizeType = m_domSizePolicy->hasAttributeHSizeType() ? m_domSizePolicy->attributeHSizeType() : QString();
+ const QString rhsAttributeHSizeType = rhs.m_domSizePolicy->hasAttributeHSizeType() ? rhs.m_domSizePolicy->attributeHSizeType() : QString();
+
+ if (const int hrc = attributeHSizeType.compare(rhsAttributeHSizeType))
+ return hrc;
+
+ const QString attributeVSizeType = m_domSizePolicy->hasAttributeVSizeType() ? m_domSizePolicy->attributeVSizeType() : QString();
+ const QString rhsAttributeVSizeType = rhs.m_domSizePolicy->hasAttributeVSizeType() ? rhs.m_domSizePolicy->attributeVSizeType() : QString();
+
+ return attributeVSizeType.compare(rhsAttributeVSizeType);
+}
+
+// --- WriteInitialization: LayoutDefaultHandler
+
+WriteInitialization::LayoutDefaultHandler::LayoutDefaultHandler()
+{
+ qFill(m_state, m_state + NumProperties, 0u);
+ qFill(m_defaultValues, m_defaultValues + NumProperties, 0);
+}
+
+
+
+void WriteInitialization::LayoutDefaultHandler::acceptLayoutDefault(DomLayoutDefault *node)
+{
+ if (!node)
+ return;
+ if (node->hasAttributeMargin()) {
+ m_state[Margin] |= HasDefaultValue;
+ m_defaultValues[Margin] = node->attributeMargin();
+ }
+ if (node->hasAttributeSpacing()) {
+ m_state[Spacing] |= HasDefaultValue;
+ m_defaultValues[Spacing] = node->attributeSpacing();
+ }
+}
+
+void WriteInitialization::LayoutDefaultHandler::acceptLayoutFunction(DomLayoutFunction *node)
+{
+ if (!node)
+ return;
+ if (node->hasAttributeMargin()) {
+ m_state[Margin] |= HasDefaultFunction;
+ m_functions[Margin] = node->attributeMargin();
+ m_functions[Margin] += QLatin1String("()");
+ }
+ if (node->hasAttributeSpacing()) {
+ m_state[Spacing] |= HasDefaultFunction;
+ m_functions[Spacing] = node->attributeSpacing();
+ m_functions[Spacing] += QLatin1String("()");
+ }
+}
+
+static inline void writeContentsMargins(const QString &indent, const QString &objectName, int value, QTextStream &str)
+{
+ QString contentsMargins;
+ QTextStream(&contentsMargins) << value << ", " << value << ", " << value << ", " << value;
+ writeSetter(indent, objectName, QLatin1String("setContentsMargins"), contentsMargins, str);
+ }
+
+void WriteInitialization::LayoutDefaultHandler::writeProperty(int p, const QString &indent, const QString &objectName,
+ const DomPropertyMap &properties, const QString &propertyName, const QString &setter,
+ 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();
+ // 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];
+ if (!useLayoutFunctionPre43) {
+ bool ifndefMac = (!(m_state[p] & (HasDefaultFunction|HasDefaultValue))
+ && value == defaultStyleValue);
+ if (ifndefMac)
+ str << "#ifndef Q_OS_MAC\n";
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, value, str);
+ } else {
+ writeSetter(indent, objectName, setter, value, str);
+ }
+ if (ifndefMac)
+ str << "#endif\n";
+ return;
+ }
+ }
+ if (suppressDefault)
+ return;
+ // get default.
+ if (m_state[p] & HasDefaultFunction) {
+ // Do not use setContentsMargins to avoid repetitive evaluations.
+ writeSetter(indent, objectName, setter, m_functions[p], str);
+ return;
+ }
+ if (m_state[p] & HasDefaultValue) {
+ if (p == Margin) { // Use setContentsMargins for numeric values
+ writeContentsMargins(indent, objectName, m_defaultValues[p], str);
+ } else {
+ writeSetter(indent, objectName, setter, m_defaultValues[p], str);
+ }
+ }
+ return;
+}
+
+
+void WriteInitialization::LayoutDefaultHandler::writeProperties(const QString &indent, const QString &varName,
+ const DomPropertyMap &properties, int marginType,
+ bool suppressMarginDefault,
+ QTextStream &str) const {
+ // Write out properties and ignore the ones found in
+ // subsequent writing of the property list.
+ int defaultSpacing = marginType == WriteInitialization::Use43UiFile ? -1 : 6;
+ writeProperty(Spacing, indent, varName, properties, QLatin1String("spacing"), QLatin1String("setSpacing"),
+ defaultSpacing, false, str);
+ // We use 9 as TopLevelMargin, since Designer seem to always use 9.
+ static const int layoutmargins[4] = {-1, 9, 9, 0};
+ writeProperty(Margin, indent, varName, properties, QLatin1String("margin"), QLatin1String("setMargin"),
+ layoutmargins[marginType], suppressMarginDefault, str);
+}
+
+static bool needsTranslation(DomString *str)
+{
+ if (!str)
+ return false;
+ return !str->hasAttributeNotr() || !toBool(str->attributeNotr());
+}
+
+// --- WriteInitialization
+WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) :
+ m_uic(uic),
+ m_driver(uic->driver()), m_output(uic->output()), m_option(uic->option()),
+ m_indent(m_option.indent + m_option.indent),
+ m_dindent(m_indent + m_option.indent),
+ m_stdsetdef(true),
+ m_layoutMarginType(TopLevelMargin),
+ m_mainFormUsedInRetranslateUi(false),
+ 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_firstThemeIcon(true)
+{
+}
+
+void WriteInitialization::acceptUI(DomUI *node)
+{
+ m_registeredImages.clear();
+ m_actionGroupChain.push(0);
+ m_widgetChain.push(0);
+ m_layoutChain.push(0);
+
+ acceptLayoutDefault(node->elementLayoutDefault());
+ acceptLayoutFunction(node->elementLayoutFunction());
+
+ 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";
+
+ m_stdsetdef = true;
+ if (node->hasAttributeStdSetDef())
+ m_stdsetdef = node->attributeStdSetDef();
+
+ const QString className = node->elementClass() + m_option.postfix;
+ m_generatedClass = className;
+
+ const QString varName = m_driver->findOrInsertWidget(node->elementWidget());
+ m_mainFormVarName = varName;
+ m_registeredWidgets.insert(varName, node->elementWidget()); // register the main widget
+
+ const QString widgetClassName = node->elementWidget()->attributeClass();
+
+ 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);
+
+ if (connection == QLatin1String("(default)"))
+ continue;
+
+ const QString varConn = connection + QLatin1String("Connection");
+ m_output << m_indent << varConn << " = QSqlDatabase::database(" << fixString(connection, m_dindent) << ");\n";
+ }
+
+ acceptWidget(node->elementWidget());
+
+ if (m_buddies.size() > 0)
+ openIfndef(m_output, QLatin1String(shortcutDefineC));
+ for (int i=0; i<m_buddies.size(); ++i) {
+ const Buddy &b = m_buddies.at(i);
+
+ if (!m_registeredWidgets.contains(b.objName)) {
+ fprintf(stderr, "%s: Warning: Buddy assignment: '%s' is not a valid widget.\n",
+ qPrintable(m_option.messagePrefix()),
+ b.objName.toLatin1().data());
+ continue;
+ } else if (!m_registeredWidgets.contains(b.buddy)) {
+ fprintf(stderr, "%s: Warning: Buddy assignment: '%s' is not a valid widget.\n",
+ qPrintable(m_option.messagePrefix()),
+ b.buddy.toLatin1().data());
+ continue;
+ }
+
+ m_output << m_indent << b.objName << "->setBuddy(" << b.buddy << ");\n";
+ }
+ if (m_buddies.size() > 0)
+ closeIfndef(m_output, QLatin1String(shortcutDefineC));
+
+ if (node->elementTabStops())
+ acceptTabStops(node->elementTabStops());
+
+ if (m_delayedActionInitialization.size())
+ m_output << "\n" << m_delayedActionInitialization;
+
+ m_output << "\n" << m_indent << "retranslateUi(" << varName << ");\n";
+
+ if (node->elementConnections())
+ acceptConnections(node->elementConnections());
+
+ if (!m_delayedInitialization.isEmpty())
+ m_output << "\n" << m_delayedInitialization << "\n";
+
+ if (m_option.autoConnection)
+ m_output << "\n" << m_indent << "QMetaObject::connectSlotsByName(" << varName << ");\n";
+
+ m_output << m_option.indent << "} // setupUi\n\n";
+
+ if (!m_mainFormUsedInRetranslateUi) {
+ m_refreshInitialization += m_indent;
+ m_refreshInitialization += QLatin1String("Q_UNUSED(");
+ m_refreshInitialization += varName ;
+ m_refreshInitialization += QLatin1String(");\n");
+ }
+
+ m_output << m_option.indent << "void " << "retranslateUi(" << widgetClassName << " *" << varName << ")\n"
+ << m_option.indent << "{\n"
+ << m_refreshInitialization
+ << m_option.indent << "} // retranslateUi\n\n";
+
+ m_layoutChain.pop();
+ m_widgetChain.pop();
+ m_actionGroupChain.pop();
+}
+
+void WriteInitialization::addWizardPage(const QString &pageVarName, const DomWidget *page, const QString &parentWidget)
+{
+ /* 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();
+ 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())
+ id = ds->text();
+ break;
+ }
+ }
+ if (id.isEmpty()) {
+ m_output << m_indent << parentWidget << "->addPage(" << pageVarName << ");\n";
+ } else {
+ m_output << m_indent << parentWidget << "->setPage(" << id << ", " << pageVarName << ");\n";
+ }
+}
+
+void WriteInitialization::acceptWidget(DomWidget *node)
+{
+ m_layoutMarginType = m_widgetChain.count() == 1 ? TopLevelMargin : ChildMargin;
+ const QString className = node->attributeClass();
+ const QString varName = m_driver->findOrInsertWidget(node);
+ m_registeredWidgets.insert(varName, node); // register the current widget
+
+ QString parentWidget, parentClass;
+ if (m_widgetChain.top()) {
+ parentWidget = m_driver->findOrInsertWidget(m_widgetChain.top());
+ parentClass = m_widgetChain.top()->attributeClass();
+ }
+
+ const QString savedParentWidget = parentWidget;
+
+ if (m_uic->isContainer(parentClass) || m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("Q3ToolBar")))
+ parentWidget.clear();
+
+ if (m_widgetChain.size() != 1)
+ m_output << m_indent << varName << " = new " << m_uic->customWidgetsInfo()->realClassName(className) << '(' << parentWidget << ");\n";
+
+ parentWidget = savedParentWidget;
+
+ if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3ComboBox"))) {
+ initializeComboBox3(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QComboBox"))) {
+ initializeComboBox(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) {
+ initializeListWidget(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeWidget"))) {
+ initializeTreeWidget(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableWidget"))) {
+ initializeTableWidget(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3ListBox"))) {
+ initializeQ3ListBox(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3ListView"))) {
+ initializeQ3ListView(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3IconView"))) {
+ initializeQ3IconView(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3Table"))) {
+ initializeQ3Table(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3DataTable"))) {
+ initializeQ3SqlDataTable(node);
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3DataBrowser"))) {
+ initializeQ3SqlDataBrowser(node);
+ }
+
+ if (m_uic->isButton(className))
+ addButtonGroup(node, varName);
+
+ writeProperties(varName, className, node->elementProperty());
+
+ if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QMenu")) && parentWidget.size()) {
+ initializeMenu(node, parentWidget);
+ }
+
+ if (node->elementLayout().isEmpty())
+ m_layoutChain.push(0);
+
+ m_layoutWidget = false;
+ if (className == QLatin1String("QWidget") && !node->hasAttributeNative()) {
+ if (const DomWidget* parentWidget = m_widgetChain.top()) {
+ const QString parentClass = parentWidget->attributeClass();
+ if (parentClass != QLatin1String("QMainWindow")
+ && !m_uic->isCustomWidgetContainer(parentClass)
+ && !m_uic->isContainer(parentClass))
+ m_layoutWidget = true;
+ }
+ }
+ m_widgetChain.push(node);
+ m_layoutChain.push(0);
+ TreeWalker::acceptWidget(node);
+ m_layoutChain.pop();
+ m_widgetChain.pop();
+ m_layoutWidget = false;
+
+ const DomPropertyMap attributes = propertyMap(node->elementAttribute());
+
+ const QString pageDefaultString = QLatin1String("Page");
+
+ int id = -1;
+ if (const DomProperty *pid = attributes.value(QLatin1String("id"))) {
+ id = pid->elementNumber();
+ }
+
+ if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QMainWindow"))
+ || m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("Q3MainWindow"))) {
+
+ if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QMenuBar"))) {
+ if (!m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("Q3MainWindow")))
+ m_output << m_indent << parentWidget << "->setMenuBar(" << varName <<");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBar"))) {
+ m_output << m_indent << parentWidget << "->addToolBar("
+ << toolBarAreaStringFromDOMAttributes(attributes) << varName << ");\n";
+
+ if (const DomProperty *pbreak = attributes.value(QLatin1String("toolBarBreak"))) {
+ if (pbreak->elementBool() == QLatin1String("true")) {
+ m_output << m_indent << parentWidget << "->insertToolBarBreak(" << varName << ");\n";
+ }
+ }
+
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QDockWidget"))) {
+ QString area;
+ if (DomProperty *pstyle = attributes.value(QLatin1String("dockWidgetArea"))) {
+ area += QLatin1String("static_cast<Qt::DockWidgetArea>(");
+ area += QString::number(pstyle->elementNumber());
+ area += QLatin1String("), ");
+ }
+
+ m_output << m_indent << parentWidget << "->addDockWidget(" << area << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"))) {
+ m_output << m_indent << parentWidget << "->setStatusBar(" << varName << ");\n";
+ } else if (!m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3DockWindow"))
+ && !m_uic->customWidgetsInfo()->extends(className, QLatin1String("Q3ToolBar"))) {
+ m_output << m_indent << parentWidget << "->setCentralWidget(" << varName << ");\n";
+ }
+ }
+
+ // Check for addPageMethod of a custom plugin first
+ const QString addPageMethod = m_uic->customWidgetsInfo()->customWidgetAddPageMethod(parentClass);
+ if (!addPageMethod.isEmpty()) {
+ m_output << m_indent << parentWidget << "->" << addPageMethod << '(' << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QStackedWidget"))) {
+ m_output << m_indent << parentWidget << "->addWidget(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QToolBar"))) {
+ m_output << m_indent << parentWidget << "->addWidget(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("Q3WidgetStack"))) {
+ m_output << m_indent << parentWidget << "->addWidget(" << varName << ", " << id << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QDockWidget"))) {
+ m_output << m_indent << parentWidget << "->setWidget(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QScrollArea"))) {
+ m_output << m_indent << parentWidget << "->setWidget(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QSplitter"))) {
+ m_output << m_indent << parentWidget << "->addWidget(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QMdiArea"))) {
+ m_output << m_indent << parentWidget << "->addSubWindow(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QWorkspace"))) {
+ m_output << m_indent << parentWidget << "->addWindow(" << varName << ");\n";
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QWizard"))) {
+ addWizardPage(varName, node, parentWidget);
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QToolBox"))) {
+ QString icon;
+ if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) {
+ icon += QLatin1String(", ") ;
+ icon += iconCall(picon);
+ }
+
+ const DomProperty *plabel = attributes.value(QLatin1String("label"));
+ DomString *plabelString = plabel ? plabel->elementString() : 0;
+
+ m_output << m_indent << parentWidget << "->addItem(" << varName << icon << ", " << noTrCall(plabelString, pageDefaultString) << ");\n";
+
+ autoTrOutput(plabelString, pageDefaultString) << m_indent << parentWidget << "->setItemText("
+ << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(plabelString, pageDefaultString) << ");\n";
+
+#ifndef QT_NO_TOOLTIP
+ if (DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) {
+ autoTrOutput(ptoolTip->elementString()) << m_indent << parentWidget << "->setItemToolTip("
+ << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(ptoolTip->elementString()) << ");\n";
+ }
+#endif // QT_NO_TOOLTIP
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QTabWidget"))) {
+ QString icon;
+ if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) {
+ icon += QLatin1String(", ");
+ icon += iconCall(picon);
+ }
+
+ const DomProperty *ptitle = attributes.value(QLatin1String("title"));
+ DomString *ptitleString = ptitle ? ptitle->elementString() : 0;
+
+ m_output << m_indent << parentWidget << "->addTab(" << varName << icon << ", " << "QString());\n";
+
+ autoTrOutput(ptitleString, pageDefaultString) << m_indent << parentWidget << "->setTabText("
+ << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(ptitleString, pageDefaultString) << ");\n";
+
+#ifndef QT_NO_TOOLTIP
+ if (const DomProperty *ptoolTip = attributes.value(QLatin1String("toolTip"))) {
+ autoTrOutput(ptoolTip->elementString()) << m_indent << parentWidget << "->setTabToolTip("
+ << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(ptoolTip->elementString()) << ");\n";
+ }
+#endif // QT_NO_TOOLTIP
+#ifndef QT_NO_WHATSTHIS
+ if (const DomProperty *pwhatsThis = attributes.value(QLatin1String("whatsThis"))) {
+ autoTrOutput(pwhatsThis->elementString()) << m_indent << parentWidget << "->setTabWhatsThis("
+ << parentWidget << "->indexOf(" << varName << "), " << autoTrCall(pwhatsThis->elementString()) << ");\n";
+ }
+#endif // QT_NO_WHATSTHIS
+ } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("Q3Wizard"))) {
+ const DomProperty *ptitle = attributes.value(QLatin1String("title"));
+ DomString *ptitleString = ptitle ? ptitle->elementString() : 0;
+
+ m_output << m_indent << parentWidget << "->addPage(" << varName << ", " << noTrCall(ptitleString, pageDefaultString) << ");\n";
+
+ autoTrOutput(ptitleString, pageDefaultString) << m_indent << parentWidget << "->setTitle("
+ << varName << ", " << autoTrCall(ptitleString, pageDefaultString) << ");\n";
+
+ }
+
+ //
+ // Special handling for qtableview/qtreeview fake header attributes
+ //
+ static QStringList realPropertyNames =
+ (QStringList() << QLatin1String("visible")
+ << QLatin1String("cascadingSectionResizes")
+ << QLatin1String("defaultSectionSize")
+ << QLatin1String("highlightSections")
+ << QLatin1String("minimumSectionSize")
+ << QLatin1String("showSortIndicator")
+ << QLatin1String("stretchLastSection"));
+
+ if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeView"))
+ || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeWidget"))) {
+ DomPropertyList headerProperties;
+ foreach (const QString &realPropertyName, realPropertyNames) {
+ const QString upperPropertyName = realPropertyName.at(0).toUpper()
+ + realPropertyName.mid(1);
+ const QString fakePropertyName = QLatin1String("header") + upperPropertyName;
+ if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
+ fakeProperty->setAttributeName(realPropertyName);
+ headerProperties << fakeProperty;
+ }
+ }
+ writeProperties(varName + QLatin1String("->header()"), QLatin1String("QHeaderView"),
+ headerProperties, WritePropertyIgnoreObjectName);
+
+ } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableView"))
+ || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableWidget"))) {
+
+ static QStringList headerPrefixes =
+ (QStringList() << QLatin1String("horizontalHeader")
+ << QLatin1String("verticalHeader"));
+
+ foreach (const QString &headerPrefix, headerPrefixes) {
+ DomPropertyList headerProperties;
+ foreach (const QString &realPropertyName, realPropertyNames) {
+ const QString upperPropertyName = realPropertyName.at(0).toUpper()
+ + realPropertyName.mid(1);
+ const QString fakePropertyName = headerPrefix + upperPropertyName;
+ if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
+ fakeProperty->setAttributeName(realPropertyName);
+ headerProperties << fakeProperty;
+ }
+ }
+ writeProperties(varName + QLatin1String("->") + headerPrefix + QLatin1String("()"),
+ QLatin1String("QHeaderView"),
+ headerProperties, WritePropertyIgnoreObjectName);
+ }
+ }
+
+ if (node->elementLayout().isEmpty())
+ m_layoutChain.pop();
+
+ const QStringList zOrder = node->elementZOrder();
+ for (int i = 0; i < zOrder.size(); ++i) {
+ const QString name = zOrder.at(i);
+
+ if (!m_registeredWidgets.contains(name)) {
+ fprintf(stderr, "%s: Warning: Z-order assignment: '%s' is not a valid widget.\n",
+ qPrintable(m_option.messagePrefix()),
+ name.toLatin1().data());
+ continue;
+ }
+
+ if (name.isEmpty()) {
+ continue;
+ }
+
+ m_output << m_indent << name << "->raise();\n";
+ }
+}
+
+void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QString &varName)
+{
+ const DomPropertyMap attributes = propertyMap(buttonNode->elementAttribute());
+ // Look up the button group name as specified in the attribute and find the uniquified name
+ const DomProperty *prop = attributes.value(QLatin1String("buttonGroup"));
+ if (!prop)
+ return;
+ const QString attributeName = toString(prop->elementString());
+ const DomButtonGroup *group = m_driver->findButtonGroup(attributeName);
+ // Legacy feature: Create missing groups on the fly as the UIC button group feature
+ // was present before the actual Designer support (4.5)
+ const bool createGroupOnTheFly = group == 0;
+ if (createGroupOnTheFly) {
+ DomButtonGroup *newGroup = new DomButtonGroup;
+ newGroup->setAttributeName(attributeName);
+ group = newGroup;
+ fprintf(stderr, "%s: Warning: Creating button group `%s'\n",
+ qPrintable(m_option.messagePrefix()),
+ attributeName.toLatin1().data());
+ }
+ const QString groupName = m_driver->findOrInsertButtonGroup(group);
+ // Create on demand
+ if (!m_buttonGroups.contains(groupName)) {
+ const QString className = QLatin1String("QButtonGroup");
+ m_output << m_indent;
+ if (createGroupOnTheFly)
+ m_output << className << " *";
+ m_output << groupName << " = new " << className << '(' << m_mainFormVarName << ");\n";
+ m_buttonGroups.insert(groupName);
+ writeProperties(groupName, className, group->elementProperty());
+ }
+ m_output << m_indent << groupName << "->addButton(" << varName << ");\n";
+}
+
+void WriteInitialization::acceptLayout(DomLayout *node)
+{
+ const QString className = node->attributeClass();
+ const QString varName = m_driver->findOrInsertLayout(node);
+
+ const DomPropertyMap properties = propertyMap(node->elementProperty());
+ const bool oldLayoutProperties = properties.constFind(QLatin1String("margin")) != properties.constEnd();
+
+ bool isGroupBox = false;
+
+ if (m_widgetChain.top()) {
+ const QString parentWidget = m_widgetChain.top()->attributeClass();
+
+ if (!m_layoutChain.top() && (m_uic->customWidgetsInfo()->extends(parentWidget, QLatin1String("Q3GroupBox"))
+ || m_uic->customWidgetsInfo()->extends(parentWidget, QLatin1String("Q3ButtonGroup")))) {
+ const QString parent = m_driver->findOrInsertWidget(m_widgetChain.top());
+
+ isGroupBox = true;
+ // special case for group box
+
+ m_output << m_indent << parent << "->setColumnLayout(0, Qt::Vertical);\n";
+ QString objectName = parent;
+ objectName += QLatin1String("->layout()");
+ int marginType = Use43UiFile;
+ if (oldLayoutProperties)
+ marginType = m_layoutMarginType;
+
+ m_LayoutDefaultHandler.writeProperties(m_indent,
+ objectName, properties, marginType, false, m_output);
+ }
+ }
+
+ m_output << m_indent << varName << " = new " << className << '(';
+
+ if (!m_layoutChain.top() && !isGroupBox)
+ m_output << m_driver->findOrInsertWidget(m_widgetChain.top());
+
+ m_output << ");\n";
+
+ if (isGroupBox) {
+ const QString tempName = m_driver->unique(QLatin1String("boxlayout"));
+ m_output << m_indent << "QBoxLayout *" << tempName << " = qobject_cast<QBoxLayout *>(" <<
+ m_driver->findOrInsertWidget(m_widgetChain.top()) << "->layout());\n";
+ m_output << m_indent << "if (" << tempName << ")\n";
+ m_output << m_dindent << tempName << "->addLayout(" << varName << ");\n";
+ }
+
+ if (isGroupBox) {
+ m_output << m_indent << varName << "->setAlignment(Qt::AlignTop);\n";
+ } else {
+ // Suppress margin on a read child layout
+ const bool suppressMarginDefault = m_layoutChain.top();
+ int marginType = Use43UiFile;
+ if (oldLayoutProperties)
+ marginType = m_layoutMarginType;
+ m_LayoutDefaultHandler.writeProperties(m_indent, varName, properties, marginType, suppressMarginDefault, m_output);
+ }
+
+ m_layoutMarginType = SubLayoutMargin;
+
+ DomPropertyList propList = node->elementProperty();
+ if (m_layoutWidget) {
+ bool left, top, right, bottom;
+ left = top = right = bottom = false;
+ for (int i = 0; i < propList.size(); ++i) {
+ const DomProperty *p = propList.at(i);
+ const QString propertyName = p->attributeName();
+ if (propertyName == QLatin1String("leftMargin") && p->kind() == DomProperty::Number)
+ left = true;
+ else if (propertyName == QLatin1String("topMargin") && p->kind() == DomProperty::Number)
+ top = true;
+ else if (propertyName == QLatin1String("rightMargin") && p->kind() == DomProperty::Number)
+ right = true;
+ else if (propertyName == QLatin1String("bottomMargin") && p->kind() == DomProperty::Number)
+ bottom = true;
+ }
+ if (!left) {
+ DomProperty *p = new DomProperty();
+ p->setAttributeName(QLatin1String("leftMargin"));
+ p->setElementNumber(0);
+ propList.append(p);
+ }
+ if (!top) {
+ DomProperty *p = new DomProperty();
+ p->setAttributeName(QLatin1String("topMargin"));
+ p->setElementNumber(0);
+ propList.append(p);
+ }
+ if (!right) {
+ DomProperty *p = new DomProperty();
+ p->setAttributeName(QLatin1String("rightMargin"));
+ p->setElementNumber(0);
+ propList.append(p);
+ }
+ if (!bottom) {
+ DomProperty *p = new DomProperty();
+ p->setAttributeName(QLatin1String("bottomMargin"));
+ p->setElementNumber(0);
+ propList.append(p);
+ }
+ m_layoutWidget = false;
+ }
+
+ writeProperties(varName, className, propList, WritePropertyIgnoreMargin|WritePropertyIgnoreSpacing);
+
+ m_layoutChain.push(node);
+ TreeWalker::acceptLayout(node);
+ m_layoutChain.pop();
+
+ // Stretch? (Unless we are compiling for UIC3)
+ const QString numberNull = QString(QLatin1Char('0'));
+ writePropertyList(varName, QLatin1String("setStretch"), node->attributeStretch(), numberNull);
+ writePropertyList(varName, QLatin1String("setRowStretch"), node->attributeRowStretch(), numberNull);
+ writePropertyList(varName, QLatin1String("setColumnStretch"), node->attributeColumnStretch(), numberNull);
+ writePropertyList(varName, QLatin1String("setColumnMinimumWidth"), node->attributeColumnMinimumWidth(), numberNull);
+ writePropertyList(varName, QLatin1String("setRowMinimumHeight"), node->attributeRowMinimumHeight(), numberNull);
+}
+
+// Apply a comma-separated list of values using a function "setSomething(int idx, value)"
+void WriteInitialization::writePropertyList(const QString &varName,
+ const QString &setFunction,
+ const QString &value,
+ const QString &defaultValue)
+{
+ if (value.isEmpty())
+ return;
+ const QStringList list = value.split(QLatin1Char(','));
+ const int count = list.count();
+ for (int i = 0; i < count; i++)
+ if (list.at(i) != defaultValue)
+ m_output << m_indent << varName << "->" << setFunction << '(' << i << ", " << list.at(i) << ");\n";
+}
+
+void WriteInitialization::acceptSpacer(DomSpacer *node)
+{
+ m_output << m_indent << m_driver->findOrInsertSpacer(node) << " = ";
+ writeSpacerItem(node, m_output);
+ m_output << ";\n";
+}
+
+static inline QString formLayoutRole(int column, int colspan)
+{
+ if (colspan > 1)
+ return QLatin1String("QFormLayout::SpanningRole");
+ return column == 0 ? QLatin1String("QFormLayout::LabelRole") : QLatin1String("QFormLayout::FieldRole");
+}
+
+void WriteInitialization::acceptLayoutItem(DomLayoutItem *node)
+{
+ TreeWalker::acceptLayoutItem(node);
+
+ DomLayout *layout = m_layoutChain.top();
+
+ if (!layout)
+ return;
+
+ const QString layoutName = m_driver->findOrInsertLayout(layout);
+ const QString itemName = m_driver->findOrInsertLayoutItem(node);
+
+ QString addArgs;
+ QString methodPrefix = QLatin1String("add"); //Consistent API-design galore!
+ if (layout->attributeClass() == QLatin1String("QGridLayout")) {
+ const int row = node->attributeRow();
+ const int col = node->attributeColumn();
+
+ const int rowSpan = node->hasAttributeRowSpan() ? node->attributeRowSpan() : 1;
+ const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1;
+
+ addArgs = QString::fromLatin1("%1, %2, %3, %4, %5").arg(itemName).arg(row).arg(col).arg(rowSpan).arg(colSpan);
+ if (!node->attributeAlignment().isEmpty())
+ addArgs += QLatin1String(", ") + node->attributeAlignment();
+ } else {
+ if (layout->attributeClass() == QLatin1String("QFormLayout")) {
+ methodPrefix = QLatin1String("set");
+ const int row = node->attributeRow();
+ const int colSpan = node->hasAttributeColSpan() ? node->attributeColSpan() : 1;
+ const QString role = formLayoutRole(node->attributeColumn(), colSpan);
+ addArgs = QString::fromLatin1("%1, %2, %3").arg(row).arg(role).arg(itemName);
+ } else {
+ addArgs = itemName;
+ if (layout->attributeClass().contains(QLatin1String("Box")) && !node->attributeAlignment().isEmpty())
+ addArgs += QLatin1String(", 0, ") + node->attributeAlignment();
+ }
+ }
+
+ // figure out "add" method
+ m_output << "\n" << m_indent << layoutName << "->";
+ switch (node->kind()) {
+ case DomLayoutItem::Widget:
+ m_output << methodPrefix << "Widget(" << addArgs;
+ break;
+ case DomLayoutItem::Layout:
+ m_output << methodPrefix << "Layout(" << addArgs;
+ break;
+ case DomLayoutItem::Spacer:
+ m_output << methodPrefix << "Item(" << addArgs;
+ break;
+ case DomLayoutItem::Unknown:
+ Q_ASSERT( 0 );
+ break;
+ }
+ m_output << ");\n\n";
+}
+
+void WriteInitialization::acceptActionGroup(DomActionGroup *node)
+{
+ const QString actionName = m_driver->findOrInsertActionGroup(node);
+ QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());
+
+ if (m_actionGroupChain.top())
+ varName = m_driver->findOrInsertActionGroup(m_actionGroupChain.top());
+
+ m_output << m_indent << actionName << " = new QActionGroup(" << varName << ");\n";
+ writeProperties(actionName, QLatin1String("QActionGroup"), node->elementProperty());
+
+ m_actionGroupChain.push(node);
+ TreeWalker::acceptActionGroup(node);
+ m_actionGroupChain.pop();
+}
+
+void WriteInitialization::acceptAction(DomAction *node)
+{
+ if (node->hasAttributeMenu())
+ return;
+
+ const QString actionName = m_driver->findOrInsertAction(node);
+ m_registeredActions.insert(actionName, node);
+ QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());
+
+ if (m_actionGroupChain.top())
+ varName = m_driver->findOrInsertActionGroup(m_actionGroupChain.top());
+
+ m_output << m_indent << actionName << " = new QAction(" << varName << ");\n";
+ writeProperties(actionName, QLatin1String("QAction"), node->elementProperty());
+}
+
+void WriteInitialization::acceptActionRef(DomActionRef *node)
+{
+ QString actionName = node->attributeName();
+ const bool isSeparator = actionName == QLatin1String("separator");
+ bool isMenu = false;
+
+ QString varName = m_driver->findOrInsertWidget(m_widgetChain.top());
+
+ if (actionName.isEmpty() || !m_widgetChain.top()) {
+ return;
+ } else if (m_driver->actionGroupByName(actionName)) {
+ return;
+ } else if (DomWidget *w = m_driver->widgetByName(actionName)) {
+ isMenu = m_uic->isMenu(w->attributeClass());
+ bool inQ3ToolBar = m_uic->customWidgetsInfo()->extends(m_widgetChain.top()->attributeClass(), QLatin1String("Q3ToolBar"));
+ if (!isMenu && inQ3ToolBar) {
+ m_actionOut << m_indent << actionName << "->setParent(" << varName << ");\n";
+ return;
+ }
+ } else if (!(m_driver->actionByName(actionName) || isSeparator)) {
+ fprintf(stderr, "%s: Warning: action `%s' not declared\n",
+ qPrintable(m_option.messagePrefix()),
+ actionName.toLatin1().data());
+ return;
+ }
+
+ if (m_widgetChain.top() && isSeparator) {
+ // separator is always reserved!
+ m_actionOut << m_indent << varName << "->addSeparator();\n";
+ return;
+ }
+
+ if (isMenu)
+ actionName += QLatin1String("->menuAction()");
+
+ m_actionOut << m_indent << varName << "->addAction(" << actionName << ");\n";
+}
+
+void WriteInitialization::writeProperties(const QString &varName,
+ const QString &className,
+ const DomPropertyList &lst,
+ unsigned flags)
+{
+ const bool isTopLevel = m_widgetChain.count() == 1;
+
+ if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) {
+ DomPropertyMap properties = propertyMap(lst);
+ if (properties.contains(QLatin1String("control"))) {
+ DomProperty *p = properties.value(QLatin1String("control"));
+ m_output << m_indent << varName << "->setControl(QString::fromUtf8("
+ << fixString(toString(p->elementString()), m_dindent) << "));\n";
+ }
+ }
+
+ DomWidget *buttonGroupWidget = findWidget(QLatin1String("Q3ButtonGroup"));
+
+ QString indent;
+ if (!m_widgetChain.top()) {
+ indent = m_option.indent;
+ m_output << m_indent << "if (" << varName << "->objectName().isEmpty())\n";
+ }
+ if (!(flags & WritePropertyIgnoreObjectName))
+ m_output << m_indent << indent << varName
+ << "->setObjectName(QString::fromUtf8(" << fixString(varName, m_dindent) << "));\n";
+
+ int leftMargin, topMargin, rightMargin, bottomMargin;
+ leftMargin = topMargin = rightMargin = bottomMargin = -1;
+ bool frameShadowEncountered = false;
+
+ for (int i=0; i<lst.size(); ++i) {
+ const DomProperty *p = lst.at(i);
+ if (!checkProperty(m_option.inputFile, p))
+ continue;
+ const QString propertyName = p->attributeName();
+ QString propertyValue;
+
+ // special case for the property `geometry': Do not use position
+ if (isTopLevel && propertyName == QLatin1String("geometry") && p->elementRect()) {
+ const DomRect *r = p->elementRect();
+ m_output << m_indent << varName << "->resize(" << r->elementWidth() << ", " << r->elementHeight() << ");\n";
+ continue;
+ } else if (propertyName == QLatin1String("buttonGroupId")) { // Q3ButtonGroup support
+ if (buttonGroupWidget)
+ m_output << m_indent << m_driver->findOrInsertWidget(buttonGroupWidget) << "->insert("
+ << varName << ", " << p->elementNumber() << ");\n";
+ continue;
+ } else if (propertyName == QLatin1String("currentRow") // QListWidget::currentRow
+ && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QListWidget"))) {
+ m_delayedOut << m_indent << varName << "->setCurrentRow("
+ << p->elementNumber() << ");\n";
+ continue;
+ } else if (propertyName == QLatin1String("currentIndex") // set currentIndex later
+ && (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QComboBox"))
+ || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QStackedWidget"))
+ || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTabWidget"))
+ || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox")))) {
+ m_delayedOut << m_indent << varName << "->setCurrentIndex("
+ << p->elementNumber() << ");\n";
+ continue;
+ } else if (propertyName == QLatin1String("tabSpacing")
+ && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))) {
+ m_delayedOut << m_indent << varName << "->layout()->setSpacing("
+ << p->elementNumber() << ");\n";
+ continue;
+ } else if (propertyName == QLatin1String("control") // ActiveQt support
+ && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QAxWidget"))) {
+ // already done ;)
+ continue;
+ } else if (propertyName == QLatin1String("database")
+ && p->elementStringList()) {
+ // Sql support
+ continue;
+ } else if (propertyName == QLatin1String("frameworkCode")
+ && p->kind() == DomProperty::Bool) {
+ // Sql support
+ continue;
+ } else if (propertyName == QLatin1String("orientation")
+ && m_uic->customWidgetsInfo()->extends(className, QLatin1String("Line"))) {
+ // Line support
+ QString shape = QLatin1String("QFrame::HLine");
+ if (p->elementEnum() == QLatin1String("Qt::Vertical"))
+ shape = QLatin1String("QFrame::VLine");
+
+ m_output << m_indent << varName << "->setFrameShape(" << shape << ");\n";
+ // QFrame Default is 'Plain'. Make the line 'Sunken' unless otherwise specified
+ if (!frameShadowEncountered)
+ m_output << m_indent << varName << "->setFrameShadow(QFrame::Sunken);\n";
+ continue;
+ } else if ((flags & WritePropertyIgnoreMargin) && propertyName == QLatin1String("margin")) {
+ continue;
+ } else if ((flags & WritePropertyIgnoreSpacing) && propertyName == QLatin1String("spacing")) {
+ continue;
+ } else if (propertyName == QLatin1String("leftMargin") && p->kind() == DomProperty::Number) {
+ leftMargin = p->elementNumber();
+ continue;
+ } else if (propertyName == QLatin1String("topMargin") && p->kind() == DomProperty::Number) {
+ topMargin = p->elementNumber();
+ continue;
+ } else if (propertyName == QLatin1String("rightMargin") && p->kind() == DomProperty::Number) {
+ rightMargin = p->elementNumber();
+ continue;
+ } else if (propertyName == QLatin1String("bottomMargin") && p->kind() == DomProperty::Number) {
+ bottomMargin = p->elementNumber();
+ continue;
+ } else if (propertyName == QLatin1String("frameShadow"))
+ frameShadowEncountered = true;
+
+ bool stdset = m_stdsetdef;
+ if (p->hasAttributeStdset())
+ stdset = p->attributeStdset();
+
+ QString setFunction;
+
+ if (stdset) {
+ setFunction = QLatin1String("->set");
+ setFunction += propertyName.left(1).toUpper();
+ setFunction += propertyName.mid(1);
+ setFunction += QLatin1Char('(');
+ } else {
+ setFunction = QLatin1String("->setProperty(\"");
+ setFunction += propertyName;
+ setFunction += QLatin1String("\", QVariant(");
+ }
+
+ QString varNewName = varName;
+
+ switch (p->kind()) {
+ case DomProperty::Bool: {
+ propertyValue = p->elementBool();
+ break;
+ }
+ case DomProperty::Color:
+ propertyValue = domColor2QString(p->elementColor());
+ break;
+ case DomProperty::Cstring:
+ if (propertyName == QLatin1String("buddy") && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QLabel"))) {
+ m_buddies.append(Buddy(varName, p->elementCstring()));
+ } else {
+ if (stdset)
+ propertyValue = fixString(p->elementCstring(), m_dindent);
+ else {
+ propertyValue = QLatin1String("QByteArray(");
+ propertyValue += fixString(p->elementCstring(), m_dindent);
+ propertyValue += QLatin1Char(')');
+ }
+ }
+ break;
+ case DomProperty::Cursor:
+ propertyValue = QString::fromLatin1("QCursor(static_cast<Qt::CursorShape>(%1))")
+ .arg(p->elementCursor());
+ break;
+ case DomProperty::CursorShape:
+ if (p->hasAttributeStdset() && !p->attributeStdset())
+ varNewName += QLatin1String("->viewport()");
+ propertyValue = QString::fromLatin1("QCursor(Qt::%1)")
+ .arg(p->elementCursorShape());
+ break;
+ case DomProperty::Enum:
+ propertyValue = p->elementEnum();
+ if (!propertyValue.contains(QLatin1String("::"))) {
+ QString scope = className;
+ scope += QLatin1String("::");
+ propertyValue.prepend(scope);
+ }
+ break;
+ case DomProperty::Set:
+ propertyValue = p->elementSet();
+ break;
+ case DomProperty::Font:
+ propertyValue = writeFontProperties(p->elementFont());
+ break;
+ case DomProperty::IconSet:
+ propertyValue = writeIconProperties(p->elementIconSet());
+ break;
+ case DomProperty::Pixmap:
+ propertyValue = pixCall(p);
+ break;
+ case DomProperty::Palette: {
+ const DomPalette *pal = p->elementPalette();
+ const QString paletteName = m_driver->unique(QLatin1String("palette"));
+ m_output << m_indent << "QPalette " << paletteName << ";\n";
+
+ writeColorGroup(pal->elementActive(), QLatin1String("QPalette::Active"), paletteName);
+ writeColorGroup(pal->elementInactive(), QLatin1String("QPalette::Inactive"), paletteName);
+ writeColorGroup(pal->elementDisabled(), QLatin1String("QPalette::Disabled"), paletteName);
+
+ propertyValue = paletteName;
+ break;
+ }
+ case DomProperty::Point: {
+ const DomPoint *po = p->elementPoint();
+ propertyValue = QString::fromLatin1("QPoint(%1, %2)")
+ .arg(po->elementX()).arg(po->elementY());
+ break;
+ }
+ case DomProperty::PointF: {
+ const DomPointF *pof = p->elementPointF();
+ propertyValue = QString::fromLatin1("QPointF(%1, %2)")
+ .arg(pof->elementX()).arg(pof->elementY());
+ break;
+ }
+ case DomProperty::Rect: {
+ const DomRect *r = p->elementRect();
+ propertyValue = QString::fromLatin1("QRect(%1, %2, %3, %4)")
+ .arg(r->elementX()).arg(r->elementY())
+ .arg(r->elementWidth()).arg(r->elementHeight());
+ break;
+ }
+ case DomProperty::RectF: {
+ const DomRectF *rf = p->elementRectF();
+ propertyValue = QString::fromLatin1("QRectF(%1, %2, %3, %4)")
+ .arg(rf->elementX()).arg(rf->elementY())
+ .arg(rf->elementWidth()).arg(rf->elementHeight());
+ break;
+ }
+ case DomProperty::Locale: {
+ const DomLocale *locale = p->elementLocale();
+ propertyValue = QString::fromLatin1("QLocale(QLocale::%1, QLocale::%2)")
+ .arg(locale->attributeLanguage()).arg(locale->attributeCountry());
+ break;
+ }
+ case DomProperty::SizePolicy: {
+ const QString spName = writeSizePolicy( p->elementSizePolicy());
+ m_output << m_indent << spName << QString::fromLatin1(
+ ".setHeightForWidth(%1->sizePolicy().hasHeightForWidth());\n")
+ .arg(varName);
+
+ propertyValue = spName;
+ break;
+ }
+ case DomProperty::Size: {
+ const DomSize *s = p->elementSize();
+ propertyValue = QString::fromLatin1("QSize(%1, %2)")
+ .arg(s->elementWidth()).arg(s->elementHeight());
+ break;
+ }
+ case DomProperty::SizeF: {
+ const DomSizeF *sf = p->elementSizeF();
+ propertyValue = QString::fromLatin1("QSizeF(%1, %2)")
+ .arg(sf->elementWidth()).arg(sf->elementHeight());
+ break;
+ }
+ case DomProperty::String: {
+ if (propertyName == QLatin1String("objectName")) {
+ const QString v = p->elementString()->text();
+ if (v == varName)
+ break;
+
+ // ### qWarning("Deprecated: the property `objectName' is different from the variable name");
+ }
+
+ propertyValue = autoTrCall(p->elementString());
+ break;
+ }
+ case DomProperty::Number:
+ propertyValue = QString::number(p->elementNumber());
+ break;
+ case DomProperty::UInt:
+ propertyValue = QString::number(p->elementUInt());
+ propertyValue += QLatin1Char('u');
+ break;
+ case DomProperty::LongLong:
+ propertyValue = QLatin1String("Q_INT64_C(");
+ propertyValue += QString::number(p->elementLongLong());
+ propertyValue += QLatin1Char(')');;
+ break;
+ case DomProperty::ULongLong:
+ propertyValue = QLatin1String("Q_UINT64_C(");
+ propertyValue += QString::number(p->elementULongLong());
+ propertyValue += QLatin1Char(')');
+ break;
+ case DomProperty::Float:
+ propertyValue = QString::number(p->elementFloat());
+ break;
+ case DomProperty::Double:
+ propertyValue = QString::number(p->elementDouble());
+ break;
+ case DomProperty::Char: {
+ const DomChar *c = p->elementChar();
+ propertyValue = QString::fromLatin1("QChar(%1)")
+ .arg(c->elementUnicode());
+ break;
+ }
+ case DomProperty::Date: {
+ const DomDate *d = p->elementDate();
+ propertyValue = QString::fromLatin1("QDate(%1, %2, %3)")
+ .arg(d->elementYear())
+ .arg(d->elementMonth())
+ .arg(d->elementDay());
+ break;
+ }
+ case DomProperty::Time: {
+ const DomTime *t = p->elementTime();
+ propertyValue = QString::fromLatin1("QTime(%1, %2, %3)")
+ .arg(t->elementHour())
+ .arg(t->elementMinute())
+ .arg(t->elementSecond());
+ break;
+ }
+ case DomProperty::DateTime: {
+ const DomDateTime *dt = p->elementDateTime();
+ propertyValue = QString::fromLatin1("QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))")
+ .arg(dt->elementYear())
+ .arg(dt->elementMonth())
+ .arg(dt->elementDay())
+ .arg(dt->elementHour())
+ .arg(dt->elementMinute())
+ .arg(dt->elementSecond());
+ break;
+ }
+ case DomProperty::StringList:
+ propertyValue = QLatin1String("QStringList()");
+ if (p->elementStringList()->elementString().size()) {
+ const QStringList lst = p->elementStringList()->elementString();
+ for (int i=0; i<lst.size(); ++i) {
+ propertyValue += QLatin1String(" << QString::fromUtf8(");
+ propertyValue += fixString(lst.at(i), m_dindent);
+ propertyValue += QLatin1Char(')');
+ }
+ }
+ break;
+
+ case DomProperty::Url: {
+ const DomUrl* u = p->elementUrl();
+ propertyValue = QString::fromLatin1("QUrl(%1)")
+ .arg(fixString(u->elementString()->text(), m_dindent));
+ break;
+ }
+ case DomProperty::Brush:
+ propertyValue = writeBrushInitialization(p->elementBrush());
+ break;
+ case DomProperty::Unknown:
+ break;
+ }
+
+ if (propertyValue.size()) {
+ const char* defineC = 0;
+ if (propertyName == QLatin1String("toolTip"))
+ defineC = toolTipDefineC;
+ else if (propertyName == QLatin1String("whatsThis"))
+ defineC = whatsThisDefineC;
+ else if (propertyName == QLatin1String("statusTip"))
+ defineC = statusTipDefineC;
+ else if (propertyName == QLatin1String("accessibleName") || propertyName == QLatin1String("accessibleDescription"))
+ defineC = accessibilityDefineC;
+
+ QTextStream &o = autoTrOutput(p->elementString());
+
+ if (defineC)
+ openIfndef(o, QLatin1String(defineC));
+ o << m_indent << varNewName << setFunction << propertyValue;
+ if (!stdset)
+ o << ')';
+ o << ");\n";
+ if (defineC)
+ closeIfndef(o, QLatin1String(defineC));
+
+ if (varName == m_mainFormVarName && &o == &m_refreshOut) {
+ // this is the only place (currently) where we output mainForm name to the retranslateUi().
+ // Other places output merely instances of a certain class (which cannot be main form, e.g. QListWidget).
+ m_mainFormUsedInRetranslateUi = true;
+ }
+ }
+ }
+ if (leftMargin != -1 || topMargin != -1 || rightMargin != -1 || bottomMargin != -1) {
+ QString objectName = varName;
+ if (m_widgetChain.top()) {
+ const QString parentWidget = m_widgetChain.top()->attributeClass();
+
+ if (!m_layoutChain.top() && (m_uic->customWidgetsInfo()->extends(parentWidget, QLatin1String("Q3GroupBox"))
+ || m_uic->customWidgetsInfo()->extends(parentWidget, QLatin1String("Q3ButtonGroup")))) {
+ objectName = m_driver->findOrInsertWidget(m_widgetChain.top()) + QLatin1String("->layout()");
+ }
+ }
+ m_output << m_indent << objectName << QLatin1String("->setContentsMargins(")
+ << leftMargin << QLatin1String(", ")
+ << topMargin << QLatin1String(", ")
+ << rightMargin << QLatin1String(", ")
+ << bottomMargin << QLatin1String(");\n");
+ }
+}
+
+QString WriteInitialization::writeSizePolicy(const DomSizePolicy *sp)
+{
+
+ // check cache
+ const SizePolicyHandle sizePolicyHandle(sp);
+ const SizePolicyNameMap::const_iterator it = m_sizePolicyNameMap.constFind(sizePolicyHandle);
+ if ( it != m_sizePolicyNameMap.constEnd()) {
+ return it.value();
+ }
+
+
+ // insert with new name
+ const QString spName = m_driver->unique(QLatin1String("sizePolicy"));
+ m_sizePolicyNameMap.insert(sizePolicyHandle, spName);
+
+ m_output << m_indent << "QSizePolicy " << spName;
+ do {
+ if (sp->hasElementHSizeType() && sp->hasElementVSizeType()) {
+ m_output << "(static_cast<QSizePolicy::Policy>(" << sp->elementHSizeType()
+ << "), static_cast<QSizePolicy::Policy>(" << sp->elementVSizeType() << "));\n";
+ break;
+ }
+ if (sp->hasAttributeHSizeType() && sp->hasAttributeVSizeType()) {
+ m_output << "(QSizePolicy::" << sp->attributeHSizeType() << ", QSizePolicy::"
+ << sp->attributeVSizeType() << ");\n";
+ break;
+ }
+ m_output << ";\n";
+ } while (false);
+
+ m_output << m_indent << spName << ".setHorizontalStretch("
+ << sp->elementHorStretch() << ");\n";
+ m_output << m_indent << spName << ".setVerticalStretch("
+ << sp->elementVerStretch() << ");\n";
+ return spName;
+}
+// Check for a font with the given properties in the FontPropertiesNameMap
+// or create a new one. Returns the name.
+
+QString WriteInitialization::writeFontProperties(const DomFont *f)
+{
+ // check cache
+ const FontHandle fontHandle(f);
+ const FontPropertiesNameMap::const_iterator it = m_fontPropertiesNameMap.constFind(fontHandle);
+ if ( it != m_fontPropertiesNameMap.constEnd()) {
+ return it.value();
+ }
+
+ // insert with new name
+ const QString fontName = m_driver->unique(QLatin1String("font"));
+ m_fontPropertiesNameMap.insert(FontHandle(f), fontName);
+
+ m_output << m_indent << "QFont " << fontName << ";\n";
+ if (f->hasElementFamily() && !f->elementFamily().isEmpty()) {
+ m_output << m_indent << fontName << ".setFamily(QString::fromUtf8(" << fixString(f->elementFamily(), m_dindent)
+ << "));\n";
+ }
+ if (f->hasElementPointSize() && f->elementPointSize() > 0) {
+ m_output << m_indent << fontName << ".setPointSize(" << f->elementPointSize()
+ << ");\n";
+ }
+
+ if (f->hasElementBold()) {
+ m_output << m_indent << fontName << ".setBold("
+ << (f->elementBold() ? "true" : "false") << ");\n";
+ }
+ if (f->hasElementItalic()) {
+ m_output << m_indent << fontName << ".setItalic("
+ << (f->elementItalic() ? "true" : "false") << ");\n";
+ }
+ if (f->hasElementUnderline()) {
+ m_output << m_indent << fontName << ".setUnderline("
+ << (f->elementUnderline() ? "true" : "false") << ");\n";
+ }
+ if (f->hasElementWeight() && f->elementWeight() > 0) {
+ m_output << m_indent << fontName << ".setWeight("
+ << f->elementWeight() << ");" << endl;
+ }
+ if (f->hasElementStrikeOut()) {
+ m_output << m_indent << fontName << ".setStrikeOut("
+ << (f->elementStrikeOut() ? "true" : "false") << ");\n";
+ }
+ if (f->hasElementKerning()) {
+ m_output << m_indent << fontName << ".setKerning("
+ << (f->elementKerning() ? "true" : "false") << ");\n";
+ }
+ if (f->hasElementAntialiasing()) {
+ m_output << m_indent << fontName << ".setStyleStrategy("
+ << (f->elementAntialiasing() ? "QFont::PreferDefault" : "QFont::NoAntialias") << ");\n";
+ }
+ if (f->hasElementStyleStrategy()) {
+ m_output << m_indent << fontName << ".setStyleStrategy(QFont::"
+ << f->elementStyleStrategy() << ");\n";
+ }
+ return fontName;
+}
+
+// Post 4.4 write resource icon
+static void writeResourceIcon(QTextStream &output,
+ const QString &iconName,
+ const QString &indent,
+ const DomResourceIcon *i)
+{
+ if (i->hasElementNormalOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOff()->text(), indent) << "), QSize(), QIcon::Normal, QIcon::Off);\n";
+ if (i->hasElementNormalOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementNormalOn()->text(), indent) << "), QSize(), QIcon::Normal, QIcon::On);\n";
+ if (i->hasElementDisabledOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOff()->text(), indent) << "), QSize(), QIcon::Disabled, QIcon::Off);\n";
+ if (i->hasElementDisabledOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementDisabledOn()->text(), indent) << "), QSize(), QIcon::Disabled, QIcon::On);\n";
+ if (i->hasElementActiveOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOff()->text(), indent) << "), QSize(), QIcon::Active, QIcon::Off);\n";
+ if (i->hasElementActiveOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementActiveOn()->text(), indent) << "), QSize(), QIcon::Active, QIcon::On);\n";
+ if (i->hasElementSelectedOff())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOff()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::Off);\n";
+ if (i->hasElementSelectedOn())
+ output << indent << iconName << ".addFile(QString::fromUtf8(" << fixString(i->elementSelectedOn()->text(), indent) << "), QSize(), QIcon::Selected, QIcon::On);\n";
+}
+
+QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
+{
+ // check cache
+ const IconHandle iconHandle(i);
+ const IconPropertiesNameMap::const_iterator it = m_iconPropertiesNameMap.constFind(iconHandle);
+ if (it != m_iconPropertiesNameMap.constEnd()) {
+ return it.value();
+ }
+
+ // insert with new name
+ const QString iconName = m_driver->unique(QLatin1String("icon"));
+ m_iconPropertiesNameMap.insert(IconHandle(i), iconName);
+ if (isIconFormat44(i)) {
+ if (i->attributeTheme().isEmpty()) {
+ // No theme: Write resource icon as is
+ m_output << m_indent << "QIcon " << iconName << ";\n";
+ writeResourceIcon(m_output, iconName, m_indent, i);
+ } else {
+ // Theme: Generate code to check the theme and default to resource
+ const QString themeIconName = fixString(i->attributeTheme(), QString());
+ if (iconHasStatePixmaps(i)) {
+ // Theme + default state pixmaps:
+ // Generate code to check the theme and default to state pixmaps
+ m_output << m_indent << "QIcon " << iconName << ";\n";
+ const char themeNameStringVariableC[] = "iconThemeName";
+ // Store theme name in a variable
+ m_output << m_indent;
+ if (m_firstThemeIcon) { // Declare variable string
+ m_output << "QString ";
+ m_firstThemeIcon = false;
+ }
+ m_output << themeNameStringVariableC << " = QString::fromUtf8("
+ << themeIconName << ");\n";
+ m_output << m_indent << "if (QIcon::hasThemeIcon("
+ << themeNameStringVariableC
+ << ")) {\n"
+ << m_dindent << iconName << " = QIcon::fromTheme(" << themeNameStringVariableC << ");\n"
+ << m_indent << "} else {\n";
+ writeResourceIcon(m_output, iconName, m_dindent, i);
+ m_output << m_indent << "}\n";
+ } else {
+ // Theme, but no state pixmaps: Construct from theme directly.
+ m_output << m_indent << "QIcon " << iconName
+ << "(QIcon::fromTheme(QString::fromUtf8("
+ << themeIconName << ")));\n";
+ } // Theme, but not state
+ } // >= 4.4
+ } else { // pre-4.4 legacy
+ m_output << m_indent << "const QIcon " << iconName << " = " << pixCall(QLatin1String("QIcon"), i->text())<< ";\n";
+ }
+ return iconName;
+}
+
+QString WriteInitialization::domColor2QString(const DomColor *c)
+{
+ if (c->hasAttributeAlpha())
+ return QString::fromLatin1("QColor(%1, %2, %3, %4)")
+ .arg(c->elementRed())
+ .arg(c->elementGreen())
+ .arg(c->elementBlue())
+ .arg(c->attributeAlpha());
+ return QString::fromLatin1("QColor(%1, %2, %3)")
+ .arg(c->elementRed())
+ .arg(c->elementGreen())
+ .arg(c->elementBlue());
+}
+
+void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName)
+{
+ if (!colorGroup)
+ return;
+
+ // old format
+ const QList<DomColor*> colors = colorGroup->elementColor();
+ for (int i=0; i<colors.size(); ++i) {
+ const DomColor *color = colors.at(i);
+
+ m_output << m_indent << paletteName << ".setColor(" << group
+ << ", " << "static_cast<QPalette::ColorRole>(" << QString::number(i) << ')'
+ << ", " << domColor2QString(color)
+ << ");\n";
+ }
+
+ // new format
+ const QList<DomColorRole *> colorRoles = colorGroup->elementColorRole();
+ QListIterator<DomColorRole *> itRole(colorRoles);
+ while (itRole.hasNext()) {
+ const DomColorRole *colorRole = itRole.next();
+ if (colorRole->hasAttributeRole()) {
+ const QString brushName = writeBrushInitialization(colorRole->elementBrush());
+ m_output << m_indent << paletteName << ".setBrush(" << group
+ << ", " << "QPalette::" << colorRole->attributeRole()
+ << ", " << brushName << ");\n";
+ }
+ }
+}
+
+// Write initialization for brush unless it is found in the cache. Returns the name to use
+// in an expression.
+QString WriteInitialization::writeBrushInitialization(const DomBrush *brush)
+{
+ // Simple solid, colored brushes are cached
+ const bool solidColoredBrush = !brush->hasAttributeBrushStyle() || brush->attributeBrushStyle() == QLatin1String("SolidPattern");
+ uint rgb = 0;
+ if (solidColoredBrush) {
+ if (const DomColor *color = brush->elementColor()) {
+ rgb = ((color->elementRed() & 0xFF) << 24) |
+ ((color->elementGreen() & 0xFF) << 16) |
+ ((color->elementBlue() & 0xFF) << 8) |
+ ((color->attributeAlpha() & 0xFF));
+ const ColorBrushHash::const_iterator cit = m_colorBrushHash.constFind(rgb);
+ if (cit != m_colorBrushHash.constEnd())
+ return cit.value();
+ }
+ }
+ // Create and enter into cache if simple
+ const QString brushName = m_driver->unique(QLatin1String("brush"));
+ writeBrush(brush, brushName);
+ if (solidColoredBrush)
+ m_colorBrushHash.insert(rgb, brushName);
+ return brushName;
+}
+
+void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brushName)
+{
+ QString style = QLatin1String("SolidPattern");
+ if (brush->hasAttributeBrushStyle())
+ style = brush->attributeBrushStyle();
+
+ if (style == QLatin1String("LinearGradientPattern") ||
+ style == QLatin1String("RadialGradientPattern") ||
+ style == QLatin1String("ConicalGradientPattern")) {
+ const DomGradient *gradient = brush->elementGradient();
+ const QString gradientType = gradient->attributeType();
+ const QString gradientName = m_driver->unique(QLatin1String("gradient"));
+ if (gradientType == QLatin1String("LinearGradient")) {
+ m_output << m_indent << "QLinearGradient " << gradientName
+ << '(' << gradient->attributeStartX()
+ << ", " << gradient->attributeStartY()
+ << ", " << gradient->attributeEndX()
+ << ", " << gradient->attributeEndY() << ");\n";
+ } else if (gradientType == QLatin1String("RadialGradient")) {
+ m_output << m_indent << "QRadialGradient " << gradientName
+ << '(' << gradient->attributeCentralX()
+ << ", " << gradient->attributeCentralY()
+ << ", " << gradient->attributeRadius()
+ << ", " << gradient->attributeFocalX()
+ << ", " << gradient->attributeFocalY() << ");\n";
+ } else if (gradientType == QLatin1String("ConicalGradient")) {
+ m_output << m_indent << "QConicalGradient " << gradientName
+ << '(' << gradient->attributeCentralX()
+ << ", " << gradient->attributeCentralY()
+ << ", " << gradient->attributeAngle() << ");\n";
+ }
+
+ m_output << m_indent << gradientName << ".setSpread(QGradient::"
+ << gradient->attributeSpread() << ");\n";
+
+ if (gradient->hasAttributeCoordinateMode()) {
+ m_output << m_indent << gradientName << ".setCoordinateMode(QGradient::"
+ << gradient->attributeCoordinateMode() << ");\n";
+ }
+
+ const QList<DomGradientStop *> stops = gradient->elementGradientStop();
+ QListIterator<DomGradientStop *> it(stops);
+ while (it.hasNext()) {
+ const DomGradientStop *stop = it.next();
+ const DomColor *color = stop->elementColor();
+ m_output << m_indent << gradientName << ".setColorAt("
+ << stop->attributePosition() << ", "
+ << domColor2QString(color) << ");\n";
+ }
+ m_output << m_indent << "QBrush " << brushName << '('
+ << gradientName << ");\n";
+ } else if (style == QLatin1String("TexturePattern")) {
+ const DomProperty *property = brush->elementTexture();
+ const QString iconValue = iconCall(property);
+
+ m_output << m_indent << "QBrush " << brushName << " = QBrush("
+ << iconValue << ");\n";
+ } else {
+ const DomColor *color = brush->elementColor();
+ m_output << m_indent << "QBrush " << brushName << '('
+ << domColor2QString(color) << ");\n";
+
+ m_output << m_indent << brushName << ".setStyle("
+ << "Qt::" << style << ");\n";
+ }
+}
+
+void WriteInitialization::acceptCustomWidget(DomCustomWidget *node)
+{
+ Q_UNUSED(node);
+}
+
+void WriteInitialization::acceptCustomWidgets(DomCustomWidgets *node)
+{
+ Q_UNUSED(node);
+}
+
+void WriteInitialization::acceptTabStops(DomTabStops *tabStops)
+{
+ QString lastName;
+
+ const QStringList l = tabStops->elementTabStop();
+ for (int i=0; i<l.size(); ++i) {
+ const QString name = l.at(i);
+
+ if (!m_registeredWidgets.contains(name)) {
+ fprintf(stderr, "%s: Warning: Tab-stop assignment: '%s' is not a valid widget.\n",
+ qPrintable(m_option.messagePrefix()),
+ name.toLatin1().data());
+ continue;
+ }
+
+ if (i == 0) {
+ lastName = name;
+ continue;
+ } else if (name.isEmpty() || lastName.isEmpty()) {
+ continue;
+ }
+
+ m_output << m_indent << "QWidget::setTabOrder(" << lastName << ", " << name << ");\n";
+
+ lastName = name;
+ }
+}
+
+void WriteInitialization::initializeQ3ListBox(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString className = w->attributeClass();
+
+ const QList<DomItem*> items = w->elementItem();
+
+ if (items.isEmpty())
+ return;
+
+ m_refreshOut << m_indent << varName << "->clear();\n";
+
+ 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("pixmap"));
+ if (!(text || pixmap))
+ continue;
+
+ m_refreshOut << m_indent << varName << "->insertItem(";
+ if (pixmap) {
+ m_refreshOut << pixCall(pixmap);
+
+ if (text)
+ m_refreshOut << ", ";
+ }
+ if (text)
+ m_refreshOut << trCall(text->elementString());
+ m_refreshOut << ");\n";
+ }
+}
+
+void WriteInitialization::initializeQ3IconView(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString className = w->attributeClass();
+
+ const QList<DomItem*> items = w->elementItem();
+
+ if (items.isEmpty())
+ return;
+
+ m_refreshOut << m_indent << varName << "->clear();\n";
+
+ 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("pixmap"));
+ if (!(text || pixmap))
+ continue;
+
+ const QString itemName = m_driver->unique(QLatin1String("__item"));
+ m_refreshOut << "\n";
+ m_refreshOut << m_indent << "Q3IconViewItem *" << itemName << " = new Q3IconViewItem(" << varName << ");\n";
+
+ if (pixmap) {
+ m_refreshOut << m_indent << itemName << "->setPixmap(" << pixCall(pixmap) << ");\n";
+ }
+
+ if (text) {
+ m_refreshOut << m_indent << itemName << "->setText(" << trCall(text->elementString()) << ");\n";
+ }
+ }
+}
+
+void WriteInitialization::initializeQ3ListView(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString className = w->attributeClass();
+
+ // columns
+ const QList<DomColumn*> columns = w->elementColumn();
+ for (int i=0; i<columns.size(); ++i) {
+ const DomColumn *column = columns.at(i);
+
+ const DomPropertyMap properties = propertyMap(column->elementProperty());
+ const DomProperty *text = properties.value(QLatin1String("text"));
+ const DomProperty *pixmap = properties.value(QLatin1String("pixmap"));
+ const DomProperty *clickable = properties.value(QLatin1String("clickable"));
+ const DomProperty *resizable = properties.value(QLatin1String("resizable"));
+
+ const QString txt = trCall(text->elementString());
+ m_output << m_indent << varName << "->addColumn(" << txt << ");\n";
+ m_refreshOut << m_indent << varName << "->header()->setLabel(" << i << ", " << txt << ");\n";
+
+ if (pixmap) {
+ m_output << m_indent << varName << "->header()->setLabel("
+ << varName << "->header()->count() - 1, " << pixCall(pixmap) << ", " << txt << ");\n";
+ }
+
+ if (clickable != 0) {
+ m_output << m_indent << varName << "->header()->setClickEnabled(" << clickable->elementBool() << ", " << varName << "->header()->count() - 1);\n";
+ }
+
+ if (resizable != 0) {
+ m_output << m_indent << varName << "->header()->setResizeEnabled(" << resizable->elementBool() << ", " << varName << "->header()->count() - 1);\n";
+ }
+ }
+
+ if (w->elementItem().size()) {
+ m_refreshOut << m_indent << varName << "->clear();\n";
+
+ initializeQ3ListViewItems(className, varName, w->elementItem());
+ }
+}
+
+void WriteInitialization::initializeQ3ListViewItems(const QString &className, const QString &varName, const QList<DomItem *> &items)
+{
+ if (items.isEmpty())
+ return;
+
+ // items
+ for (int i=0; i<items.size(); ++i) {
+ const DomItem *item = items.at(i);
+
+ const QString itemName = m_driver->unique(QLatin1String("__item"));
+ m_refreshOut << "\n";
+ m_refreshOut << m_indent << "Q3ListViewItem *" << itemName << " = new Q3ListViewItem(" << varName << ");\n";
+
+ int textCount = 0, pixCount = 0;
+ const DomPropertyList properties = item->elementProperty();
+ for (int i=0; i<properties.size(); ++i) {
+ const DomProperty *p = properties.at(i);
+ if (p->attributeName() == QLatin1String("text"))
+ m_refreshOut << m_indent << itemName << "->setText(" << textCount++ << ", "
+ << trCall(p->elementString()) << ");\n";
+
+ if (p->attributeName() == QLatin1String("pixmap"))
+ m_refreshOut << m_indent << itemName << "->setPixmap(" << pixCount++ << ", "
+ << pixCall(p) << ");\n";
+ }
+
+ if (item->elementItem().size()) {
+ m_refreshOut << m_indent << itemName << "->setOpen(true);\n";
+ initializeQ3ListViewItems(className, itemName, item->elementItem());
+ }
+ }
+}
+
+
+void WriteInitialization::initializeQ3Table(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString className = w->attributeClass();
+
+ // columns
+ const QList<DomColumn*> columns = w->elementColumn();
+
+ for (int i=0; i<columns.size(); ++i) {
+ const DomColumn *column = columns.at(i);
+
+ const DomPropertyMap properties = propertyMap(column->elementProperty());
+ const DomProperty *text = properties.value(QLatin1String("text"));
+ const DomProperty *pixmap = properties.value(QLatin1String("pixmap"));
+
+ m_refreshOut << m_indent << varName << "->horizontalHeader()->setLabel(" << i << ", ";
+ if (pixmap) {
+ m_refreshOut << pixCall(pixmap) << ", ";
+ }
+ m_refreshOut << trCall(text->elementString()) << ");\n";
+ }
+
+ // rows
+ const QList<DomRow*> rows = w->elementRow();
+ for (int i=0; i<rows.size(); ++i) {
+ const DomRow *row = rows.at(i);
+
+ const DomPropertyMap properties = propertyMap(row->elementProperty());
+ const DomProperty *text = properties.value(QLatin1String("text"));
+ const DomProperty *pixmap = properties.value(QLatin1String("pixmap"));
+
+ m_refreshOut << m_indent << varName << "->verticalHeader()->setLabel(" << i << ", ";
+ if (pixmap) {
+ m_refreshOut << pixCall(pixmap) << ", ";
+ }
+ m_refreshOut << trCall(text->elementString()) << ");\n";
+ }
+
+
+ //initializeQ3TableItems(className, varName, w->elementItem());
+}
+
+void WriteInitialization::initializeQ3TableItems(const QString &className, const QString &varName, const QList<DomItem *> &items)
+{
+ Q_UNUSED(className);
+ Q_UNUSED(varName);
+ Q_UNUSED(items);
+}
+
+QString WriteInitialization::iconCall(const DomProperty *icon)
+{
+ if (icon->kind() == DomProperty::IconSet)
+ return writeIconProperties(icon->elementIconSet());
+ return pixCall(icon);
+}
+
+QString WriteInitialization::pixCall(const DomProperty *p) const
+{
+ QString type, s;
+ switch (p->kind()) {
+ case DomProperty::IconSet:
+ type = QLatin1String("QIcon");
+ s = p->elementIconSet()->text();
+ break;
+ case DomProperty::Pixmap:
+ type = QLatin1String("QPixmap");
+ s = p->elementPixmap()->text();
+ break;
+ default:
+ qWarning("%s: Warning: Unknown icon format encountered. The ui-file was generated with a too-recent version of Designer.",
+ qPrintable(m_option.messagePrefix()));
+ return QLatin1String("QIcon()");
+ break;
+ }
+ return pixCall(type, s);
+}
+
+QString WriteInitialization::pixCall(const QString &t, const QString &text) const
+{
+ QString type = t;
+ if (text.isEmpty()) {
+ 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();
+ QString rc = QLatin1String("QPixmap(QString::fromUtf8(\":/");
+ rc += m_generatedClass;
+ rc += QLatin1String("/images/");
+ rc += text;
+ rc += QLatin1Char('.');
+ rc += extension;
+ rc += QLatin1String("\"))");
+ return rc;
+ }
+ QString rc = WriteIconInitialization::iconFromDataFunction();
+ rc += QLatin1Char('(');
+ rc += text;
+ rc += QLatin1String("_ID)");
+ return rc;
+ }
+
+ QString pixFunc = m_uic->pixmapFunction();
+ if (pixFunc.isEmpty())
+ pixFunc = QLatin1String("QString::fromUtf8");
+
+ type += QLatin1Char('(');
+ type += pixFunc;
+ type += QLatin1Char('(');
+ type += fixString(text, m_dindent);
+ type += QLatin1String("))");
+ return type;
+}
+
+void WriteInitialization::initializeComboBox3(DomWidget *w)
+{
+ const QList<DomItem*> items = w->elementItem();
+ if (items.empty())
+ return;
+ // Basic legacy Qt3 support, write out translatable text items, ignore pixmaps
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString textProperty = QLatin1String("text");
+
+ m_refreshOut << m_indent << varName << "->clear();\n";
+ m_refreshOut << m_indent << varName << "->insertStringList(QStringList()" << '\n';
+ const int itemCount = items.size();
+ for (int i = 0; i< itemCount; ++i) {
+ const DomItem *item = items.at(i);
+ if (const DomProperty *text = propertyMap(item->elementProperty()).value(textProperty))
+ m_refreshOut << m_indent << " << " << autoTrCall(text->elementString()) << "\n";
+ }
+ m_refreshOut << m_indent << ", 0);\n";
+}
+
+void WriteInitialization::initializeComboBox(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString className = w->attributeClass();
+
+ const QList<DomItem*> 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) {
+ 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
+ }
+
+ 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";
+ }
+ }
+ m_refreshOut << "\n";
+ }
+}
+
+QString WriteInitialization::disableSorting(DomWidget *w, const QString &varName)
+{
+ // turn off sortingEnabled to force programmatic item order (setItem())
+ QString tempName;
+ if (!w->elementItem().isEmpty()) {
+ tempName = m_driver->unique(QLatin1String("__sortingEnabled"));
+ m_refreshOut << "\n";
+ m_refreshOut << m_indent << "const bool " << tempName
+ << " = " << varName << "->isSortingEnabled();\n";
+ m_refreshOut << m_indent << varName << "->setSortingEnabled(false);\n";
+ }
+ return tempName;
+}
+
+void WriteInitialization::enableSorting(DomWidget *w, const QString &varName, const QString &tempName)
+{
+ if (!w->elementItem().isEmpty()) {
+ m_refreshOut << m_indent << varName << "->setSortingEnabled(" << tempName << ");\n\n";
+ }
+}
+
+/*
+ * Initializers are just strings containing the function call and need to be prepended
+ * the line indentation and the object they are supposed to initialize.
+ * String initializers come with a preprocessor conditional (ifdef), so the code
+ * compiles with QT_NO_xxx. A null pointer means no conditional. String initializers
+ * are written to the retranslateUi() function, others to setupUi().
+ */
+
+
+/*!
+ Create non-string inititializer.
+ \param value the value to initialize the attribute with. May be empty, in which case
+ the initializer is omitted.
+ See above for other parameters.
+*/
+void WriteInitialization::addInitializer(Item *item,
+ const QString &name, int column, const QString &value, const QString &directive, bool translatable) const
+{
+ if (!value.isEmpty())
+ item->addSetter(QLatin1String("->set") + name.at(0).toUpper() + name.mid(1) +
+ QLatin1Char('(') + (column < 0 ? QString() : QString::number(column) +
+ QLatin1String(", ")) + value + QLatin1String(");"), directive, translatable);
+}
+
+/*!
+ Create string inititializer.
+ \param initializers in/out list of inializers
+ \param properties map property name -> property to extract data from
+ \param name the property to extract
+ \param col the item column to generate the initializer for. This is relevant for
+ tree widgets only. If it is -1, no column index will be generated.
+ \param ifdef preprocessor symbol for disabling compilation of this initializer
+*/
+void WriteInitialization::addStringInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column, const QString &directive) const
+{
+ if (const DomProperty *p = properties.value(name)) {
+ DomString *str = p->elementString();
+ QString text = toString(str);
+ if (!text.isEmpty()) {
+ bool translatable = needsTranslation(str);
+ QString value = autoTrCall(str);
+ addInitializer(item, name, column, value, directive, translatable);
+ }
+ }
+}
+
+void WriteInitialization::addBrushInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column)
+{
+ if (const DomProperty *p = properties.value(name)) {
+ if (p->elementBrush())
+ addInitializer(item, name, column, writeBrushInitialization(p->elementBrush()));
+ else if (p->elementColor())
+ addInitializer(item, name, column, domColor2QString(p->elementColor()));
+ }
+}
+
+/*!
+ Create inititializer for a flag value in the Qt namespace.
+ If the named property is not in the map, the initializer is omitted.
+*/
+void WriteInitialization::addQtFlagsInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column) const
+{
+ if (const DomProperty *p = properties.value(name)) {
+ QString v = p->elementSet();
+ if (!v.isEmpty()) {
+ v.replace(QLatin1Char('|'), QLatin1String("|Qt::"));
+ addInitializer(item, name, column, QLatin1String("Qt::") + v);
+ }
+ }
+}
+
+/*!
+ Create inititializer for an enum value in the Qt namespace.
+ If the named property is not in the map, the initializer is omitted.
+*/
+void WriteInitialization::addQtEnumInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column) const
+{
+ if (const DomProperty *p = properties.value(name)) {
+ QString v = p->elementEnum();
+ if (!v.isEmpty())
+ addInitializer(item, name, column, QLatin1String("Qt::") + v);
+ }
+}
+
+/*!
+ Create inititializers for all common properties that may be bound to a column.
+*/
+void WriteInitialization::addCommonInitializers(Item *item,
+ const DomPropertyMap &properties, int column)
+{
+ if (const DomProperty *icon = properties.value(QLatin1String("icon")))
+ addInitializer(item, QLatin1String("icon"), column, iconCall(icon));
+ addBrushInitializer(item, properties, QLatin1String("foreground"), column);
+ addBrushInitializer(item, properties, QLatin1String("background"), column);
+ if (const DomProperty *font = properties.value(QLatin1String("font")))
+ addInitializer(item, QLatin1String("font"), column, writeFontProperties(font->elementFont()));
+ addQtFlagsInitializer(item, properties, QLatin1String("textAlignment"), column);
+ addQtEnumInitializer(item, properties, QLatin1String("checkState"), column);
+ addStringInitializer(item, properties, QLatin1String("text"), column);
+ addStringInitializer(item, properties, QLatin1String("toolTip"), column, QLatin1String(toolTipDefineC));
+ addStringInitializer(item, properties, QLatin1String("whatsThis"), column, QLatin1String(whatsThisDefineC));
+ addStringInitializer(item, properties, QLatin1String("statusTip"), column, QLatin1String(statusTipDefineC));
+}
+
+void WriteInitialization::initializeListWidget(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+ const QString className = w->attributeClass();
+
+ const QList<DomItem*> items = w->elementItem();
+
+ if (items.isEmpty())
+ return;
+
+ QString tempName = disableSorting(w, varName);
+ // items
+ // TODO: the generated code should be data-driven to reduce its size
+ for (int i = 0; i < items.size(); ++i) {
+ const DomItem *domItem = items.at(i);
+
+ const DomPropertyMap properties = propertyMap(domItem->elementProperty());
+
+ Item item(QLatin1String("QListWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ addQtFlagsInitializer(&item, properties, QLatin1String("flags"));
+ addCommonInitializers(&item, properties);
+
+ item.writeSetupUi(varName);
+ item.writeRetranslateUi(varName + QLatin1String("->item(") + QString::number(i) + QLatin1Char(')'));
+ }
+ enableSorting(w, varName, tempName);
+}
+
+void WriteInitialization::initializeTreeWidget(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+
+ // columns
+ Item item(QLatin1String("QTreeWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+
+ const QList<DomColumn*> columns = w->elementColumn();
+ for (int i = 0; i < columns.size(); ++i) {
+ const DomColumn *column = columns.at(i);
+
+ const DomPropertyMap properties = propertyMap(column->elementProperty());
+ addCommonInitializers(&item, properties, i);
+ }
+ const QString itemName = item.writeSetupUi(QString(), Item::DontConstruct);
+ item.writeRetranslateUi(varName + QLatin1String("->headerItem()"));
+ if (!itemName.isNull())
+ m_output << m_indent << varName << "->setHeaderItem(" << itemName << ");\n";
+
+ if (w->elementItem().size() == 0)
+ return;
+
+ QString tempName = disableSorting(w, varName);
+
+ QList<Item *> items = initializeTreeWidgetItems(w->elementItem());
+ for (int i = 0; i < items.count(); i++) {
+ Item *itm = items[i];
+ itm->writeSetupUi(varName);
+ itm->writeRetranslateUi(varName + QLatin1String("->topLevelItem(") + QString::number(i) + QLatin1Char(')'));
+ delete itm;
+ }
+
+ enableSorting(w, varName, tempName);
+}
+
+/*!
+ Create and write out initializers for tree widget items.
+ This function makes sure that only needed items are fetched (subject to preprocessor
+ conditionals), that each item is fetched from its parent widget/item exactly once
+ and that no temporary variables are created for items that are needed only once. As
+ fetches are built top-down from the root, but determining how often and under which
+ 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)
+{
+ // items
+ QList<Item *> items;
+
+ for (int i = 0; i < domItems.size(); ++i) {
+ const DomItem *domItem = domItems.at(i);
+
+ Item *item = new Item(QLatin1String("QTreeWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ items << item;
+
+ QHash<QString, DomProperty *> map;
+
+ int col = -1;
+ const DomPropertyList properties = domItem->elementProperty();
+ for (int j = 0; j < properties.size(); ++j) {
+ DomProperty *p = properties.at(j);
+ if (p->attributeName() == QLatin1String("text")) {
+ if (!map.isEmpty()) {
+ addCommonInitializers(item, map, col);
+ map.clear();
+ }
+ col++;
+ }
+ map.insert(p->attributeName(), p);
+ }
+ addCommonInitializers(item, map, col);
+ // AbstractFromBuilder saves flags last, so they always end up in the last column's map.
+ addQtFlagsInitializer(item, map, QLatin1String("flags"));
+
+ QList<Item *> subItems = initializeTreeWidgetItems(domItem->elementItem());
+ foreach (Item *subItem, subItems)
+ item->addChild(subItem);
+ }
+ return items;
+}
+
+void WriteInitialization::initializeTableWidget(DomWidget *w)
+{
+ const QString varName = m_driver->findOrInsertWidget(w);
+
+ // columns
+ const QList<DomColumn *> columns = w->elementColumn();
+
+ if (columns.size() != 0) {
+ m_output << m_indent << "if (" << varName << "->columnCount() < " << columns.size() << ")\n"
+ << m_dindent << varName << "->setColumnCount(" << columns.size() << ");\n";
+ }
+
+ for (int i = 0; i < columns.size(); ++i) {
+ const DomColumn *column = columns.at(i);
+ if (!column->elementProperty().isEmpty()) {
+ const DomPropertyMap properties = propertyMap(column->elementProperty());
+
+ Item item(QLatin1String("QTableWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ addCommonInitializers(&item, properties);
+
+ QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable);
+ item.writeRetranslateUi(varName + QLatin1String("->horizontalHeaderItem(") + QString::number(i) + QLatin1Char(')'));
+ m_output << m_indent << varName << "->setHorizontalHeaderItem(" << QString::number(i) << ", " << itemName << ");\n";
+ }
+ }
+
+ // rows
+ const QList<DomRow *> rows = w->elementRow();
+
+ if (rows.size() != 0) {
+ m_output << m_indent << "if (" << varName << "->rowCount() < " << rows.size() << ")\n"
+ << m_dindent << varName << "->setRowCount(" << rows.size() << ");\n";
+ }
+
+ for (int i = 0; i < rows.size(); ++i) {
+ const DomRow *row = rows.at(i);
+ if (!row->elementProperty().isEmpty()) {
+ const DomPropertyMap properties = propertyMap(row->elementProperty());
+
+ Item item(QLatin1String("QTableWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ addCommonInitializers(&item, properties);
+
+ QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable);
+ item.writeRetranslateUi(varName + QLatin1String("->verticalHeaderItem(") + QString::number(i) + QLatin1Char(')'));
+ m_output << m_indent << varName << "->setVerticalHeaderItem(" << QString::number(i) << ", " << itemName << ");\n";
+ }
+ }
+
+ // items
+ QString tempName = disableSorting(w, varName);
+
+ const QList<DomItem *> items = w->elementItem();
+
+ for (int i = 0; i < items.size(); ++i) {
+ const DomItem *cell = items.at(i);
+ if (cell->hasAttributeRow() && cell->hasAttributeColumn() && !cell->elementProperty().isEmpty()) {
+ const int r = cell->attributeRow();
+ const int c = cell->attributeColumn();
+ const DomPropertyMap properties = propertyMap(cell->elementProperty());
+
+ Item item(QLatin1String("QTableWidgetItem"), m_indent, m_output, m_refreshOut, m_driver);
+ addQtFlagsInitializer(&item, properties, QLatin1String("flags"));
+ addCommonInitializers(&item, properties);
+
+ QString itemName = item.writeSetupUi(QString(), Item::ConstructItemAndVariable);
+ item.writeRetranslateUi(varName + QLatin1String("->item(") + QString::number(r) + QLatin1String(", ") + QString::number(c) + QLatin1Char(')'));
+ m_output << m_indent << varName << "->setItem(" << QString::number(r) << ", " << QString::number(c) << ", " << itemName << ");\n";
+ }
+ }
+ enableSorting(w, varName, tempName);
+}
+
+QString WriteInitialization::trCall(const QString &str, const QString &commentHint) const
+{
+ if (str.isEmpty())
+ return QLatin1String("QString()");
+
+ QString result;
+ const QString comment = commentHint.isEmpty() ? QString(QLatin1Char('0')) : fixString(commentHint, m_dindent);
+
+ if (m_option.translateFunction.isEmpty()) {
+ result = QLatin1String("QApplication::translate(\"");
+ result += m_generatedClass;
+ result += QLatin1Char('"');
+ result += QLatin1String(", ");
+ } else {
+ result = m_option.translateFunction;
+ result += QLatin1Char('(');
+ }
+
+ result += fixString(str, m_dindent);
+ result += QLatin1String(", ");
+ result += comment;
+
+ if (m_option.translateFunction.isEmpty()) {
+ result += QLatin1String(", ");
+ result += QLatin1String("QApplication::UnicodeUTF8");
+ }
+
+ result += QLatin1Char(')');
+ return result;
+}
+
+void WriteInitialization::initializeQ3SqlDataTable(DomWidget *w)
+{
+ const DomPropertyMap properties = propertyMap(w->elementProperty());
+
+ const DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"), 0);
+ if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
+ return;
+
+ QString connection;
+ QString table;
+ QString field;
+
+ const DomProperty *db = properties.value(QLatin1String("database"), 0);
+ if (db && db->elementStringList()) {
+ const QStringList info = db->elementStringList()->elementString();
+ connection = info.size() > 0 ? info.at(0) : QString();
+ table = info.size() > 1 ? info.at(1) : QString();
+ field = info.size() > 2 ? info.at(2) : QString();
+ }
+
+ if (table.isEmpty() || connection.isEmpty()) {
+ fprintf(stderr, "%s: Warning: Invalid database connection\n", qPrintable(m_option.messagePrefix()));
+ return;
+ }
+
+ const QString varName = m_driver->findOrInsertWidget(w);
+
+ m_output << m_indent << "if (!" << varName << "->sqlCursor()) {\n";
+
+ m_output << m_dindent << varName << "->setSqlCursor(";
+
+ if (connection == QLatin1String("(default)")) {
+ m_output << "new Q3SqlCursor(" << fixString(table, m_dindent) << "), false, true);\n";
+ } else {
+ m_output << "new Q3SqlCursor(" << fixString(table, m_dindent) << ", true, " << connection << "Connection" << "), false, true);\n";
+ }
+ m_output << m_dindent << varName << "->refresh(Q3DataTable::RefreshAll);\n";
+ m_output << m_indent << "}\n";
+}
+
+void WriteInitialization::initializeQ3SqlDataBrowser(DomWidget *w)
+{
+ const DomPropertyMap properties = propertyMap(w->elementProperty());
+
+ const DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"), 0);
+ if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
+ return;
+
+ QString connection;
+ QString table;
+ QString field;
+
+ const DomProperty *db = properties.value(QLatin1String("database"), 0);
+ if (db && db->elementStringList()) {
+ const QStringList info = db->elementStringList()->elementString();
+ connection = info.size() > 0 ? info.at(0) : QString();
+ table = info.size() > 1 ? info.at(1) : QString();
+ field = info.size() > 2 ? info.at(2) : QString();
+ }
+
+ if (table.isEmpty() || connection.isEmpty()) {
+ fprintf(stderr, "%s: Warning: Invalid database connection\n", qPrintable(m_option.messagePrefix()));
+ return;
+ }
+
+ const QString varName = m_driver->findOrInsertWidget(w);
+
+ m_output << m_indent << "if (!" << varName << "->sqlCursor()) {\n";
+
+ m_output << m_dindent << varName << "->setSqlCursor(";
+
+ if (connection == QLatin1String("(default)")) {
+ m_output << "new Q3SqlCursor(" << fixString(table, m_dindent) << "), true);\n";
+ } else {
+ m_output << "new Q3SqlCursor(" << fixString(table, m_dindent) << ", true, " << connection << "Connection" << "), false, true);\n";
+ }
+ m_output << m_dindent << varName << "->refresh();\n";
+ m_output << m_indent << "}\n";
+}
+
+void WriteInitialization::initializeMenu(DomWidget *w, const QString &/*parentWidget*/)
+{
+ const QString menuName = m_driver->findOrInsertWidget(w);
+ const QString menuAction = menuName + QLatin1String("Action");
+
+ const DomAction *action = m_driver->actionByName(menuAction);
+ if (action && action->hasAttributeMenu()) {
+ m_output << m_indent << menuAction << " = " << menuName << "->menuAction();\n";
+ }
+}
+
+QString WriteInitialization::trCall(DomString *str, const QString &defaultString) const
+{
+ QString value = defaultString;
+ QString comment;
+ if (str) {
+ value = toString(str);
+ comment = str->attributeComment();
+ }
+ return trCall(value, comment);
+}
+
+QString WriteInitialization::noTrCall(DomString *str, const QString &defaultString) const
+{
+ QString value = defaultString;
+ if (!str && defaultString.isEmpty())
+ return QString();
+ if (str)
+ value = str->text();
+ QString ret = QLatin1String("QString::fromUtf8(");
+ ret += fixString(value, m_dindent);
+ ret += QLatin1Char(')');
+ return ret;
+}
+
+QString WriteInitialization::autoTrCall(DomString *str, const QString &defaultString) const
+{
+ if ((!str && !defaultString.isEmpty()) || needsTranslation(str))
+ return trCall(str, defaultString);
+ return noTrCall(str, defaultString);
+}
+
+QTextStream &WriteInitialization::autoTrOutput(DomString *str, const QString &defaultString)
+{
+ if ((!str && !defaultString.isEmpty()) || needsTranslation(str))
+ return m_refreshOut;
+ return m_output;
+}
+
+bool WriteInitialization::isValidObject(const QString &name) const
+{
+ return m_registeredWidgets.contains(name)
+ || m_registeredActions.contains(name);
+}
+
+QString WriteInitialization::findDeclaration(const QString &name)
+{
+ const QString normalized = Driver::normalizedName(name);
+
+ if (DomWidget *widget = m_driver->widgetByName(normalized))
+ return m_driver->findOrInsertWidget(widget);
+ if (DomAction *action = m_driver->actionByName(normalized))
+ return m_driver->findOrInsertAction(action);
+ if (const DomButtonGroup *group = m_driver->findButtonGroup(normalized))
+ return m_driver->findOrInsertButtonGroup(group);
+ return QString();
+}
+
+void WriteInitialization::acceptConnection(DomConnection *connection)
+{
+ const QString sender = findDeclaration(connection->elementSender());
+ const QString receiver = findDeclaration(connection->elementReceiver());
+
+ if (sender.isEmpty() || receiver.isEmpty())
+ return;
+
+ m_output << m_indent << "QObject::connect("
+ << sender
+ << ", "
+ << "SIGNAL("<<connection->elementSignal()<<')'
+ << ", "
+ << receiver
+ << ", "
+ << "SLOT("<<connection->elementSlot()<<')'
+ << ");\n";
+}
+
+DomImage *WriteInitialization::findImage(const QString &name) const
+{
+ return m_registeredImages.value(name);
+}
+
+DomWidget *WriteInitialization::findWidget(const QLatin1String &widgetClass)
+{
+ for (int i = m_widgetChain.count() - 1; i >= 0; --i) {
+ DomWidget *widget = m_widgetChain.at(i);
+
+ if (widget && m_uic->customWidgetsInfo()->extends(widget->attributeClass(), widgetClass))
+ return widget;
+ }
+
+ 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;
+ foreach (const DomScript *domScript, scripts) {
+ const QString snippet = domScript->text();
+ if (!snippet.isEmpty()) {
+ script += snippet.trimmed();
+ script += 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";
+ foreach (DomWidget *child, childWidgets) {
+ m_output << " << " << m_driver->findOrInsertWidget(child);
+ }
+ m_output << ";\n";
+ }
+ m_output << m_indent << "scriptContext.run(QString::fromUtf8("
+ << fixString(script, m_dindent) << "), "
+ << m_driver->findOrInsertWidget(node) << ", childWidgets);\n";
+}
+
+
+static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet<QString> &directives)
+{
+ if (directives.isEmpty())
+ return;
+
+ QMap<QString, bool> map; // bool is dummy. The idea is to sort that (always generate in the same order) by putting a set into a map
+ foreach (const QString &str, directives)
+ map.insert(str, true);
+
+ if (map.size() == 1) {
+ outputStream << "#ifndef " << map.constBegin().key() << endl;
+ return;
+ }
+
+ outputStream << "#if";
+ bool doOr = false;
+ foreach (const QString &str, map.keys()) {
+ if (doOr)
+ outputStream << " ||";
+ outputStream << " !defined(" << str << ')';
+ doOr = true;
+ }
+ outputStream << endl;
+}
+
+static void generateMultiDirectiveEnd(QTextStream &outputStream, const QSet<QString> &directives)
+{
+ if (directives.isEmpty())
+ return;
+
+ outputStream << "#endif" << endl;
+}
+
+WriteInitialization::Item::Item(const QString &itemClassName, const QString &indent, QTextStream &setupUiStream, QTextStream &retranslateUiStream, Driver *driver)
+ :
+ m_parent(0),
+ m_itemClassName(itemClassName),
+ m_indent(indent),
+ m_setupUiStream(setupUiStream),
+ m_retranslateUiStream(retranslateUiStream),
+ m_driver(driver)
+{
+
+}
+
+WriteInitialization::Item::~Item()
+{
+ foreach (Item *child, m_children)
+ delete child;
+}
+
+QString WriteInitialization::Item::writeSetupUi(const QString &parent, Item::EmptyItemPolicy emptyItemPolicy)
+{
+ if (emptyItemPolicy == Item::DontConstruct && m_setupUiData.policy == ItemData::DontGenerate)
+ return QString();
+
+ bool generateMultiDirective = false;
+ if (emptyItemPolicy == Item::ConstructItemOnly && m_children.size() == 0) {
+ if (m_setupUiData.policy == ItemData::DontGenerate) {
+ m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n";
+ return QString();
+ } else if (m_setupUiData.policy == ItemData::GenerateWithMultiDirective) {
+ generateMultiDirective = true;
+ }
+ }
+
+ if (generateMultiDirective)
+ generateMultiDirectiveBegin(m_setupUiStream, m_setupUiData.directives);
+
+ const QString uniqueName = m_driver->unique(QLatin1String("__") + m_itemClassName.toLower());
+ m_setupUiStream << m_indent << m_itemClassName << " *" << uniqueName << " = new " << m_itemClassName << '(' << parent << ");\n";
+
+ if (generateMultiDirective) {
+ m_setupUiStream << "#else\n";
+ m_setupUiStream << m_indent << "new " << m_itemClassName << '(' << parent << ");\n";
+ generateMultiDirectiveEnd(m_setupUiStream, m_setupUiData.directives);
+ }
+
+ QMultiMap<QString, QString>::ConstIterator it = m_setupUiData.setters.constBegin();
+ while (it != m_setupUiData.setters.constEnd()) {
+ openIfndef(m_setupUiStream, it.key());
+ m_setupUiStream << m_indent << uniqueName << it.value() << endl;
+ closeIfndef(m_setupUiStream, it.key());
+ ++it;
+ }
+ foreach (Item *child, m_children)
+ child->writeSetupUi(uniqueName);
+ return uniqueName;
+}
+
+void WriteInitialization::Item::writeRetranslateUi(const QString &parentPath)
+{
+ if (m_retranslateUiData.policy == ItemData::DontGenerate)
+ return;
+
+ if (m_retranslateUiData.policy == ItemData::GenerateWithMultiDirective)
+ generateMultiDirectiveBegin(m_retranslateUiStream, m_retranslateUiData.directives);
+
+ const QString uniqueName = m_driver->unique(QLatin1String("___") + m_itemClassName.toLower());
+ m_retranslateUiStream << m_indent << m_itemClassName << " *" << uniqueName << " = " << parentPath << ";\n";
+
+ if (m_retranslateUiData.policy == ItemData::GenerateWithMultiDirective)
+ generateMultiDirectiveEnd(m_retranslateUiStream, m_retranslateUiData.directives);
+
+ QString oldDirective;
+ QMultiMap<QString, QString>::ConstIterator it = m_retranslateUiData.setters.constBegin();
+ while (it != m_retranslateUiData.setters.constEnd()) {
+ const QString newDirective = it.key();
+ if (oldDirective != newDirective) {
+ closeIfndef(m_retranslateUiStream, oldDirective);
+ openIfndef(m_retranslateUiStream, newDirective);
+ oldDirective = newDirective;
+ }
+ m_retranslateUiStream << m_indent << uniqueName << it.value() << endl;
+ ++it;
+ }
+ closeIfndef(m_retranslateUiStream, oldDirective);
+
+ for (int i = 0; i < m_children.size(); i++)
+ m_children[i]->writeRetranslateUi(uniqueName + QLatin1String("->child(") + QString::number(i) + QLatin1Char(')'));
+}
+
+void WriteInitialization::Item::addSetter(const QString &setter, const QString &directive, bool translatable)
+{
+ const ItemData::TemporaryVariableGeneratorPolicy newPolicy = directive.isNull() ? ItemData::Generate : ItemData::GenerateWithMultiDirective;
+ if (translatable) {
+ m_retranslateUiData.setters.insert(directive, setter);
+ if (ItemData::GenerateWithMultiDirective == newPolicy)
+ m_retranslateUiData.directives << directive;
+ if (m_retranslateUiData.policy < newPolicy)
+ m_retranslateUiData.policy = newPolicy;
+ } else {
+ m_setupUiData.setters.insert(directive, setter);
+ if (ItemData::GenerateWithMultiDirective == newPolicy)
+ m_setupUiData.directives << directive;
+ if (m_setupUiData.policy < newPolicy)
+ m_setupUiData.policy = newPolicy;
+ }
+}
+
+void WriteInitialization::Item::addChild(Item *child)
+{
+ m_children << child;
+ child->m_parent = this;
+
+ Item *c = child;
+ Item *p = this;
+ while (p) {
+ p->m_setupUiData.directives |= c->m_setupUiData.directives;
+ p->m_retranslateUiData.directives |= c->m_retranslateUiData.directives;
+ if (p->m_setupUiData.policy < c->m_setupUiData.policy)
+ p->m_setupUiData.policy = c->m_setupUiData.policy;
+ if (p->m_retranslateUiData.policy < c->m_retranslateUiData.policy)
+ p->m_retranslateUiData.policy = c->m_retranslateUiData.policy;
+ c = p;
+ p = p->m_parent;
+ }
+}
+
+
+} // namespace CPP
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h
new file mode 100644
index 0000000000..302fbe4bc5
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteinitialization.h
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CPPWRITEINITIALIZATION_H
+#define CPPWRITEINITIALIZATION_H
+
+#include "treewalker.h"
+#include <QtCore/QPair>
+#include <QtCore/QHash>
+#include <QtCore/QSet>
+#include <QtCore/QMap>
+#include <QtCore/QStack>
+#include <QtCore/QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+class Driver;
+class Uic;
+class DomBrush;
+class DomFont;
+class DomResourceIcon;
+class DomSizePolicy;
+struct Option;
+
+namespace CPP {
+ // Handle for a flat DOM font to get comparison functionality required for maps
+ class FontHandle {
+ public:
+ FontHandle(const DomFont *domFont);
+ int compare(const FontHandle &) const;
+ private:
+ const DomFont *m_domFont;
+#if defined(Q_OS_MAC) && defined(Q_CC_GNU) && (__GNUC__ == 3 && __GNUC_MINOR__ == 3)
+ friend uint qHash(const FontHandle &);
+#endif
+ };
+ inline bool operator ==(const FontHandle &f1, const FontHandle &f2) { return f1.compare(f2) == 0; }
+ inline bool operator <(const FontHandle &f1, const FontHandle &f2) { return f1.compare(f2) < 0; }
+
+ // Handle for a flat DOM icon to get comparison functionality required for maps
+ class IconHandle {
+ public:
+ IconHandle(const DomResourceIcon *domIcon);
+ int compare(const IconHandle &) const;
+ private:
+ const DomResourceIcon *m_domIcon;
+#if defined(Q_OS_MAC) && defined(Q_CC_GNU) && (__GNUC__ == 3 && __GNUC_MINOR__ == 3)
+ friend uint qHash(const IconHandle &);
+#endif
+ };
+ inline bool operator ==(const IconHandle &i1, const IconHandle &i2) { return i1.compare(i2) == 0; }
+ inline bool operator <(const IconHandle &i1, const IconHandle &i2) { return i1.compare(i2) < 0; }
+
+ // Handle for a flat DOM size policy to get comparison functionality required for maps
+ class SizePolicyHandle {
+ public:
+ SizePolicyHandle(const DomSizePolicy *domSizePolicy);
+ int compare(const SizePolicyHandle &) const;
+ private:
+ const DomSizePolicy *m_domSizePolicy;
+#if defined(Q_OS_MAC) && defined(Q_CC_GNU) && (__GNUC__ == 3 && __GNUC_MINOR__ == 3)
+ friend uint qHash(const SizePolicyHandle &);
+#endif
+ };
+ inline bool operator ==(const SizePolicyHandle &f1, const SizePolicyHandle &f2) { return f1.compare(f2) == 0; }
+#if !(defined(Q_OS_MAC) && defined(Q_CC_GNU) && (__GNUC__ == 3 && __GNUC_MINOR__ == 3))
+ inline bool operator <(const SizePolicyHandle &f1, const SizePolicyHandle &f2) { return f1.compare(f2) < 0; }
+#endif
+
+
+
+struct WriteInitialization : public TreeWalker
+{
+ typedef QList<DomProperty*> DomPropertyList;
+ typedef QHash<QString, DomProperty*> DomPropertyMap;
+
+ WriteInitialization(Uic *uic, bool activateScripts);
+
+//
+// widgets
+//
+ void acceptUI(DomUI *node);
+ void acceptWidget(DomWidget *node);
+ void acceptWidgetScripts(const DomScripts &, DomWidget *node, const DomWidgets &childWidgets);
+
+ void acceptLayout(DomLayout *node);
+ void acceptSpacer(DomSpacer *node);
+ void acceptLayoutItem(DomLayoutItem *node);
+
+//
+// actions
+//
+ void acceptActionGroup(DomActionGroup *node);
+ void acceptAction(DomAction *node);
+ void acceptActionRef(DomActionRef *node);
+
+//
+// tab stops
+//
+ void acceptTabStops(DomTabStops *tabStops);
+
+//
+// custom widgets
+//
+ void acceptCustomWidgets(DomCustomWidgets *node);
+ void acceptCustomWidget(DomCustomWidget *node);
+
+//
+// layout defaults/functions
+//
+ void acceptLayoutDefault(DomLayoutDefault *node) { m_LayoutDefaultHandler.acceptLayoutDefault(node); }
+ void acceptLayoutFunction(DomLayoutFunction *node) { m_LayoutDefaultHandler.acceptLayoutFunction(node); }
+
+//
+// signal/slot connections
+//
+ void acceptConnection(DomConnection *connection);
+
+//
+// images
+//
+ void acceptImage(DomImage *image);
+
+ enum {
+ Use43UiFile = 0,
+ TopLevelMargin,
+ ChildMargin,
+ SubLayoutMargin
+ };
+
+private:
+ static QString domColor2QString(const DomColor *c);
+
+ QString iconCall(const DomProperty *prop);
+ QString pixCall(const DomProperty *prop) const;
+ QString pixCall(const QString &type, const QString &text) const;
+ QString trCall(const QString &str, const QString &comment = QString()) const;
+ QString trCall(DomString *str, const QString &defaultString = QString()) const;
+ QString noTrCall(DomString *str, const QString &defaultString = QString()) const;
+ QString autoTrCall(DomString *str, const QString &defaultString = QString()) const;
+ QTextStream &autoTrOutput(DomString *str, const QString &defaultString = QString());
+ // Apply a comma-separated list of values using a function "setSomething(int idx, value)"
+ void writePropertyList(const QString &varName, const QString &setFunction, const QString &value, const QString &defaultValue);
+
+ enum { WritePropertyIgnoreMargin = 1, WritePropertyIgnoreSpacing = 2, WritePropertyIgnoreObjectName = 4 };
+ void writeProperties(const QString &varName, const QString &className, const DomPropertyList &lst, unsigned flags = 0);
+ void writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName);
+ void writeBrush(const DomBrush *brush, const QString &brushName);
+
+//
+// special initialization
+//
+ class Item {
+ public:
+ Item(const QString &itemClassName, const QString &indent, QTextStream &setupUiStream, QTextStream &retranslateUiStream, Driver *driver);
+ ~Item();
+ enum EmptyItemPolicy {
+ DontConstruct,
+ ConstructItemOnly,
+ ConstructItemAndVariable
+ };
+ QString writeSetupUi(const QString &parent, EmptyItemPolicy emptyItemPolicy = ConstructItemOnly);
+ void writeRetranslateUi(const QString &parentPath);
+ void addSetter(const QString &setter, const QString &directive = QString(), bool translatable = false); // don't call it if you already added *this as a child of another Item
+ void addChild(Item *child); // all setters should already been added
+ int setupUiCount() const { return m_setupUiData.setters.count(); }
+ int retranslateUiCount() const { return m_retranslateUiData.setters.count(); }
+ private:
+ struct ItemData {
+ ItemData() : policy(DontGenerate) {}
+ QMultiMap<QString, QString> setters; // directive to setter
+ QSet<QString> directives;
+ enum TemporaryVariableGeneratorPolicy { // policies with priority, number describes the priority
+ DontGenerate = 1,
+ GenerateWithMultiDirective = 2,
+ Generate = 3
+ } policy;
+ };
+ ItemData m_setupUiData;
+ ItemData m_retranslateUiData;
+ QList<Item *> m_children;
+ Item *m_parent;
+
+ const QString m_itemClassName;
+ const QString m_indent;
+ QTextStream &m_setupUiStream;
+ QTextStream &m_retranslateUiStream;
+ Driver *m_driver;
+ };
+
+ void addInitializer(Item *item,
+ const QString &name, int column, const QString &value, const QString &directive = QString(), bool translatable = false) const;
+ void addQtFlagsInitializer(Item *item, const DomPropertyMap &properties,
+ const QString &name, int column = -1) const;
+ void addQtEnumInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column = -1) const;
+ void addBrushInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column = -1);
+ void addStringInitializer(Item *item,
+ const DomPropertyMap &properties, const QString &name, int column = -1, const QString &directive = QString()) const;
+ void addCommonInitializers(Item *item,
+ const DomPropertyMap &properties, int column = -1);
+
+ void initializeMenu(DomWidget *w, const QString &parentWidget);
+ void initializeComboBox(DomWidget *w);
+ void initializeComboBox3(DomWidget *w);
+ void initializeListWidget(DomWidget *w);
+ void initializeTreeWidget(DomWidget *w);
+ QList<Item *> initializeTreeWidgetItems(const QList<DomItem *> &domItems);
+ void initializeTableWidget(DomWidget *w);
+
+ QString disableSorting(DomWidget *w, const QString &varName);
+ void enableSorting(DomWidget *w, const QString &varName, const QString &tempName);
+
+//
+// special initialization for the Q3 support classes
+//
+ void initializeQ3ListBox(DomWidget *w);
+ void initializeQ3IconView(DomWidget *w);
+ void initializeQ3ListView(DomWidget *w);
+ void initializeQ3ListViewItems(const QString &className, const QString &varName, const QList<DomItem*> &items);
+ void initializeQ3Table(DomWidget *w);
+ void initializeQ3TableItems(const QString &className, const QString &varName, const QList<DomItem*> &items);
+
+//
+// Sql
+//
+ void initializeQ3SqlDataTable(DomWidget *w);
+ void initializeQ3SqlDataBrowser(DomWidget *w);
+
+ QString findDeclaration(const QString &name);
+ DomWidget *findWidget(const QLatin1String &widgetClass);
+ DomImage *findImage(const QString &name) const;
+
+ bool isValidObject(const QString &name) const;
+
+private:
+ QString writeFontProperties(const DomFont *f);
+ QString writeIconProperties(const DomResourceIcon *i);
+ QString writeSizePolicy(const DomSizePolicy *sp);
+ QString writeBrushInitialization(const DomBrush *brush);
+ void addButtonGroup(const DomWidget *node, const QString &varName);
+ void addWizardPage(const QString &pageVarName, const DomWidget *page, const QString &parentWidget);
+
+ const Uic *m_uic;
+ Driver *m_driver;
+ QTextStream &m_output;
+ const Option &m_option;
+ QString m_indent;
+ QString m_dindent;
+ bool m_stdsetdef;
+
+ struct Buddy
+ {
+ Buddy(const QString &oN, const QString &b)
+ : objName(oN), buddy(b) {}
+ QString objName;
+ QString buddy;
+ };
+
+ QStack<DomWidget*> m_widgetChain;
+ QStack<DomLayout*> m_layoutChain;
+ QStack<DomActionGroup*> m_actionGroupChain;
+ QList<Buddy> m_buddies;
+
+ 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;
+ // Map from font properties to font variable name for reuse
+ // Map from size policy to variable for reuse
+#if defined(Q_OS_MAC) && defined(Q_CC_GNU) && (__GNUC__ == 3 && __GNUC_MINOR__ == 3)
+ typedef QHash<FontHandle, QString> FontPropertiesNameMap;
+ typedef QHash<IconHandle, QString> IconPropertiesNameMap;
+ typedef QHash<SizePolicyHandle, QString> SizePolicyNameMap;
+#else
+ typedef QMap<FontHandle, QString> FontPropertiesNameMap;
+ typedef QMap<IconHandle, QString> IconPropertiesNameMap;
+ typedef QMap<SizePolicyHandle, QString> SizePolicyNameMap;
+#endif
+ FontPropertiesNameMap m_fontPropertiesNameMap;
+ IconPropertiesNameMap m_iconPropertiesNameMap;
+ SizePolicyNameMap m_sizePolicyNameMap;
+
+ class LayoutDefaultHandler {
+ public:
+ LayoutDefaultHandler();
+ void acceptLayoutDefault(DomLayoutDefault *node);
+ void acceptLayoutFunction(DomLayoutFunction *node);
+
+ // Write out the layout margin and spacing properties applying the defaults.
+ void writeProperties(const QString &indent, const QString &varName,
+ const DomPropertyMap &pm, int marginType,
+ bool suppressMarginDefault, QTextStream &str) const;
+ private:
+ void writeProperty(int p, const QString &indent, const QString &objectName, const DomPropertyMap &pm,
+ const QString &propertyName, const QString &setter, int defaultStyleValue,
+ bool suppressDefault, QTextStream &str) const;
+
+ enum Properties { Margin, Spacing, NumProperties };
+ enum StateFlags { HasDefaultValue = 1, HasDefaultFunction = 2};
+ unsigned m_state[NumProperties];
+ int m_defaultValues[NumProperties];
+ QString m_functions[NumProperties];
+ };
+
+ // layout defaults
+ LayoutDefaultHandler m_LayoutDefaultHandler;
+ int m_layoutMarginType;
+
+ QString m_generatedClass;
+ QString m_mainFormVarName;
+ bool m_mainFormUsedInRetranslateUi;
+
+ QString m_delayedInitialization;
+ QTextStream m_delayedOut;
+
+ QString m_refreshInitialization;
+ QTextStream m_refreshOut;
+
+ QString m_delayedActionInitialization;
+ QTextStream m_actionOut;
+ const bool m_activateScripts;
+
+ bool m_layoutWidget;
+ bool m_firstThemeIcon;
+};
+
+} // namespace CPP
+
+QT_END_NAMESPACE
+
+#endif // CPPWRITEINITIALIZATION_H
diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp
new file mode 100644
index 0000000000..320995eadd
--- /dev/null
+++ b/src/tools/uic/customwidgetsinfo.cpp
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "customwidgetsinfo.h"
+#include "driver.h"
+#include "ui4.h"
+#include "utils.h"
+
+QT_BEGIN_NAMESPACE
+
+CustomWidgetsInfo::CustomWidgetsInfo()
+{
+}
+
+void CustomWidgetsInfo::acceptUI(DomUI *node)
+{
+ m_customWidgets.clear();
+
+ if (node->elementCustomWidgets())
+ acceptCustomWidgets(node->elementCustomWidgets());
+}
+
+void CustomWidgetsInfo::acceptCustomWidgets(DomCustomWidgets *node)
+{
+ TreeWalker::acceptCustomWidgets(node);
+}
+
+void CustomWidgetsInfo::acceptCustomWidget(DomCustomWidget *node)
+{
+ if (node->elementClass().isEmpty())
+ return;
+
+ m_customWidgets.insert(node->elementClass(), node);
+}
+
+bool CustomWidgetsInfo::extends(const QString &classNameIn, const QLatin1String &baseClassName) const
+{
+ if (classNameIn == baseClassName)
+ return true;
+
+ QString className = classNameIn;
+ while (const DomCustomWidget *c = customWidget(className)) {
+ const QString extends = c->elementExtends();
+ if (className == extends) // Faulty legacy custom widget entries exist.
+ return false;
+ if (extends == baseClassName)
+ return true;
+ className = extends;
+ }
+ return false;
+}
+
+bool CustomWidgetsInfo::isCustomWidgetContainer(const QString &className) const
+{
+ if (const DomCustomWidget *dcw = m_customWidgets.value(className, 0))
+ if (dcw->hasElementContainer())
+ return dcw->elementContainer() != 0;
+ return false;
+}
+
+QString CustomWidgetsInfo::realClassName(const QString &className) const
+{
+ if (className == QLatin1String("Line"))
+ return QLatin1String("QFrame");
+
+ 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))
+ return dcw->elementAddPageMethod();
+ return QString();
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/customwidgetsinfo.h b/src/tools/uic/customwidgetsinfo.h
new file mode 100644
index 0000000000..198e92cfac
--- /dev/null
+++ b/src/tools/uic/customwidgetsinfo.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CUSTOMWIDGETSINFO_H
+#define CUSTOMWIDGETSINFO_H
+
+#include "treewalker.h"
+#include <QtCore/QStringList>
+#include <QtCore/QMap>
+
+QT_BEGIN_NAMESPACE
+
+class Driver;
+class DomScript;
+
+class CustomWidgetsInfo : public TreeWalker
+{
+public:
+ CustomWidgetsInfo();
+
+ void acceptUI(DomUI *node);
+
+ void acceptCustomWidgets(DomCustomWidgets *node);
+ void acceptCustomWidget(DomCustomWidget *node);
+
+ inline QStringList customWidgets() const
+ { return m_customWidgets.keys(); }
+
+ inline bool hasCustomWidget(const QString &name) const
+ { return m_customWidgets.contains(name); }
+
+ 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;
+
+ bool extends(const QString &className, const QLatin1String &baseClassName) const;
+
+ bool isCustomWidgetContainer(const QString &className) const;
+
+private:
+ typedef QMap<QString, DomCustomWidget*> NameCustomWidgetMap;
+ NameCustomWidgetMap m_customWidgets;
+ bool m_scriptsActivated;
+};
+
+QT_END_NAMESPACE
+
+#endif // CUSTOMWIDGETSINFO_H
diff --git a/src/tools/uic/databaseinfo.cpp b/src/tools/uic/databaseinfo.cpp
new file mode 100644
index 0000000000..c4fa88b585
--- /dev/null
+++ b/src/tools/uic/databaseinfo.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "databaseinfo.h"
+#include "driver.h"
+#include "ui4.h"
+#include "utils.h"
+
+QT_BEGIN_NAMESPACE
+
+DatabaseInfo::DatabaseInfo(Driver *drv)
+ : driver(drv)
+{
+}
+
+void DatabaseInfo::acceptUI(DomUI *node)
+{
+ m_connections.clear();
+ m_cursors.clear();
+ m_fields.clear();
+
+ TreeWalker::acceptUI(node);
+
+ m_connections = unique(m_connections);
+}
+
+void DatabaseInfo::acceptWidget(DomWidget *node)
+{
+ QHash<QString, DomProperty*> properties = propertyMap(node->elementProperty());
+
+ DomProperty *frameworkCode = properties.value(QLatin1String("frameworkCode"), 0);
+ if (frameworkCode && toBool(frameworkCode->elementBool()) == false)
+ return;
+
+ DomProperty *db = properties.value(QLatin1String("database"), 0);
+ if (db && db->elementStringList()) {
+ QStringList info = db->elementStringList()->elementString();
+
+ QString connection = info.size() > 0 ? info.at(0) : QString();
+ if (connection.isEmpty())
+ return;
+ m_connections.append(connection);
+
+ QString table = info.size() > 1 ? info.at(1) : QString();
+ if (table.isEmpty())
+ return;
+ m_cursors[connection].append(table);
+
+ QString field = info.size() > 2 ? info.at(2) : QString();
+ if (field.isEmpty())
+ return;
+ m_fields[connection].append(field);
+ }
+
+ TreeWalker::acceptWidget(node);
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/databaseinfo.h b/src/tools/uic/databaseinfo.h
new file mode 100644
index 0000000000..b52c92826f
--- /dev/null
+++ b/src/tools/uic/databaseinfo.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DATABASEINFO_H
+#define DATABASEINFO_H
+
+#include "treewalker.h"
+#include <QtCore/QStringList>
+#include <QtCore/QMap>
+
+QT_BEGIN_NAMESPACE
+
+class Driver;
+
+class DatabaseInfo : public TreeWalker
+{
+public:
+ DatabaseInfo(Driver *driver);
+
+ void acceptUI(DomUI *node);
+ void acceptWidget(DomWidget *node);
+
+ inline QStringList connections() const
+ { return m_connections; }
+
+ inline QStringList cursors(const QString &connection) const
+ { return m_cursors.value(connection); }
+
+ inline QStringList fields(const QString &connection) const
+ { return m_fields.value(connection); }
+
+private:
+ Driver *driver;
+ QStringList m_connections;
+ QMap<QString, QStringList> m_cursors;
+ QMap<QString, QStringList> m_fields;
+};
+
+QT_END_NAMESPACE
+
+#endif // DATABASEINFO_H
diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp
new file mode 100644
index 0000000000..e5365886a1
--- /dev/null
+++ b/src/tools/uic/driver.cpp
@@ -0,0 +1,381 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "driver.h"
+#include "uic.h"
+#include "ui4.h"
+
+#include <QtCore/QRegExp>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+Driver::Driver()
+ : m_stdout(stdout, QFile::WriteOnly | QFile::Text)
+{
+ m_output = &m_stdout;
+}
+
+Driver::~Driver()
+{
+}
+
+QString Driver::findOrInsertWidget(DomWidget *ui_widget)
+{
+ if (!m_widgets.contains(ui_widget))
+ m_widgets.insert(ui_widget, unique(ui_widget->attributeName(), ui_widget->attributeClass()));
+
+ return m_widgets.value(ui_widget);
+}
+
+QString Driver::findOrInsertSpacer(DomSpacer *ui_spacer)
+{
+ if (!m_spacers.contains(ui_spacer)) {
+ const QString name = ui_spacer->hasAttributeName() ? ui_spacer->attributeName() : QString();
+ m_spacers.insert(ui_spacer, unique(name, QLatin1String("QSpacerItem")));
+ }
+
+ return m_spacers.value(ui_spacer);
+}
+
+QString Driver::findOrInsertLayout(DomLayout *ui_layout)
+{
+ if (!m_layouts.contains(ui_layout)) {
+ const QString name = ui_layout->hasAttributeName() ? ui_layout->attributeName() : QString();
+ m_layouts.insert(ui_layout, unique(name, ui_layout->attributeClass()));
+ }
+
+ return m_layouts.value(ui_layout);
+}
+
+QString Driver::findOrInsertLayoutItem(DomLayoutItem *ui_layoutItem)
+{
+ switch (ui_layoutItem->kind()) {
+ case DomLayoutItem::Widget:
+ return findOrInsertWidget(ui_layoutItem->elementWidget());
+ case DomLayoutItem::Spacer:
+ return findOrInsertSpacer(ui_layoutItem->elementSpacer());
+ case DomLayoutItem::Layout:
+ return findOrInsertLayout(ui_layoutItem->elementLayout());
+ case DomLayoutItem::Unknown:
+ break;
+ }
+
+ Q_ASSERT( 0 );
+
+ return QString();
+}
+
+QString Driver::findOrInsertActionGroup(DomActionGroup *ui_group)
+{
+ if (!m_actionGroups.contains(ui_group))
+ m_actionGroups.insert(ui_group, unique(ui_group->attributeName(), QLatin1String("QActionGroup")));
+
+ return m_actionGroups.value(ui_group);
+}
+
+QString Driver::findOrInsertAction(DomAction *ui_action)
+{
+ if (!m_actions.contains(ui_action))
+ m_actions.insert(ui_action, unique(ui_action->attributeName(), QLatin1String("QAction")));
+
+ return m_actions.value(ui_action);
+}
+
+QString Driver::findOrInsertButtonGroup(const DomButtonGroup *ui_group)
+{
+ ButtonGroupNameHash::iterator it = m_buttonGroups.find(ui_group);
+ if (it == m_buttonGroups.end())
+ it = m_buttonGroups.insert(ui_group, unique(ui_group->attributeName(), QLatin1String("QButtonGroup")));
+ return it.value();
+}
+
+// Find a group by its non-uniqified name
+const DomButtonGroup *Driver::findButtonGroup(const QString &attributeName) const
+{
+ const ButtonGroupNameHash::const_iterator cend = m_buttonGroups.constEnd();
+ for (ButtonGroupNameHash::const_iterator it = m_buttonGroups.constBegin(); it != cend; ++it)
+ if (it.key()->attributeName() == attributeName)
+ return it.key();
+ return 0;
+}
+
+
+QString Driver::findOrInsertName(const QString &name)
+{
+ return unique(name);
+}
+
+QString Driver::normalizedName(const QString &name)
+{
+ QString result = name;
+ QChar *data = result.data();
+ for (int i = name.size(); --i >= 0; ++data) {
+ if (!data->isLetterOrNumber())
+ *data = QLatin1Char('_');
+ }
+ return result;
+}
+
+QString Driver::unique(const QString &instanceName, const QString &className)
+{
+ QString name;
+ bool alreadyUsed = false;
+
+ if (instanceName.size()) {
+ int id = 1;
+ name = instanceName;
+ name = normalizedName(name);
+ QString base = name;
+
+ while (m_nameRepository.contains(name)) {
+ alreadyUsed = true;
+ name = base + QString::number(id++);
+ }
+ } else if (className.size()) {
+ name = unique(qtify(className));
+ } else {
+ name = unique(QLatin1String("var"));
+ }
+
+ if (alreadyUsed && className.size()) {
+ fprintf(stderr, "%s: Warning: The name '%s' (%s) is already in use, defaulting to '%s'.\n",
+ qPrintable(m_option.messagePrefix()),
+ qPrintable(instanceName), qPrintable(className),
+ qPrintable(name));
+ }
+
+ m_nameRepository.insert(name, true);
+ return name;
+}
+
+QString Driver::qtify(const QString &name)
+{
+ QString qname = name;
+
+ if (qname.at(0) == QLatin1Char('Q') || qname.at(0) == QLatin1Char('K'))
+ qname = qname.mid(1);
+
+ int i=0;
+ while (i < qname.length()) {
+ if (qname.at(i).toLower() != qname.at(i))
+ qname[i] = qname.at(i).toLower();
+ else
+ break;
+
+ ++i;
+ }
+
+ return qname;
+}
+
+static bool isAnsiCCharacter(const QChar& c)
+{
+ return (c.toUpper() >= QLatin1Char('A') && c.toUpper() <= QLatin1Char('Z'))
+ || c.isDigit() || c == QLatin1Char('_');
+}
+
+QString Driver::headerFileName() const
+{
+ QString name = m_option.outputFile;
+
+ if (name.isEmpty()) {
+ name = QLatin1String("ui_"); // ### use ui_ as prefix.
+ name.append(m_option.inputFile);
+ }
+
+ return headerFileName(name);
+}
+
+QString Driver::headerFileName(const QString &fileName)
+{
+ if (fileName.isEmpty())
+ return headerFileName(QLatin1String("noname"));
+
+ QFileInfo info(fileName);
+ QString baseName = info.baseName();
+ // Transform into a valid C++ identifier
+ if (!baseName.isEmpty() && baseName.at(0).isDigit())
+ baseName.prepend(QLatin1Char('_'));
+ for (int i = 0; i < baseName.size(); ++i) {
+ QChar c = baseName.at(i);
+ if (!isAnsiCCharacter(c)) {
+ // Replace character by its unicode value
+ QString hex = QString::number(c.unicode(), 16);
+ baseName.replace(i, 1, QLatin1Char('_') + hex + QLatin1Char('_'));
+ i += hex.size() + 1;
+ }
+ }
+ return baseName.toUpper() + QLatin1String("_H");
+}
+
+bool Driver::printDependencies(const QString &fileName)
+{
+ Q_ASSERT(m_option.dependencies == true);
+
+ m_option.inputFile = fileName;
+
+ Uic tool(this);
+ return tool.printDependencies();
+}
+
+bool Driver::uic(const QString &fileName, DomUI *ui, QTextStream *out)
+{
+ m_option.inputFile = fileName;
+
+ QTextStream *oldOutput = m_output;
+
+ m_output = out != 0 ? out : &m_stdout;
+
+ Uic tool(this);
+ bool rtn = false;
+#ifdef QT_UIC_CPP_GENERATOR
+ rtn = tool.write(ui);
+#else
+ Q_UNUSED(ui);
+ fprintf(stderr, "uic: option to generate cpp code not compiled in [%s:%d]\n",
+ __FILE__, __LINE__);
+#endif
+
+ m_output = oldOutput;
+
+ return rtn;
+}
+
+bool Driver::uic(const QString &fileName, QTextStream *out)
+{
+ QFile f;
+ if (fileName.isEmpty())
+ f.open(stdin, QIODevice::ReadOnly);
+ else {
+ f.setFileName(fileName);
+ if (!f.open(QIODevice::ReadOnly))
+ return false;
+ }
+
+ m_option.inputFile = fileName;
+
+ QTextStream *oldOutput = m_output;
+ bool deleteOutput = false;
+
+ if (out) {
+ m_output = out;
+ } else {
+#ifdef Q_WS_WIN
+ // As one might also redirect the output to a file on win,
+ // we should not create the textstream with QFile::Text flag.
+ // The redirected file is opened in TextMode and this will
+ // result in broken line endings as writing will replace \n again.
+ m_output = new QTextStream(stdout, QIODevice::WriteOnly);
+#else
+ m_output = new QTextStream(stdout, QIODevice::WriteOnly | QFile::Text);
+#endif
+ deleteOutput = true;
+ }
+
+ Uic tool(this);
+ bool rtn = tool.write(&f);
+ f.close();
+
+ if (deleteOutput)
+ delete m_output;
+
+ m_output = oldOutput;
+
+ return rtn;
+}
+
+void Driver::reset()
+{
+ Q_ASSERT( m_output == 0 );
+
+ m_option = Option();
+ m_output = 0;
+ m_problems.clear();
+
+ QStringList m_problems;
+
+ m_widgets.clear();
+ m_spacers.clear();
+ m_layouts.clear();
+ m_actionGroups.clear();
+ m_actions.clear();
+ m_nameRepository.clear();
+ m_pixmaps.clear();
+}
+
+void Driver::insertPixmap(const QString &pixmap)
+{
+ m_pixmaps.insert(pixmap, true);
+}
+
+bool Driver::containsPixmap(const QString &pixmap) const
+{
+ return m_pixmaps.contains(pixmap);
+}
+
+DomWidget *Driver::widgetByName(const QString &name) const
+{
+ return m_widgets.key(name);
+}
+
+DomSpacer *Driver::spacerByName(const QString &name) const
+{
+ return m_spacers.key(name);
+}
+
+DomLayout *Driver::layoutByName(const QString &name) const
+{
+ return m_layouts.key(name);
+}
+
+DomActionGroup *Driver::actionGroupByName(const QString &name) const
+{
+ return m_actionGroups.key(name);
+}
+
+DomAction *Driver::actionByName(const QString &name) const
+{
+ return m_actions.key(name);
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/driver.h b/src/tools/uic/driver.h
new file mode 100644
index 0000000000..f152343328
--- /dev/null
+++ b/src/tools/uic/driver.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRIVER_H
+#define DRIVER_H
+
+#include "option.h"
+#include <QtCore/QHash>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+class QTextStream;
+class DomUI;
+class DomWidget;
+class DomSpacer;
+class DomLayout;
+class DomLayoutItem;
+class DomActionGroup;
+class DomAction;
+class DomButtonGroup;
+
+class Driver
+{
+public:
+ Driver();
+ virtual ~Driver();
+
+ // tools
+ bool printDependencies(const QString &fileName);
+ bool uic(const QString &fileName, QTextStream *output = 0);
+ bool uic(const QString &fileName, DomUI *ui, QTextStream *output = 0);
+
+ // configuration
+ inline QTextStream &output() const { return *m_output; }
+ inline Option &option() { return m_option; }
+
+ // initialization
+ void reset();
+
+ // error
+ inline QStringList problems() { return m_problems; }
+ inline void addProblem(const QString &problem) { m_problems.append(problem); }
+
+ // utils
+ static QString headerFileName(const QString &fileName);
+ QString headerFileName() const;
+
+ static QString normalizedName(const QString &name);
+ static QString qtify(const QString &name);
+ QString unique(const QString &instanceName=QString(),
+ const QString &className=QString());
+
+ // symbol table
+ QString findOrInsertWidget(DomWidget *ui_widget);
+ QString findOrInsertSpacer(DomSpacer *ui_spacer);
+ QString findOrInsertLayout(DomLayout *ui_layout);
+ QString findOrInsertLayoutItem(DomLayoutItem *ui_layoutItem);
+ QString findOrInsertName(const QString &name);
+ QString findOrInsertActionGroup(DomActionGroup *ui_group);
+ QString findOrInsertAction(DomAction *ui_action);
+ QString findOrInsertButtonGroup(const DomButtonGroup *ui_group);
+ // Find a group by its non-uniqified name
+ const DomButtonGroup *findButtonGroup(const QString &attributeName) const;
+
+ inline bool hasName(const QString &name) const
+ { return m_nameRepository.contains(name); }
+
+ DomWidget *widgetByName(const QString &name) const;
+ DomSpacer *spacerByName(const QString &name) const;
+ DomLayout *layoutByName(const QString &name) const;
+ DomActionGroup *actionGroupByName(const QString &name) const;
+ DomAction *actionByName(const QString &name) const;
+
+ // pixmap
+ void insertPixmap(const QString &pixmap);
+ bool containsPixmap(const QString &pixmap) const;
+
+private:
+ Option m_option;
+ QTextStream m_stdout;
+ QTextStream *m_output;
+
+ QStringList m_problems;
+
+ // symbol tables
+ QHash<DomWidget*, QString> m_widgets;
+ QHash<DomSpacer*, QString> m_spacers;
+ QHash<DomLayout*, QString> m_layouts;
+ QHash<DomActionGroup*, QString> m_actionGroups;
+ typedef QHash<const DomButtonGroup*, QString> ButtonGroupNameHash;
+ ButtonGroupNameHash m_buttonGroups;
+ QHash<DomAction*, QString> m_actions;
+ QHash<QString, bool> m_nameRepository;
+ QHash<QString, bool> m_pixmaps;
+};
+
+QT_END_NAMESPACE
+
+#endif // DRIVER_H
diff --git a/src/tools/uic/globaldefs.h b/src/tools/uic/globaldefs.h
new file mode 100644
index 0000000000..9ab758b731
--- /dev/null
+++ b/src/tools/uic/globaldefs.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GLOBALDEFS_H
+#define GLOBALDEFS_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+enum { BOXLAYOUT_DEFAULT_MARGIN = 11 };
+enum { BOXLAYOUT_DEFAULT_SPACING = 6 };
+
+QT_END_NAMESPACE
+
+#endif // GLOBALDEFS_H
diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp
new file mode 100644
index 0000000000..f8d4c40433
--- /dev/null
+++ b/src/tools/uic/main.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "uic.h"
+#include "option.h"
+#include "driver.h"
+#include "../../corelib/global/qconfig.cpp"
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+#include <QtCore/QTextStream>
+#include <QtCore/QTextCodec>
+
+QT_BEGIN_NAMESPACE
+
+static const char *error = 0;
+
+void showHelp(const char *appName)
+{
+ fprintf(stderr, "Qt User Interface Compiler version %s\n", QT_VERSION_STR);
+ if (error)
+ fprintf(stderr, "%s: %s\n", appName, error);
+
+ fprintf(stderr, "Usage: %s [options] <uifile>\n\n"
+ " -h, -help display this help and exit\n"
+ " -v, -version display version\n"
+ " -d, -dependencies display the dependencies\n"
+ " -o <file> place the output into <file>\n"
+ " -tr <func> use func() for i18n\n"
+ " -p, -no-protection disable header protection\n"
+ " -n, -no-implicit-includes disable generation of #include-directives\n"
+ " for forms generated by uic3\n"
+ " -g <name> change generator\n"
+ "\n", appName);
+}
+
+int runUic(int argc, char *argv[])
+{
+ Driver driver;
+
+ const char *fileName = 0;
+
+ int arg = 1;
+ while (arg < argc) {
+ QString opt = QString::fromLocal8Bit(argv[arg]);
+ if (opt == QLatin1String("-h") || opt == QLatin1String("-help")) {
+ showHelp(argv[0]);
+ return 0;
+ } else if (opt == QLatin1String("-d") || opt == QLatin1String("-dependencies")) {
+ driver.option().dependencies = true;
+ } else if (opt == QLatin1String("-v") || opt == QLatin1String("-version")) {
+ fprintf(stderr, "Qt User Interface Compiler version %s\n", QT_VERSION_STR);
+ return 0;
+ } else if (opt == QLatin1String("-o") || opt == QLatin1String("-output")) {
+ ++arg;
+ if (!argv[arg]) {
+ showHelp(argv[0]);
+ return 1;
+ }
+ driver.option().outputFile = QFile::decodeName(argv[arg]);
+ } else if (opt == QLatin1String("-p") || opt == QLatin1String("-no-protection")) {
+ driver.option().headerProtection = false;
+ } else if (opt == QLatin1String("-n") || opt == QLatin1String("-no-implicit-includes")) {
+ driver.option().implicitIncludes = false;
+ } else if (opt == QLatin1String("-postfix")) {
+ ++arg;
+ if (!argv[arg]) {
+ showHelp(argv[0]);
+ return 1;
+ }
+ driver.option().postfix = QLatin1String(argv[arg]);
+ } else if (opt == QLatin1String("-3")) {
+ ++arg;
+ if (!argv[arg]) {
+ showHelp(argv[0]);
+ return 1;
+ }
+ driver.option().uic3 = QFile::decodeName(argv[arg]);
+ } else if (opt == QLatin1String("-tr") || opt == QLatin1String("-translate")) {
+ ++arg;
+ if (!argv[arg]) {
+ showHelp(argv[0]);
+ return 1;
+ }
+ driver.option().translateFunction = QLatin1String(argv[arg]);
+ } else if (opt == QLatin1String("-g") || opt == QLatin1String("-generator")) {
+ ++arg;
+ if (!argv[arg]) {
+ showHelp(argv[0]);
+ return 1;
+ }
+ QString name = QString::fromLocal8Bit(argv[arg]).toLower ();
+ driver.option().generator = (name == QLatin1String ("java")) ? Option::JavaGenerator : Option::CppGenerator;
+ } else if (!fileName) {
+ fileName = argv[arg];
+ } else {
+ showHelp(argv[0]);
+ return 1;
+ }
+
+ ++arg;
+ }
+
+ QString inputFile;
+ if (fileName)
+ inputFile = QString::fromLocal8Bit(fileName);
+ else
+ driver.option().headerProtection = false;
+
+ if (driver.option().dependencies) {
+ return !driver.printDependencies(inputFile);
+ }
+
+ QTextStream *out = 0;
+ QFile f;
+ if (driver.option().outputFile.size()) {
+ f.setFileName(driver.option().outputFile);
+ if (!f.open(QIODevice::WriteOnly | QFile::Text)) {
+ fprintf(stderr, "Could not create output file\n");
+ return 1;
+ }
+ out = new QTextStream(&f);
+ out->setCodec(QTextCodec::codecForName("UTF-8"));
+ }
+
+ bool rtn = driver.uic(inputFile, out);
+ delete out;
+
+ if (!rtn) {
+ if (driver.option().outputFile.size()) {
+ f.close();
+ f.remove();
+ }
+ fprintf(stderr, "File '%s' is not valid\n", inputFile.isEmpty() ? "<stdin>" : inputFile.toLocal8Bit().constData());
+ }
+
+ return !rtn;
+}
+
+QT_END_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ return QT_PREPEND_NAMESPACE(runUic)(argc, argv);
+}
diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h
new file mode 100644
index 0000000000..976b531c4b
--- /dev/null
+++ b/src/tools/uic/option.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OPTION_H
+#define OPTION_H
+
+#include <QtCore/QString>
+#include <QtCore/QDir>
+
+QT_BEGIN_NAMESPACE
+
+struct Option
+{
+ enum Generator
+ {
+ CppGenerator,
+ JavaGenerator
+ };
+
+ unsigned int headerProtection : 1;
+ unsigned int copyrightHeader : 1;
+ unsigned int generateImplemetation : 1;
+ 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;
+ Generator generator;
+
+ QString inputFile;
+ QString outputFile;
+ QString qrcOutputFile;
+ QString indent;
+ QString prefix;
+ QString postfix;
+ QString translateFunction;
+ QString uic3;
+#ifdef QT_UIC_JAVA_GENERATOR
+ QString javaPackage;
+ QString javaOutputDirectory;
+#endif
+
+ Option()
+ : headerProtection(1),
+ copyrightHeader(1),
+ generateImplemetation(0),
+ generateNamespace(1),
+ autoConnection(1),
+ dependencies(0),
+ extractImages(0),
+ limitXPM_LineLength(0),
+ implicitIncludes(1),
+ generator(CppGenerator),
+ prefix(QLatin1String("Ui_"))
+ { indent.fill(QLatin1Char(' '), 4); }
+
+ QString messagePrefix() const
+ {
+ return inputFile.isEmpty() ?
+ QString(QLatin1String("stdin")) :
+ QDir::toNativeSeparators(inputFile);
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // OPTION_H
diff --git a/src/tools/uic/treewalker.cpp b/src/tools/uic/treewalker.cpp
new file mode 100644
index 0000000000..ed72284d0c
--- /dev/null
+++ b/src/tools/uic/treewalker.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "treewalker.h"
+#include "ui4.h"
+
+QT_BEGIN_NAMESPACE
+
+void TreeWalker::acceptUI(DomUI *ui)
+{
+ acceptWidget(ui->elementWidget());
+ if (const DomButtonGroups *domButtonGroups = ui->elementButtonGroups())
+ acceptButtonGroups(domButtonGroups);
+
+ acceptTabStops(ui->elementTabStops());
+
+ if (ui->elementImages())
+ acceptImages(ui->elementImages());
+}
+
+void TreeWalker::acceptLayoutDefault(DomLayoutDefault *layoutDefault)
+{
+ Q_UNUSED(layoutDefault);
+}
+
+void TreeWalker::acceptLayoutFunction(DomLayoutFunction *layoutFunction)
+{
+ Q_UNUSED(layoutFunction);
+}
+
+void TreeWalker::acceptTabStops(DomTabStops *tabStops)
+{
+ Q_UNUSED(tabStops);
+}
+
+void TreeWalker::acceptLayout(DomLayout *layout)
+{
+ for (int i=0; i<layout->elementProperty().size(); ++i)
+ acceptProperty(layout->elementProperty().at(i));
+
+ for (int i=0; i<layout->elementItem().size(); ++i)
+ acceptLayoutItem(layout->elementItem().at(i));
+}
+
+void TreeWalker::acceptLayoutItem(DomLayoutItem *layoutItem)
+{
+ switch (layoutItem->kind()) {
+ case DomLayoutItem::Widget:
+ acceptWidget(layoutItem->elementWidget());
+ return;
+ case DomLayoutItem::Layout:
+ acceptLayout(layoutItem->elementLayout());
+ return;
+ case DomLayoutItem::Spacer:
+ acceptSpacer(layoutItem->elementSpacer());
+ return;
+ case DomLayoutItem::Unknown:
+ break;
+ }
+
+ Q_ASSERT( 0 );
+}
+
+void TreeWalker::acceptWidget(DomWidget *widget)
+{
+ for (int i=0; i<widget->elementAction().size(); ++i)
+ acceptAction(widget->elementAction().at(i));
+
+ for (int i=0; i<widget->elementActionGroup().size(); ++i)
+ acceptActionGroup(widget->elementActionGroup().at(i));
+
+ for (int i=0; i<widget->elementAddAction().size(); ++i)
+ acceptActionRef(widget->elementAddAction().at(i));
+
+ for (int i=0; i<widget->elementProperty().size(); ++i)
+ acceptProperty(widget->elementProperty().at(i));
+
+
+
+ // recurse down
+ DomWidgets childWidgets;
+ for (int i=0; i<widget->elementWidget().size(); ++i) {
+ DomWidget *child = widget->elementWidget().at(i);
+ childWidgets += child;
+ acceptWidget(child);
+ }
+
+ if (!widget->elementLayout().isEmpty())
+ acceptLayout(widget->elementLayout().at(0));
+
+ const DomScripts scripts(widget->elementScript());
+ acceptWidgetScripts(scripts, widget, childWidgets);
+}
+
+void TreeWalker::acceptSpacer(DomSpacer *spacer)
+{
+ for (int i=0; i<spacer->elementProperty().size(); ++i)
+ acceptProperty(spacer->elementProperty().at(i));
+}
+
+void TreeWalker::acceptColor(DomColor *color)
+{
+ Q_UNUSED(color);
+}
+
+void TreeWalker::acceptColorGroup(DomColorGroup *colorGroup)
+{
+ Q_UNUSED(colorGroup);
+}
+
+void TreeWalker::acceptPalette(DomPalette *palette)
+{
+ acceptColorGroup(palette->elementActive());
+ acceptColorGroup(palette->elementInactive());
+ acceptColorGroup(palette->elementDisabled());
+}
+
+void TreeWalker::acceptFont(DomFont *font)
+{
+ Q_UNUSED(font);
+}
+
+void TreeWalker::acceptPoint(DomPoint *point)
+{
+ Q_UNUSED(point);
+}
+
+void TreeWalker::acceptRect(DomRect *rect)
+{
+ Q_UNUSED(rect);
+}
+
+void TreeWalker::acceptSizePolicy(DomSizePolicy *sizePolicy)
+{
+ Q_UNUSED(sizePolicy);
+}
+
+void TreeWalker::acceptSize(DomSize *size)
+{
+ Q_UNUSED(size);
+}
+
+void TreeWalker::acceptDate(DomDate *date)
+{
+ Q_UNUSED(date);
+}
+
+void TreeWalker::acceptTime(DomTime *time)
+{
+ Q_UNUSED(time);
+}
+
+void TreeWalker::acceptDateTime(DomDateTime *dateTime)
+{
+ Q_UNUSED(dateTime);
+}
+
+void TreeWalker::acceptProperty(DomProperty *property)
+{
+ switch (property->kind()) {
+ case DomProperty::Bool:
+ case DomProperty::Color:
+ case DomProperty::Cstring:
+ case DomProperty::Cursor:
+ case DomProperty::CursorShape:
+ case DomProperty::Enum:
+ case DomProperty::Font:
+ case DomProperty::Pixmap:
+ case DomProperty::IconSet:
+ case DomProperty::Palette:
+ case DomProperty::Point:
+ case DomProperty::PointF:
+ case DomProperty::Rect:
+ case DomProperty::RectF:
+ case DomProperty::Set:
+ case DomProperty::Locale:
+ case DomProperty::SizePolicy:
+ case DomProperty::Size:
+ case DomProperty::SizeF:
+ case DomProperty::String:
+ case DomProperty::Number:
+ case DomProperty::LongLong:
+ case DomProperty::Char:
+ case DomProperty::Date:
+ case DomProperty::Time:
+ case DomProperty::DateTime:
+ case DomProperty::Url:
+ case DomProperty::Unknown:
+ case DomProperty::StringList:
+ case DomProperty::Float:
+ case DomProperty::Double:
+ case DomProperty::UInt:
+ case DomProperty::ULongLong:
+ case DomProperty::Brush:
+ break;
+ }
+}
+
+void TreeWalker::acceptCustomWidgets(DomCustomWidgets *customWidgets)
+{
+ for (int i=0; i<customWidgets->elementCustomWidget().size(); ++i)
+ acceptCustomWidget(customWidgets->elementCustomWidget().at(i));
+}
+
+void TreeWalker::acceptCustomWidget(DomCustomWidget *customWidget)
+{
+ Q_UNUSED(customWidget);
+}
+
+void TreeWalker::acceptAction(DomAction *action)
+{
+ Q_UNUSED(action);
+}
+
+void TreeWalker::acceptActionGroup(DomActionGroup *actionGroup)
+{
+ for (int i=0; i<actionGroup->elementAction().size(); ++i)
+ acceptAction(actionGroup->elementAction().at(i));
+
+ for (int i=0; i<actionGroup->elementActionGroup().size(); ++i)
+ acceptActionGroup(actionGroup->elementActionGroup().at(i));
+}
+
+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)
+ acceptInclude(includes->elementInclude().at(i));
+}
+
+void TreeWalker::acceptInclude(DomInclude *incl)
+{
+ Q_UNUSED(incl);
+}
+
+void TreeWalker::acceptConnections(DomConnections *connections)
+{
+ for (int i=0; i<connections->elementConnection().size(); ++i)
+ acceptConnection(connections->elementConnection().at(i));
+}
+
+void TreeWalker::acceptConnection(DomConnection *connection)
+{
+ acceptConnectionHints(connection->elementHints());
+}
+
+void TreeWalker::acceptConnectionHints(DomConnectionHints *connectionHints)
+{
+ for (int i=0; i<connectionHints->elementHint().size(); ++i)
+ acceptConnectionHint(connectionHints->elementHint().at(i));
+}
+
+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);
+}
+
+void TreeWalker::acceptButtonGroup(const DomButtonGroup *)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h
new file mode 100644
index 0000000000..a4e5d6e6be
--- /dev/null
+++ b/src/tools/uic/treewalker.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TREEWALKER_H
+#define TREEWALKER_H
+
+#include <QtCore/QList>
+
+QT_BEGIN_NAMESPACE
+
+class DomUI;
+class DomLayoutDefault;
+class DomLayoutFunction;
+class DomTabStops;
+class DomLayout;
+class DomLayoutItem;
+class DomWidget;
+class DomSpacer;
+class DomColor;
+class DomColorGroup;
+class DomPalette;
+class DomFont;
+class DomPoint;
+class DomRect;
+class DomSizePolicy;
+class DomSize;
+class DomDate;
+class DomTime;
+class DomDateTime;
+class DomProperty;
+class DomCustomWidgets;
+class DomCustomWidget;
+class DomAction;
+class DomActionGroup;
+class DomActionRef;
+class DomImages;
+class DomImage;
+class DomItem;
+class DomIncludes;
+class DomInclude;
+class DomString;
+class DomResourcePixmap;
+class DomResources;
+class DomResource;
+class DomConnections;
+class DomConnection;
+class DomConnectionHints;
+class DomConnectionHint;
+class DomScript;
+class DomButtonGroups;
+class DomButtonGroup;
+
+struct TreeWalker
+{
+ inline virtual ~TreeWalker() {}
+
+ virtual void acceptUI(DomUI *ui);
+ virtual void acceptLayoutDefault(DomLayoutDefault *layoutDefault);
+ virtual void acceptLayoutFunction(DomLayoutFunction *layoutFunction);
+ virtual void acceptTabStops(DomTabStops *tabStops);
+ virtual void acceptCustomWidgets(DomCustomWidgets *customWidgets);
+ virtual void acceptCustomWidget(DomCustomWidget *customWidget);
+ virtual void acceptLayout(DomLayout *layout);
+ virtual void acceptLayoutItem(DomLayoutItem *layoutItem);
+ virtual void acceptWidget(DomWidget *widget);
+ virtual void acceptSpacer(DomSpacer *spacer);
+ virtual void acceptColor(DomColor *color);
+ virtual void acceptColorGroup(DomColorGroup *colorGroup);
+ virtual void acceptPalette(DomPalette *palette);
+ virtual void acceptFont(DomFont *font);
+ virtual void acceptPoint(DomPoint *point);
+ virtual void acceptRect(DomRect *rect);
+ virtual void acceptSizePolicy(DomSizePolicy *sizePolicy);
+ virtual void acceptSize(DomSize *size);
+ virtual void acceptDate(DomDate *date);
+ 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);
+ virtual void acceptIncludes(DomIncludes *includes);
+ virtual void acceptInclude(DomInclude *incl);
+ virtual void acceptAction(DomAction *action);
+ virtual void acceptActionGroup(DomActionGroup *actionGroup);
+ virtual void acceptActionRef(DomActionRef *actionRef);
+ virtual void acceptConnections(DomConnections *connections);
+ virtual void acceptConnection(DomConnection *connection);
+ virtual void acceptConnectionHints(DomConnectionHints *connectionHints);
+ virtual void acceptConnectionHint(DomConnectionHint *connectionHint);
+ virtual void acceptButtonGroups(const DomButtonGroups *buttonGroups);
+ virtual void acceptButtonGroup(const DomButtonGroup *buttonGroup);
+};
+
+QT_END_NAMESPACE
+
+#endif // TREEWALKER_H
diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp
new file mode 100644
index 0000000000..94d931b87c
--- /dev/null
+++ b/src/tools/uic/ui4.cpp
@@ -0,0 +1,11154 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "ui4.h"
+
+#ifdef QUILOADER_QDOM_READ
+#include <QtXml/QDomElement>
+#endif
+
+QT_BEGIN_NAMESPACE
+#ifdef QFORMINTERNAL_NAMESPACE
+using namespace QFormInternal;
+#endif
+
+/*******************************************************************************
+** 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;
+ 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;
+}
+
+void DomUI::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("version")) {
+ setAttributeVersion(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("language")) {
+ setAttributeLanguage(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("displayname")) {
+ setAttributeDisplayname(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("stdsetdef")) {
+ setAttributeStdsetdef(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("stdSetDef")) {
+ setAttributeStdSetDef(attribute.value().toString().toInt());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("author")) {
+ setElementAuthor(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("comment")) {
+ setElementComment(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("exportmacro")) {
+ setElementExportMacro(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("class")) {
+ setElementClass(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("widget")) {
+ DomWidget *v = new DomWidget();
+ v->read(reader);
+ setElementWidget(v);
+ continue;
+ }
+ if (tag == QLatin1String("layoutdefault")) {
+ DomLayoutDefault *v = new DomLayoutDefault();
+ v->read(reader);
+ setElementLayoutDefault(v);
+ continue;
+ }
+ if (tag == QLatin1String("layoutfunction")) {
+ DomLayoutFunction *v = new DomLayoutFunction();
+ v->read(reader);
+ setElementLayoutFunction(v);
+ continue;
+ }
+ if (tag == QLatin1String("pixmapfunction")) {
+ setElementPixmapFunction(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("customwidgets")) {
+ DomCustomWidgets *v = new DomCustomWidgets();
+ v->read(reader);
+ setElementCustomWidgets(v);
+ continue;
+ }
+ if (tag == QLatin1String("tabstops")) {
+ DomTabStops *v = new DomTabStops();
+ v->read(reader);
+ setElementTabStops(v);
+ continue;
+ }
+ if (tag == QLatin1String("images")) {
+ DomImages *v = new DomImages();
+ v->read(reader);
+ setElementImages(v);
+ continue;
+ }
+ if (tag == QLatin1String("includes")) {
+ DomIncludes *v = new DomIncludes();
+ v->read(reader);
+ setElementIncludes(v);
+ continue;
+ }
+ if (tag == QLatin1String("resources")) {
+ DomResources *v = new DomResources();
+ v->read(reader);
+ setElementResources(v);
+ continue;
+ }
+ if (tag == QLatin1String("connections")) {
+ DomConnections *v = new DomConnections();
+ v->read(reader);
+ setElementConnections(v);
+ continue;
+ }
+ if (tag == QLatin1String("designerdata")) {
+ DomDesignerData *v = new DomDesignerData();
+ v->read(reader);
+ setElementDesignerdata(v);
+ continue;
+ }
+ if (tag == QLatin1String("slots")) {
+ DomSlots *v = new DomSlots();
+ v->read(reader);
+ setElementSlots(v);
+ continue;
+ }
+ if (tag == QLatin1String("buttongroups")) {
+ DomButtonGroups *v = new DomButtonGroups();
+ v->read(reader);
+ setElementButtonGroups(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomUI::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("version")))
+ setAttributeVersion(node.attribute(QLatin1String("version")));
+ if (node.hasAttribute(QLatin1String("language")))
+ setAttributeLanguage(node.attribute(QLatin1String("language")));
+ if (node.hasAttribute(QLatin1String("displayname")))
+ setAttributeDisplayname(node.attribute(QLatin1String("displayname")));
+ if (node.hasAttribute(QLatin1String("stdsetdef")))
+ setAttributeStdsetdef(node.attribute(QLatin1String("stdsetdef")).toInt());
+ if (node.hasAttribute(QLatin1String("stdSetDef")))
+ setAttributeStdSetDef(node.attribute(QLatin1String("stdSetDef")).toInt());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("author")) {
+ setElementAuthor(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("comment")) {
+ setElementComment(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("exportmacro")) {
+ setElementExportMacro(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("class")) {
+ setElementClass(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("widget")) {
+ DomWidget *v = new DomWidget();
+ v->read(e);
+ setElementWidget(v);
+ continue;
+ }
+ if (tag == QLatin1String("layoutdefault")) {
+ DomLayoutDefault *v = new DomLayoutDefault();
+ v->read(e);
+ setElementLayoutDefault(v);
+ continue;
+ }
+ if (tag == QLatin1String("layoutfunction")) {
+ DomLayoutFunction *v = new DomLayoutFunction();
+ v->read(e);
+ setElementLayoutFunction(v);
+ continue;
+ }
+ if (tag == QLatin1String("pixmapfunction")) {
+ setElementPixmapFunction(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("customwidgets")) {
+ DomCustomWidgets *v = new DomCustomWidgets();
+ v->read(e);
+ setElementCustomWidgets(v);
+ continue;
+ }
+ if (tag == QLatin1String("tabstops")) {
+ DomTabStops *v = new DomTabStops();
+ v->read(e);
+ setElementTabStops(v);
+ continue;
+ }
+ if (tag == QLatin1String("images")) {
+ DomImages *v = new DomImages();
+ v->read(e);
+ setElementImages(v);
+ continue;
+ }
+ if (tag == QLatin1String("includes")) {
+ DomIncludes *v = new DomIncludes();
+ v->read(e);
+ setElementIncludes(v);
+ continue;
+ }
+ if (tag == QLatin1String("resources")) {
+ DomResources *v = new DomResources();
+ v->read(e);
+ setElementResources(v);
+ continue;
+ }
+ if (tag == QLatin1String("connections")) {
+ DomConnections *v = new DomConnections();
+ v->read(e);
+ setElementConnections(v);
+ continue;
+ }
+ if (tag == QLatin1String("designerdata")) {
+ DomDesignerData *v = new DomDesignerData();
+ v->read(e);
+ setElementDesignerdata(v);
+ continue;
+ }
+ if (tag == QLatin1String("slots")) {
+ DomSlots *v = new DomSlots();
+ v->read(e);
+ setElementSlots(v);
+ continue;
+ }
+ if (tag == QLatin1String("buttongroups")) {
+ DomButtonGroups *v = new DomButtonGroups();
+ v->read(e);
+ setElementButtonGroups(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("ui") : tagName.toLower());
+
+ if (hasAttributeVersion())
+ writer.writeAttribute(QLatin1String("version"), attributeVersion());
+
+ if (hasAttributeLanguage())
+ writer.writeAttribute(QLatin1String("language"), attributeLanguage());
+
+ if (hasAttributeDisplayname())
+ writer.writeAttribute(QLatin1String("displayname"), attributeDisplayname());
+
+ if (hasAttributeStdsetdef())
+ writer.writeAttribute(QLatin1String("stdsetdef"), QString::number(attributeStdsetdef()));
+
+ if (hasAttributeStdSetDef())
+ writer.writeAttribute(QLatin1String("stdsetdef"), QString::number(attributeStdSetDef()));
+
+ if (m_children & Author) {
+ writer.writeTextElement(QLatin1String("author"), m_author);
+ }
+
+ if (m_children & Comment) {
+ writer.writeTextElement(QLatin1String("comment"), m_comment);
+ }
+
+ if (m_children & ExportMacro) {
+ writer.writeTextElement(QLatin1String("exportmacro"), m_exportMacro);
+ }
+
+ if (m_children & Class) {
+ writer.writeTextElement(QLatin1String("class"), m_class);
+ }
+
+ if (m_children & Widget) {
+ m_widget->write(writer, QLatin1String("widget"));
+ }
+
+ if (m_children & LayoutDefault) {
+ m_layoutDefault->write(writer, QLatin1String("layoutdefault"));
+ }
+
+ if (m_children & LayoutFunction) {
+ m_layoutFunction->write(writer, QLatin1String("layoutfunction"));
+ }
+
+ if (m_children & PixmapFunction) {
+ writer.writeTextElement(QLatin1String("pixmapfunction"), m_pixmapFunction);
+ }
+
+ if (m_children & CustomWidgets) {
+ m_customWidgets->write(writer, QLatin1String("customwidgets"));
+ }
+
+ if (m_children & TabStops) {
+ m_tabStops->write(writer, QLatin1String("tabstops"));
+ }
+
+ if (m_children & Images) {
+ m_images->write(writer, QLatin1String("images"));
+ }
+
+ if (m_children & Includes) {
+ m_includes->write(writer, QLatin1String("includes"));
+ }
+
+ if (m_children & Resources) {
+ m_resources->write(writer, QLatin1String("resources"));
+ }
+
+ if (m_children & Connections) {
+ m_connections->write(writer, QLatin1String("connections"));
+ }
+
+ if (m_children & Designerdata) {
+ m_designerdata->write(writer, QLatin1String("designerdata"));
+ }
+
+ if (m_children & Slots) {
+ m_slots->write(writer, QLatin1String("slots"));
+ }
+
+ if (m_children & ButtonGroups) {
+ m_buttonGroups->write(writer, QLatin1String("buttongroups"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomUI::setElementAuthor(const QString& a)
+{
+ m_children |= Author;
+ m_author = a;
+}
+
+void DomUI::setElementComment(const QString& a)
+{
+ m_children |= Comment;
+ m_comment = a;
+}
+
+void DomUI::setElementExportMacro(const QString& a)
+{
+ m_children |= ExportMacro;
+ m_exportMacro = a;
+}
+
+void DomUI::setElementClass(const QString& a)
+{
+ m_children |= Class;
+ m_class = a;
+}
+
+DomWidget* DomUI::takeElementWidget()
+{
+ DomWidget* a = m_widget;
+ m_widget = 0;
+ m_children ^= Widget;
+ return a;
+}
+
+void DomUI::setElementWidget(DomWidget* a)
+{
+ delete m_widget;
+ m_children |= Widget;
+ m_widget = a;
+}
+
+DomLayoutDefault* DomUI::takeElementLayoutDefault()
+{
+ DomLayoutDefault* a = m_layoutDefault;
+ m_layoutDefault = 0;
+ m_children ^= LayoutDefault;
+ return a;
+}
+
+void DomUI::setElementLayoutDefault(DomLayoutDefault* a)
+{
+ delete m_layoutDefault;
+ m_children |= LayoutDefault;
+ m_layoutDefault = a;
+}
+
+DomLayoutFunction* DomUI::takeElementLayoutFunction()
+{
+ DomLayoutFunction* a = m_layoutFunction;
+ m_layoutFunction = 0;
+ m_children ^= LayoutFunction;
+ return a;
+}
+
+void DomUI::setElementLayoutFunction(DomLayoutFunction* a)
+{
+ delete m_layoutFunction;
+ m_children |= LayoutFunction;
+ m_layoutFunction = a;
+}
+
+void DomUI::setElementPixmapFunction(const QString& a)
+{
+ m_children |= PixmapFunction;
+ m_pixmapFunction = a;
+}
+
+DomCustomWidgets* DomUI::takeElementCustomWidgets()
+{
+ DomCustomWidgets* a = m_customWidgets;
+ m_customWidgets = 0;
+ m_children ^= CustomWidgets;
+ return a;
+}
+
+void DomUI::setElementCustomWidgets(DomCustomWidgets* a)
+{
+ delete m_customWidgets;
+ m_children |= CustomWidgets;
+ m_customWidgets = a;
+}
+
+DomTabStops* DomUI::takeElementTabStops()
+{
+ DomTabStops* a = m_tabStops;
+ m_tabStops = 0;
+ m_children ^= TabStops;
+ return 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* a = m_includes;
+ m_includes = 0;
+ m_children ^= Includes;
+ return a;
+}
+
+void DomUI::setElementIncludes(DomIncludes* a)
+{
+ delete m_includes;
+ m_children |= Includes;
+ m_includes = a;
+}
+
+DomResources* DomUI::takeElementResources()
+{
+ DomResources* a = m_resources;
+ m_resources = 0;
+ m_children ^= Resources;
+ return a;
+}
+
+void DomUI::setElementResources(DomResources* a)
+{
+ delete m_resources;
+ m_children |= Resources;
+ m_resources = a;
+}
+
+DomConnections* DomUI::takeElementConnections()
+{
+ DomConnections* a = m_connections;
+ m_connections = 0;
+ m_children ^= Connections;
+ return a;
+}
+
+void DomUI::setElementConnections(DomConnections* a)
+{
+ delete m_connections;
+ m_children |= Connections;
+ m_connections = a;
+}
+
+DomDesignerData* DomUI::takeElementDesignerdata()
+{
+ DomDesignerData* a = m_designerdata;
+ m_designerdata = 0;
+ m_children ^= Designerdata;
+ return a;
+}
+
+void DomUI::setElementDesignerdata(DomDesignerData* a)
+{
+ delete m_designerdata;
+ m_children |= Designerdata;
+ m_designerdata = a;
+}
+
+DomSlots* DomUI::takeElementSlots()
+{
+ DomSlots* a = m_slots;
+ m_slots = 0;
+ m_children ^= Slots;
+ return a;
+}
+
+void DomUI::setElementSlots(DomSlots* a)
+{
+ delete m_slots;
+ m_children |= Slots;
+ m_slots = a;
+}
+
+DomButtonGroups* DomUI::takeElementButtonGroups()
+{
+ DomButtonGroups* a = m_buttonGroups;
+ m_buttonGroups = 0;
+ m_children ^= ButtonGroups;
+ return a;
+}
+
+void DomUI::setElementButtonGroups(DomButtonGroups* a)
+{
+ delete m_buttonGroups;
+ m_children |= ButtonGroups;
+ m_buttonGroups = a;
+}
+
+void DomUI::clearElementAuthor()
+{
+ m_children &= ~Author;
+}
+
+void DomUI::clearElementComment()
+{
+ m_children &= ~Comment;
+}
+
+void DomUI::clearElementExportMacro()
+{
+ m_children &= ~ExportMacro;
+}
+
+void DomUI::clearElementClass()
+{
+ m_children &= ~Class;
+}
+
+void DomUI::clearElementWidget()
+{
+ delete m_widget;
+ m_widget = 0;
+ m_children &= ~Widget;
+}
+
+void DomUI::clearElementLayoutDefault()
+{
+ delete m_layoutDefault;
+ m_layoutDefault = 0;
+ m_children &= ~LayoutDefault;
+}
+
+void DomUI::clearElementLayoutFunction()
+{
+ delete m_layoutFunction;
+ m_layoutFunction = 0;
+ m_children &= ~LayoutFunction;
+}
+
+void DomUI::clearElementPixmapFunction()
+{
+ m_children &= ~PixmapFunction;
+}
+
+void DomUI::clearElementCustomWidgets()
+{
+ delete m_customWidgets;
+ m_customWidgets = 0;
+ m_children &= ~CustomWidgets;
+}
+
+void DomUI::clearElementTabStops()
+{
+ delete m_tabStops;
+ m_tabStops = 0;
+ m_children &= ~TabStops;
+}
+
+void DomUI::clearElementImages()
+{
+ delete m_images;
+ m_images = 0;
+ m_children &= ~Images;
+}
+
+void DomUI::clearElementIncludes()
+{
+ delete m_includes;
+ m_includes = 0;
+ m_children &= ~Includes;
+}
+
+void DomUI::clearElementResources()
+{
+ delete m_resources;
+ m_resources = 0;
+ m_children &= ~Resources;
+}
+
+void DomUI::clearElementConnections()
+{
+ delete m_connections;
+ m_connections = 0;
+ m_children &= ~Connections;
+}
+
+void DomUI::clearElementDesignerdata()
+{
+ delete m_designerdata;
+ m_designerdata = 0;
+ m_children &= ~Designerdata;
+}
+
+void DomUI::clearElementSlots()
+{
+ delete m_slots;
+ m_slots = 0;
+ m_children &= ~Slots;
+}
+
+void DomUI::clearElementButtonGroups()
+{
+ delete m_buttonGroups;
+ m_buttonGroups = 0;
+ 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);
+ m_include.clear();
+}
+
+void DomIncludes::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("include")) {
+ DomInclude *v = new DomInclude();
+ v->read(reader);
+ m_include.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomIncludes::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("include")) {
+ DomInclude *v = new DomInclude();
+ v->read(e);
+ m_include.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomIncludes::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("includes") : tagName.toLower());
+
+ for (int i = 0; i < m_include.size(); ++i) {
+ DomInclude* v = m_include[i];
+ v->write(writer, QLatin1String("include"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomIncludes::setElementInclude(const QList<DomInclude*>& a)
+{
+ m_children |= Include;
+ m_include = a;
+}
+
+void DomInclude::clear(bool clear_all)
+{
+
+ if (clear_all) {
+ m_text = QLatin1String("");
+ 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 = QLatin1String("");
+}
+
+DomInclude::~DomInclude()
+{
+}
+
+void DomInclude::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("location")) {
+ setAttributeLocation(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("impldecl")) {
+ setAttributeImpldecl(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomInclude::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("location")))
+ setAttributeLocation(node.attribute(QLatin1String("location")));
+ if (node.hasAttribute(QLatin1String("impldecl")))
+ setAttributeImpldecl(node.attribute(QLatin1String("impldecl")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text = QLatin1String("");
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomInclude::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("include") : tagName.toLower());
+
+ if (hasAttributeLocation())
+ writer.writeAttribute(QLatin1String("location"), attributeLocation());
+
+ if (hasAttributeImpldecl())
+ writer.writeAttribute(QLatin1String("impldecl"), attributeImpldecl());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ 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);
+ m_include.clear();
+}
+
+void DomResources::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("include")) {
+ DomResource *v = new DomResource();
+ v->read(reader);
+ m_include.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomResources::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("include")) {
+ DomResource *v = new DomResource();
+ v->read(e);
+ m_include.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomResources::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resources") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ for (int i = 0; i < m_include.size(); ++i) {
+ DomResource* v = m_include[i];
+ v->write(writer, QLatin1String("include"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomResources::setElementInclude(const QList<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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("location")) {
+ setAttributeLocation(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomResource::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("location")))
+ setAttributeLocation(node.attribute(QLatin1String("location")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomResource::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resource") : tagName.toLower());
+
+ if (hasAttributeLocation())
+ writer.writeAttribute(QLatin1String("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);
+ m_action.clear();
+ qDeleteAll(m_actionGroup);
+ m_actionGroup.clear();
+ qDeleteAll(m_property);
+ m_property.clear();
+ qDeleteAll(m_attribute);
+ m_attribute.clear();
+}
+
+void DomActionGroup::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("action")) {
+ DomAction *v = new DomAction();
+ v->read(reader);
+ m_action.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("actiongroup")) {
+ DomActionGroup *v = new DomActionGroup();
+ v->read(reader);
+ m_actionGroup.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ m_attribute.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomActionGroup::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("action")) {
+ DomAction *v = new DomAction();
+ v->read(e);
+ m_action.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("actiongroup")) {
+ DomActionGroup *v = new DomActionGroup();
+ v->read(e);
+ m_actionGroup.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_attribute.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomActionGroup::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("actiongroup") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ for (int i = 0; i < m_action.size(); ++i) {
+ DomAction* v = m_action[i];
+ v->write(writer, QLatin1String("action"));
+ }
+ for (int i = 0; i < m_actionGroup.size(); ++i) {
+ DomActionGroup* v = m_actionGroup[i];
+ v->write(writer, QLatin1String("actiongroup"));
+ }
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ for (int i = 0; i < m_attribute.size(); ++i) {
+ DomProperty* v = m_attribute[i];
+ v->write(writer, QLatin1String("attribute"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomActionGroup::setElementAction(const QList<DomAction*>& a)
+{
+ m_children |= Action;
+ m_action = a;
+}
+
+void DomActionGroup::setElementActionGroup(const QList<DomActionGroup*>& a)
+{
+ m_children |= ActionGroup;
+ m_actionGroup = a;
+}
+
+void DomActionGroup::setElementProperty(const QList<DomProperty*>& a)
+{
+ m_children |= Property;
+ m_property = 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);
+ m_property.clear();
+ qDeleteAll(m_attribute);
+ m_attribute.clear();
+}
+
+void DomAction::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("menu")) {
+ setAttributeMenu(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ m_attribute.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomAction::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("menu")))
+ setAttributeMenu(node.attribute(QLatin1String("menu")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_attribute.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomAction::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("action") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeMenu())
+ writer.writeAttribute(QLatin1String("menu"), attributeMenu());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ for (int i = 0; i < m_attribute.size(); ++i) {
+ DomProperty* v = m_attribute[i];
+ v->write(writer, QLatin1String("attribute"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomAction::setElementProperty(const QList<DomProperty*>& a)
+{
+ m_children |= Property;
+ m_property = 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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomActionRef::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomActionRef::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("actionref") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("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);
+ m_property.clear();
+ qDeleteAll(m_attribute);
+ m_attribute.clear();
+}
+
+void DomButtonGroup::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ m_attribute.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomButtonGroup::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_attribute.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomButtonGroup::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("buttongroup") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ for (int i = 0; i < m_attribute.size(); ++i) {
+ DomProperty* v = m_attribute[i];
+ v->write(writer, QLatin1String("attribute"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomButtonGroup::setElementProperty(const QList<DomProperty*>& a)
+{
+ m_children |= Property;
+ m_property = 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);
+ m_buttonGroup.clear();
+}
+
+void DomButtonGroups::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("buttongroup")) {
+ DomButtonGroup *v = new DomButtonGroup();
+ v->read(reader);
+ m_buttonGroup.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomButtonGroups::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("buttongroup")) {
+ DomButtonGroup *v = new DomButtonGroup();
+ v->read(e);
+ m_buttonGroup.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomButtonGroups::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("buttongroups") : tagName.toLower());
+
+ for (int i = 0; i < m_buttonGroup.size(); ++i) {
+ DomButtonGroup* v = m_buttonGroup[i];
+ v->write(writer, QLatin1String("buttongroup"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomButtonGroups::setElementButtonGroup(const QList<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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomImages::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("image")) {
+ DomImage *v = new DomImage();
+ v->read(e);
+ m_image.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+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, QLatin1String("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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomImage::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("data")) {
+ DomImageData *v = new DomImageData();
+ v->read(e);
+ setElementData(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomImage::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("image") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (m_children & Data) {
+ m_data->write(writer, QLatin1String("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 = QLatin1String("");
+ 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 = QLatin1String("");
+}
+
+DomImageData::~DomImageData()
+{
+}
+
+void DomImageData::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("format")) {
+ setAttributeFormat(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("length")) {
+ setAttributeLength(attribute.value().toString().toInt());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomImageData::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("format")))
+ setAttributeFormat(node.attribute(QLatin1String("format")));
+ if (node.hasAttribute(QLatin1String("length")))
+ setAttributeLength(node.attribute(QLatin1String("length")).toInt());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text = QLatin1String("");
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomImageData::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("imagedata") : tagName.toLower());
+
+ if (hasAttributeFormat())
+ writer.writeAttribute(QLatin1String("format"), attributeFormat());
+
+ if (hasAttributeLength())
+ writer.writeAttribute(QLatin1String("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);
+ m_customWidget.clear();
+}
+
+void DomCustomWidgets::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("customwidget")) {
+ DomCustomWidget *v = new DomCustomWidget();
+ v->read(reader);
+ m_customWidget.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomCustomWidgets::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("customwidget")) {
+ DomCustomWidget *v = new DomCustomWidget();
+ v->read(e);
+ m_customWidget.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomCustomWidgets::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("customwidgets") : tagName.toLower());
+
+ for (int i = 0; i < m_customWidget.size(); ++i) {
+ DomCustomWidget* v = m_customWidget[i];
+ v->write(writer, QLatin1String("customwidget"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomCustomWidgets::setElementCustomWidget(const QList<DomCustomWidget*>& a)
+{
+ m_children |= CustomWidget;
+ m_customWidget = a;
+}
+
+void DomHeader::clear(bool clear_all)
+{
+
+ if (clear_all) {
+ m_text = QLatin1String("");
+ m_has_attr_location = false;
+ }
+
+ m_children = 0;
+}
+
+DomHeader::DomHeader()
+{
+ m_children = 0;
+ m_has_attr_location = false;
+ m_text = QLatin1String("");
+}
+
+DomHeader::~DomHeader()
+{
+}
+
+void DomHeader::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("location")) {
+ setAttributeLocation(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomHeader::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("location")))
+ setAttributeLocation(node.attribute(QLatin1String("location")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text = QLatin1String("");
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomHeader::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("header") : tagName.toLower());
+
+ if (hasAttributeLocation())
+ writer.writeAttribute(QLatin1String("location"), attributeLocation());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ 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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("class")) {
+ setElementClass(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("extends")) {
+ setElementExtends(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("header")) {
+ DomHeader *v = new DomHeader();
+ v->read(reader);
+ setElementHeader(v);
+ continue;
+ }
+ if (tag == QLatin1String("sizehint")) {
+ DomSize *v = new DomSize();
+ v->read(reader);
+ setElementSizeHint(v);
+ continue;
+ }
+ if (tag == QLatin1String("addpagemethod")) {
+ setElementAddPageMethod(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("container")) {
+ setElementContainer(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("sizepolicy")) {
+ DomSizePolicyData *v = new DomSizePolicyData();
+ v->read(reader);
+ setElementSizePolicy(v);
+ continue;
+ }
+ if (tag == QLatin1String("pixmap")) {
+ setElementPixmap(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("script")) {
+ DomScript *v = new DomScript();
+ v->read(reader);
+ setElementScript(v);
+ continue;
+ }
+ if (tag == QLatin1String("properties")) {
+ DomProperties *v = new DomProperties();
+ v->read(reader);
+ setElementProperties(v);
+ continue;
+ }
+ if (tag == QLatin1String("slots")) {
+ DomSlots *v = new DomSlots();
+ v->read(reader);
+ setElementSlots(v);
+ continue;
+ }
+ if (tag == QLatin1String("propertyspecifications")) {
+ DomPropertySpecifications *v = new DomPropertySpecifications();
+ v->read(reader);
+ setElementPropertyspecifications(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomCustomWidget::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("class")) {
+ setElementClass(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("extends")) {
+ setElementExtends(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("header")) {
+ DomHeader *v = new DomHeader();
+ v->read(e);
+ setElementHeader(v);
+ continue;
+ }
+ if (tag == QLatin1String("sizehint")) {
+ DomSize *v = new DomSize();
+ v->read(e);
+ setElementSizeHint(v);
+ continue;
+ }
+ if (tag == QLatin1String("addpagemethod")) {
+ setElementAddPageMethod(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("container")) {
+ setElementContainer(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("sizepolicy")) {
+ DomSizePolicyData *v = new DomSizePolicyData();
+ v->read(e);
+ setElementSizePolicy(v);
+ continue;
+ }
+ if (tag == QLatin1String("pixmap")) {
+ setElementPixmap(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("script")) {
+ DomScript *v = new DomScript();
+ v->read(e);
+ setElementScript(v);
+ continue;
+ }
+ if (tag == QLatin1String("properties")) {
+ DomProperties *v = new DomProperties();
+ v->read(e);
+ setElementProperties(v);
+ continue;
+ }
+ if (tag == QLatin1String("slots")) {
+ DomSlots *v = new DomSlots();
+ v->read(e);
+ setElementSlots(v);
+ continue;
+ }
+ if (tag == QLatin1String("propertyspecifications")) {
+ DomPropertySpecifications *v = new DomPropertySpecifications();
+ v->read(e);
+ setElementPropertyspecifications(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomCustomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("customwidget") : tagName.toLower());
+
+ if (m_children & Class) {
+ writer.writeTextElement(QLatin1String("class"), m_class);
+ }
+
+ if (m_children & Extends) {
+ writer.writeTextElement(QLatin1String("extends"), m_extends);
+ }
+
+ if (m_children & Header) {
+ m_header->write(writer, QLatin1String("header"));
+ }
+
+ if (m_children & SizeHint) {
+ m_sizeHint->write(writer, QLatin1String("sizehint"));
+ }
+
+ if (m_children & AddPageMethod) {
+ writer.writeTextElement(QLatin1String("addpagemethod"), m_addPageMethod);
+ }
+
+ if (m_children & Container) {
+ writer.writeTextElement(QLatin1String("container"), QString::number(m_container));
+ }
+
+ if (m_children & SizePolicy) {
+ m_sizePolicy->write(writer, QLatin1String("sizepolicy"));
+ }
+
+ if (m_children & Pixmap) {
+ writer.writeTextElement(QLatin1String("pixmap"), m_pixmap);
+ }
+
+ if (m_children & Script) {
+ m_script->write(writer, QLatin1String("script"));
+ }
+
+ if (m_children & Properties) {
+ m_properties->write(writer, QLatin1String("properties"));
+ }
+
+ if (m_children & Slots) {
+ m_slots->write(writer, QLatin1String("slots"));
+ }
+
+ if (m_children & Propertyspecifications) {
+ m_propertyspecifications->write(writer, QLatin1String("propertyspecifications"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomCustomWidget::setElementClass(const QString& a)
+{
+ m_children |= Class;
+ m_class = a;
+}
+
+void DomCustomWidget::setElementExtends(const QString& a)
+{
+ m_children |= Extends;
+ m_extends = a;
+}
+
+DomHeader* DomCustomWidget::takeElementHeader()
+{
+ DomHeader* a = m_header;
+ m_header = 0;
+ m_children ^= Header;
+ return a;
+}
+
+void DomCustomWidget::setElementHeader(DomHeader* a)
+{
+ delete m_header;
+ m_children |= Header;
+ m_header = a;
+}
+
+DomSize* DomCustomWidget::takeElementSizeHint()
+{
+ DomSize* a = m_sizeHint;
+ m_sizeHint = 0;
+ m_children ^= SizeHint;
+ return a;
+}
+
+void DomCustomWidget::setElementSizeHint(DomSize* a)
+{
+ delete m_sizeHint;
+ m_children |= SizeHint;
+ m_sizeHint = a;
+}
+
+void DomCustomWidget::setElementAddPageMethod(const QString& a)
+{
+ m_children |= AddPageMethod;
+ m_addPageMethod = a;
+}
+
+void DomCustomWidget::setElementContainer(int a)
+{
+ m_children |= Container;
+ 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)
+{
+ 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()
+{
+ 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;
+ m_slots = 0;
+ m_children ^= Slots;
+ return a;
+}
+
+void DomCustomWidget::setElementSlots(DomSlots* a)
+{
+ delete m_slots;
+ m_children |= Slots;
+ m_slots = a;
+}
+
+DomPropertySpecifications* DomCustomWidget::takeElementPropertyspecifications()
+{
+ DomPropertySpecifications* a = m_propertyspecifications;
+ m_propertyspecifications = 0;
+ m_children ^= Propertyspecifications;
+ return a;
+}
+
+void DomCustomWidget::setElementPropertyspecifications(DomPropertySpecifications* a)
+{
+ delete m_propertyspecifications;
+ m_children |= Propertyspecifications;
+ m_propertyspecifications = a;
+}
+
+void DomCustomWidget::clearElementClass()
+{
+ m_children &= ~Class;
+}
+
+void DomCustomWidget::clearElementExtends()
+{
+ m_children &= ~Extends;
+}
+
+void DomCustomWidget::clearElementHeader()
+{
+ delete m_header;
+ m_header = 0;
+ m_children &= ~Header;
+}
+
+void DomCustomWidget::clearElementSizeHint()
+{
+ delete m_sizeHint;
+ m_sizeHint = 0;
+ m_children &= ~SizeHint;
+}
+
+void DomCustomWidget::clearElementAddPageMethod()
+{
+ m_children &= ~AddPageMethod;
+}
+
+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;
+ m_slots = 0;
+ m_children &= ~Slots;
+}
+
+void DomCustomWidget::clearElementPropertyspecifications()
+{
+ delete m_propertyspecifications;
+ m_propertyspecifications = 0;
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomProperties::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomPropertyData *v = new DomPropertyData();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+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, QLatin1String("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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("type")) {
+ setAttributeType(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPropertyData::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("type")))
+ setAttributeType(node.attribute(QLatin1String("type")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPropertyData::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertydata") : tagName.toLower());
+
+ if (hasAttributeType())
+ writer.writeAttribute(QLatin1String("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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomSizePolicyData::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("hordata")) {
+ setElementHorData(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("verdata")) {
+ setElementVerData(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomSizePolicyData::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicydata") : tagName.toLower());
+
+ if (m_children & HorData) {
+ writer.writeTextElement(QLatin1String("hordata"), QString::number(m_horData));
+ }
+
+ if (m_children & VerData) {
+ writer.writeTextElement(QLatin1String("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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("spacing")) {
+ setAttributeSpacing(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("margin")) {
+ setAttributeMargin(attribute.value().toString().toInt());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomLayoutDefault::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("spacing")))
+ setAttributeSpacing(node.attribute(QLatin1String("spacing")).toInt());
+ if (node.hasAttribute(QLatin1String("margin")))
+ setAttributeMargin(node.attribute(QLatin1String("margin")).toInt());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomLayoutDefault::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutdefault") : tagName.toLower());
+
+ if (hasAttributeSpacing())
+ writer.writeAttribute(QLatin1String("spacing"), QString::number(attributeSpacing()));
+
+ if (hasAttributeMargin())
+ writer.writeAttribute(QLatin1String("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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("spacing")) {
+ setAttributeSpacing(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("margin")) {
+ setAttributeMargin(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomLayoutFunction::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("spacing")))
+ setAttributeSpacing(node.attribute(QLatin1String("spacing")));
+ if (node.hasAttribute(QLatin1String("margin")))
+ setAttributeMargin(node.attribute(QLatin1String("margin")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomLayoutFunction::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutfunction") : tagName.toLower());
+
+ if (hasAttributeSpacing())
+ writer.writeAttribute(QLatin1String("spacing"), attributeSpacing());
+
+ if (hasAttributeMargin())
+ writer.writeAttribute(QLatin1String("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();
+}
+
+void DomTabStops::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("tabstop")) {
+ m_tabStop.append(reader.readElementText());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomTabStops::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("tabstop")) {
+ m_tabStop.append(e.text());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomTabStops::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("tabstops") : tagName.toLower());
+
+ for (int i = 0; i < m_tabStop.size(); ++i) {
+ QString v = m_tabStop[i];
+ writer.writeTextElement(QLatin1String("tabstop"), v);
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+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);
+ m_property.clear();
+ qDeleteAll(m_attribute);
+ m_attribute.clear();
+ qDeleteAll(m_item);
+ m_item.clear();
+}
+
+void DomLayout::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("class")) {
+ setAttributeClass(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("stretch")) {
+ setAttributeStretch(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("rowstretch")) {
+ setAttributeRowStretch(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("columnstretch")) {
+ setAttributeColumnStretch(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("rowminimumheight")) {
+ setAttributeRowMinimumHeight(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("columnminimumwidth")) {
+ setAttributeColumnMinimumWidth(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ m_attribute.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("item")) {
+ DomLayoutItem *v = new DomLayoutItem();
+ v->read(reader);
+ m_item.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomLayout::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("class")))
+ setAttributeClass(node.attribute(QLatin1String("class")));
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("stretch")))
+ setAttributeStretch(node.attribute(QLatin1String("stretch")));
+ if (node.hasAttribute(QLatin1String("rowstretch")))
+ setAttributeRowStretch(node.attribute(QLatin1String("rowstretch")));
+ if (node.hasAttribute(QLatin1String("columnstretch")))
+ setAttributeColumnStretch(node.attribute(QLatin1String("columnstretch")));
+ if (node.hasAttribute(QLatin1String("rowminimumheight")))
+ setAttributeRowMinimumHeight(node.attribute(QLatin1String("rowminimumheight")));
+ if (node.hasAttribute(QLatin1String("columnminimumwidth")))
+ setAttributeColumnMinimumWidth(node.attribute(QLatin1String("columnminimumwidth")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_attribute.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("item")) {
+ DomLayoutItem *v = new DomLayoutItem();
+ v->read(e);
+ m_item.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomLayout::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layout") : tagName.toLower());
+
+ if (hasAttributeClass())
+ writer.writeAttribute(QLatin1String("class"), attributeClass());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeStretch())
+ writer.writeAttribute(QLatin1String("stretch"), attributeStretch());
+
+ if (hasAttributeRowStretch())
+ writer.writeAttribute(QLatin1String("rowstretch"), attributeRowStretch());
+
+ if (hasAttributeColumnStretch())
+ writer.writeAttribute(QLatin1String("columnstretch"), attributeColumnStretch());
+
+ if (hasAttributeRowMinimumHeight())
+ writer.writeAttribute(QLatin1String("rowminimumheight"), attributeRowMinimumHeight());
+
+ if (hasAttributeColumnMinimumWidth())
+ writer.writeAttribute(QLatin1String("columnminimumwidth"), attributeColumnMinimumWidth());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ for (int i = 0; i < m_attribute.size(); ++i) {
+ DomProperty* v = m_attribute[i];
+ v->write(writer, QLatin1String("attribute"));
+ }
+ for (int i = 0; i < m_item.size(); ++i) {
+ DomLayoutItem* v = m_item[i];
+ v->write(writer, QLatin1String("item"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomLayout::setElementProperty(const QList<DomProperty*>& a)
+{
+ m_children |= Property;
+ m_property = a;
+}
+
+void DomLayout::setElementAttribute(const QList<DomProperty*>& a)
+{
+ m_children |= Attribute;
+ m_attribute = a;
+}
+
+void DomLayout::setElementItem(const QList<DomLayoutItem*>& a)
+{
+ m_children |= Item;
+ m_item = a;
+}
+
+void DomLayoutItem::clear(bool clear_all)
+{
+ 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()
+{
+ delete m_widget;
+ delete m_layout;
+ delete m_spacer;
+}
+
+void DomLayoutItem::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("row")) {
+ setAttributeRow(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("column")) {
+ setAttributeColumn(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("rowspan")) {
+ setAttributeRowSpan(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("colspan")) {
+ setAttributeColSpan(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("alignment")) {
+ setAttributeAlignment(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("widget")) {
+ DomWidget *v = new DomWidget();
+ v->read(reader);
+ setElementWidget(v);
+ continue;
+ }
+ if (tag == QLatin1String("layout")) {
+ DomLayout *v = new DomLayout();
+ v->read(reader);
+ setElementLayout(v);
+ continue;
+ }
+ if (tag == QLatin1String("spacer")) {
+ DomSpacer *v = new DomSpacer();
+ v->read(reader);
+ setElementSpacer(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomLayoutItem::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("row")))
+ setAttributeRow(node.attribute(QLatin1String("row")).toInt());
+ if (node.hasAttribute(QLatin1String("column")))
+ setAttributeColumn(node.attribute(QLatin1String("column")).toInt());
+ if (node.hasAttribute(QLatin1String("rowspan")))
+ setAttributeRowSpan(node.attribute(QLatin1String("rowspan")).toInt());
+ if (node.hasAttribute(QLatin1String("colspan")))
+ setAttributeColSpan(node.attribute(QLatin1String("colspan")).toInt());
+ if (node.hasAttribute(QLatin1String("alignment")))
+ setAttributeAlignment(node.attribute(QLatin1String("alignment")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("widget")) {
+ DomWidget *v = new DomWidget();
+ v->read(e);
+ setElementWidget(v);
+ continue;
+ }
+ if (tag == QLatin1String("layout")) {
+ DomLayout *v = new DomLayout();
+ v->read(e);
+ setElementLayout(v);
+ continue;
+ }
+ if (tag == QLatin1String("spacer")) {
+ DomSpacer *v = new DomSpacer();
+ v->read(e);
+ setElementSpacer(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomLayoutItem::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("layoutitem") : tagName.toLower());
+
+ if (hasAttributeRow())
+ writer.writeAttribute(QLatin1String("row"), QString::number(attributeRow()));
+
+ if (hasAttributeColumn())
+ writer.writeAttribute(QLatin1String("column"), QString::number(attributeColumn()));
+
+ if (hasAttributeRowSpan())
+ writer.writeAttribute(QLatin1String("rowspan"), QString::number(attributeRowSpan()));
+
+ if (hasAttributeColSpan())
+ writer.writeAttribute(QLatin1String("colspan"), QString::number(attributeColSpan()));
+
+ if (hasAttributeAlignment())
+ writer.writeAttribute(QLatin1String("alignment"), attributeAlignment());
+
+ switch (kind()) {
+ case Widget: {
+ DomWidget* v = elementWidget();
+ if (v != 0) {
+ v->write(writer, QLatin1String("widget"));
+ }
+ break;
+ }
+ case Layout: {
+ DomLayout* v = elementLayout();
+ if (v != 0) {
+ v->write(writer, QLatin1String("layout"));
+ }
+ break;
+ }
+ case Spacer: {
+ DomSpacer* v = elementSpacer();
+ if (v != 0) {
+ v->write(writer, QLatin1String("spacer"));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomWidget* DomLayoutItem::takeElementWidget()
+{
+ DomWidget* a = m_widget;
+ m_widget = 0;
+ return a;
+}
+
+void DomLayoutItem::setElementWidget(DomWidget* a)
+{
+ clear(false);
+ m_kind = Widget;
+ m_widget = a;
+}
+
+DomLayout* DomLayoutItem::takeElementLayout()
+{
+ DomLayout* a = m_layout;
+ m_layout = 0;
+ return a;
+}
+
+void DomLayoutItem::setElementLayout(DomLayout* a)
+{
+ clear(false);
+ m_kind = Layout;
+ m_layout = a;
+}
+
+DomSpacer* DomLayoutItem::takeElementSpacer()
+{
+ DomSpacer* a = m_spacer;
+ m_spacer = 0;
+ return a;
+}
+
+void DomLayoutItem::setElementSpacer(DomSpacer* a)
+{
+ clear(false);
+ 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);
+ m_property.clear();
+}
+
+void DomRow::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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomRow::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomRow::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("row") : tagName.toLower());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+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);
+ m_property.clear();
+}
+
+void DomColumn::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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomColumn::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomColumn::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("column") : tagName.toLower());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+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);
+ m_property.clear();
+ qDeleteAll(m_item);
+ m_item.clear();
+}
+
+void DomItem::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("row")) {
+ setAttributeRow(attribute.value().toString().toInt());
+ continue;
+ }
+ if (name == QLatin1String("column")) {
+ setAttributeColumn(attribute.value().toString().toInt());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ if (tag == QLatin1String("item")) {
+ DomItem *v = new DomItem();
+ v->read(reader);
+ m_item.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomItem::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("row")))
+ setAttributeRow(node.attribute(QLatin1String("row")).toInt());
+ if (node.hasAttribute(QLatin1String("column")))
+ setAttributeColumn(node.attribute(QLatin1String("column")).toInt());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("item")) {
+ DomItem *v = new DomItem();
+ v->read(e);
+ m_item.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomItem::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("item") : tagName.toLower());
+
+ if (hasAttributeRow())
+ writer.writeAttribute(QLatin1String("row"), QString::number(attributeRow()));
+
+ if (hasAttributeColumn())
+ writer.writeAttribute(QLatin1String("column"), QString::number(attributeColumn()));
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ for (int i = 0; i < m_item.size(); ++i) {
+ DomItem* v = m_item[i];
+ v->write(writer, QLatin1String("item"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomItem::setElementProperty(const QList<DomProperty*>& a)
+{
+ m_children |= Property;
+ m_property = a;
+}
+
+void DomItem::setElementItem(const QList<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);
+ 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();
+}
+
+void DomWidget::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("class")) {
+ setAttributeClass(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("native")) {
+ setAttributeNative((attribute.value().toString() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("class")) {
+ m_class.append(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("property")) {
+ 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);
+ continue;
+ }
+ if (tag == QLatin1String("widgetdata")) {
+ DomWidgetData *v = new DomWidgetData();
+ v->read(reader);
+ m_widgetData.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ m_attribute.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("row")) {
+ DomRow *v = new DomRow();
+ v->read(reader);
+ m_row.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("column")) {
+ DomColumn *v = new DomColumn();
+ v->read(reader);
+ m_column.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("item")) {
+ DomItem *v = new DomItem();
+ v->read(reader);
+ m_item.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("layout")) {
+ DomLayout *v = new DomLayout();
+ v->read(reader);
+ m_layout.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("widget")) {
+ DomWidget *v = new DomWidget();
+ v->read(reader);
+ m_widget.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("action")) {
+ DomAction *v = new DomAction();
+ v->read(reader);
+ m_action.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("actiongroup")) {
+ DomActionGroup *v = new DomActionGroup();
+ v->read(reader);
+ m_actionGroup.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("addaction")) {
+ DomActionRef *v = new DomActionRef();
+ v->read(reader);
+ m_addAction.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("zorder")) {
+ m_zOrder.append(reader.readElementText());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomWidget::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("class")))
+ setAttributeClass(node.attribute(QLatin1String("class")));
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("native")))
+ setAttributeNative((node.attribute(QLatin1String("native")) == QLatin1String("true") ? true : false));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("class")) {
+ m_class.append(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("script")) {
+ DomScript *v = new DomScript();
+ v->read(e);
+ m_script.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("widgetdata")) {
+ DomWidgetData *v = new DomWidgetData();
+ v->read(e);
+ m_widgetData.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("attribute")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_attribute.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("row")) {
+ DomRow *v = new DomRow();
+ v->read(e);
+ m_row.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("column")) {
+ DomColumn *v = new DomColumn();
+ v->read(e);
+ m_column.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("item")) {
+ DomItem *v = new DomItem();
+ v->read(e);
+ m_item.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("layout")) {
+ DomLayout *v = new DomLayout();
+ v->read(e);
+ m_layout.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("widget")) {
+ DomWidget *v = new DomWidget();
+ v->read(e);
+ m_widget.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("action")) {
+ DomAction *v = new DomAction();
+ v->read(e);
+ m_action.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("actiongroup")) {
+ DomActionGroup *v = new DomActionGroup();
+ v->read(e);
+ m_actionGroup.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("addaction")) {
+ DomActionRef *v = new DomActionRef();
+ v->read(e);
+ m_addAction.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("zorder")) {
+ m_zOrder.append(e.text());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomWidget::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("widget") : tagName.toLower());
+
+ if (hasAttributeClass())
+ writer.writeAttribute(QLatin1String("class"), attributeClass());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeNative())
+ writer.writeAttribute(QLatin1String("native"), (attributeNative() ? QLatin1String("true") : QLatin1String("false")));
+
+ for (int i = 0; i < m_class.size(); ++i) {
+ QString v = m_class[i];
+ writer.writeTextElement(QLatin1String("class"), v);
+ }
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ for (int i = 0; i < m_script.size(); ++i) {
+ DomScript* v = m_script[i];
+ v->write(writer, QLatin1String("script"));
+ }
+ for (int i = 0; i < m_widgetData.size(); ++i) {
+ DomWidgetData* v = m_widgetData[i];
+ v->write(writer, QLatin1String("widgetdata"));
+ }
+ for (int i = 0; i < m_attribute.size(); ++i) {
+ DomProperty* v = m_attribute[i];
+ v->write(writer, QLatin1String("attribute"));
+ }
+ for (int i = 0; i < m_row.size(); ++i) {
+ DomRow* v = m_row[i];
+ v->write(writer, QLatin1String("row"));
+ }
+ for (int i = 0; i < m_column.size(); ++i) {
+ DomColumn* v = m_column[i];
+ v->write(writer, QLatin1String("column"));
+ }
+ for (int i = 0; i < m_item.size(); ++i) {
+ DomItem* v = m_item[i];
+ v->write(writer, QLatin1String("item"));
+ }
+ for (int i = 0; i < m_layout.size(); ++i) {
+ DomLayout* v = m_layout[i];
+ v->write(writer, QLatin1String("layout"));
+ }
+ for (int i = 0; i < m_widget.size(); ++i) {
+ DomWidget* v = m_widget[i];
+ v->write(writer, QLatin1String("widget"));
+ }
+ for (int i = 0; i < m_action.size(); ++i) {
+ DomAction* v = m_action[i];
+ v->write(writer, QLatin1String("action"));
+ }
+ for (int i = 0; i < m_actionGroup.size(); ++i) {
+ DomActionGroup* v = m_actionGroup[i];
+ v->write(writer, QLatin1String("actiongroup"));
+ }
+ for (int i = 0; i < m_addAction.size(); ++i) {
+ DomActionRef* v = m_addAction[i];
+ v->write(writer, QLatin1String("addaction"));
+ }
+ for (int i = 0; i < m_zOrder.size(); ++i) {
+ QString v = m_zOrder[i];
+ writer.writeTextElement(QLatin1String("zorder"), v);
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomWidget::setElementClass(const QStringList& a)
+{
+ m_children |= Class;
+ m_class = 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)
+{
+ m_children |= Attribute;
+ m_attribute = a;
+}
+
+void DomWidget::setElementRow(const QList<DomRow*>& a)
+{
+ m_children |= Row;
+ m_row = a;
+}
+
+void DomWidget::setElementColumn(const QList<DomColumn*>& a)
+{
+ m_children |= Column;
+ m_column = a;
+}
+
+void DomWidget::setElementItem(const QList<DomItem*>& a)
+{
+ m_children |= Item;
+ m_item = a;
+}
+
+void DomWidget::setElementLayout(const QList<DomLayout*>& a)
+{
+ m_children |= Layout;
+ m_layout = a;
+}
+
+void DomWidget::setElementWidget(const QList<DomWidget*>& a)
+{
+ m_children |= Widget;
+ m_widget = a;
+}
+
+void DomWidget::setElementAction(const QList<DomAction*>& a)
+{
+ m_children |= Action;
+ m_action = a;
+}
+
+void DomWidget::setElementActionGroup(const QList<DomActionGroup*>& a)
+{
+ m_children |= ActionGroup;
+ m_actionGroup = a;
+}
+
+void DomWidget::setElementAddAction(const QList<DomActionRef*>& a)
+{
+ m_children |= AddAction;
+ m_addAction = 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);
+ m_property.clear();
+}
+
+void DomSpacer::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomSpacer::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomSpacer::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("spacer") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("alpha")) {
+ setAttributeAlpha(attribute.value().toString().toInt());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("red")) {
+ setElementRed(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("green")) {
+ setElementGreen(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("blue")) {
+ setElementBlue(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomColor::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("alpha")))
+ setAttributeAlpha(node.attribute(QLatin1String("alpha")).toInt());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("red")) {
+ setElementRed(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("green")) {
+ setElementGreen(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("blue")) {
+ setElementBlue(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomColor::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("color") : tagName.toLower());
+
+ if (hasAttributeAlpha())
+ writer.writeAttribute(QLatin1String("alpha"), QString::number(attributeAlpha()));
+
+ if (m_children & Red) {
+ writer.writeTextElement(QLatin1String("red"), QString::number(m_red));
+ }
+
+ if (m_children & Green) {
+ writer.writeTextElement(QLatin1String("green"), QString::number(m_green));
+ }
+
+ if (m_children & Blue) {
+ writer.writeTextElement(QLatin1String("blue"), QString::number(m_blue));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomColor::setElementRed(int a)
+{
+ m_children |= Red;
+ m_red = a;
+}
+
+void DomColor::setElementGreen(int a)
+{
+ m_children |= Green;
+ m_green = a;
+}
+
+void DomColor::setElementBlue(int a)
+{
+ m_children |= Blue;
+ m_blue = a;
+}
+
+void DomColor::clearElementRed()
+{
+ m_children &= ~Red;
+}
+
+void DomColor::clearElementGreen()
+{
+ m_children &= ~Green;
+}
+
+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;
+}
+
+void DomGradientStop::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("position")) {
+ setAttributePosition(attribute.value().toString().toDouble());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(reader);
+ setElementColor(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomGradientStop::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("position")))
+ setAttributePosition(node.attribute(QLatin1String("position")).toDouble());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(e);
+ setElementColor(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomGradientStop::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("gradientstop") : tagName.toLower());
+
+ if (hasAttributePosition())
+ writer.writeAttribute(QLatin1String("position"), QString::number(attributePosition(), 'f', 15));
+
+ if (m_children & Color) {
+ m_color->write(writer, QLatin1String("color"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomColor* DomGradientStop::takeElementColor()
+{
+ DomColor* a = m_color;
+ m_color = 0;
+ m_children ^= Color;
+ return a;
+}
+
+void DomGradientStop::setElementColor(DomColor* a)
+{
+ delete m_color;
+ m_children |= Color;
+ m_color = a;
+}
+
+void DomGradientStop::clearElementColor()
+{
+ delete m_color;
+ m_color = 0;
+ 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);
+ m_gradientStop.clear();
+}
+
+void DomGradient::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("startx")) {
+ setAttributeStartX(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("starty")) {
+ setAttributeStartY(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("endx")) {
+ setAttributeEndX(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("endy")) {
+ setAttributeEndY(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("centralx")) {
+ setAttributeCentralX(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("centraly")) {
+ setAttributeCentralY(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("focalx")) {
+ setAttributeFocalX(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("focaly")) {
+ setAttributeFocalY(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("radius")) {
+ setAttributeRadius(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("angle")) {
+ setAttributeAngle(attribute.value().toString().toDouble());
+ continue;
+ }
+ if (name == QLatin1String("type")) {
+ setAttributeType(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("spread")) {
+ setAttributeSpread(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("coordinatemode")) {
+ setAttributeCoordinateMode(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("gradientstop")) {
+ DomGradientStop *v = new DomGradientStop();
+ v->read(reader);
+ m_gradientStop.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomGradient::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("startx")))
+ setAttributeStartX(node.attribute(QLatin1String("startx")).toDouble());
+ if (node.hasAttribute(QLatin1String("starty")))
+ setAttributeStartY(node.attribute(QLatin1String("starty")).toDouble());
+ if (node.hasAttribute(QLatin1String("endx")))
+ setAttributeEndX(node.attribute(QLatin1String("endx")).toDouble());
+ if (node.hasAttribute(QLatin1String("endy")))
+ setAttributeEndY(node.attribute(QLatin1String("endy")).toDouble());
+ if (node.hasAttribute(QLatin1String("centralx")))
+ setAttributeCentralX(node.attribute(QLatin1String("centralx")).toDouble());
+ if (node.hasAttribute(QLatin1String("centraly")))
+ setAttributeCentralY(node.attribute(QLatin1String("centraly")).toDouble());
+ if (node.hasAttribute(QLatin1String("focalx")))
+ setAttributeFocalX(node.attribute(QLatin1String("focalx")).toDouble());
+ if (node.hasAttribute(QLatin1String("focaly")))
+ setAttributeFocalY(node.attribute(QLatin1String("focaly")).toDouble());
+ if (node.hasAttribute(QLatin1String("radius")))
+ setAttributeRadius(node.attribute(QLatin1String("radius")).toDouble());
+ if (node.hasAttribute(QLatin1String("angle")))
+ setAttributeAngle(node.attribute(QLatin1String("angle")).toDouble());
+ if (node.hasAttribute(QLatin1String("type")))
+ setAttributeType(node.attribute(QLatin1String("type")));
+ if (node.hasAttribute(QLatin1String("spread")))
+ setAttributeSpread(node.attribute(QLatin1String("spread")));
+ if (node.hasAttribute(QLatin1String("coordinatemode")))
+ setAttributeCoordinateMode(node.attribute(QLatin1String("coordinatemode")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("gradientstop")) {
+ DomGradientStop *v = new DomGradientStop();
+ v->read(e);
+ m_gradientStop.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomGradient::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("gradient") : tagName.toLower());
+
+ if (hasAttributeStartX())
+ writer.writeAttribute(QLatin1String("startx"), QString::number(attributeStartX(), 'f', 15));
+
+ if (hasAttributeStartY())
+ writer.writeAttribute(QLatin1String("starty"), QString::number(attributeStartY(), 'f', 15));
+
+ if (hasAttributeEndX())
+ writer.writeAttribute(QLatin1String("endx"), QString::number(attributeEndX(), 'f', 15));
+
+ if (hasAttributeEndY())
+ writer.writeAttribute(QLatin1String("endy"), QString::number(attributeEndY(), 'f', 15));
+
+ if (hasAttributeCentralX())
+ writer.writeAttribute(QLatin1String("centralx"), QString::number(attributeCentralX(), 'f', 15));
+
+ if (hasAttributeCentralY())
+ writer.writeAttribute(QLatin1String("centraly"), QString::number(attributeCentralY(), 'f', 15));
+
+ if (hasAttributeFocalX())
+ writer.writeAttribute(QLatin1String("focalx"), QString::number(attributeFocalX(), 'f', 15));
+
+ if (hasAttributeFocalY())
+ writer.writeAttribute(QLatin1String("focaly"), QString::number(attributeFocalY(), 'f', 15));
+
+ if (hasAttributeRadius())
+ writer.writeAttribute(QLatin1String("radius"), QString::number(attributeRadius(), 'f', 15));
+
+ if (hasAttributeAngle())
+ writer.writeAttribute(QLatin1String("angle"), QString::number(attributeAngle(), 'f', 15));
+
+ if (hasAttributeType())
+ writer.writeAttribute(QLatin1String("type"), attributeType());
+
+ if (hasAttributeSpread())
+ writer.writeAttribute(QLatin1String("spread"), attributeSpread());
+
+ if (hasAttributeCoordinateMode())
+ writer.writeAttribute(QLatin1String("coordinatemode"), attributeCoordinateMode());
+
+ for (int i = 0; i < m_gradientStop.size(); ++i) {
+ DomGradientStop* v = m_gradientStop[i];
+ v->write(writer, QLatin1String("gradientstop"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomGradient::setElementGradientStop(const QList<DomGradientStop*>& a)
+{
+ m_children |= GradientStop;
+ m_gradientStop = a;
+}
+
+void DomBrush::clear(bool clear_all)
+{
+ 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()
+{
+ delete m_color;
+ delete m_texture;
+ delete m_gradient;
+}
+
+void DomBrush::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("brushstyle")) {
+ setAttributeBrushStyle(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(reader);
+ setElementColor(v);
+ continue;
+ }
+ if (tag == QLatin1String("texture")) {
+ DomProperty *v = new DomProperty();
+ v->read(reader);
+ setElementTexture(v);
+ continue;
+ }
+ if (tag == QLatin1String("gradient")) {
+ DomGradient *v = new DomGradient();
+ v->read(reader);
+ setElementGradient(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomBrush::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("brushstyle")))
+ setAttributeBrushStyle(node.attribute(QLatin1String("brushstyle")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(e);
+ setElementColor(v);
+ continue;
+ }
+ if (tag == QLatin1String("texture")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ setElementTexture(v);
+ continue;
+ }
+ if (tag == QLatin1String("gradient")) {
+ DomGradient *v = new DomGradient();
+ v->read(e);
+ setElementGradient(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomBrush::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("brush") : tagName.toLower());
+
+ if (hasAttributeBrushStyle())
+ writer.writeAttribute(QLatin1String("brushstyle"), attributeBrushStyle());
+
+ switch (kind()) {
+ case Color: {
+ DomColor* v = elementColor();
+ if (v != 0) {
+ v->write(writer, QLatin1String("color"));
+ }
+ break;
+ }
+ case Texture: {
+ DomProperty* v = elementTexture();
+ if (v != 0) {
+ v->write(writer, QLatin1String("texture"));
+ }
+ break;
+ }
+ case Gradient: {
+ DomGradient* v = elementGradient();
+ if (v != 0) {
+ v->write(writer, QLatin1String("gradient"));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomColor* DomBrush::takeElementColor()
+{
+ DomColor* a = m_color;
+ m_color = 0;
+ return a;
+}
+
+void DomBrush::setElementColor(DomColor* a)
+{
+ clear(false);
+ m_kind = Color;
+ m_color = a;
+}
+
+DomProperty* DomBrush::takeElementTexture()
+{
+ DomProperty* a = m_texture;
+ m_texture = 0;
+ return a;
+}
+
+void DomBrush::setElementTexture(DomProperty* a)
+{
+ clear(false);
+ m_kind = Texture;
+ m_texture = a;
+}
+
+DomGradient* DomBrush::takeElementGradient()
+{
+ DomGradient* a = m_gradient;
+ m_gradient = 0;
+ return a;
+}
+
+void DomBrush::setElementGradient(DomGradient* a)
+{
+ clear(false);
+ 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;
+}
+
+void DomColorRole::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("role")) {
+ setAttributeRole(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("brush")) {
+ DomBrush *v = new DomBrush();
+ v->read(reader);
+ setElementBrush(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomColorRole::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("role")))
+ setAttributeRole(node.attribute(QLatin1String("role")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("brush")) {
+ DomBrush *v = new DomBrush();
+ v->read(e);
+ setElementBrush(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomColorRole::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("colorrole") : tagName.toLower());
+
+ if (hasAttributeRole())
+ writer.writeAttribute(QLatin1String("role"), attributeRole());
+
+ if (m_children & Brush) {
+ m_brush->write(writer, QLatin1String("brush"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomBrush* DomColorRole::takeElementBrush()
+{
+ DomBrush* a = m_brush;
+ m_brush = 0;
+ m_children ^= Brush;
+ return a;
+}
+
+void DomColorRole::setElementBrush(DomBrush* a)
+{
+ delete m_brush;
+ m_children |= Brush;
+ m_brush = a;
+}
+
+void DomColorRole::clearElementBrush()
+{
+ delete m_brush;
+ m_brush = 0;
+ 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);
+ m_colorRole.clear();
+ qDeleteAll(m_color);
+ m_color.clear();
+}
+
+void DomColorGroup::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("colorrole")) {
+ DomColorRole *v = new DomColorRole();
+ v->read(reader);
+ m_colorRole.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(reader);
+ m_color.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomColorGroup::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("colorrole")) {
+ DomColorRole *v = new DomColorRole();
+ v->read(e);
+ m_colorRole.append(v);
+ continue;
+ }
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(e);
+ m_color.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomColorGroup::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("colorgroup") : tagName.toLower());
+
+ for (int i = 0; i < m_colorRole.size(); ++i) {
+ DomColorRole* v = m_colorRole[i];
+ v->write(writer, QLatin1String("colorrole"));
+ }
+ for (int i = 0; i < m_color.size(); ++i) {
+ DomColor* v = m_color[i];
+ v->write(writer, QLatin1String("color"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomColorGroup::setElementColorRole(const QList<DomColorRole*>& a)
+{
+ m_children |= ColorRole;
+ m_colorRole = a;
+}
+
+void DomColorGroup::setElementColor(const QList<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;
+ delete m_inactive;
+ delete m_disabled;
+}
+
+void DomPalette::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("active")) {
+ DomColorGroup *v = new DomColorGroup();
+ v->read(reader);
+ setElementActive(v);
+ continue;
+ }
+ if (tag == QLatin1String("inactive")) {
+ DomColorGroup *v = new DomColorGroup();
+ v->read(reader);
+ setElementInactive(v);
+ continue;
+ }
+ if (tag == QLatin1String("disabled")) {
+ DomColorGroup *v = new DomColorGroup();
+ v->read(reader);
+ setElementDisabled(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPalette::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("active")) {
+ DomColorGroup *v = new DomColorGroup();
+ v->read(e);
+ setElementActive(v);
+ continue;
+ }
+ if (tag == QLatin1String("inactive")) {
+ DomColorGroup *v = new DomColorGroup();
+ v->read(e);
+ setElementInactive(v);
+ continue;
+ }
+ if (tag == QLatin1String("disabled")) {
+ DomColorGroup *v = new DomColorGroup();
+ v->read(e);
+ setElementDisabled(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPalette::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("palette") : tagName.toLower());
+
+ if (m_children & Active) {
+ m_active->write(writer, QLatin1String("active"));
+ }
+
+ if (m_children & Inactive) {
+ m_inactive->write(writer, QLatin1String("inactive"));
+ }
+
+ if (m_children & Disabled) {
+ m_disabled->write(writer, QLatin1String("disabled"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomColorGroup* DomPalette::takeElementActive()
+{
+ DomColorGroup* a = m_active;
+ m_active = 0;
+ m_children ^= Active;
+ return a;
+}
+
+void DomPalette::setElementActive(DomColorGroup* a)
+{
+ delete m_active;
+ m_children |= Active;
+ m_active = a;
+}
+
+DomColorGroup* DomPalette::takeElementInactive()
+{
+ DomColorGroup* a = m_inactive;
+ m_inactive = 0;
+ m_children ^= Inactive;
+ return a;
+}
+
+void DomPalette::setElementInactive(DomColorGroup* a)
+{
+ delete m_inactive;
+ m_children |= Inactive;
+ m_inactive = a;
+}
+
+DomColorGroup* DomPalette::takeElementDisabled()
+{
+ DomColorGroup* a = m_disabled;
+ m_disabled = 0;
+ m_children ^= Disabled;
+ return a;
+}
+
+void DomPalette::setElementDisabled(DomColorGroup* a)
+{
+ delete m_disabled;
+ m_children |= Disabled;
+ m_disabled = a;
+}
+
+void DomPalette::clearElementActive()
+{
+ delete m_active;
+ m_active = 0;
+ m_children &= ~Active;
+}
+
+void DomPalette::clearElementInactive()
+{
+ delete m_inactive;
+ m_inactive = 0;
+ m_children &= ~Inactive;
+}
+
+void DomPalette::clearElementDisabled()
+{
+ delete m_disabled;
+ m_disabled = 0;
+ 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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("family")) {
+ setElementFamily(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("pointsize")) {
+ setElementPointSize(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("weight")) {
+ setElementWeight(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("italic")) {
+ setElementItalic((reader.readElementText() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("bold")) {
+ setElementBold((reader.readElementText() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("underline")) {
+ setElementUnderline((reader.readElementText() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("strikeout")) {
+ setElementStrikeOut((reader.readElementText() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("antialiasing")) {
+ setElementAntialiasing((reader.readElementText() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("stylestrategy")) {
+ setElementStyleStrategy(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("kerning")) {
+ setElementKerning((reader.readElementText() == QLatin1String("true") ? true : false));
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomFont::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("family")) {
+ setElementFamily(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("pointsize")) {
+ setElementPointSize(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("weight")) {
+ setElementWeight(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("italic")) {
+ setElementItalic((e.text() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("bold")) {
+ setElementBold((e.text() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("underline")) {
+ setElementUnderline((e.text() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("strikeout")) {
+ setElementStrikeOut((e.text() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("antialiasing")) {
+ setElementAntialiasing((e.text() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ if (tag == QLatin1String("stylestrategy")) {
+ setElementStyleStrategy(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("kerning")) {
+ setElementKerning((e.text() == QLatin1String("true") ? true : false));
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomFont::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("font") : tagName.toLower());
+
+ if (m_children & Family) {
+ writer.writeTextElement(QLatin1String("family"), m_family);
+ }
+
+ if (m_children & PointSize) {
+ writer.writeTextElement(QLatin1String("pointsize"), QString::number(m_pointSize));
+ }
+
+ if (m_children & Weight) {
+ writer.writeTextElement(QLatin1String("weight"), QString::number(m_weight));
+ }
+
+ if (m_children & Italic) {
+ writer.writeTextElement(QLatin1String("italic"), (m_italic ? QLatin1String("true") : QLatin1String("false")));
+ }
+
+ if (m_children & Bold) {
+ writer.writeTextElement(QLatin1String("bold"), (m_bold ? QLatin1String("true") : QLatin1String("false")));
+ }
+
+ if (m_children & Underline) {
+ writer.writeTextElement(QLatin1String("underline"), (m_underline ? QLatin1String("true") : QLatin1String("false")));
+ }
+
+ if (m_children & StrikeOut) {
+ writer.writeTextElement(QLatin1String("strikeout"), (m_strikeOut ? QLatin1String("true") : QLatin1String("false")));
+ }
+
+ if (m_children & Antialiasing) {
+ writer.writeTextElement(QLatin1String("antialiasing"), (m_antialiasing ? QLatin1String("true") : QLatin1String("false")));
+ }
+
+ if (m_children & StyleStrategy) {
+ writer.writeTextElement(QLatin1String("stylestrategy"), m_styleStrategy);
+ }
+
+ if (m_children & Kerning) {
+ writer.writeTextElement(QLatin1String("kerning"), (m_kerning ? QLatin1String("true") : QLatin1String("false")));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomFont::setElementFamily(const QString& a)
+{
+ m_children |= Family;
+ m_family = a;
+}
+
+void DomFont::setElementPointSize(int a)
+{
+ m_children |= PointSize;
+ m_pointSize = a;
+}
+
+void DomFont::setElementWeight(int a)
+{
+ m_children |= Weight;
+ m_weight = a;
+}
+
+void DomFont::setElementItalic(bool a)
+{
+ m_children |= Italic;
+ m_italic = a;
+}
+
+void DomFont::setElementBold(bool a)
+{
+ m_children |= Bold;
+ m_bold = a;
+}
+
+void DomFont::setElementUnderline(bool a)
+{
+ m_children |= Underline;
+ m_underline = a;
+}
+
+void DomFont::setElementStrikeOut(bool a)
+{
+ m_children |= StrikeOut;
+ m_strikeOut = a;
+}
+
+void DomFont::setElementAntialiasing(bool a)
+{
+ m_children |= Antialiasing;
+ m_antialiasing = a;
+}
+
+void DomFont::setElementStyleStrategy(const QString& a)
+{
+ m_children |= StyleStrategy;
+ m_styleStrategy = a;
+}
+
+void DomFont::setElementKerning(bool a)
+{
+ m_children |= Kerning;
+ m_kerning = a;
+}
+
+void DomFont::clearElementFamily()
+{
+ m_children &= ~Family;
+}
+
+void DomFont::clearElementPointSize()
+{
+ m_children &= ~PointSize;
+}
+
+void DomFont::clearElementWeight()
+{
+ m_children &= ~Weight;
+}
+
+void DomFont::clearElementItalic()
+{
+ m_children &= ~Italic;
+}
+
+void DomFont::clearElementBold()
+{
+ m_children &= ~Bold;
+}
+
+void DomFont::clearElementUnderline()
+{
+ m_children &= ~Underline;
+}
+
+void DomFont::clearElementStrikeOut()
+{
+ m_children &= ~StrikeOut;
+}
+
+void DomFont::clearElementAntialiasing()
+{
+ m_children &= ~Antialiasing;
+}
+
+void DomFont::clearElementStyleStrategy()
+{
+ m_children &= ~StyleStrategy;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPoint::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(e.text().toInt());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPoint::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("point") : tagName.toLower());
+
+ if (m_children & X) {
+ writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x));
+ }
+
+ if (m_children & Y) {
+ writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomPoint::setElementX(int a)
+{
+ m_children |= X;
+ m_x = a;
+}
+
+void DomPoint::setElementY(int a)
+{
+ m_children |= Y;
+ m_y = a;
+}
+
+void DomPoint::clearElementX()
+{
+ m_children &= ~X;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("width")) {
+ setElementWidth(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomRect::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(e.text().toInt());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("width")) {
+ setElementWidth(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomRect::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("rect") : tagName.toLower());
+
+ if (m_children & X) {
+ writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x));
+ }
+
+ if (m_children & Y) {
+ writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y));
+ }
+
+ if (m_children & Width) {
+ writer.writeTextElement(QLatin1String("width"), QString::number(m_width));
+ }
+
+ if (m_children & Height) {
+ writer.writeTextElement(QLatin1String("height"), QString::number(m_height));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomRect::setElementX(int a)
+{
+ m_children |= X;
+ m_x = a;
+}
+
+void DomRect::setElementY(int a)
+{
+ m_children |= Y;
+ m_y = a;
+}
+
+void DomRect::setElementWidth(int a)
+{
+ m_children |= Width;
+ m_width = a;
+}
+
+void DomRect::setElementHeight(int a)
+{
+ m_children |= Height;
+ m_height = a;
+}
+
+void DomRect::clearElementX()
+{
+ m_children &= ~X;
+}
+
+void DomRect::clearElementY()
+{
+ m_children &= ~Y;
+}
+
+void DomRect::clearElementWidth()
+{
+ m_children &= ~Width;
+}
+
+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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("language")) {
+ setAttributeLanguage(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("country")) {
+ setAttributeCountry(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomLocale::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("language")))
+ setAttributeLanguage(node.attribute(QLatin1String("language")));
+ if (node.hasAttribute(QLatin1String("country")))
+ setAttributeCountry(node.attribute(QLatin1String("country")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomLocale::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("locale") : tagName.toLower());
+
+ if (hasAttributeLanguage())
+ writer.writeAttribute(QLatin1String("language"), attributeLanguage());
+
+ if (hasAttributeCountry())
+ writer.writeAttribute(QLatin1String("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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("hsizetype")) {
+ setAttributeHSizeType(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("vsizetype")) {
+ setAttributeVSizeType(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("hsizetype")) {
+ setElementHSizeType(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("vsizetype")) {
+ setElementVSizeType(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("horstretch")) {
+ setElementHorStretch(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("verstretch")) {
+ setElementVerStretch(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomSizePolicy::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("hsizetype")))
+ setAttributeHSizeType(node.attribute(QLatin1String("hsizetype")));
+ if (node.hasAttribute(QLatin1String("vsizetype")))
+ setAttributeVSizeType(node.attribute(QLatin1String("vsizetype")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("hsizetype")) {
+ setElementHSizeType(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("vsizetype")) {
+ setElementVSizeType(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("horstretch")) {
+ setElementHorStretch(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("verstretch")) {
+ setElementVerStretch(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomSizePolicy::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizepolicy") : tagName.toLower());
+
+ if (hasAttributeHSizeType())
+ writer.writeAttribute(QLatin1String("hsizetype"), attributeHSizeType());
+
+ if (hasAttributeVSizeType())
+ writer.writeAttribute(QLatin1String("vsizetype"), attributeVSizeType());
+
+ if (m_children & HSizeType) {
+ writer.writeTextElement(QLatin1String("hsizetype"), QString::number(m_hSizeType));
+ }
+
+ if (m_children & VSizeType) {
+ writer.writeTextElement(QLatin1String("vsizetype"), QString::number(m_vSizeType));
+ }
+
+ if (m_children & HorStretch) {
+ writer.writeTextElement(QLatin1String("horstretch"), QString::number(m_horStretch));
+ }
+
+ if (m_children & VerStretch) {
+ writer.writeTextElement(QLatin1String("verstretch"), QString::number(m_verStretch));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomSizePolicy::setElementHSizeType(int a)
+{
+ m_children |= HSizeType;
+ m_hSizeType = a;
+}
+
+void DomSizePolicy::setElementVSizeType(int a)
+{
+ m_children |= VSizeType;
+ m_vSizeType = a;
+}
+
+void DomSizePolicy::setElementHorStretch(int a)
+{
+ m_children |= HorStretch;
+ m_horStretch = a;
+}
+
+void DomSizePolicy::setElementVerStretch(int a)
+{
+ m_children |= VerStretch;
+ m_verStretch = a;
+}
+
+void DomSizePolicy::clearElementHSizeType()
+{
+ m_children &= ~HSizeType;
+}
+
+void DomSizePolicy::clearElementVSizeType()
+{
+ m_children &= ~VSizeType;
+}
+
+void DomSizePolicy::clearElementHorStretch()
+{
+ m_children &= ~HorStretch;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("width")) {
+ setElementWidth(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomSize::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("width")) {
+ setElementWidth(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomSize::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("size") : tagName.toLower());
+
+ if (m_children & Width) {
+ writer.writeTextElement(QLatin1String("width"), QString::number(m_width));
+ }
+
+ if (m_children & Height) {
+ writer.writeTextElement(QLatin1String("height"), QString::number(m_height));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomSize::setElementWidth(int a)
+{
+ m_children |= Width;
+ m_width = a;
+}
+
+void DomSize::setElementHeight(int a)
+{
+ m_children |= Height;
+ m_height = a;
+}
+
+void DomSize::clearElementWidth()
+{
+ m_children &= ~Width;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("year")) {
+ setElementYear(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("month")) {
+ setElementMonth(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("day")) {
+ setElementDay(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomDate::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("year")) {
+ setElementYear(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("month")) {
+ setElementMonth(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("day")) {
+ setElementDay(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomDate::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("date") : tagName.toLower());
+
+ if (m_children & Year) {
+ writer.writeTextElement(QLatin1String("year"), QString::number(m_year));
+ }
+
+ if (m_children & Month) {
+ writer.writeTextElement(QLatin1String("month"), QString::number(m_month));
+ }
+
+ if (m_children & Day) {
+ writer.writeTextElement(QLatin1String("day"), QString::number(m_day));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomDate::setElementYear(int a)
+{
+ m_children |= Year;
+ m_year = a;
+}
+
+void DomDate::setElementMonth(int a)
+{
+ m_children |= Month;
+ m_month = a;
+}
+
+void DomDate::setElementDay(int a)
+{
+ m_children |= Day;
+ m_day = a;
+}
+
+void DomDate::clearElementYear()
+{
+ m_children &= ~Year;
+}
+
+void DomDate::clearElementMonth()
+{
+ m_children &= ~Month;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("hour")) {
+ setElementHour(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("minute")) {
+ setElementMinute(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("second")) {
+ setElementSecond(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomTime::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("hour")) {
+ setElementHour(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("minute")) {
+ setElementMinute(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("second")) {
+ setElementSecond(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomTime::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("time") : tagName.toLower());
+
+ if (m_children & Hour) {
+ writer.writeTextElement(QLatin1String("hour"), QString::number(m_hour));
+ }
+
+ if (m_children & Minute) {
+ writer.writeTextElement(QLatin1String("minute"), QString::number(m_minute));
+ }
+
+ if (m_children & Second) {
+ writer.writeTextElement(QLatin1String("second"), QString::number(m_second));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomTime::setElementHour(int a)
+{
+ m_children |= Hour;
+ m_hour = a;
+}
+
+void DomTime::setElementMinute(int a)
+{
+ m_children |= Minute;
+ m_minute = a;
+}
+
+void DomTime::setElementSecond(int a)
+{
+ m_children |= Second;
+ m_second = a;
+}
+
+void DomTime::clearElementHour()
+{
+ m_children &= ~Hour;
+}
+
+void DomTime::clearElementMinute()
+{
+ m_children &= ~Minute;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("hour")) {
+ setElementHour(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("minute")) {
+ setElementMinute(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("second")) {
+ setElementSecond(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("year")) {
+ setElementYear(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("month")) {
+ setElementMonth(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("day")) {
+ setElementDay(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomDateTime::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("hour")) {
+ setElementHour(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("minute")) {
+ setElementMinute(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("second")) {
+ setElementSecond(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("year")) {
+ setElementYear(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("month")) {
+ setElementMonth(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("day")) {
+ setElementDay(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomDateTime::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("datetime") : tagName.toLower());
+
+ if (m_children & Hour) {
+ writer.writeTextElement(QLatin1String("hour"), QString::number(m_hour));
+ }
+
+ if (m_children & Minute) {
+ writer.writeTextElement(QLatin1String("minute"), QString::number(m_minute));
+ }
+
+ if (m_children & Second) {
+ writer.writeTextElement(QLatin1String("second"), QString::number(m_second));
+ }
+
+ if (m_children & Year) {
+ writer.writeTextElement(QLatin1String("year"), QString::number(m_year));
+ }
+
+ if (m_children & Month) {
+ writer.writeTextElement(QLatin1String("month"), QString::number(m_month));
+ }
+
+ if (m_children & Day) {
+ writer.writeTextElement(QLatin1String("day"), QString::number(m_day));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomDateTime::setElementHour(int a)
+{
+ m_children |= Hour;
+ m_hour = a;
+}
+
+void DomDateTime::setElementMinute(int a)
+{
+ m_children |= Minute;
+ m_minute = a;
+}
+
+void DomDateTime::setElementSecond(int a)
+{
+ m_children |= Second;
+ m_second = a;
+}
+
+void DomDateTime::setElementYear(int a)
+{
+ m_children |= Year;
+ m_year = a;
+}
+
+void DomDateTime::setElementMonth(int a)
+{
+ m_children |= Month;
+ m_month = a;
+}
+
+void DomDateTime::setElementDay(int a)
+{
+ m_children |= Day;
+ m_day = a;
+}
+
+void DomDateTime::clearElementHour()
+{
+ m_children &= ~Hour;
+}
+
+void DomDateTime::clearElementMinute()
+{
+ m_children &= ~Minute;
+}
+
+void DomDateTime::clearElementSecond()
+{
+ m_children &= ~Second;
+}
+
+void DomDateTime::clearElementYear()
+{
+ m_children &= ~Year;
+}
+
+void DomDateTime::clearElementMonth()
+{
+ m_children &= ~Month;
+}
+
+void DomDateTime::clearElementDay()
+{
+ m_children &= ~Day;
+}
+
+void DomStringList::clear(bool clear_all)
+{
+ m_string.clear();
+
+ if (clear_all) {
+ m_text.clear();
+ }
+
+ m_children = 0;
+}
+
+DomStringList::DomStringList()
+{
+ m_children = 0;
+}
+
+DomStringList::~DomStringList()
+{
+ m_string.clear();
+}
+
+void DomStringList::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("string")) {
+ m_string.append(reader.readElementText());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomStringList::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("string")) {
+ m_string.append(e.text());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomStringList::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringlist") : tagName.toLower());
+
+ for (int i = 0; i < m_string.size(); ++i) {
+ QString v = m_string[i];
+ writer.writeTextElement(QLatin1String("string"), v);
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomStringList::setElementString(const QStringList& a)
+{
+ m_children |= String;
+ m_string = a;
+}
+
+void DomResourcePixmap::clear(bool clear_all)
+{
+
+ if (clear_all) {
+ m_text = QLatin1String("");
+ 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 = QLatin1String("");
+}
+
+DomResourcePixmap::~DomResourcePixmap()
+{
+}
+
+void DomResourcePixmap::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("resource")) {
+ setAttributeResource(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("alias")) {
+ setAttributeAlias(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomResourcePixmap::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("resource")))
+ setAttributeResource(node.attribute(QLatin1String("resource")));
+ if (node.hasAttribute(QLatin1String("alias")))
+ setAttributeAlias(node.attribute(QLatin1String("alias")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text = QLatin1String("");
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomResourcePixmap::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourcepixmap") : tagName.toLower());
+
+ if (hasAttributeResource())
+ writer.writeAttribute(QLatin1String("resource"), attributeResource());
+
+ if (hasAttributeAlias())
+ writer.writeAttribute(QLatin1String("alias"), attributeAlias());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ 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 = QLatin1String("");
+ 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 = QLatin1String("");
+ 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;
+ delete m_normalOn;
+ delete m_disabledOff;
+ delete m_disabledOn;
+ delete m_activeOff;
+ delete m_activeOn;
+ delete m_selectedOff;
+ delete m_selectedOn;
+}
+
+void DomResourceIcon::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("theme")) {
+ setAttributeTheme(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("resource")) {
+ setAttributeResource(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("normaloff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementNormalOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("normalon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementNormalOn(v);
+ continue;
+ }
+ if (tag == QLatin1String("disabledoff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementDisabledOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("disabledon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementDisabledOn(v);
+ continue;
+ }
+ if (tag == QLatin1String("activeoff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementActiveOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("activeon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementActiveOn(v);
+ continue;
+ }
+ if (tag == QLatin1String("selectedoff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementSelectedOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("selectedon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementSelectedOn(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomResourceIcon::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("theme")))
+ setAttributeTheme(node.attribute(QLatin1String("theme")));
+ if (node.hasAttribute(QLatin1String("resource")))
+ setAttributeResource(node.attribute(QLatin1String("resource")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("normaloff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementNormalOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("normalon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementNormalOn(v);
+ continue;
+ }
+ if (tag == QLatin1String("disabledoff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementDisabledOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("disabledon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementDisabledOn(v);
+ continue;
+ }
+ if (tag == QLatin1String("activeoff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementActiveOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("activeon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementActiveOn(v);
+ continue;
+ }
+ if (tag == QLatin1String("selectedoff")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementSelectedOff(v);
+ continue;
+ }
+ if (tag == QLatin1String("selectedon")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementSelectedOn(v);
+ continue;
+ }
+ }
+ m_text = QLatin1String("");
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomResourceIcon::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("resourceicon") : tagName.toLower());
+
+ if (hasAttributeTheme())
+ writer.writeAttribute(QLatin1String("theme"), attributeTheme());
+
+ if (hasAttributeResource())
+ writer.writeAttribute(QLatin1String("resource"), attributeResource());
+
+ if (m_children & NormalOff) {
+ m_normalOff->write(writer, QLatin1String("normaloff"));
+ }
+
+ if (m_children & NormalOn) {
+ m_normalOn->write(writer, QLatin1String("normalon"));
+ }
+
+ if (m_children & DisabledOff) {
+ m_disabledOff->write(writer, QLatin1String("disabledoff"));
+ }
+
+ if (m_children & DisabledOn) {
+ m_disabledOn->write(writer, QLatin1String("disabledon"));
+ }
+
+ if (m_children & ActiveOff) {
+ m_activeOff->write(writer, QLatin1String("activeoff"));
+ }
+
+ if (m_children & ActiveOn) {
+ m_activeOn->write(writer, QLatin1String("activeon"));
+ }
+
+ if (m_children & SelectedOff) {
+ m_selectedOff->write(writer, QLatin1String("selectedoff"));
+ }
+
+ if (m_children & SelectedOn) {
+ m_selectedOn->write(writer, QLatin1String("selectedon"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementNormalOff()
+{
+ DomResourcePixmap* a = m_normalOff;
+ m_normalOff = 0;
+ m_children ^= NormalOff;
+ return a;
+}
+
+void DomResourceIcon::setElementNormalOff(DomResourcePixmap* a)
+{
+ delete m_normalOff;
+ m_children |= NormalOff;
+ m_normalOff = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementNormalOn()
+{
+ DomResourcePixmap* a = m_normalOn;
+ m_normalOn = 0;
+ m_children ^= NormalOn;
+ return a;
+}
+
+void DomResourceIcon::setElementNormalOn(DomResourcePixmap* a)
+{
+ delete m_normalOn;
+ m_children |= NormalOn;
+ m_normalOn = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementDisabledOff()
+{
+ DomResourcePixmap* a = m_disabledOff;
+ m_disabledOff = 0;
+ m_children ^= DisabledOff;
+ return a;
+}
+
+void DomResourceIcon::setElementDisabledOff(DomResourcePixmap* a)
+{
+ delete m_disabledOff;
+ m_children |= DisabledOff;
+ m_disabledOff = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementDisabledOn()
+{
+ DomResourcePixmap* a = m_disabledOn;
+ m_disabledOn = 0;
+ m_children ^= DisabledOn;
+ return a;
+}
+
+void DomResourceIcon::setElementDisabledOn(DomResourcePixmap* a)
+{
+ delete m_disabledOn;
+ m_children |= DisabledOn;
+ m_disabledOn = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementActiveOff()
+{
+ DomResourcePixmap* a = m_activeOff;
+ m_activeOff = 0;
+ m_children ^= ActiveOff;
+ return a;
+}
+
+void DomResourceIcon::setElementActiveOff(DomResourcePixmap* a)
+{
+ delete m_activeOff;
+ m_children |= ActiveOff;
+ m_activeOff = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementActiveOn()
+{
+ DomResourcePixmap* a = m_activeOn;
+ m_activeOn = 0;
+ m_children ^= ActiveOn;
+ return a;
+}
+
+void DomResourceIcon::setElementActiveOn(DomResourcePixmap* a)
+{
+ delete m_activeOn;
+ m_children |= ActiveOn;
+ m_activeOn = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementSelectedOff()
+{
+ DomResourcePixmap* a = m_selectedOff;
+ m_selectedOff = 0;
+ m_children ^= SelectedOff;
+ return a;
+}
+
+void DomResourceIcon::setElementSelectedOff(DomResourcePixmap* a)
+{
+ delete m_selectedOff;
+ m_children |= SelectedOff;
+ m_selectedOff = a;
+}
+
+DomResourcePixmap* DomResourceIcon::takeElementSelectedOn()
+{
+ DomResourcePixmap* a = m_selectedOn;
+ m_selectedOn = 0;
+ m_children ^= SelectedOn;
+ return a;
+}
+
+void DomResourceIcon::setElementSelectedOn(DomResourcePixmap* a)
+{
+ delete m_selectedOn;
+ m_children |= SelectedOn;
+ m_selectedOn = a;
+}
+
+void DomResourceIcon::clearElementNormalOff()
+{
+ delete m_normalOff;
+ m_normalOff = 0;
+ m_children &= ~NormalOff;
+}
+
+void DomResourceIcon::clearElementNormalOn()
+{
+ delete m_normalOn;
+ m_normalOn = 0;
+ m_children &= ~NormalOn;
+}
+
+void DomResourceIcon::clearElementDisabledOff()
+{
+ delete m_disabledOff;
+ m_disabledOff = 0;
+ m_children &= ~DisabledOff;
+}
+
+void DomResourceIcon::clearElementDisabledOn()
+{
+ delete m_disabledOn;
+ m_disabledOn = 0;
+ m_children &= ~DisabledOn;
+}
+
+void DomResourceIcon::clearElementActiveOff()
+{
+ delete m_activeOff;
+ m_activeOff = 0;
+ m_children &= ~ActiveOff;
+}
+
+void DomResourceIcon::clearElementActiveOn()
+{
+ delete m_activeOn;
+ m_activeOn = 0;
+ m_children &= ~ActiveOn;
+}
+
+void DomResourceIcon::clearElementSelectedOff()
+{
+ delete m_selectedOff;
+ m_selectedOff = 0;
+ m_children &= ~SelectedOff;
+}
+
+void DomResourceIcon::clearElementSelectedOn()
+{
+ delete m_selectedOn;
+ m_selectedOn = 0;
+ m_children &= ~SelectedOn;
+}
+
+void DomString::clear(bool clear_all)
+{
+
+ if (clear_all) {
+ m_text = QLatin1String("");
+ 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 = QLatin1String("");
+}
+
+DomString::~DomString()
+{
+}
+
+void DomString::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("notr")) {
+ setAttributeNotr(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("comment")) {
+ setAttributeComment(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("extracomment")) {
+ setAttributeExtraComment(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomString::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("notr")))
+ setAttributeNotr(node.attribute(QLatin1String("notr")));
+ if (node.hasAttribute(QLatin1String("comment")))
+ setAttributeComment(node.attribute(QLatin1String("comment")));
+ if (node.hasAttribute(QLatin1String("extracomment")))
+ setAttributeExtraComment(node.attribute(QLatin1String("extracomment")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text = QLatin1String("");
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomString::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("string") : tagName.toLower());
+
+ if (hasAttributeNotr())
+ writer.writeAttribute(QLatin1String("notr"), attributeNotr());
+
+ if (hasAttributeComment())
+ writer.writeAttribute(QLatin1String("comment"), attributeComment());
+
+ if (hasAttributeExtraComment())
+ writer.writeAttribute(QLatin1String("extracomment"), attributeExtraComment());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ 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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(reader.readElementText().toDouble());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(reader.readElementText().toDouble());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPointF::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(e.text().toDouble());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(e.text().toDouble());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPointF::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("pointf") : tagName.toLower());
+
+ if (m_children & X) {
+ writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15));
+ }
+
+ 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();
+}
+
+void DomPointF::setElementX(double a)
+{
+ m_children |= X;
+ m_x = a;
+}
+
+void DomPointF::setElementY(double a)
+{
+ m_children |= Y;
+ m_y = a;
+}
+
+void DomPointF::clearElementX()
+{
+ m_children &= ~X;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(reader.readElementText().toDouble());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(reader.readElementText().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("width")) {
+ setElementWidth(reader.readElementText().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(reader.readElementText().toDouble());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomRectF::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(e.text().toDouble());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(e.text().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("width")) {
+ setElementWidth(e.text().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(e.text().toDouble());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomRectF::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("rectf") : tagName.toLower());
+
+ if (m_children & X) {
+ writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x, 'f', 15));
+ }
+
+ if (m_children & Y) {
+ writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y, 'f', 15));
+ }
+
+ if (m_children & Width) {
+ writer.writeTextElement(QLatin1String("width"), QString::number(m_width, 'f', 15));
+ }
+
+ if (m_children & Height) {
+ writer.writeTextElement(QLatin1String("height"), QString::number(m_height, 'f', 15));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomRectF::setElementX(double a)
+{
+ m_children |= X;
+ m_x = a;
+}
+
+void DomRectF::setElementY(double a)
+{
+ m_children |= Y;
+ m_y = a;
+}
+
+void DomRectF::setElementWidth(double a)
+{
+ m_children |= Width;
+ m_width = a;
+}
+
+void DomRectF::setElementHeight(double a)
+{
+ m_children |= Height;
+ m_height = a;
+}
+
+void DomRectF::clearElementX()
+{
+ m_children &= ~X;
+}
+
+void DomRectF::clearElementY()
+{
+ m_children &= ~Y;
+}
+
+void DomRectF::clearElementWidth()
+{
+ m_children &= ~Width;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("width")) {
+ setElementWidth(reader.readElementText().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(reader.readElementText().toDouble());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomSizeF::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("width")) {
+ setElementWidth(e.text().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("height")) {
+ setElementHeight(e.text().toDouble());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomSizeF::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("sizef") : tagName.toLower());
+
+ if (m_children & Width) {
+ writer.writeTextElement(QLatin1String("width"), QString::number(m_width, 'f', 15));
+ }
+
+ if (m_children & Height) {
+ writer.writeTextElement(QLatin1String("height"), QString::number(m_height, 'f', 15));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomSizeF::setElementWidth(double a)
+{
+ m_children |= Width;
+ m_width = a;
+}
+
+void DomSizeF::setElementHeight(double a)
+{
+ m_children |= Height;
+ m_height = a;
+}
+
+void DomSizeF::clearElementWidth()
+{
+ m_children &= ~Width;
+}
+
+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();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("unicode")) {
+ setElementUnicode(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomChar::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("unicode")) {
+ setElementUnicode(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomChar::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("char") : tagName.toLower());
+
+ if (m_children & Unicode) {
+ writer.writeTextElement(QLatin1String("unicode"), QString::number(m_unicode));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomChar::setElementUnicode(int a)
+{
+ m_children |= Unicode;
+ m_unicode = a;
+}
+
+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;
+}
+
+void DomUrl::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("string")) {
+ DomString *v = new DomString();
+ v->read(reader);
+ setElementString(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomUrl::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("string")) {
+ DomString *v = new DomString();
+ v->read(e);
+ setElementString(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomUrl::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("url") : tagName.toLower());
+
+ if (m_children & String) {
+ m_string->write(writer, QLatin1String("string"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+DomString* DomUrl::takeElementString()
+{
+ DomString* a = m_string;
+ m_string = 0;
+ m_children ^= String;
+ return a;
+}
+
+void DomUrl::setElementString(DomString* a)
+{
+ delete m_string;
+ m_children |= String;
+ m_string = a;
+}
+
+void DomUrl::clearElementString()
+{
+ delete m_string;
+ m_string = 0;
+ m_children &= ~String;
+}
+
+void DomProperty::clear(bool clear_all)
+{
+ delete m_color;
+ delete m_font;
+ delete m_iconSet;
+ delete m_pixmap;
+ delete m_palette;
+ delete m_point;
+ delete m_rect;
+ delete m_locale;
+ delete m_sizePolicy;
+ delete m_size;
+ delete m_string;
+ delete m_stringList;
+ delete m_date;
+ delete m_time;
+ delete m_dateTime;
+ delete m_pointF;
+ delete m_rectF;
+ delete m_sizeF;
+ 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()
+{
+ delete m_color;
+ delete m_font;
+ delete m_iconSet;
+ delete m_pixmap;
+ delete m_palette;
+ delete m_point;
+ delete m_rect;
+ delete m_locale;
+ delete m_sizePolicy;
+ delete m_size;
+ delete m_string;
+ delete m_stringList;
+ delete m_date;
+ delete m_time;
+ delete m_dateTime;
+ delete m_pointF;
+ delete m_rectF;
+ delete m_sizeF;
+ delete m_char;
+ delete m_url;
+ delete m_brush;
+}
+
+void DomProperty::read(QXmlStreamReader &reader)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("stdset")) {
+ setAttributeStdset(attribute.value().toString().toInt());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QLatin1String("bool")) {
+ setElementBool(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(reader);
+ setElementColor(v);
+ continue;
+ }
+ if (tag == QLatin1String("cstring")) {
+ setElementCstring(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("cursor")) {
+ setElementCursor(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("cursorshape")) {
+ setElementCursorShape(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("enum")) {
+ setElementEnum(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("font")) {
+ DomFont *v = new DomFont();
+ v->read(reader);
+ setElementFont(v);
+ continue;
+ }
+ if (tag == QLatin1String("iconset")) {
+ DomResourceIcon *v = new DomResourceIcon();
+ v->read(reader);
+ setElementIconSet(v);
+ continue;
+ }
+ if (tag == QLatin1String("pixmap")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(reader);
+ setElementPixmap(v);
+ continue;
+ }
+ if (tag == QLatin1String("palette")) {
+ DomPalette *v = new DomPalette();
+ v->read(reader);
+ setElementPalette(v);
+ continue;
+ }
+ if (tag == QLatin1String("point")) {
+ DomPoint *v = new DomPoint();
+ v->read(reader);
+ setElementPoint(v);
+ continue;
+ }
+ if (tag == QLatin1String("rect")) {
+ DomRect *v = new DomRect();
+ v->read(reader);
+ setElementRect(v);
+ continue;
+ }
+ if (tag == QLatin1String("set")) {
+ setElementSet(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("locale")) {
+ DomLocale *v = new DomLocale();
+ v->read(reader);
+ setElementLocale(v);
+ continue;
+ }
+ if (tag == QLatin1String("sizepolicy")) {
+ DomSizePolicy *v = new DomSizePolicy();
+ v->read(reader);
+ setElementSizePolicy(v);
+ continue;
+ }
+ if (tag == QLatin1String("size")) {
+ DomSize *v = new DomSize();
+ v->read(reader);
+ setElementSize(v);
+ continue;
+ }
+ if (tag == QLatin1String("string")) {
+ DomString *v = new DomString();
+ v->read(reader);
+ setElementString(v);
+ continue;
+ }
+ if (tag == QLatin1String("stringlist")) {
+ DomStringList *v = new DomStringList();
+ v->read(reader);
+ setElementStringList(v);
+ continue;
+ }
+ if (tag == QLatin1String("number")) {
+ setElementNumber(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("float")) {
+ setElementFloat(reader.readElementText().toFloat());
+ continue;
+ }
+ if (tag == QLatin1String("double")) {
+ setElementDouble(reader.readElementText().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("date")) {
+ DomDate *v = new DomDate();
+ v->read(reader);
+ setElementDate(v);
+ continue;
+ }
+ if (tag == QLatin1String("time")) {
+ DomTime *v = new DomTime();
+ v->read(reader);
+ setElementTime(v);
+ continue;
+ }
+ if (tag == QLatin1String("datetime")) {
+ DomDateTime *v = new DomDateTime();
+ v->read(reader);
+ setElementDateTime(v);
+ continue;
+ }
+ if (tag == QLatin1String("pointf")) {
+ DomPointF *v = new DomPointF();
+ v->read(reader);
+ setElementPointF(v);
+ continue;
+ }
+ if (tag == QLatin1String("rectf")) {
+ DomRectF *v = new DomRectF();
+ v->read(reader);
+ setElementRectF(v);
+ continue;
+ }
+ if (tag == QLatin1String("sizef")) {
+ DomSizeF *v = new DomSizeF();
+ v->read(reader);
+ setElementSizeF(v);
+ continue;
+ }
+ if (tag == QLatin1String("longlong")) {
+ setElementLongLong(reader.readElementText().toLongLong());
+ continue;
+ }
+ if (tag == QLatin1String("char")) {
+ DomChar *v = new DomChar();
+ v->read(reader);
+ setElementChar(v);
+ continue;
+ }
+ if (tag == QLatin1String("url")) {
+ DomUrl *v = new DomUrl();
+ v->read(reader);
+ setElementUrl(v);
+ continue;
+ }
+ if (tag == QLatin1String("uint")) {
+ setElementUInt(reader.readElementText().toUInt());
+ continue;
+ }
+ if (tag == QLatin1String("ulonglong")) {
+ setElementULongLong(reader.readElementText().toULongLong());
+ continue;
+ }
+ if (tag == QLatin1String("brush")) {
+ DomBrush *v = new DomBrush();
+ v->read(reader);
+ setElementBrush(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomProperty::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("stdset")))
+ setAttributeStdset(node.attribute(QLatin1String("stdset")).toInt());
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("bool")) {
+ setElementBool(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("color")) {
+ DomColor *v = new DomColor();
+ v->read(e);
+ setElementColor(v);
+ continue;
+ }
+ if (tag == QLatin1String("cstring")) {
+ setElementCstring(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("cursor")) {
+ setElementCursor(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("cursorshape")) {
+ setElementCursorShape(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("enum")) {
+ setElementEnum(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("font")) {
+ DomFont *v = new DomFont();
+ v->read(e);
+ setElementFont(v);
+ continue;
+ }
+ if (tag == QLatin1String("iconset")) {
+ DomResourceIcon *v = new DomResourceIcon();
+ v->read(e);
+ setElementIconSet(v);
+ continue;
+ }
+ if (tag == QLatin1String("pixmap")) {
+ DomResourcePixmap *v = new DomResourcePixmap();
+ v->read(e);
+ setElementPixmap(v);
+ continue;
+ }
+ if (tag == QLatin1String("palette")) {
+ DomPalette *v = new DomPalette();
+ v->read(e);
+ setElementPalette(v);
+ continue;
+ }
+ if (tag == QLatin1String("point")) {
+ DomPoint *v = new DomPoint();
+ v->read(e);
+ setElementPoint(v);
+ continue;
+ }
+ if (tag == QLatin1String("rect")) {
+ DomRect *v = new DomRect();
+ v->read(e);
+ setElementRect(v);
+ continue;
+ }
+ if (tag == QLatin1String("set")) {
+ setElementSet(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("locale")) {
+ DomLocale *v = new DomLocale();
+ v->read(e);
+ setElementLocale(v);
+ continue;
+ }
+ if (tag == QLatin1String("sizepolicy")) {
+ DomSizePolicy *v = new DomSizePolicy();
+ v->read(e);
+ setElementSizePolicy(v);
+ continue;
+ }
+ if (tag == QLatin1String("size")) {
+ DomSize *v = new DomSize();
+ v->read(e);
+ setElementSize(v);
+ continue;
+ }
+ if (tag == QLatin1String("string")) {
+ DomString *v = new DomString();
+ v->read(e);
+ setElementString(v);
+ continue;
+ }
+ if (tag == QLatin1String("stringlist")) {
+ DomStringList *v = new DomStringList();
+ v->read(e);
+ setElementStringList(v);
+ continue;
+ }
+ if (tag == QLatin1String("number")) {
+ setElementNumber(e.text().toInt());
+ continue;
+ }
+ if (tag == QLatin1String("float")) {
+ setElementFloat(e.text().toFloat());
+ continue;
+ }
+ if (tag == QLatin1String("double")) {
+ setElementDouble(e.text().toDouble());
+ continue;
+ }
+ if (tag == QLatin1String("date")) {
+ DomDate *v = new DomDate();
+ v->read(e);
+ setElementDate(v);
+ continue;
+ }
+ if (tag == QLatin1String("time")) {
+ DomTime *v = new DomTime();
+ v->read(e);
+ setElementTime(v);
+ continue;
+ }
+ if (tag == QLatin1String("datetime")) {
+ DomDateTime *v = new DomDateTime();
+ v->read(e);
+ setElementDateTime(v);
+ continue;
+ }
+ if (tag == QLatin1String("pointf")) {
+ DomPointF *v = new DomPointF();
+ v->read(e);
+ setElementPointF(v);
+ continue;
+ }
+ if (tag == QLatin1String("rectf")) {
+ DomRectF *v = new DomRectF();
+ v->read(e);
+ setElementRectF(v);
+ continue;
+ }
+ if (tag == QLatin1String("sizef")) {
+ DomSizeF *v = new DomSizeF();
+ v->read(e);
+ setElementSizeF(v);
+ continue;
+ }
+ if (tag == QLatin1String("longlong")) {
+ setElementLongLong(e.text().toLongLong());
+ continue;
+ }
+ if (tag == QLatin1String("char")) {
+ DomChar *v = new DomChar();
+ v->read(e);
+ setElementChar(v);
+ continue;
+ }
+ if (tag == QLatin1String("url")) {
+ DomUrl *v = new DomUrl();
+ v->read(e);
+ setElementUrl(v);
+ continue;
+ }
+ if (tag == QLatin1String("uint")) {
+ setElementUInt(e.text().toUInt());
+ continue;
+ }
+ if (tag == QLatin1String("ulonglong")) {
+ setElementULongLong(e.text().toULongLong());
+ continue;
+ }
+ if (tag == QLatin1String("brush")) {
+ DomBrush *v = new DomBrush();
+ v->read(e);
+ setElementBrush(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomProperty::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("property") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeStdset())
+ writer.writeAttribute(QLatin1String("stdset"), QString::number(attributeStdset()));
+
+ switch (kind()) {
+ case Bool: {
+ writer.writeTextElement(QLatin1String("bool"), elementBool());
+ break;
+ }
+ case Color: {
+ DomColor* v = elementColor();
+ if (v != 0) {
+ v->write(writer, QLatin1String("color"));
+ }
+ break;
+ }
+ case Cstring: {
+ writer.writeTextElement(QLatin1String("cstring"), elementCstring());
+ break;
+ }
+ case Cursor: {
+ writer.writeTextElement(QLatin1String("cursor"), QString::number(elementCursor()));
+ break;
+ }
+ case CursorShape: {
+ writer.writeTextElement(QLatin1String("cursorShape"), elementCursorShape());
+ break;
+ }
+ case Enum: {
+ writer.writeTextElement(QLatin1String("enum"), elementEnum());
+ break;
+ }
+ case Font: {
+ DomFont* v = elementFont();
+ if (v != 0) {
+ v->write(writer, QLatin1String("font"));
+ }
+ break;
+ }
+ case IconSet: {
+ DomResourceIcon* v = elementIconSet();
+ if (v != 0) {
+ v->write(writer, QLatin1String("iconset"));
+ }
+ break;
+ }
+ case Pixmap: {
+ DomResourcePixmap* v = elementPixmap();
+ if (v != 0) {
+ v->write(writer, QLatin1String("pixmap"));
+ }
+ break;
+ }
+ case Palette: {
+ DomPalette* v = elementPalette();
+ if (v != 0) {
+ v->write(writer, QLatin1String("palette"));
+ }
+ break;
+ }
+ case Point: {
+ DomPoint* v = elementPoint();
+ if (v != 0) {
+ v->write(writer, QLatin1String("point"));
+ }
+ break;
+ }
+ case Rect: {
+ DomRect* v = elementRect();
+ if (v != 0) {
+ v->write(writer, QLatin1String("rect"));
+ }
+ break;
+ }
+ case Set: {
+ writer.writeTextElement(QLatin1String("set"), elementSet());
+ break;
+ }
+ case Locale: {
+ DomLocale* v = elementLocale();
+ if (v != 0) {
+ v->write(writer, QLatin1String("locale"));
+ }
+ break;
+ }
+ case SizePolicy: {
+ DomSizePolicy* v = elementSizePolicy();
+ if (v != 0) {
+ v->write(writer, QLatin1String("sizepolicy"));
+ }
+ break;
+ }
+ case Size: {
+ DomSize* v = elementSize();
+ if (v != 0) {
+ v->write(writer, QLatin1String("size"));
+ }
+ break;
+ }
+ case String: {
+ DomString* v = elementString();
+ if (v != 0) {
+ v->write(writer, QLatin1String("string"));
+ }
+ break;
+ }
+ case StringList: {
+ DomStringList* v = elementStringList();
+ if (v != 0) {
+ v->write(writer, QLatin1String("stringlist"));
+ }
+ break;
+ }
+ case Number: {
+ writer.writeTextElement(QLatin1String("number"), QString::number(elementNumber()));
+ break;
+ }
+ case Float: {
+ writer.writeTextElement(QLatin1String("float"), QString::number(elementFloat(), 'f', 8));
+ break;
+ }
+ case Double: {
+ writer.writeTextElement(QLatin1String("double"), QString::number(elementDouble(), 'f', 15));
+ break;
+ }
+ case Date: {
+ DomDate* v = elementDate();
+ if (v != 0) {
+ v->write(writer, QLatin1String("date"));
+ }
+ break;
+ }
+ case Time: {
+ DomTime* v = elementTime();
+ if (v != 0) {
+ v->write(writer, QLatin1String("time"));
+ }
+ break;
+ }
+ case DateTime: {
+ DomDateTime* v = elementDateTime();
+ if (v != 0) {
+ v->write(writer, QLatin1String("datetime"));
+ }
+ break;
+ }
+ case PointF: {
+ DomPointF* v = elementPointF();
+ if (v != 0) {
+ v->write(writer, QLatin1String("pointf"));
+ }
+ break;
+ }
+ case RectF: {
+ DomRectF* v = elementRectF();
+ if (v != 0) {
+ v->write(writer, QLatin1String("rectf"));
+ }
+ break;
+ }
+ case SizeF: {
+ DomSizeF* v = elementSizeF();
+ if (v != 0) {
+ v->write(writer, QLatin1String("sizef"));
+ }
+ break;
+ }
+ case LongLong: {
+ writer.writeTextElement(QLatin1String("longLong"), QString::number(elementLongLong()));
+ break;
+ }
+ case Char: {
+ DomChar* v = elementChar();
+ if (v != 0) {
+ v->write(writer, QLatin1String("char"));
+ }
+ break;
+ }
+ case Url: {
+ DomUrl* v = elementUrl();
+ if (v != 0) {
+ v->write(writer, QLatin1String("url"));
+ }
+ break;
+ }
+ case UInt: {
+ writer.writeTextElement(QLatin1String("UInt"), QString::number(elementUInt()));
+ break;
+ }
+ case ULongLong: {
+ writer.writeTextElement(QLatin1String("uLongLong"), QString::number(elementULongLong()));
+ break;
+ }
+ case Brush: {
+ DomBrush* v = elementBrush();
+ if (v != 0) {
+ v->write(writer, QLatin1String("brush"));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomProperty::setElementBool(const QString& a)
+{
+ clear(false);
+ m_kind = Bool;
+ m_bool = a;
+}
+
+DomColor* DomProperty::takeElementColor()
+{
+ DomColor* a = m_color;
+ m_color = 0;
+ return a;
+}
+
+void DomProperty::setElementColor(DomColor* a)
+{
+ clear(false);
+ m_kind = Color;
+ m_color = a;
+}
+
+void DomProperty::setElementCstring(const QString& a)
+{
+ clear(false);
+ m_kind = Cstring;
+ m_cstring = a;
+}
+
+void DomProperty::setElementCursor(int a)
+{
+ clear(false);
+ m_kind = Cursor;
+ m_cursor = a;
+}
+
+void DomProperty::setElementCursorShape(const QString& a)
+{
+ clear(false);
+ m_kind = CursorShape;
+ m_cursorShape = a;
+}
+
+void DomProperty::setElementEnum(const QString& a)
+{
+ clear(false);
+ m_kind = Enum;
+ m_enum = a;
+}
+
+DomFont* DomProperty::takeElementFont()
+{
+ DomFont* a = m_font;
+ m_font = 0;
+ return a;
+}
+
+void DomProperty::setElementFont(DomFont* a)
+{
+ clear(false);
+ m_kind = Font;
+ m_font = a;
+}
+
+DomResourceIcon* DomProperty::takeElementIconSet()
+{
+ DomResourceIcon* a = m_iconSet;
+ m_iconSet = 0;
+ return a;
+}
+
+void DomProperty::setElementIconSet(DomResourceIcon* a)
+{
+ clear(false);
+ m_kind = IconSet;
+ m_iconSet = a;
+}
+
+DomResourcePixmap* DomProperty::takeElementPixmap()
+{
+ DomResourcePixmap* a = m_pixmap;
+ m_pixmap = 0;
+ return a;
+}
+
+void DomProperty::setElementPixmap(DomResourcePixmap* a)
+{
+ clear(false);
+ m_kind = Pixmap;
+ m_pixmap = a;
+}
+
+DomPalette* DomProperty::takeElementPalette()
+{
+ DomPalette* a = m_palette;
+ m_palette = 0;
+ return a;
+}
+
+void DomProperty::setElementPalette(DomPalette* a)
+{
+ clear(false);
+ m_kind = Palette;
+ m_palette = a;
+}
+
+DomPoint* DomProperty::takeElementPoint()
+{
+ DomPoint* a = m_point;
+ m_point = 0;
+ return a;
+}
+
+void DomProperty::setElementPoint(DomPoint* a)
+{
+ clear(false);
+ m_kind = Point;
+ m_point = a;
+}
+
+DomRect* DomProperty::takeElementRect()
+{
+ DomRect* a = m_rect;
+ m_rect = 0;
+ return a;
+}
+
+void DomProperty::setElementRect(DomRect* a)
+{
+ clear(false);
+ m_kind = Rect;
+ m_rect = a;
+}
+
+void DomProperty::setElementSet(const QString& a)
+{
+ clear(false);
+ m_kind = Set;
+ m_set = a;
+}
+
+DomLocale* DomProperty::takeElementLocale()
+{
+ DomLocale* a = m_locale;
+ m_locale = 0;
+ return a;
+}
+
+void DomProperty::setElementLocale(DomLocale* a)
+{
+ clear(false);
+ m_kind = Locale;
+ m_locale = a;
+}
+
+DomSizePolicy* DomProperty::takeElementSizePolicy()
+{
+ DomSizePolicy* a = m_sizePolicy;
+ m_sizePolicy = 0;
+ return a;
+}
+
+void DomProperty::setElementSizePolicy(DomSizePolicy* a)
+{
+ clear(false);
+ m_kind = SizePolicy;
+ m_sizePolicy = a;
+}
+
+DomSize* DomProperty::takeElementSize()
+{
+ DomSize* a = m_size;
+ m_size = 0;
+ return a;
+}
+
+void DomProperty::setElementSize(DomSize* a)
+{
+ clear(false);
+ m_kind = Size;
+ m_size = a;
+}
+
+DomString* DomProperty::takeElementString()
+{
+ DomString* a = m_string;
+ m_string = 0;
+ return a;
+}
+
+void DomProperty::setElementString(DomString* a)
+{
+ clear(false);
+ m_kind = String;
+ m_string = a;
+}
+
+DomStringList* DomProperty::takeElementStringList()
+{
+ DomStringList* a = m_stringList;
+ m_stringList = 0;
+ return a;
+}
+
+void DomProperty::setElementStringList(DomStringList* a)
+{
+ clear(false);
+ m_kind = StringList;
+ m_stringList = a;
+}
+
+void DomProperty::setElementNumber(int a)
+{
+ clear(false);
+ m_kind = Number;
+ m_number = a;
+}
+
+void DomProperty::setElementFloat(float a)
+{
+ clear(false);
+ m_kind = Float;
+ m_float = a;
+}
+
+void DomProperty::setElementDouble(double a)
+{
+ clear(false);
+ m_kind = Double;
+ m_double = a;
+}
+
+DomDate* DomProperty::takeElementDate()
+{
+ DomDate* a = m_date;
+ m_date = 0;
+ return a;
+}
+
+void DomProperty::setElementDate(DomDate* a)
+{
+ clear(false);
+ m_kind = Date;
+ m_date = a;
+}
+
+DomTime* DomProperty::takeElementTime()
+{
+ DomTime* a = m_time;
+ m_time = 0;
+ return a;
+}
+
+void DomProperty::setElementTime(DomTime* a)
+{
+ clear(false);
+ m_kind = Time;
+ m_time = a;
+}
+
+DomDateTime* DomProperty::takeElementDateTime()
+{
+ DomDateTime* a = m_dateTime;
+ m_dateTime = 0;
+ return a;
+}
+
+void DomProperty::setElementDateTime(DomDateTime* a)
+{
+ clear(false);
+ m_kind = DateTime;
+ m_dateTime = a;
+}
+
+DomPointF* DomProperty::takeElementPointF()
+{
+ DomPointF* a = m_pointF;
+ m_pointF = 0;
+ return a;
+}
+
+void DomProperty::setElementPointF(DomPointF* a)
+{
+ clear(false);
+ m_kind = PointF;
+ m_pointF = a;
+}
+
+DomRectF* DomProperty::takeElementRectF()
+{
+ DomRectF* a = m_rectF;
+ m_rectF = 0;
+ return a;
+}
+
+void DomProperty::setElementRectF(DomRectF* a)
+{
+ clear(false);
+ m_kind = RectF;
+ m_rectF = a;
+}
+
+DomSizeF* DomProperty::takeElementSizeF()
+{
+ DomSizeF* a = m_sizeF;
+ m_sizeF = 0;
+ return a;
+}
+
+void DomProperty::setElementSizeF(DomSizeF* a)
+{
+ clear(false);
+ m_kind = SizeF;
+ m_sizeF = a;
+}
+
+void DomProperty::setElementLongLong(qlonglong a)
+{
+ clear(false);
+ m_kind = LongLong;
+ m_longLong = a;
+}
+
+DomChar* DomProperty::takeElementChar()
+{
+ DomChar* a = m_char;
+ m_char = 0;
+ return a;
+}
+
+void DomProperty::setElementChar(DomChar* a)
+{
+ clear(false);
+ m_kind = Char;
+ m_char = a;
+}
+
+DomUrl* DomProperty::takeElementUrl()
+{
+ DomUrl* a = m_url;
+ m_url = 0;
+ return a;
+}
+
+void DomProperty::setElementUrl(DomUrl* a)
+{
+ clear(false);
+ m_kind = Url;
+ m_url = a;
+}
+
+void DomProperty::setElementUInt(uint a)
+{
+ clear(false);
+ m_kind = UInt;
+ m_UInt = a;
+}
+
+void DomProperty::setElementULongLong(qulonglong a)
+{
+ clear(false);
+ m_kind = ULongLong;
+ m_uLongLong = a;
+}
+
+DomBrush* DomProperty::takeElementBrush()
+{
+ DomBrush* a = m_brush;
+ m_brush = 0;
+ return a;
+}
+
+void DomProperty::setElementBrush(DomBrush* a)
+{
+ clear(false);
+ 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);
+ m_connection.clear();
+}
+
+void DomConnections::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("connection")) {
+ DomConnection *v = new DomConnection();
+ v->read(reader);
+ m_connection.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomConnections::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("connection")) {
+ DomConnection *v = new DomConnection();
+ v->read(e);
+ m_connection.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomConnections::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connections") : tagName.toLower());
+
+ for (int i = 0; i < m_connection.size(); ++i) {
+ DomConnection* v = m_connection[i];
+ v->write(writer, QLatin1String("connection"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomConnections::setElementConnection(const QList<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;
+}
+
+void DomConnection::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("sender")) {
+ setElementSender(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("signal")) {
+ setElementSignal(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("receiver")) {
+ setElementReceiver(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("slot")) {
+ setElementSlot(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("hints")) {
+ DomConnectionHints *v = new DomConnectionHints();
+ v->read(reader);
+ setElementHints(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomConnection::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("sender")) {
+ setElementSender(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("signal")) {
+ setElementSignal(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("receiver")) {
+ setElementReceiver(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("slot")) {
+ setElementSlot(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("hints")) {
+ DomConnectionHints *v = new DomConnectionHints();
+ v->read(e);
+ setElementHints(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomConnection::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connection") : tagName.toLower());
+
+ if (m_children & Sender) {
+ writer.writeTextElement(QLatin1String("sender"), m_sender);
+ }
+
+ if (m_children & Signal) {
+ writer.writeTextElement(QLatin1String("signal"), m_signal);
+ }
+
+ if (m_children & Receiver) {
+ writer.writeTextElement(QLatin1String("receiver"), m_receiver);
+ }
+
+ if (m_children & Slot) {
+ writer.writeTextElement(QLatin1String("slot"), m_slot);
+ }
+
+ if (m_children & Hints) {
+ m_hints->write(writer, QLatin1String("hints"));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomConnection::setElementSender(const QString& a)
+{
+ m_children |= Sender;
+ m_sender = a;
+}
+
+void DomConnection::setElementSignal(const QString& a)
+{
+ m_children |= Signal;
+ m_signal = a;
+}
+
+void DomConnection::setElementReceiver(const QString& a)
+{
+ m_children |= Receiver;
+ m_receiver = a;
+}
+
+void DomConnection::setElementSlot(const QString& a)
+{
+ m_children |= Slot;
+ m_slot = a;
+}
+
+DomConnectionHints* DomConnection::takeElementHints()
+{
+ DomConnectionHints* a = m_hints;
+ m_hints = 0;
+ m_children ^= Hints;
+ return a;
+}
+
+void DomConnection::setElementHints(DomConnectionHints* a)
+{
+ delete m_hints;
+ m_children |= Hints;
+ m_hints = a;
+}
+
+void DomConnection::clearElementSender()
+{
+ m_children &= ~Sender;
+}
+
+void DomConnection::clearElementSignal()
+{
+ m_children &= ~Signal;
+}
+
+void DomConnection::clearElementReceiver()
+{
+ m_children &= ~Receiver;
+}
+
+void DomConnection::clearElementSlot()
+{
+ m_children &= ~Slot;
+}
+
+void DomConnection::clearElementHints()
+{
+ delete m_hints;
+ m_hints = 0;
+ 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);
+ m_hint.clear();
+}
+
+void DomConnectionHints::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("hint")) {
+ DomConnectionHint *v = new DomConnectionHint();
+ v->read(reader);
+ m_hint.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomConnectionHints::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("hint")) {
+ DomConnectionHint *v = new DomConnectionHint();
+ v->read(e);
+ m_hint.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomConnectionHints::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connectionhints") : tagName.toLower());
+
+ for (int i = 0; i < m_hint.size(); ++i) {
+ DomConnectionHint* v = m_hint[i];
+ v->write(writer, QLatin1String("hint"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomConnectionHints::setElementHint(const QList<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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("type")) {
+ setAttributeType(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ for (bool finished = false; !finished && !reader.hasError();) {
+ switch (reader.readNext()) {
+ case QXmlStreamReader::StartElement : {
+ const QString tag = reader.name().toString().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(reader.readElementText().toInt());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomConnectionHint::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("type")))
+ setAttributeType(node.attribute(QLatin1String("type")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QString(QLatin1Char('x'))) {
+ setElementX(e.text().toInt());
+ continue;
+ }
+ if (tag == QString(QLatin1Char('y'))) {
+ setElementY(e.text().toInt());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomConnectionHint::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("connectionhint") : tagName.toLower());
+
+ if (hasAttributeType())
+ writer.writeAttribute(QLatin1String("type"), attributeType());
+
+ if (m_children & X) {
+ writer.writeTextElement(QString(QLatin1Char('x')), QString::number(m_x));
+ }
+
+ if (m_children & Y) {
+ writer.writeTextElement(QString(QLatin1Char('y')), QString::number(m_y));
+ }
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomConnectionHint::setElementX(int a)
+{
+ m_children |= X;
+ m_x = a;
+}
+
+void DomConnectionHint::setElementY(int a)
+{
+ m_children |= Y;
+ m_y = a;
+}
+
+void DomConnectionHint::clearElementX()
+{
+ m_children &= ~X;
+}
+
+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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.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.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomScript::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("source")))
+ setAttributeSource(node.attribute(QLatin1String("source")));
+ if (node.hasAttribute(QLatin1String("language")))
+ setAttributeLanguage(node.attribute(QLatin1String("language")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomScript::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("script") : tagName.toLower());
+
+ if (hasAttributeSource())
+ writer.writeAttribute(QLatin1String("source"), attributeSource());
+
+ if (hasAttributeLanguage())
+ writer.writeAttribute(QLatin1String("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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomWidgetData::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+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, QLatin1String("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);
+ m_property.clear();
+}
+
+void DomDesignerData::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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomDesignerData::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("property")) {
+ DomProperty *v = new DomProperty();
+ v->read(e);
+ m_property.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomDesignerData::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("designerdata") : tagName.toLower());
+
+ for (int i = 0; i < m_property.size(); ++i) {
+ DomProperty* v = m_property[i];
+ v->write(writer, QLatin1String("property"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+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();
+ m_slot.clear();
+}
+
+void DomSlots::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("signal")) {
+ m_signal.append(reader.readElementText());
+ continue;
+ }
+ if (tag == QLatin1String("slot")) {
+ m_slot.append(reader.readElementText());
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomSlots::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("signal")) {
+ m_signal.append(e.text());
+ continue;
+ }
+ if (tag == QLatin1String("slot")) {
+ m_slot.append(e.text());
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomSlots::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("slots") : tagName.toLower());
+
+ for (int i = 0; i < m_signal.size(); ++i) {
+ QString v = m_signal[i];
+ writer.writeTextElement(QLatin1String("signal"), v);
+ }
+ for (int i = 0; i < m_slot.size(); ++i) {
+ QString v = m_slot[i];
+ writer.writeTextElement(QLatin1String("slot"), v);
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomSlots::setElementSignal(const QStringList& a)
+{
+ m_children |= Signal;
+ m_signal = a;
+}
+
+void DomSlots::setElementSlot(const QStringList& a)
+{
+ m_children |= Slot;
+ m_slot = a;
+}
+
+void DomPropertySpecifications::clear(bool clear_all)
+{
+ qDeleteAll(m_stringpropertyspecification);
+ m_stringpropertyspecification.clear();
+
+ if (clear_all) {
+ m_text.clear();
+ }
+
+ m_children = 0;
+}
+
+DomPropertySpecifications::DomPropertySpecifications()
+{
+ m_children = 0;
+}
+
+DomPropertySpecifications::~DomPropertySpecifications()
+{
+ qDeleteAll(m_stringpropertyspecification);
+ m_stringpropertyspecification.clear();
+}
+
+void DomPropertySpecifications::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("stringpropertyspecification")) {
+ DomStringPropertySpecification *v = new DomStringPropertySpecification();
+ v->read(reader);
+ m_stringpropertyspecification.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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomPropertySpecifications::read(const QDomElement &node)
+{
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ if (tag == QLatin1String("stringpropertyspecification")) {
+ DomStringPropertySpecification *v = new DomStringPropertySpecification();
+ v->read(e);
+ m_stringpropertyspecification.append(v);
+ continue;
+ }
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomPropertySpecifications::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("propertyspecifications") : tagName.toLower());
+
+ for (int i = 0; i < m_stringpropertyspecification.size(); ++i) {
+ DomStringPropertySpecification* v = m_stringpropertyspecification[i];
+ v->write(writer, QLatin1String("stringpropertyspecification"));
+ }
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+void DomPropertySpecifications::setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a)
+{
+ m_children |= Stringpropertyspecification;
+ m_stringpropertyspecification = a;
+}
+
+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)
+{
+
+ foreach (const QXmlStreamAttribute &attribute, reader.attributes()) {
+ QStringRef name = attribute.name();
+ if (name == QLatin1String("name")) {
+ setAttributeName(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("type")) {
+ setAttributeType(attribute.value().toString());
+ continue;
+ }
+ if (name == QLatin1String("notr")) {
+ setAttributeNotr(attribute.value().toString());
+ continue;
+ }
+ reader.raiseError(QLatin1String("Unexpected attribute ") + name.toString());
+ }
+
+ 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;
+ }
+ }
+}
+
+#ifdef QUILOADER_QDOM_READ
+void DomStringPropertySpecification::read(const QDomElement &node)
+{
+ if (node.hasAttribute(QLatin1String("name")))
+ setAttributeName(node.attribute(QLatin1String("name")));
+ if (node.hasAttribute(QLatin1String("type")))
+ setAttributeType(node.attribute(QLatin1String("type")));
+ if (node.hasAttribute(QLatin1String("notr")))
+ setAttributeNotr(node.attribute(QLatin1String("notr")));
+
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ if (!n.isElement())
+ continue;
+ QDomElement e = n.toElement();
+ QString tag = e.tagName().toLower();
+ }
+ m_text.clear();
+ for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling()) {
+ if (child.isText())
+ m_text.append(child.nodeValue());
+ }
+}
+#endif
+
+void DomStringPropertySpecification::write(QXmlStreamWriter &writer, const QString &tagName) const
+{
+ writer.writeStartElement(tagName.isEmpty() ? QString::fromUtf8("stringpropertyspecification") : tagName.toLower());
+
+ if (hasAttributeName())
+ writer.writeAttribute(QLatin1String("name"), attributeName());
+
+ if (hasAttributeType())
+ writer.writeAttribute(QLatin1String("type"), attributeType());
+
+ if (hasAttributeNotr())
+ writer.writeAttribute(QLatin1String("notr"), attributeNotr());
+
+ if (!m_text.isEmpty())
+ writer.writeCharacters(m_text);
+
+ writer.writeEndElement();
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h
new file mode 100644
index 0000000000..6caf515893
--- /dev/null
+++ b/src/tools/uic/ui4.h
@@ -0,0 +1,3807 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of Qt Designer. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+// THIS FILE IS AUTOMATICALLY GENERATED
+
+#ifndef UI4_H
+#define UI4_H
+
+#include <QtCore/QList>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QXmlStreamReader>
+#include <QtCore/QXmlStreamWriter>
+#include <QtCore/qglobal.h>
+
+#if defined(QT_UIC3)
+ #define QUILOADER_QDOM_READ
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QUILOADER_QDOM_READ
+ class QDomElement;
+#endif
+
+
+#define QDESIGNER_UILIB_EXTERN Q_DECL_EXPORT
+#define QDESIGNER_UILIB_IMPORT Q_DECL_IMPORT
+
+#if defined(QT_DESIGNER_STATIC) || defined(QT_UIC) || defined(QT_UIC3)
+# define QDESIGNER_UILIB_EXPORT
+#elif defined(QDESIGNER_UILIB_LIBRARY)
+# define QDESIGNER_UILIB_EXPORT QDESIGNER_UILIB_EXTERN
+#else
+# define QDESIGNER_UILIB_EXPORT QDESIGNER_UILIB_IMPORT
+#endif
+
+#ifndef QDESIGNER_UILIB_EXPORT
+# define QDESIGNER_UILIB_EXPORT
+#endif
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+
+/*******************************************************************************
+** Forward declarations
+*/
+
+class DomUI;
+class DomIncludes;
+class DomInclude;
+class DomResources;
+class DomResource;
+class DomActionGroup;
+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;
+class DomLayout;
+class DomLayoutItem;
+class DomRow;
+class DomColumn;
+class DomItem;
+class DomWidget;
+class DomSpacer;
+class DomColor;
+class DomGradientStop;
+class DomGradient;
+class DomBrush;
+class DomColorRole;
+class DomColorGroup;
+class DomPalette;
+class DomFont;
+class DomPoint;
+class DomRect;
+class DomLocale;
+class DomSizePolicy;
+class DomSize;
+class DomDate;
+class DomTime;
+class DomDateTime;
+class DomStringList;
+class DomResourcePixmap;
+class DomResourceIcon;
+class DomString;
+class DomPointF;
+class DomRectF;
+class DomSizeF;
+class DomChar;
+class DomUrl;
+class DomProperty;
+class DomConnections;
+class DomConnection;
+class DomConnectionHints;
+class DomConnectionHint;
+class DomScript;
+class DomWidgetData;
+class DomDesignerData;
+class DomSlots;
+class DomPropertySpecifications;
+class DomStringPropertySpecification;
+
+/*******************************************************************************
+** Declarations
+*/
+
+class QDESIGNER_UILIB_EXPORT DomUI {
+public:
+ DomUI();
+ ~DomUI();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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 clearAttributeDisplayname() { m_has_attr_displayname = false; }
+
+ inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; }
+ inline int attributeStdsetdef() const { return m_attr_stdsetdef; }
+ inline void setAttributeStdsetdef(int a) { m_attr_stdsetdef = a; m_has_attr_stdsetdef = true; }
+ inline void clearAttributeStdsetdef() { m_has_attr_stdsetdef = false; }
+
+ inline bool hasAttributeStdSetDef() const { return m_has_attr_stdSetDef; }
+ inline int attributeStdSetDef() const { return m_attr_stdSetDef; }
+ inline void setAttributeStdSetDef(int a) { m_attr_stdSetDef = a; m_has_attr_stdSetDef = true; }
+ inline void clearAttributeStdSetDef() { m_has_attr_stdSetDef = false; }
+
+ // child element accessors
+ inline QString elementAuthor() const { return m_author; }
+ 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);
+ inline bool hasElementComment() const { return m_children & Comment; }
+ void clearElementComment();
+
+ inline QString elementExportMacro() const { return m_exportMacro; }
+ 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);
+ inline bool hasElementClass() const { return m_children & Class; }
+ void clearElementClass();
+
+ 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 bool hasElementLayoutDefault() const { return m_children & LayoutDefault; }
+ void clearElementLayoutDefault();
+
+ 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);
+ inline bool hasElementPixmapFunction() const { return m_children & PixmapFunction; }
+ void clearElementPixmapFunction();
+
+ 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 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 bool hasElementIncludes() const { return m_children & Includes; }
+ void clearElementIncludes();
+
+ 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 bool hasElementConnections() const { return m_children & Connections; }
+ void clearElementConnections();
+
+ 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 bool hasElementSlots() const { return m_children & Slots; }
+ void clearElementSlots();
+
+ 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;
+
+ QString m_attr_language;
+ bool m_has_attr_language;
+
+ QString m_attr_displayname;
+ bool m_has_attr_displayname;
+
+ int m_attr_stdsetdef;
+ bool m_has_attr_stdsetdef;
+
+ int m_attr_stdSetDef;
+ bool m_has_attr_stdSetDef;
+
+ // child element data
+ uint m_children;
+ QString m_author;
+ QString m_comment;
+ QString m_exportMacro;
+ QString m_class;
+ DomWidget* m_widget;
+ DomLayoutDefault* m_layoutDefault;
+ DomLayoutFunction* m_layoutFunction;
+ 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;
+ enum Child {
+ Author = 1,
+ Comment = 2,
+ ExportMacro = 4,
+ Class = 8,
+ Widget = 16,
+ LayoutDefault = 32,
+ LayoutFunction = 64,
+ PixmapFunction = 128,
+ CustomWidgets = 256,
+ TabStops = 512,
+ Images = 1024,
+ Includes = 2048,
+ Resources = 4096,
+ Connections = 8192,
+ Designerdata = 16384,
+ Slots = 32768,
+ ButtonGroups = 65536
+ };
+
+ DomUI(const DomUI &other);
+ void operator = (const DomUI&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomIncludes {
+public:
+ DomIncludes();
+ ~DomIncludes();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomInclude*> m_include;
+ enum Child {
+ Include = 1
+ };
+
+ DomIncludes(const DomIncludes &other);
+ void operator = (const DomIncludes&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomInclude {
+public:
+ DomInclude();
+ ~DomInclude();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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;
+
+ QString m_attr_impldecl;
+ bool m_has_attr_impldecl;
+
+ // child element data
+ uint m_children;
+
+ DomInclude(const DomInclude &other);
+ void operator = (const DomInclude&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomResources {
+public:
+ DomResources();
+ ~DomResources();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 QList<DomResource*> elementInclude() const { return m_include; }
+ void setElementInclude(const QList<DomResource*>& a);
+
+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;
+ QList<DomResource*> m_include;
+ enum Child {
+ Include = 1
+ };
+
+ DomResources(const DomResources &other);
+ void operator = (const DomResources&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomResource {
+public:
+ DomResource();
+ ~DomResource();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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);
+};
+
+class QDESIGNER_UILIB_EXPORT DomActionGroup {
+public:
+ DomActionGroup();
+ ~DomActionGroup();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 QList<DomAction*> elementAction() const { return m_action; }
+ void setElementAction(const QList<DomAction*>& a);
+
+ inline QList<DomActionGroup*> elementActionGroup() const { return m_actionGroup; }
+ void setElementActionGroup(const QList<DomActionGroup*>& a);
+
+ inline QList<DomProperty*> elementProperty() const { return m_property; }
+ void setElementProperty(const QList<DomProperty*>& a);
+
+ inline QList<DomProperty*> elementAttribute() const { return m_attribute; }
+ 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;
+
+ // child element data
+ uint m_children;
+ QList<DomAction*> m_action;
+ QList<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 {
+public:
+ DomAction();
+ ~DomAction();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+
+ 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 clearAttributeMenu() { m_has_attr_menu = false; }
+
+ // child element accessors
+ inline QList<DomProperty*> elementProperty() const { return m_property; }
+ void setElementProperty(const QList<DomProperty*>& a);
+
+ inline QList<DomProperty*> elementAttribute() const { return m_attribute; }
+ 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;
+
+ QString m_attr_menu;
+ bool m_has_attr_menu;
+
+ // child element data
+ uint m_children;
+ 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 {
+public:
+ DomActionRef();
+ ~DomActionRef();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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
+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);
+};
+
+class QDESIGNER_UILIB_EXPORT DomButtonGroup {
+public:
+ DomButtonGroup();
+ ~DomButtonGroup();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 QList<DomProperty*> elementProperty() const { return m_property; }
+ void setElementProperty(const QList<DomProperty*>& a);
+
+ inline QList<DomProperty*> elementAttribute() const { return m_attribute; }
+ 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;
+
+ // child element data
+ uint m_children;
+ 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 {
+public:
+ DomButtonGroups();
+ ~DomButtonGroups();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ void write(QXmlStreamWriter &writer, const QString &tagName = QString()) const;
+ inline QString text() const { return m_text; }
+ inline void setText(const QString &s) { m_text = s; }
+
+ // attribute accessors
+ inline bool hasAttributeName() const { return m_has_attr_name; }
+ inline QString attributeName() const { return m_attr_name; }
+ inline void setAttributeName(const QString& a) { m_attr_name = a; m_has_attr_name = true; }
+ inline void clearAttributeName() { m_has_attr_name = false; }
+
+ // child element accessors
+ inline DomImageData* elementData() const { return m_data; }
+ DomImageData* takeElementData();
+ void setElementData(DomImageData* a);
+ inline bool hasElementData() const { return m_children & Data; }
+ void clearElementData();
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ // child element data
+ uint m_children;
+ DomImageData* m_data;
+ enum Child {
+ Data = 1
+ };
+
+ DomImage(const DomImage &other);
+ void operator = (const DomImage&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomImageData {
+public:
+ DomImageData();
+ ~DomImageData();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 {
+public:
+ DomCustomWidgets();
+ ~DomCustomWidgets();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomCustomWidget*> m_customWidget;
+ enum Child {
+ CustomWidget = 1
+ };
+
+ DomCustomWidgets(const DomCustomWidgets &other);
+ void operator = (const DomCustomWidgets&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomHeader {
+public:
+ DomHeader();
+ ~DomHeader();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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);
+};
+
+class QDESIGNER_UILIB_EXPORT DomCustomWidget {
+public:
+ DomCustomWidget();
+ ~DomCustomWidget();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementClass() const { return m_children & Class; }
+ void clearElementClass();
+
+ inline QString elementExtends() const { return m_extends; }
+ 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 bool hasElementHeader() const { return m_children & Header; }
+ void clearElementHeader();
+
+ 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);
+ inline bool hasElementAddPageMethod() const { return m_children & AddPageMethod; }
+ void clearElementAddPageMethod();
+
+ inline int elementContainer() const { return m_container; }
+ void setElementContainer(int a);
+ 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);
+ 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 bool hasElementSlots() const { return m_children & Slots; }
+ void clearElementSlots();
+
+ 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;
+ QString m_class;
+ QString m_extends;
+ DomHeader* m_header;
+ DomSize* m_sizeHint;
+ QString m_addPageMethod;
+ int m_container;
+ DomSizePolicyData* m_sizePolicy;
+ QString m_pixmap;
+ DomScript* m_script;
+ DomProperties* m_properties;
+ DomSlots* m_slots;
+ DomPropertySpecifications* m_propertyspecifications;
+ enum Child {
+ Class = 1,
+ Extends = 2,
+ Header = 4,
+ 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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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
+ };
+
+ DomSizePolicyData(const DomSizePolicyData &other);
+ void operator = (const DomSizePolicyData&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomLayoutDefault {
+public:
+ DomLayoutDefault();
+ ~DomLayoutDefault();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 int attributeSpacing() const { return m_attr_spacing; }
+ inline void setAttributeSpacing(int 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 int attributeMargin() const { return m_attr_margin; }
+ 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;
+
+ // child element data
+ uint m_children;
+
+ DomLayoutDefault(const DomLayoutDefault &other);
+ void operator = (const DomLayoutDefault&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomLayoutFunction {
+public:
+ DomLayoutFunction();
+ ~DomLayoutFunction();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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;
+
+ QString m_attr_margin;
+ bool m_has_attr_margin;
+
+ // child element data
+ uint m_children;
+
+ DomLayoutFunction(const DomLayoutFunction &other);
+ void operator = (const DomLayoutFunction&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomTabStops {
+public:
+ DomTabStops();
+ ~DomTabStops();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QStringList m_tabStop;
+ enum Child {
+ TabStop = 1
+ };
+
+ DomTabStops(const DomTabStops &other);
+ void operator = (const DomTabStops&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomLayout {
+public:
+ DomLayout();
+ ~DomLayout();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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 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 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 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 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 clearAttributeColumnMinimumWidth() { m_has_attr_columnMinimumWidth = false; }
+
+ // child element accessors
+ inline QList<DomProperty*> elementProperty() const { return m_property; }
+ void setElementProperty(const QList<DomProperty*>& a);
+
+ inline QList<DomProperty*> elementAttribute() const { return m_attribute; }
+ void setElementAttribute(const QList<DomProperty*>& a);
+
+ inline QList<DomLayoutItem*> elementItem() const { return m_item; }
+ void setElementItem(const QList<DomLayoutItem*>& a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_class;
+ bool m_has_attr_class;
+
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ QString m_attr_stretch;
+ bool m_has_attr_stretch;
+
+ QString m_attr_rowStretch;
+ bool m_has_attr_rowStretch;
+
+ QString m_attr_columnStretch;
+ bool m_has_attr_columnStretch;
+
+ QString m_attr_rowMinimumHeight;
+ bool m_has_attr_rowMinimumHeight;
+
+ QString m_attr_columnMinimumWidth;
+ bool m_has_attr_columnMinimumWidth;
+
+ // child element data
+ uint m_children;
+ QList<DomProperty*> m_property;
+ QList<DomProperty*> m_attribute;
+ QList<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 {
+public:
+ DomLayoutItem();
+ ~DomLayoutItem();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+ inline int attributeRow() const { return m_attr_row; }
+ inline void setAttributeRow(int a) { m_attr_row = a; m_has_attr_row = true; }
+ inline void clearAttributeRow() { m_has_attr_row = false; }
+
+ inline bool hasAttributeColumn() const { return m_has_attr_column; }
+ inline int attributeColumn() const { return m_attr_column; }
+ inline void setAttributeColumn(int a) { m_attr_column = a; m_has_attr_column = true; }
+ inline void clearAttributeColumn() { m_has_attr_column = false; }
+
+ inline bool hasAttributeRowSpan() const { return m_has_attr_rowSpan; }
+ inline int attributeRowSpan() const { return m_attr_rowSpan; }
+ inline void setAttributeRowSpan(int a) { m_attr_rowSpan = a; m_has_attr_rowSpan = true; }
+ inline void clearAttributeRowSpan() { m_has_attr_rowSpan = false; }
+
+ inline bool hasAttributeColSpan() const { return m_has_attr_colSpan; }
+ inline int attributeColSpan() const { return m_attr_colSpan; }
+ inline void setAttributeColSpan(int a) { m_attr_colSpan = a; m_has_attr_colSpan = true; }
+ inline void clearAttributeColSpan() { m_has_attr_colSpan = false; }
+
+ 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 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 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ int m_attr_row;
+ bool m_has_attr_row;
+
+ int m_attr_column;
+ bool m_has_attr_column;
+
+ int m_attr_rowSpan;
+ bool m_has_attr_rowSpan;
+
+ int m_attr_colSpan;
+ bool m_has_attr_colSpan;
+
+ QString m_attr_alignment;
+ bool m_has_attr_alignment;
+
+ // child element data
+ Kind m_kind;
+ DomWidget* m_widget;
+ DomLayout* m_layout;
+ DomSpacer* m_spacer;
+
+ DomLayoutItem(const DomLayoutItem &other);
+ void operator = (const DomLayoutItem&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomRow {
+public:
+ DomRow();
+ ~DomRow();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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
+ };
+
+ DomRow(const DomRow &other);
+ void operator = (const DomRow&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomColumn {
+public:
+ DomColumn();
+ ~DomColumn();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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
+ };
+
+ DomColumn(const DomColumn &other);
+ void operator = (const DomColumn&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomItem {
+public:
+ DomItem();
+ ~DomItem();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+ inline int attributeRow() const { return m_attr_row; }
+ inline void setAttributeRow(int a) { m_attr_row = a; m_has_attr_row = true; }
+ inline void clearAttributeRow() { m_has_attr_row = false; }
+
+ inline bool hasAttributeColumn() const { return m_has_attr_column; }
+ inline int attributeColumn() const { return m_attr_column; }
+ inline void setAttributeColumn(int a) { m_attr_column = a; m_has_attr_column = true; }
+ inline void clearAttributeColumn() { m_has_attr_column = false; }
+
+ // child element accessors
+ inline QList<DomProperty*> elementProperty() const { return m_property; }
+ void setElementProperty(const QList<DomProperty*>& a);
+
+ inline QList<DomItem*> elementItem() const { return m_item; }
+ void setElementItem(const QList<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_column;
+ bool m_has_attr_column;
+
+ // child element data
+ uint m_children;
+ QList<DomProperty*> m_property;
+ QList<DomItem*> m_item;
+ enum Child {
+ Property = 1,
+ Item = 2
+ };
+
+ DomItem(const DomItem &other);
+ void operator = (const DomItem&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomWidget {
+public:
+ DomWidget();
+ ~DomWidget();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 clearAttributeName() { m_has_attr_name = false; }
+
+ inline bool hasAttributeNative() const { return m_has_attr_native; }
+ inline bool attributeNative() const { return m_attr_native; }
+ inline void setAttributeNative(bool a) { m_attr_native = a; m_has_attr_native = true; }
+ inline void clearAttributeNative() { m_has_attr_native = false; }
+
+ // child element accessors
+ inline QStringList elementClass() const { return m_class; }
+ 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);
+
+ inline QList<DomProperty*> elementAttribute() const { return m_attribute; }
+ void setElementAttribute(const QList<DomProperty*>& a);
+
+ inline QList<DomRow*> elementRow() const { return m_row; }
+ void setElementRow(const QList<DomRow*>& a);
+
+ inline QList<DomColumn*> elementColumn() const { return m_column; }
+ void setElementColumn(const QList<DomColumn*>& a);
+
+ inline QList<DomItem*> elementItem() const { return m_item; }
+ void setElementItem(const QList<DomItem*>& a);
+
+ inline QList<DomLayout*> elementLayout() const { return m_layout; }
+ void setElementLayout(const QList<DomLayout*>& a);
+
+ inline QList<DomWidget*> elementWidget() const { return m_widget; }
+ void setElementWidget(const QList<DomWidget*>& a);
+
+ inline QList<DomAction*> elementAction() const { return m_action; }
+ void setElementAction(const QList<DomAction*>& a);
+
+ inline QList<DomActionGroup*> elementActionGroup() const { return m_actionGroup; }
+ void setElementActionGroup(const QList<DomActionGroup*>& a);
+
+ inline QList<DomActionRef*> elementAddAction() const { return m_addAction; }
+ void setElementAddAction(const QList<DomActionRef*>& a);
+
+ inline QStringList elementZOrder() const { return m_zOrder; }
+ 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;
+
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ bool m_attr_native;
+ bool m_has_attr_native;
+
+ // child element data
+ uint m_children;
+ 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;
+ 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
+ };
+
+ DomWidget(const DomWidget &other);
+ void operator = (const DomWidget&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomSpacer {
+public:
+ DomSpacer();
+ ~DomSpacer();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ // child element data
+ uint m_children;
+ QList<DomProperty*> m_property;
+ enum Child {
+ Property = 1
+ };
+
+ DomSpacer(const DomSpacer &other);
+ void operator = (const DomSpacer&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomColor {
+public:
+ DomColor();
+ ~DomColor();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+ inline int attributeAlpha() const { return m_attr_alpha; }
+ inline void setAttributeAlpha(int a) { m_attr_alpha = a; m_has_attr_alpha = true; }
+ inline void clearAttributeAlpha() { m_has_attr_alpha = false; }
+
+ // child element accessors
+ inline int elementRed() const { return m_red; }
+ void setElementRed(int a);
+ inline bool hasElementRed() const { return m_children & Red; }
+ void clearElementRed();
+
+ inline int elementGreen() const { return m_green; }
+ void setElementGreen(int a);
+ inline bool hasElementGreen() const { return m_children & Green; }
+ void clearElementGreen();
+
+ inline int elementBlue() const { return m_blue; }
+ void setElementBlue(int a);
+ inline bool hasElementBlue() const { return m_children & Blue; }
+ void clearElementBlue();
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ int m_attr_alpha;
+ bool m_has_attr_alpha;
+
+ // child element data
+ uint m_children;
+ int m_red;
+ int m_green;
+ int m_blue;
+ enum Child {
+ Red = 1,
+ Green = 2,
+ Blue = 4
+ };
+
+ DomColor(const DomColor &other);
+ void operator = (const DomColor&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomGradientStop {
+public:
+ DomGradientStop();
+ ~DomGradientStop();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+ inline double attributePosition() const { return m_attr_position; }
+ inline void setAttributePosition(double a) { m_attr_position = a; m_has_attr_position = true; }
+ 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 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;
+
+ // child element data
+ uint m_children;
+ DomColor* m_color;
+ enum Child {
+ Color = 1
+ };
+
+ DomGradientStop(const DomGradientStop &other);
+ void operator = (const DomGradientStop&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomGradient {
+public:
+ DomGradient();
+ ~DomGradient();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+ inline double attributeStartX() const { return m_attr_startX; }
+ inline void setAttributeStartX(double a) { m_attr_startX = a; m_has_attr_startX = true; }
+ inline void clearAttributeStartX() { m_has_attr_startX = false; }
+
+ inline bool hasAttributeStartY() const { return m_has_attr_startY; }
+ inline double attributeStartY() const { return m_attr_startY; }
+ inline void setAttributeStartY(double a) { m_attr_startY = a; m_has_attr_startY = true; }
+ inline void clearAttributeStartY() { m_has_attr_startY = false; }
+
+ inline bool hasAttributeEndX() const { return m_has_attr_endX; }
+ inline double attributeEndX() const { return m_attr_endX; }
+ inline void setAttributeEndX(double a) { m_attr_endX = a; m_has_attr_endX = true; }
+ inline void clearAttributeEndX() { m_has_attr_endX = false; }
+
+ inline bool hasAttributeEndY() const { return m_has_attr_endY; }
+ inline double attributeEndY() const { return m_attr_endY; }
+ inline void setAttributeEndY(double a) { m_attr_endY = a; m_has_attr_endY = true; }
+ inline void clearAttributeEndY() { m_has_attr_endY = false; }
+
+ inline bool hasAttributeCentralX() const { return m_has_attr_centralX; }
+ inline double attributeCentralX() const { return m_attr_centralX; }
+ inline void setAttributeCentralX(double a) { m_attr_centralX = a; m_has_attr_centralX = true; }
+ inline void clearAttributeCentralX() { m_has_attr_centralX = false; }
+
+ inline bool hasAttributeCentralY() const { return m_has_attr_centralY; }
+ inline double attributeCentralY() const { return m_attr_centralY; }
+ inline void setAttributeCentralY(double a) { m_attr_centralY = a; m_has_attr_centralY = true; }
+ inline void clearAttributeCentralY() { m_has_attr_centralY = false; }
+
+ inline bool hasAttributeFocalX() const { return m_has_attr_focalX; }
+ inline double attributeFocalX() const { return m_attr_focalX; }
+ inline void setAttributeFocalX(double a) { m_attr_focalX = a; m_has_attr_focalX = true; }
+ inline void clearAttributeFocalX() { m_has_attr_focalX = false; }
+
+ inline bool hasAttributeFocalY() const { return m_has_attr_focalY; }
+ inline double attributeFocalY() const { return m_attr_focalY; }
+ inline void setAttributeFocalY(double a) { m_attr_focalY = a; m_has_attr_focalY = true; }
+ inline void clearAttributeFocalY() { m_has_attr_focalY = false; }
+
+ inline bool hasAttributeRadius() const { return m_has_attr_radius; }
+ inline double attributeRadius() const { return m_attr_radius; }
+ inline void setAttributeRadius(double a) { m_attr_radius = a; m_has_attr_radius = true; }
+ inline void clearAttributeRadius() { m_has_attr_radius = false; }
+
+ inline bool hasAttributeAngle() const { return m_has_attr_angle; }
+ inline double attributeAngle() const { return m_attr_angle; }
+ inline void setAttributeAngle(double a) { m_attr_angle = a; m_has_attr_angle = true; }
+ inline void clearAttributeAngle() { m_has_attr_angle = 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 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 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 clearAttributeCoordinateMode() { m_has_attr_coordinateMode = false; }
+
+ // child element accessors
+ inline QList<DomGradientStop*> elementGradientStop() const { return m_gradientStop; }
+ void setElementGradientStop(const QList<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_startY;
+ bool m_has_attr_startY;
+
+ double m_attr_endX;
+ bool m_has_attr_endX;
+
+ double m_attr_endY;
+ bool m_has_attr_endY;
+
+ double m_attr_centralX;
+ bool m_has_attr_centralX;
+
+ double m_attr_centralY;
+ bool m_has_attr_centralY;
+
+ double m_attr_focalX;
+ bool m_has_attr_focalX;
+
+ double m_attr_focalY;
+ bool m_has_attr_focalY;
+
+ double m_attr_radius;
+ bool m_has_attr_radius;
+
+ double m_attr_angle;
+ bool m_has_attr_angle;
+
+ QString m_attr_type;
+ bool m_has_attr_type;
+
+ QString m_attr_spread;
+ bool m_has_attr_spread;
+
+ QString m_attr_coordinateMode;
+ bool m_has_attr_coordinateMode;
+
+ // child element data
+ uint m_children;
+ QList<DomGradientStop*> m_gradientStop;
+ enum Child {
+ GradientStop = 1
+ };
+
+ DomGradient(const DomGradient &other);
+ void operator = (const DomGradient&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomBrush {
+public:
+ DomBrush();
+ ~DomBrush();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_brushStyle;
+ bool m_has_attr_brushStyle;
+
+ // child element data
+ Kind m_kind;
+ DomColor* m_color;
+ DomProperty* m_texture;
+ DomGradient* m_gradient;
+
+ DomBrush(const DomBrush &other);
+ void operator = (const DomBrush&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomColorRole {
+public:
+ DomColorRole();
+ ~DomColorRole();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 clearAttributeRole() { m_has_attr_role = false; }
+
+ // child element accessors
+ 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;
+
+ // child element data
+ uint m_children;
+ DomBrush* m_brush;
+ enum Child {
+ Brush = 1
+ };
+
+ DomColorRole(const DomColorRole &other);
+ void operator = (const DomColorRole&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomColorGroup {
+public:
+ DomColorGroup();
+ ~DomColorGroup();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 QList<DomColor*> elementColor() const { return m_color; }
+ void setElementColor(const QList<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;
+ enum Child {
+ ColorRole = 1,
+ Color = 2
+ };
+
+ DomColorGroup(const DomColorGroup &other);
+ void operator = (const DomColorGroup&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomPalette {
+public:
+ DomPalette();
+ ~DomPalette();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 bool hasElementActive() const { return m_children & Active; }
+ void clearElementActive();
+
+ 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 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;
+ enum Child {
+ Active = 1,
+ Inactive = 2,
+ Disabled = 4
+ };
+
+ DomPalette(const DomPalette &other);
+ void operator = (const DomPalette&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomFont {
+public:
+ DomFont();
+ ~DomFont();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementFamily() const { return m_children & Family; }
+ void clearElementFamily();
+
+ inline int elementPointSize() const { return m_pointSize; }
+ void setElementPointSize(int a);
+ inline bool hasElementPointSize() const { return m_children & PointSize; }
+ void clearElementPointSize();
+
+ inline int elementWeight() const { return m_weight; }
+ void setElementWeight(int a);
+ inline bool hasElementWeight() const { return m_children & Weight; }
+ void clearElementWeight();
+
+ inline bool elementItalic() const { return m_italic; }
+ void setElementItalic(bool a);
+ inline bool hasElementItalic() const { return m_children & Italic; }
+ void clearElementItalic();
+
+ inline bool elementBold() const { return m_bold; }
+ void setElementBold(bool a);
+ inline bool hasElementBold() const { return m_children & Bold; }
+ void clearElementBold();
+
+ inline bool elementUnderline() const { return m_underline; }
+ void setElementUnderline(bool a);
+ inline bool hasElementUnderline() const { return m_children & Underline; }
+ void clearElementUnderline();
+
+ inline bool elementStrikeOut() const { return m_strikeOut; }
+ void setElementStrikeOut(bool a);
+ inline bool hasElementStrikeOut() const { return m_children & StrikeOut; }
+ void clearElementStrikeOut();
+
+ inline bool elementAntialiasing() const { return m_antialiasing; }
+ void setElementAntialiasing(bool a);
+ inline bool hasElementAntialiasing() const { return m_children & Antialiasing; }
+ void clearElementAntialiasing();
+
+ inline QString elementStyleStrategy() const { return m_styleStrategy; }
+ void setElementStyleStrategy(const QString& a);
+ inline bool hasElementStyleStrategy() const { return m_children & StyleStrategy; }
+ void clearElementStyleStrategy();
+
+ inline bool elementKerning() const { return m_kerning; }
+ void setElementKerning(bool a);
+ inline bool hasElementKerning() const { return m_children & Kerning; }
+ void clearElementKerning();
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QString m_family;
+ int m_pointSize;
+ int m_weight;
+ bool m_italic;
+ bool m_bold;
+ bool m_underline;
+ bool m_strikeOut;
+ bool m_antialiasing;
+ QString m_styleStrategy;
+ bool m_kerning;
+ enum Child {
+ Family = 1,
+ PointSize = 2,
+ Weight = 4,
+ Italic = 8,
+ Bold = 16,
+ Underline = 32,
+ StrikeOut = 64,
+ Antialiasing = 128,
+ StyleStrategy = 256,
+ Kerning = 512
+ };
+
+ DomFont(const DomFont &other);
+ void operator = (const DomFont&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomPoint {
+public:
+ DomPoint();
+ ~DomPoint();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementX() const { return m_children & X; }
+ void clearElementX();
+
+ inline int elementY() const { return m_y; }
+ void setElementY(int a);
+ inline bool hasElementY() const { return m_children & Y; }
+ 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;
+ enum Child {
+ X = 1,
+ Y = 2
+ };
+
+ DomPoint(const DomPoint &other);
+ void operator = (const DomPoint&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomRect {
+public:
+ DomRect();
+ ~DomRect();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementX() const { return m_children & X; }
+ void clearElementX();
+
+ inline int elementY() const { return m_y; }
+ void setElementY(int a);
+ inline bool hasElementY() const { return m_children & Y; }
+ void clearElementY();
+
+ inline int elementWidth() const { return m_width; }
+ void setElementWidth(int a);
+ inline bool hasElementWidth() const { return m_children & Width; }
+ void clearElementWidth();
+
+ inline int elementHeight() const { return m_height; }
+ void setElementHeight(int a);
+ inline bool hasElementHeight() const { return m_children & Height; }
+ 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;
+ enum Child {
+ X = 1,
+ Y = 2,
+ Width = 4,
+ Height = 8
+ };
+
+ DomRect(const DomRect &other);
+ void operator = (const DomRect&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomLocale {
+public:
+ DomLocale();
+ ~DomLocale();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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;
+
+ QString m_attr_country;
+ bool m_has_attr_country;
+
+ // child element data
+ uint m_children;
+
+ DomLocale(const DomLocale &other);
+ void operator = (const DomLocale&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomSizePolicy {
+public:
+ DomSizePolicy();
+ ~DomSizePolicy();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 clearAttributeVSizeType() { m_has_attr_vSizeType = false; }
+
+ // child element accessors
+ inline int elementHSizeType() const { return m_hSizeType; }
+ void setElementHSizeType(int a);
+ inline bool hasElementHSizeType() const { return m_children & HSizeType; }
+ void clearElementHSizeType();
+
+ inline int elementVSizeType() const { return m_vSizeType; }
+ void setElementVSizeType(int a);
+ inline bool hasElementVSizeType() const { return m_children & VSizeType; }
+ void clearElementVSizeType();
+
+ inline int elementHorStretch() const { return m_horStretch; }
+ void setElementHorStretch(int a);
+ inline bool hasElementHorStretch() const { return m_children & HorStretch; }
+ void clearElementHorStretch();
+
+ inline int elementVerStretch() const { return m_verStretch; }
+ void setElementVerStretch(int a);
+ inline bool hasElementVerStretch() const { return m_children & VerStretch; }
+ void clearElementVerStretch();
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_hSizeType;
+ bool m_has_attr_hSizeType;
+
+ QString m_attr_vSizeType;
+ bool m_has_attr_vSizeType;
+
+ // child element data
+ uint m_children;
+ int m_hSizeType;
+ int m_vSizeType;
+ int m_horStretch;
+ int m_verStretch;
+ enum Child {
+ HSizeType = 1,
+ VSizeType = 2,
+ HorStretch = 4,
+ VerStretch = 8
+ };
+
+ DomSizePolicy(const DomSizePolicy &other);
+ void operator = (const DomSizePolicy&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomSize {
+public:
+ DomSize();
+ ~DomSize();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementWidth() const { return m_children & Width; }
+ void clearElementWidth();
+
+ inline int elementHeight() const { return m_height; }
+ void setElementHeight(int a);
+ inline bool hasElementHeight() const { return m_children & Height; }
+ 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;
+ enum Child {
+ Width = 1,
+ Height = 2
+ };
+
+ DomSize(const DomSize &other);
+ void operator = (const DomSize&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomDate {
+public:
+ DomDate();
+ ~DomDate();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementYear() const { return m_children & Year; }
+ void clearElementYear();
+
+ inline int elementMonth() const { return m_month; }
+ void setElementMonth(int a);
+ inline bool hasElementMonth() const { return m_children & Month; }
+ void clearElementMonth();
+
+ inline int elementDay() const { return m_day; }
+ void setElementDay(int a);
+ inline bool hasElementDay() const { return m_children & Day; }
+ 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;
+ enum Child {
+ Year = 1,
+ Month = 2,
+ Day = 4
+ };
+
+ DomDate(const DomDate &other);
+ void operator = (const DomDate&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomTime {
+public:
+ DomTime();
+ ~DomTime();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementHour() const { return m_children & Hour; }
+ void clearElementHour();
+
+ inline int elementMinute() const { return m_minute; }
+ void setElementMinute(int a);
+ inline bool hasElementMinute() const { return m_children & Minute; }
+ void clearElementMinute();
+
+ inline int elementSecond() const { return m_second; }
+ void setElementSecond(int a);
+ inline bool hasElementSecond() const { return m_children & Second; }
+ 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;
+ enum Child {
+ Hour = 1,
+ Minute = 2,
+ Second = 4
+ };
+
+ DomTime(const DomTime &other);
+ void operator = (const DomTime&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomDateTime {
+public:
+ DomDateTime();
+ ~DomDateTime();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementHour() const { return m_children & Hour; }
+ void clearElementHour();
+
+ inline int elementMinute() const { return m_minute; }
+ void setElementMinute(int a);
+ inline bool hasElementMinute() const { return m_children & Minute; }
+ void clearElementMinute();
+
+ inline int elementSecond() const { return m_second; }
+ void setElementSecond(int a);
+ inline bool hasElementSecond() const { return m_children & Second; }
+ void clearElementSecond();
+
+ inline int elementYear() const { return m_year; }
+ void setElementYear(int a);
+ inline bool hasElementYear() const { return m_children & Year; }
+ void clearElementYear();
+
+ inline int elementMonth() const { return m_month; }
+ void setElementMonth(int a);
+ inline bool hasElementMonth() const { return m_children & Month; }
+ void clearElementMonth();
+
+ inline int elementDay() const { return m_day; }
+ void setElementDay(int a);
+ inline bool hasElementDay() const { return m_children & Day; }
+ 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;
+ enum Child {
+ Hour = 1,
+ Minute = 2,
+ Second = 4,
+ Year = 8,
+ Month = 16,
+ Day = 32
+ };
+
+ DomDateTime(const DomDateTime &other);
+ void operator = (const DomDateTime&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomStringList {
+public:
+ DomStringList();
+ ~DomStringList();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 elementString() const { return m_string; }
+ void setElementString(const QStringList& a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QStringList m_string;
+ enum Child {
+ String = 1
+ };
+
+ DomStringList(const DomStringList &other);
+ void operator = (const DomStringList&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomResourcePixmap {
+public:
+ DomResourcePixmap();
+ ~DomResourcePixmap();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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;
+
+ QString m_attr_alias;
+ bool m_has_attr_alias;
+
+ // child element data
+ uint m_children;
+
+ DomResourcePixmap(const DomResourcePixmap &other);
+ void operator = (const DomResourcePixmap&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomResourceIcon {
+public:
+ DomResourceIcon();
+ ~DomResourceIcon();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 clearAttributeResource() { m_has_attr_resource = false; }
+
+ // child element accessors
+ 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 bool hasElementNormalOn() const { return m_children & NormalOn; }
+ void clearElementNormalOn();
+
+ 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 bool hasElementDisabledOn() const { return m_children & DisabledOn; }
+ void clearElementDisabledOn();
+
+ 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 bool hasElementActiveOn() const { return m_children & ActiveOn; }
+ void clearElementActiveOn();
+
+ 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 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;
+
+ QString m_attr_resource;
+ bool m_has_attr_resource;
+
+ // 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;
+ enum Child {
+ NormalOff = 1,
+ NormalOn = 2,
+ DisabledOff = 4,
+ DisabledOn = 8,
+ ActiveOff = 16,
+ ActiveOn = 32,
+ SelectedOff = 64,
+ SelectedOn = 128
+ };
+
+ DomResourceIcon(const DomResourceIcon &other);
+ void operator = (const DomResourceIcon&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomString {
+public:
+ DomString();
+ ~DomString();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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 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 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;
+
+ QString m_attr_comment;
+ bool m_has_attr_comment;
+
+ QString m_attr_extraComment;
+ bool m_has_attr_extraComment;
+
+ // child element data
+ uint m_children;
+
+ DomString(const DomString &other);
+ void operator = (const DomString&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomPointF {
+public:
+ DomPointF();
+ ~DomPointF();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementX() const { return m_children & X; }
+ void clearElementX();
+
+ inline double elementY() const { return m_y; }
+ void setElementY(double a);
+ inline bool hasElementY() const { return m_children & Y; }
+ 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;
+ enum Child {
+ X = 1,
+ Y = 2
+ };
+
+ DomPointF(const DomPointF &other);
+ void operator = (const DomPointF&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomRectF {
+public:
+ DomRectF();
+ ~DomRectF();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementX() const { return m_children & X; }
+ void clearElementX();
+
+ inline double elementY() const { return m_y; }
+ void setElementY(double a);
+ inline bool hasElementY() const { return m_children & Y; }
+ void clearElementY();
+
+ inline double elementWidth() const { return m_width; }
+ void setElementWidth(double a);
+ inline bool hasElementWidth() const { return m_children & Width; }
+ void clearElementWidth();
+
+ inline double elementHeight() const { return m_height; }
+ void setElementHeight(double a);
+ inline bool hasElementHeight() const { return m_children & Height; }
+ 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;
+ enum Child {
+ X = 1,
+ Y = 2,
+ Width = 4,
+ Height = 8
+ };
+
+ DomRectF(const DomRectF &other);
+ void operator = (const DomRectF&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomSizeF {
+public:
+ DomSizeF();
+ ~DomSizeF();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementWidth() const { return m_children & Width; }
+ void clearElementWidth();
+
+ inline double elementHeight() const { return m_height; }
+ void setElementHeight(double a);
+ inline bool hasElementHeight() const { return m_children & Height; }
+ 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;
+ enum Child {
+ Width = 1,
+ Height = 2
+ };
+
+ DomSizeF(const DomSizeF &other);
+ void operator = (const DomSizeF&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomChar {
+public:
+ DomChar();
+ ~DomChar();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementUnicode() const { return m_children & Unicode; }
+ void clearElementUnicode();
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ int m_unicode;
+ enum Child {
+ Unicode = 1
+ };
+
+ DomChar(const DomChar &other);
+ void operator = (const DomChar&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomUrl {
+public:
+ DomUrl();
+ ~DomUrl();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 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;
+ enum Child {
+ String = 1
+ };
+
+ DomUrl(const DomUrl &other);
+ void operator = (const DomUrl&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomProperty {
+public:
+ DomProperty();
+ ~DomProperty();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+
+ inline bool hasAttributeStdset() const { return m_has_attr_stdset; }
+ inline int attributeStdset() const { return m_attr_stdset; }
+ inline void setAttributeStdset(int a) { m_attr_stdset = a; m_has_attr_stdset = true; }
+ inline void clearAttributeStdset() { m_has_attr_stdset = false; }
+
+ // child element accessors
+ enum Kind { Unknown = 0, Bool, Color, Cstring, Cursor, CursorShape, Enum, Font, IconSet, Pixmap, Palette, Point, Rect, Set, Locale, SizePolicy, Size, String, StringList, Number, Float, Double, Date, Time, DateTime, PointF, RectF, SizeF, LongLong, Char, Url, UInt, ULongLong, Brush };
+ inline Kind kind() const { return m_kind; }
+
+ inline QString elementBool() const { return m_bool; }
+ void setElementBool(const QString& 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);
+
+ inline int elementCursor() const { return m_cursor; }
+ void setElementCursor(int a);
+
+ inline QString elementCursorShape() const { return m_cursorShape; }
+ void setElementCursorShape(const QString& a);
+
+ inline QString elementEnum() const { return m_enum; }
+ void setElementEnum(const QString& 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 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 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 QString elementSet() const { return m_set; }
+ void setElementSet(const QString& 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 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 DomStringList* elementStringList() const { return m_stringList; }
+ DomStringList* takeElementStringList();
+ void setElementStringList(DomStringList* a);
+
+ inline int elementNumber() const { return m_number; }
+ void setElementNumber(int a);
+
+ inline float elementFloat() const { return m_float; }
+ void setElementFloat(float a);
+
+ 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 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 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 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 DomUrl* elementUrl() const { return m_url; }
+ DomUrl* takeElementUrl();
+ void setElementUrl(DomUrl* a);
+
+ inline uint elementUInt() const { return m_UInt; }
+ void setElementUInt(uint a);
+
+ inline qulonglong elementULongLong() const { return m_uLongLong; }
+ void setElementULongLong(qulonglong a);
+
+ inline DomBrush* elementBrush() const { return m_brush; }
+ DomBrush* takeElementBrush();
+ void setElementBrush(DomBrush* a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ QString m_attr_name;
+ bool m_has_attr_name;
+
+ int m_attr_stdset;
+ bool m_has_attr_stdset;
+
+ // child element data
+ Kind m_kind;
+ QString m_bool;
+ DomColor* m_color;
+ QString m_cstring;
+ int m_cursor;
+ QString m_cursorShape;
+ QString m_enum;
+ DomFont* m_font;
+ DomResourceIcon* m_iconSet;
+ DomResourcePixmap* m_pixmap;
+ DomPalette* m_palette;
+ DomPoint* m_point;
+ DomRect* m_rect;
+ 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);
+};
+
+class QDESIGNER_UILIB_EXPORT DomConnections {
+public:
+ DomConnections();
+ ~DomConnections();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomConnection*> m_connection;
+ enum Child {
+ Connection = 1
+ };
+
+ DomConnections(const DomConnections &other);
+ void operator = (const DomConnections&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomConnection {
+public:
+ DomConnection();
+ ~DomConnection();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+ inline bool hasElementSender() const { return m_children & Sender; }
+ void clearElementSender();
+
+ inline QString elementSignal() const { return m_signal; }
+ 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);
+ inline bool hasElementReceiver() const { return m_children & Receiver; }
+ void clearElementReceiver();
+
+ inline QString elementSlot() const { return m_slot; }
+ 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 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;
+ QString m_sender;
+ QString m_signal;
+ QString m_receiver;
+ QString m_slot;
+ DomConnectionHints* m_hints;
+ enum Child {
+ Sender = 1,
+ Signal = 2,
+ Receiver = 4,
+ Slot = 8,
+ Hints = 16
+ };
+
+ DomConnection(const DomConnection &other);
+ void operator = (const DomConnection&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomConnectionHints {
+public:
+ DomConnectionHints();
+ ~DomConnectionHints();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomConnectionHint*> m_hint;
+ enum Child {
+ Hint = 1
+ };
+
+ DomConnectionHints(const DomConnectionHints &other);
+ void operator = (const DomConnectionHints&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomConnectionHint {
+public:
+ DomConnectionHint();
+ ~DomConnectionHint();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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
+ inline int elementX() const { return m_x; }
+ void setElementX(int a);
+ inline bool hasElementX() const { return m_children & X; }
+ void clearElementX();
+
+ inline int elementY() const { return m_y; }
+ void setElementY(int a);
+ inline bool hasElementY() const { return m_children & Y; }
+ void clearElementY();
+
+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;
+ int m_x;
+ int m_y;
+ 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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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 {
+public:
+ DomDesignerData();
+ ~DomDesignerData();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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
+ };
+
+ DomDesignerData(const DomDesignerData &other);
+ void operator = (const DomDesignerData&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomSlots {
+public:
+ DomSlots();
+ ~DomSlots();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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);
+
+ inline QStringList elementSlot() const { return m_slot; }
+ void setElementSlot(const QStringList& a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ 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 {
+public:
+ DomPropertySpecifications();
+ ~DomPropertySpecifications();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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<DomStringPropertySpecification*> elementStringpropertyspecification() const { return m_stringpropertyspecification; }
+ void setElementStringpropertyspecification(const QList<DomStringPropertySpecification*>& a);
+
+private:
+ QString m_text;
+ void clear(bool clear_all = true);
+
+ // attribute data
+ // child element data
+ uint m_children;
+ QList<DomStringPropertySpecification*> m_stringpropertyspecification;
+ enum Child {
+ Stringpropertyspecification = 1
+ };
+
+ DomPropertySpecifications(const DomPropertySpecifications &other);
+ void operator = (const DomPropertySpecifications&other);
+};
+
+class QDESIGNER_UILIB_EXPORT DomStringPropertySpecification {
+public:
+ DomStringPropertySpecification();
+ ~DomStringPropertySpecification();
+
+ void read(QXmlStreamReader &reader);
+#ifdef QUILOADER_QDOM_READ
+ void read(const QDomElement &node);
+#endif
+ 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; }
+
+ 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; }
+
+ 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 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;
+
+ QString m_attr_type;
+ bool m_has_attr_type;
+
+ QString m_attr_notr;
+ bool m_has_attr_notr;
+
+ // child element data
+ uint m_children;
+
+ DomStringPropertySpecification(const DomStringPropertySpecification &other);
+ void operator = (const DomStringPropertySpecification&other);
+};
+
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // UI4_H
diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp
new file mode 100644
index 0000000000..f045e58d2e
--- /dev/null
+++ b/src/tools/uic/uic.cpp
@@ -0,0 +1,387 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "uic.h"
+#include "ui4.h"
+#include "driver.h"
+#include "option.h"
+#include "treewalker.h"
+#include "validator.h"
+
+#ifdef QT_UIC_CPP_GENERATOR
+#include "cppwriteincludes.h"
+#include "cppwritedeclaration.h"
+#endif
+
+#ifdef QT_UIC_JAVA_GENERATOR
+#include "javawriteincludes.h"
+#include "javawritedeclaration.h"
+#endif
+
+#include <QtCore/QXmlStreamReader>
+#include <QtCore/QFileInfo>
+#include <QtCore/QRegExp>
+#include <QtCore/QTextStream>
+#include <QtCore/QDateTime>
+
+#if defined Q_WS_WIN
+#include <qt_windows.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+Uic::Uic(Driver *d)
+ : drv(d),
+ out(d->output()),
+ opt(d->option()),
+ info(d),
+ externalPix(true)
+{
+}
+
+Uic::~Uic()
+{
+}
+
+bool Uic::printDependencies()
+{
+ QString fileName = opt.inputFile;
+
+ QFile f;
+ if (fileName.isEmpty())
+ f.open(stdin, QIODevice::ReadOnly);
+ else {
+ f.setFileName(fileName);
+ if (!f.open(QIODevice::ReadOnly))
+ return false;
+ }
+
+ DomUI *ui = 0;
+ {
+ QXmlStreamReader reader;
+ reader.setDevice(&f);
+ ui = parseUiFile(reader);
+ if (!ui)
+ return false;
+ }
+
+ if (DomIncludes *includes = ui->elementIncludes()) {
+ foreach (DomInclude *incl, includes->elementInclude()) {
+ QString file = incl->text();
+ if (file.isEmpty())
+ continue;
+
+ fprintf(stdout, "%s\n", file.toLocal8Bit().constData());
+ }
+ }
+
+ if (DomCustomWidgets *customWidgets = ui->elementCustomWidgets()) {
+ foreach (DomCustomWidget *customWidget, customWidgets->elementCustomWidget()) {
+ if (DomHeader *header = customWidget->elementHeader()) {
+ QString file = header->text();
+ if (file.isEmpty())
+ continue;
+
+ fprintf(stdout, "%s\n", file.toLocal8Bit().constData());
+ }
+ }
+ }
+
+ delete ui;
+
+ return true;
+}
+
+void Uic::writeCopyrightHeader(DomUI *ui)
+{
+ QString comment = ui->elementComment();
+ if (comment.size())
+ out << "/*\n" << comment << "\n*/\n\n";
+
+ out << "/********************************************************************************\n";
+ out << "** Form generated from reading UI file '" << QFileInfo(opt.inputFile).fileName() << "'\n";
+ out << "**\n";
+ out << "** Created: " << QDateTime::currentDateTime().toString() << "\n";
+ out << "** " << QString::fromLatin1("by: Qt User Interface Compiler version %1\n").arg(QLatin1String(QT_VERSION_STR));
+ out << "**\n";
+ out << "** WARNING! All changes made in this file will be lost when recompiling UI file!\n";
+ out << "********************************************************************************/\n\n";
+}
+
+// Check the version with a stream reader at the <ui> element.
+
+static double versionFromUiAttribute(QXmlStreamReader &reader)
+{
+ const QXmlStreamAttributes attributes = reader.attributes();
+ const QString versionAttribute = QLatin1String("version");
+ if (!attributes.hasAttribute(versionAttribute))
+ return 4.0;
+ const QString version = attributes.value(versionAttribute).toString();
+ return version.toDouble();
+}
+
+DomUI *Uic::parseUiFile(QXmlStreamReader &reader)
+{
+ DomUI *ui = 0;
+
+ const QString uiElement = QLatin1String("ui");
+ while (!reader.atEnd()) {
+ if (reader.readNext() == QXmlStreamReader::StartElement) {
+ if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0
+ && !ui) {
+ const double version = versionFromUiAttribute(reader);
+ if (version < 4.0) {
+ const QString msg = QString::fromLatin1("uic: File generated with too old version of Qt Designer (%1)").arg(version);
+ fprintf(stderr, "%s\n", qPrintable(msg));
+ return 0;
+ }
+
+ ui = new DomUI();
+ ui->read(reader);
+ } else {
+ reader.raiseError(QLatin1String("Unexpected element ") + reader.name().toString());
+ }
+ }
+ }
+ if (reader.hasError()) {
+ delete ui;
+ ui = 0;
+ fprintf(stderr, "%s\n", qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3")
+ .arg(reader.lineNumber()).arg(reader.columnNumber())
+ .arg(reader.errorString())));
+ }
+
+ return ui;
+}
+
+bool Uic::write(QIODevice *in)
+{
+ if (option().generator == Option::JavaGenerator) {
+ // the Java generator ignores header protection
+ opt.headerProtection = false;
+ }
+
+ DomUI *ui = 0;
+ {
+ QXmlStreamReader reader;
+ reader.setDevice(in);
+ ui = parseUiFile(reader);
+
+ if (!ui)
+ return false;
+ }
+
+ double version = ui->attributeVersion().toDouble();
+ if (version < 4.0) {
+ delete ui;
+
+ fprintf(stderr, "uic: File generated with too old version of Qt Designer\n");
+ return false;
+ }
+
+ QString language = ui->attributeLanguage();
+
+
+ bool rtn = false;
+
+ if (option().generator == Option::JavaGenerator) {
+#ifdef QT_UIC_JAVA_GENERATOR
+ if (language.toLower() != QLatin1String("jambi")) {
+ fprintf(stderr, "uic: File is not a 'jambi' form\n");
+ return false;
+ }
+ rtn = jwrite (ui);
+#else
+ fprintf(stderr, "uic: option to generate java code not compiled in\n");
+#endif
+ } else {
+#ifdef QT_UIC_CPP_GENERATOR
+ if (!language.isEmpty() && language.toLower() != QLatin1String("c++")) {
+ fprintf(stderr, "uic: File is not a 'c++' ui file, language=%s\n", qPrintable(language));
+ return false;
+ }
+
+ rtn = write (ui);
+#else
+ fprintf(stderr, "uic: option to generate cpp code not compiled in\n");
+#endif
+ }
+
+ delete ui;
+
+ return rtn;
+}
+
+#ifdef QT_UIC_CPP_GENERATOR
+bool Uic::write(DomUI *ui)
+{
+ using namespace CPP;
+
+ if (!ui || !ui->elementWidget())
+ return false;
+
+ if (opt.copyrightHeader)
+ writeCopyrightHeader(ui);
+
+ if (opt.headerProtection) {
+ writeHeaderProtectionStart();
+ out << "\n";
+ }
+
+ pixFunction = ui->elementPixmapFunction();
+ 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);
+
+ if (opt.headerProtection)
+ writeHeaderProtectionEnd();
+
+ return true;
+}
+#endif
+
+#ifdef QT_UIC_JAVA_GENERATOR
+bool Uic::jwrite(DomUI *ui)
+{
+ using namespace Java;
+
+ if (!ui || !ui->elementWidget())
+ return false;
+
+ if (opt.copyrightHeader)
+ writeCopyrightHeader(ui);
+
+ pixFunction = ui->elementPixmapFunction();
+ if (pixFunction == QLatin1String("QPixmap::fromMimeSource"))
+ pixFunction = QLatin1String("qPixmapFromMimeSource");
+
+ externalPix = ui->elementImages() == 0;
+
+ info.acceptUI(ui);
+ cWidgetsInfo.acceptUI(ui);
+ WriteIncludes(this).acceptUI(ui);
+
+ Validator(this).acceptUI(ui);
+ WriteDeclaration(this).acceptUI(ui);
+
+ return true;
+}
+#endif
+
+#ifdef QT_UIC_CPP_GENERATOR
+
+void Uic::writeHeaderProtectionStart()
+{
+ QString h = drv->headerFileName();
+ out << "#ifndef " << h << "\n"
+ << "#define " << h << "\n";
+}
+
+void Uic::writeHeaderProtectionEnd()
+{
+ QString h = drv->headerFileName();
+ out << "#endif // " << h << "\n";
+}
+#endif
+
+bool Uic::isMainWindow(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("Q3MainWindow"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QMainWindow"));
+}
+
+bool Uic::isToolBar(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("Q3ToolBar"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QToolBar"));
+}
+
+bool Uic::isButton(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("QRadioButton"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QToolButton"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QCheckBox"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QPushButton"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QCommandLinkButton"));
+}
+
+bool Uic::isContainer(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("QStackedWidget"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QToolBox"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QTabWidget"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QScrollArea"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QMdiArea"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QWizard"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QDockWidget"));
+}
+
+bool Uic::isCustomWidgetContainer(const QString &className) const
+{
+ return customWidgetsInfo()->isCustomWidgetContainer(className);
+}
+
+bool Uic::isStatusBar(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("QStatusBar"));
+}
+
+bool Uic::isMenuBar(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("QMenuBar"));
+}
+
+bool Uic::isMenu(const QString &className) const
+{
+ return customWidgetsInfo()->extends(className, QLatin1String("QMenu"))
+ || customWidgetsInfo()->extends(className, QLatin1String("QPopupMenu"));
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/uic.h b/src/tools/uic/uic.h
new file mode 100644
index 0000000000..66b86b3429
--- /dev/null
+++ b/src/tools/uic/uic.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef UIC_H
+#define UIC_H
+
+#include "databaseinfo.h"
+#include "customwidgetsinfo.h"
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QHash>
+#include <QtCore/QStack>
+#include <QtCore/QXmlStreamReader>
+
+QT_BEGIN_NAMESPACE
+
+class QTextStream;
+class QIODevice;
+
+class Driver;
+class DomUI;
+class DomWidget;
+class DomSpacer;
+class DomLayout;
+class DomLayoutItem;
+class DomItem;
+
+struct Option;
+
+class Uic
+{
+public:
+ Uic(Driver *driver);
+ ~Uic();
+
+ bool printDependencies();
+
+ inline Driver *driver() const
+ { return drv; }
+
+ inline QTextStream &output()
+ { return out; }
+
+ inline const Option &option() const
+ { return opt; }
+
+ inline QString pixmapFunction() const
+ { return pixFunction; }
+
+ 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; }
+
+ inline const CustomWidgetsInfo *customWidgetsInfo() const
+ { return &cWidgetsInfo; }
+
+ bool write(QIODevice *in);
+
+#ifdef QT_UIC_JAVA_GENERATOR
+ bool jwrite(DomUI *ui);
+#endif
+
+#ifdef QT_UIC_CPP_GENERATOR
+ bool write(DomUI *ui);
+#endif
+
+ bool isMainWindow(const QString &className) const;
+ bool isToolBar(const QString &className) const;
+ bool isStatusBar(const QString &className) const;
+ bool isButton(const QString &className) const;
+ bool isContainer(const QString &className) const;
+ bool isCustomWidgetContainer(const QString &className) const;
+ bool isMenuBar(const QString &className) const;
+ bool isMenu(const QString &className) const;
+
+private:
+ // copyright header
+ void writeCopyrightHeader(DomUI *ui);
+ DomUI *parseUiFile(QXmlStreamReader &reader);
+
+#ifdef QT_UIC_CPP_GENERATOR
+ // header protection
+ void writeHeaderProtectionStart();
+ void writeHeaderProtectionEnd();
+#endif
+
+private:
+ Driver *drv;
+ QTextStream &out;
+ Option &opt;
+ DatabaseInfo info;
+ CustomWidgetsInfo cWidgetsInfo;
+ QString pixFunction;
+ bool externalPix;
+};
+
+QT_END_NAMESPACE
+
+#endif // UIC_H
diff --git a/src/tools/uic/uic.pri b/src/tools/uic/uic.pri
new file mode 100644
index 0000000000..3f0bab05dd
--- /dev/null
+++ b/src/tools/uic/uic.pri
@@ -0,0 +1,21 @@
+
+INCLUDEPATH += $$PWD
+
+HEADERS += \
+ $$PWD/customwidgetsinfo.h \
+ $$PWD/databaseinfo.h \
+ $$PWD/driver.h \
+ $$PWD/globaldefs.h \
+ $$PWD/option.h \
+ $$PWD/treewalker.h \
+ $$PWD/utils.h \
+ $$PWD/ui4.h \
+ $$PWD/validator.h
+
+SOURCES += \
+ $$PWD/customwidgetsinfo.cpp \
+ $$PWD/databaseinfo.cpp \
+ $$PWD/driver.cpp \
+ $$PWD/treewalker.cpp \
+ $$PWD/ui4.cpp \
+ $$PWD/validator.cpp
diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro
new file mode 100644
index 0000000000..9b63d42c2b
--- /dev/null
+++ b/src/tools/uic/uic.pro
@@ -0,0 +1,23 @@
+TEMPLATE = app
+TARGET = uic
+
+DESTDIR = ../../../bin
+DEFINES += QT_UIC
+INCLUDEPATH += .
+DEPENDPATH += .
+
+!contains(QT_CONFIG, qt3support):DEFINES += QT_NO_QT3_SUPPORT
+
+include(uic.pri)
+include(cpp/cpp.pri)
+
+HEADERS += uic.h
+
+SOURCES += main.cpp \
+ uic.cpp
+
+include(../bootstrap/bootstrap.pri)
+
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
+include(../../qt_targets.pri)
diff --git a/src/tools/uic/utils.h b/src/tools/uic/utils.h
new file mode 100644
index 0000000000..2171843cb8
--- /dev/null
+++ b/src/tools/uic/utils.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include "ui4.h"
+#include <QtCore/QString>
+#include <QtCore/QList>
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+
+inline bool toBool(const QString &str)
+{ return str.toLower() == QLatin1String("true"); }
+
+inline QString toString(const DomString *str)
+{ return str ? str->text() : QString(); }
+
+inline QString fixString(const QString &str, const QString &indent)
+{
+ QString cursegment;
+ QStringList result;
+ const QByteArray utf8 = str.toUtf8();
+ const int utf8Length = utf8.length();
+
+ for (int i = 0; i < utf8Length; ++i) {
+ const uchar cbyte = utf8.at(i);
+ if (cbyte >= 0x80) {
+ cursegment += QLatin1Char('\\');
+ cursegment += QString::number(cbyte, 8);
+ } else {
+ switch(cbyte) {
+ case '\\':
+ cursegment += QLatin1String("\\\\"); break;
+ case '\"':
+ cursegment += QLatin1String("\\\""); break;
+ case '\r':
+ break;
+ case '\n':
+ cursegment += QLatin1String("\\n\"\n\""); break;
+ default:
+ cursegment += QLatin1Char(cbyte);
+ }
+ }
+
+ if (cursegment.length() > 1024) {
+ result << cursegment;
+ cursegment.clear();
+ }
+ }
+
+ if (!cursegment.isEmpty())
+ result << cursegment;
+
+
+ QString joinstr = QLatin1String("\"\n");
+ joinstr += indent;
+ joinstr += indent;
+ joinstr += QLatin1Char('"');
+
+ QString rc(QLatin1Char('"'));
+ rc += result.join(joinstr);
+ rc += QLatin1Char('"');
+ return rc;
+}
+
+inline QHash<QString, DomProperty *> propertyMap(const QList<DomProperty *> &properties)
+{
+ QHash<QString, DomProperty *> map;
+
+ for (int i=0; i<properties.size(); ++i) {
+ DomProperty *p = properties.at(i);
+ map.insert(p->attributeName(), p);
+ }
+
+ return map;
+}
+
+inline QStringList unique(const QStringList &lst)
+{
+ QHash<QString, bool> h;
+ for (int i=0; i<lst.size(); ++i)
+ h.insert(lst.at(i), true);
+ return h.keys();
+}
+
+QT_END_NAMESPACE
+
+#endif // UTILS_H
diff --git a/src/tools/uic/validator.cpp b/src/tools/uic/validator.cpp
new file mode 100644
index 0000000000..c8ddfb78fa
--- /dev/null
+++ b/src/tools/uic/validator.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "validator.h"
+#include "driver.h"
+#include "ui4.h"
+#include "uic.h"
+
+QT_BEGIN_NAMESPACE
+
+Validator::Validator(Uic *uic) :
+ m_driver(uic->driver())
+{
+}
+
+void Validator::acceptUI(DomUI *node)
+{
+ TreeWalker::acceptUI(node);
+}
+
+void Validator::acceptWidget(DomWidget *node)
+{
+ (void) m_driver->findOrInsertWidget(node);
+
+ TreeWalker::acceptWidget(node);
+}
+
+void Validator::acceptLayoutItem(DomLayoutItem *node)
+{
+ (void) m_driver->findOrInsertLayoutItem(node);
+
+ TreeWalker::acceptLayoutItem(node);
+}
+
+void Validator::acceptLayout(DomLayout *node)
+{
+ (void) m_driver->findOrInsertLayout(node);
+
+ TreeWalker::acceptLayout(node);
+}
+
+void Validator::acceptActionGroup(DomActionGroup *node)
+{
+ (void) m_driver->findOrInsertActionGroup(node);
+
+ TreeWalker::acceptActionGroup(node);
+}
+
+void Validator::acceptAction(DomAction *node)
+{
+ (void) m_driver->findOrInsertAction(node);
+
+ TreeWalker::acceptAction(node);
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic/validator.h b/src/tools/uic/validator.h
new file mode 100644
index 0000000000..133d50b1b7
--- /dev/null
+++ b/src/tools/uic/validator.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef VALIDATOR_H
+#define VALIDATOR_H
+
+#include "treewalker.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTextStream;
+class Driver;
+class Uic;
+
+struct Option;
+
+struct Validator : public TreeWalker
+{
+ Validator(Uic *uic);
+
+ void acceptUI(DomUI *node);
+ void acceptWidget(DomWidget *node);
+
+ void acceptLayoutItem(DomLayoutItem *node);
+ void acceptLayout(DomLayout *node);
+
+ void acceptActionGroup(DomActionGroup *node);
+ void acceptAction(DomAction *node);
+
+private:
+ Driver *m_driver;
+};
+
+QT_END_NAMESPACE
+
+#endif // VALIDATOR_H