summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:34:13 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:34:13 (GMT)
commit67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch)
tree1dbf50b3dff8d5ca7e9344733968c72704eb15ff /src/tools
downloadQt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2
Long live Qt!
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/bootstrap/bootstrap.pri64
-rw-r--r--src/tools/bootstrap/bootstrap.pro114
-rw-r--r--src/tools/idc/idc.pro14
-rw-r--r--src/tools/idc/main.cpp369
-rw-r--r--src/tools/moc/generator.cpp1312
-rw-r--r--src/tools/moc/generator.h81
-rw-r--r--src/tools/moc/keywords.cpp979
-rw-r--r--src/tools/moc/main.cpp459
-rw-r--r--src/tools/moc/moc.cpp1230
-rw-r--r--src/tools/moc/moc.h247
-rw-r--r--src/tools/moc/moc.pri16
-rw-r--r--src/tools/moc/moc.pro18
-rw-r--r--src/tools/moc/mwerks_mac.cpp240
-rw-r--r--src/tools/moc/mwerks_mac.h67
-rw-r--r--src/tools/moc/outputrevision.h48
-rw-r--r--src/tools/moc/parser.cpp81
-rw-r--r--src/tools/moc/parser.h108
-rw-r--r--src/tools/moc/ppkeywords.cpp248
-rw-r--r--src/tools/moc/preprocessor.cpp978
-rw-r--r--src/tools/moc/preprocessor.h102
-rw-r--r--src/tools/moc/symbols.h147
-rw-r--r--src/tools/moc/token.cpp222
-rw-r--r--src/tools/moc/token.h274
-rwxr-xr-xsrc/tools/moc/util/generate.sh7
-rw-r--r--src/tools/moc/util/generate_keywords.cpp468
-rw-r--r--src/tools/moc/util/generate_keywords.pro13
-rw-r--r--src/tools/moc/util/licenseheader.txt41
-rw-r--r--src/tools/moc/utils.h111
-rw-r--r--src/tools/rcc/main.cpp262
-rw-r--r--src/tools/rcc/rcc.cpp967
-rw-r--r--src/tools/rcc/rcc.h153
-rw-r--r--src/tools/rcc/rcc.pri3
-rw-r--r--src/tools/rcc/rcc.pro16
-rw-r--r--src/tools/uic/cpp/cpp.pri20
-rw-r--r--src/tools/uic/cpp/cppextractimages.cpp148
-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.cpp181
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.h80
-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.cpp340
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.h116
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp2919
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.h371
-rw-r--r--src/tools/uic/customwidgetsinfo.cpp119
-rw-r--r--src/tools/uic/customwidgetsinfo.h89
-rw-r--r--src/tools/uic/databaseinfo.cpp96
-rw-r--r--src/tools/uic/databaseinfo.h79
-rw-r--r--src/tools/uic/driver.cpp378
-rw-r--r--src/tools/uic/driver.h140
-rw-r--r--src/tools/uic/globaldefs.h54
-rw-r--r--src/tools/uic/main.cpp197
-rw-r--r--src/tools/uic/option.h96
-rw-r--r--src/tools/uic/treewalker.cpp328
-rw-r--r--src/tools/uic/treewalker.h137
-rw-r--r--src/tools/uic/ui4.cpp11132
-rw-r--r--src/tools/uic/ui4.h3791
-rw-r--r--src/tools/uic/uic.cpp382
-rw-r--r--src/tools/uic/uic.h144
-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
-rw-r--r--src/tools/uic3/converter.cpp1305
-rw-r--r--src/tools/uic3/deps.cpp132
-rw-r--r--src/tools/uic3/domtool.cpp587
-rw-r--r--src/tools/uic3/domtool.h275
-rw-r--r--src/tools/uic3/embed.cpp336
-rw-r--r--src/tools/uic3/form.cpp921
-rw-r--r--src/tools/uic3/main.cpp414
-rw-r--r--src/tools/uic3/object.cpp66
-rw-r--r--src/tools/uic3/parser.cpp85
-rw-r--r--src/tools/uic3/parser.h57
-rw-r--r--src/tools/uic3/qt3to4.cpp225
-rw-r--r--src/tools/uic3/qt3to4.h82
-rw-r--r--src/tools/uic3/subclassing.cpp362
-rw-r--r--src/tools/uic3/ui3reader.cpp639
-rw-r--r--src/tools/uic3/ui3reader.h233
-rw-r--r--src/tools/uic3/uic.cpp341
-rw-r--r--src/tools/uic3/uic.h142
-rw-r--r--src/tools/uic3/uic3.pro43
-rw-r--r--src/tools/uic3/widgetinfo.cpp285
-rw-r--r--src/tools/uic3/widgetinfo.h77
88 files changed, 38532 insertions, 0 deletions
diff --git a/src/tools/bootstrap/bootstrap.pri b/src/tools/bootstrap/bootstrap.pri
new file mode 100644
index 0000000..1cf103b
--- /dev/null
+++ b/src/tools/bootstrap/bootstrap.pri
@@ -0,0 +1,64 @@
+CONFIG += console qtinc
+CONFIG -= qt
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+CONFIG -= app_bundle
+
+DEFINES += \
+ QT_BOOTSTRAPPED \
+ QT_LITE_UNICODE \
+ QT_TEXTCODEC \
+ QT_NO_CAST_FROM_ASCII \
+ QT_NO_CAST_TO_ASCII \
+ QT_NO_CODECS \
+ QT_NO_DATASTREAM \
+ QT_NO_GEOM_VARIANT \
+ QT_NO_LIBRARY \
+ QT_NO_QOBJECT \
+ QT_NO_STL \
+ QT_NO_SYSTEMLOCALE \
+ QT_NO_TEXTSTREAM \
+ QT_NO_THREAD \
+ QT_NO_UNICODETABLES \
+ QT_NO_USING_NAMESPACE
+win32:DEFINES += QT_NODLL
+
+INCLUDEPATH += $$QT_BUILD_TREE/include \
+ $$QT_BUILD_TREE/include/QtCore \
+ $$QT_BUILD_TREE/include/QtXml \
+ ../../xml
+DEPENDPATH += $$INCLUDEPATH \
+ ../../corelib/global \
+ ../../corelib/kernel \
+ ../../corelib/tools \
+ ../../corelib/io \
+ ../../corelib/codecs \
+ ../../xml
+
+hpux-acc*|hpuxi-acc* {
+ LIBS += ../bootstrap/libbootstrap.a
+} else {
+ contains(CONFIG, debug_and_release_target) {
+ CONFIG(debug, debug|release) {
+ LIBS+=-L../bootstrap/debug
+ } else {
+ LIBS+=-L../bootstrap/release
+ }
+ } else {
+ LIBS += -L../bootstrap
+ }
+ LIBS += -lbootstrap
+}
+!contains(QT_CONFIG, zlib):!contains(QT_CONFIG, no-zlib) {
+ unix:LIBS += -lz
+# win32:LIBS += libz.lib
+}
+win32:LIBS += -luser32
+
+mac {
+ CONFIG -= incremental
+ LIBS += -framework CoreServices
+}
+
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
new file mode 100644
index 0000000..d8a1f96
--- /dev/null
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -0,0 +1,114 @@
+TEMPLATE = lib
+TARGET = bootstrap
+CONFIG += staticlib
+
+CONFIG += console qtinc
+CONFIG -= qt
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+mac:CONFIG -= app_bundle incremental
+
+DEFINES += \
+ QT_BOOTSTRAPPED \
+ QT_LITE_UNICODE \
+ QT_NO_CAST_FROM_ASCII \
+ QT_NO_CAST_TO_ASCII \
+ QT_NO_CODECS \
+ QT_NO_DATASTREAM \
+ QT_NO_GEOM_VARIANT \
+ QT_NO_LIBRARY \
+ QT_NO_QOBJECT \
+ QT_NO_STL \
+ QT_NO_SYSTEMLOCALE \
+ QT_NO_TEXTSTREAM \
+ QT_NO_THREAD \
+ QT_NO_UNICODETABLES \
+ QT_NO_USING_NAMESPACE
+win32:DEFINES += QT_NODLL
+
+INCLUDEPATH += $$QT_BUILD_TREE/include \
+ $$QT_BUILD_TREE/include/QtCore \
+ $$QT_BUILD_TREE/include/QtXml \
+
+DEPENDPATH += $$INCLUDEPATH \
+ ../../corelib/global \
+ ../../corelib/kernel \
+ ../../corelib/tools \
+ ../../corelib/io \
+ ../../corelib/codecs \
+ ../../xml
+
+SOURCES += \
+ ../../corelib/codecs/qisciicodec.cpp \
+ ../../corelib/codecs/qlatincodec.cpp \
+ ../../corelib/codecs/qsimplecodec.cpp \
+ ../../corelib/codecs/qtextcodec.cpp \
+ ../../corelib/codecs/qtsciicodec.cpp \
+ ../../corelib/codecs/qutfcodec.cpp \
+ ../../corelib/global/qglobal.cpp \
+ ../../corelib/global/qmalloc.cpp \
+ ../../corelib/global/qnumeric.cpp \
+ ../../corelib/io/qabstractfileengine.cpp \
+ ../../corelib/io/qbuffer.cpp \
+ ../../corelib/io/qdir.cpp \
+ ../../corelib/io/qdiriterator.cpp \
+ ../../corelib/io/qfile.cpp \
+ ../../corelib/io/qfileinfo.cpp \
+ ../../corelib/io/qfsfileengine.cpp \
+ ../../corelib/io/qfsfileengine_iterator.cpp \
+ ../../corelib/io/qiodevice.cpp \
+ ../../corelib/io/qtemporaryfile.cpp \
+ ../../corelib/io/qtextstream.cpp \
+ ../../corelib/io/qurl.cpp \
+ ../../corelib/kernel/qmetatype.cpp \
+ ../../corelib/kernel/qvariant.cpp \
+ ../../corelib/tools/qbitarray.cpp \
+ ../../corelib/tools/qbytearray.cpp \
+ ../../corelib/tools/qbytearraymatcher.cpp \
+ ../../corelib/tools/qdatetime.cpp \
+ ../../corelib/tools/qhash.cpp \
+ ../../corelib/tools/qlistdata.cpp \
+ ../../corelib/tools/qlocale.cpp \
+ ../../corelib/tools/qmap.cpp \
+ ../../corelib/tools/qregexp.cpp \
+ ../../corelib/tools/qstring.cpp \
+ ../../corelib/tools/qstringlist.cpp \
+ ../../corelib/tools/qvector.cpp \
+ ../../corelib/tools/qvsnprintf.cpp \
+ ../../corelib/xml/qxmlutils.cpp \
+ ../../corelib/xml/qxmlstream.cpp \
+ ../../xml/dom/qdom.cpp \
+ ../../xml/sax/qxml.cpp
+
+unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \
+ ../../corelib/io/qfsfileengine_iterator_unix.cpp
+
+win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \
+ ../../corelib/io/qfsfileengine_iterator_win.cpp
+
+macx: {
+ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 #enables weak linking for 10.3 (exported)
+ SOURCES += ../../corelib/kernel/qcore_mac.cpp
+ LIBS += -framework CoreServices
+}
+
+contains(QT_CONFIG, zlib) {
+ INCLUDEPATH += ../../3rdparty/zlib
+ SOURCES+= \
+ ../3rdparty/zlib/adler32.c \
+ ../3rdparty/zlib/compress.c \
+ ../3rdparty/zlib/crc32.c \
+ ../3rdparty/zlib/deflate.c \
+ ../3rdparty/zlib/gzio.c \
+ ../3rdparty/zlib/inffast.c \
+ ../3rdparty/zlib/inflate.c \
+ ../3rdparty/zlib/inftrees.c \
+ ../3rdparty/zlib/trees.c \
+ ../3rdparty/zlib/uncompr.c \
+ ../3rdparty/zlib/zutil.c
+}
+
+lib.CONFIG = dummy_install
+INSTALLS += lib
diff --git a/src/tools/idc/idc.pro b/src/tools/idc/idc.pro
new file mode 100644
index 0000000..c33de67
--- /dev/null
+++ b/src/tools/idc/idc.pro
@@ -0,0 +1,14 @@
+TEMPLATE = app
+CONFIG += console
+CONFIG -= app_bundle
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+
+DESTDIR = ../../../bin
+
+SOURCES = main.cpp
+
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
diff --git a/src/tools/idc/main.cpp b/src/tools/idc/main.cpp
new file mode 100644
index 0000000..eb04114
--- /dev/null
+++ b/src/tools/idc/main.cpp
@@ -0,0 +1,369 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QSysInfo>
+#include <QProcess>
+#include <QLibraryInfo>
+#include <qt_windows.h>
+#include <io.h>
+
+QT_BEGIN_NAMESPACE
+
+static QString quotePath(const QString &s)
+{
+ if (!s.startsWith(QLatin1String("\"")) && s.contains(QLatin1Char(' ')))
+ return QLatin1String("\"") + s + QLatin1String("\"");
+ return s;
+}
+
+
+static bool runWithQtInEnvironment(const QString &cmd)
+{
+ QProcess proc;
+
+ // prepend the qt binary directory to the path
+ QStringList env = QProcess::systemEnvironment();
+ for (int i=0; i<env.count(); ++i) {
+ QString var = env.at(i);
+ int setidx = var.indexOf(QLatin1Char('='));
+ if (setidx != -1) {
+ QString varname = var.left(setidx).trimmed().toUpper();
+ if (varname == QLatin1String("PATH")) {
+ var = var.mid(setidx + 1);
+ var = QLatin1String("PATH=") +
+ QLibraryInfo::location(QLibraryInfo::BinariesPath) +
+ QLatin1Char(';') + var;
+ env[i] = var;
+ break;
+ }
+ }
+ }
+
+ proc.setEnvironment(env);
+ proc.start(cmd);
+ proc.waitForFinished(-1);
+
+ return (proc.exitCode() == 0);
+}
+
+static bool attachTypeLibrary(const QString &applicationName, int resource, const QByteArray &data, QString *errorMessage)
+{
+ HANDLE hExe = 0;
+ QT_WA({
+ TCHAR *resourceName = MAKEINTRESOURCEW(resource);
+ hExe = BeginUpdateResourceW((TCHAR*)applicationName.utf16(), false);
+ if (hExe == 0) {
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
+ return false;
+ }
+ if (!UpdateResourceW(hExe,L"TYPELIB",resourceName,0,(void*)data.data(),data.count())) {
+ EndUpdateResource(hExe, true);
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
+ return false;
+ }
+ }, {
+ char *resourceName = MAKEINTRESOURCEA(resource);
+ hExe = BeginUpdateResourceA(applicationName.toLocal8Bit(), false);
+ if (hExe == 0) {
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
+ return false;
+ }
+ if (!UpdateResourceA(hExe,"TYPELIB",resourceName,0,(void*)data.data(),data.count())) {
+ EndUpdateResource(hExe, true);
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
+ return false;
+ }
+ });
+
+ if (!EndUpdateResource(hExe,false)) {
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not write file.").arg(applicationName);
+ return false;
+ }
+
+ if (errorMessage)
+ *errorMessage = QString::fromLatin1("Type library attached to %1.").arg(applicationName);
+ return true;
+}
+
+static bool registerServer(const QString &input)
+{
+ bool ok = false;
+ if (input.endsWith(QLatin1String(".exe"))) {
+ ok = runWithQtInEnvironment(quotePath(input) + QLatin1String(" -regserver"));
+ } else {
+ HMODULE hdll = 0;
+ QT_WA({
+ hdll = LoadLibraryW((TCHAR*)input.utf16());
+ }, {
+ hdll = LoadLibraryA(input.toLocal8Bit());
+ });
+ if (!hdll) {
+ fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
+ return false;
+ }
+ typedef HRESULT(__stdcall* RegServerProc)();
+ RegServerProc DllRegisterServer = (RegServerProc)GetProcAddress(hdll, "DllRegisterServer");
+ if (!DllRegisterServer) {
+ fprintf(stderr, "Library file %s doesn't appear to be a COM library\n", (const char*)input.toLocal8Bit().data());
+ return false;
+ }
+ ok = DllRegisterServer() == S_OK;
+ }
+ return ok;
+}
+
+static bool unregisterServer(const QString &input)
+{
+ bool ok = false;
+ if (input.endsWith(QLatin1String(".exe"))) {
+ ok = runWithQtInEnvironment(quotePath(input) + QLatin1String(" -unregserver"));
+ } else {
+ HMODULE hdll = 0;
+ QT_WA({
+ hdll = LoadLibraryW((TCHAR*)input.utf16());
+ }, {
+ hdll = LoadLibraryA(input.toLocal8Bit());
+ });
+ if (!hdll) {
+ fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
+ return false;
+ }
+ typedef HRESULT(__stdcall* RegServerProc)();
+ RegServerProc DllUnregisterServer = (RegServerProc)GetProcAddress(hdll, "DllUnregisterServer");
+ if (!DllUnregisterServer) {
+ fprintf(stderr, "Library file %s doesn't appear to be a COM library\n", (const char*)input.toLocal8Bit().data());
+ return false;
+ }
+ ok = DllUnregisterServer() == S_OK;
+ }
+ return ok;
+}
+
+static HRESULT dumpIdl(const QString &input, const QString &idlfile, const QString &version)
+{
+ HRESULT res = E_FAIL;
+
+ if (input.endsWith(QLatin1String(".exe"))) {
+ if (runWithQtInEnvironment(quotePath(input) + QLatin1String(" -dumpidl ") + idlfile + QLatin1String(" -version ") + version))
+ res = S_OK;
+ } else {
+ HMODULE hdll = 0;
+ QT_WA({
+ hdll = LoadLibraryW((TCHAR*)input.utf16());
+ }, {
+ hdll = LoadLibraryA(input.toLocal8Bit());
+ });
+ if (!hdll) {
+ fprintf(stderr, "Couldn't load library file %s\n", (const char*)input.toLocal8Bit().data());
+ return 3;
+ }
+ typedef HRESULT(__stdcall* DumpIDLProc)(const QString&, const QString&);
+ DumpIDLProc DumpIDL = (DumpIDLProc)GetProcAddress(hdll, "DumpIDL");
+ if (!DumpIDL) {
+ fprintf(stderr, "Couldn't resolve 'DumpIDL' symbol in %s\n", (const char*)input.toLocal8Bit().data());
+ return 3;
+ }
+ res = DumpIDL(idlfile, version);
+ FreeLibrary(hdll);
+ }
+
+ return res;
+}
+
+static void slashify(QString &s)
+{
+ if (!s.contains(QLatin1Char('/')))
+ return;
+
+ int i = 0;
+ while (i < (int)s.length()) {
+ if (s[i] == QLatin1Char('/'))
+ s[i] = QLatin1Char('\\');
+ ++i;
+ }
+}
+
+int runIdc(int argc, char **argv)
+{
+ QString error;
+ QString tlbfile;
+ QString idlfile;
+ QString input;
+ QString version = QLatin1String("1.0");
+
+ int i = 1;
+ while (i < argc) {
+ QString p = QString::fromLocal8Bit(argv[i]).toLower();
+
+ if (p == QLatin1String("/idl") || p == QLatin1String("-idl")) {
+ ++i;
+ if (i > argc) {
+ error = QLatin1String("Missing name for interface definition file!");
+ break;
+ }
+ idlfile = QLatin1String(argv[i]);
+ idlfile = idlfile.trimmed().toLower();
+ } else if (p == QLatin1String("/version") || p == QLatin1String("-version")) {
+ ++i;
+ if (i > argc)
+ version = QLatin1String("1.0");
+ else
+ version = QLatin1String(argv[i]);
+ } else if (p == QLatin1String("/tlb") || p == QLatin1String("-tlb")) {
+ if (QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based)
+ fprintf(stderr, "IDC requires Windows NT/2000/XP!\n");
+
+ ++i;
+ if (i > argc) {
+ error = QLatin1String("Missing name for type library file!");
+ break;
+ }
+ tlbfile = QLatin1String(argv[i]);
+ tlbfile = tlbfile.trimmed().toLower();
+ } else if (p == QLatin1String("/v") || p == QLatin1String("-v")) {
+ fprintf(stdout, "Qt Interface Definition Compiler version 1.0\n");
+ return 0;
+ } else if (p == QLatin1String("/regserver") || p == QLatin1String("-regserver")) {
+ if (!registerServer(input)) {
+ fprintf(stderr, "Failed to register server!\n");
+ return 1;
+ }
+ fprintf(stderr, "Server registered successfully!\n");
+ return 0;
+ } else if (p == QLatin1String("/unregserver") || p == QLatin1String("-unregserver")) {
+ if (!unregisterServer(input)) {
+ fprintf(stderr, "Failed to unregister server!\n");
+ return 1;
+ }
+ fprintf(stderr, "Server unregistered successfully!\n");
+ return 0;
+ } else if (p[0] == QLatin1Char('/') || p[0] == QLatin1Char('-')) {
+ error = QLatin1String("Unknown option \"") + p + QLatin1String("\"");
+ break;
+ } else {
+ input = QLatin1String(argv[i]);
+ input = input.trimmed().toLower();
+ }
+ i++;
+ }
+ if (!error.isEmpty()) {
+ fprintf(stderr, "%s", error.toLatin1().data());
+ fprintf(stderr, "\n");
+ return 5;
+ }
+ if (input.isEmpty()) {
+ fprintf(stderr, "No input file specified!\n");
+ return 1;
+ }
+ if (input.endsWith(QLatin1String(".exe")) && tlbfile.isEmpty() && idlfile.isEmpty()) {
+ fprintf(stderr, "No type output file specified!\n");
+ return 2;
+ }
+ if (input.endsWith(QLatin1String(".dll")) && idlfile.isEmpty() && tlbfile.isEmpty()) {
+ fprintf(stderr, "No interface definition file and no type library file specified!\n");
+ return 3;
+ }
+ slashify(input);
+ if (!tlbfile.isEmpty()) {
+ slashify(tlbfile);
+ QFile file(tlbfile);
+ if (!file.open(QIODevice::ReadOnly)) {
+ fprintf(stderr, "Couldn't open %s for read\n", (const char*)tlbfile.toLocal8Bit().data());
+ return 4;
+ }
+ QByteArray data = file.readAll();
+ QString error;
+ bool ok = attachTypeLibrary(input, 1, data, &error);
+ fprintf(stderr, "%s", error.toLatin1().data());
+ fprintf(stderr, "\n");
+ return ok ? 0 : 4;
+ } else if (!idlfile.isEmpty()) {
+ slashify(idlfile);
+ idlfile = quotePath(idlfile);
+ fprintf(stderr, "\n\n%s\n\n", (const char*)idlfile.toLocal8Bit().data());
+ quotePath(input);
+ HRESULT res = dumpIdl(input, idlfile, version);
+
+ switch(res) {
+ case S_OK:
+ break;
+ case -1:
+ fprintf(stderr, "Couldn't open %s for writing!\n", (const char*)idlfile.toLocal8Bit().data());
+ return res;
+ case 1:
+ fprintf(stderr, "Malformed appID value in %s!\n", (const char*)input.toLocal8Bit().data());
+ return res;
+ case 2:
+ fprintf(stderr, "Malformed typeLibID value in %s!\n", (const char*)input.toLocal8Bit().data());
+ return res;
+ case 3:
+ fprintf(stderr, "Class has no metaobject information (error in %s)!\n", (const char*)input.toLocal8Bit().data());
+ return res;
+ case 4:
+ fprintf(stderr, "Malformed classID value in %s!\n", (const char*)input.toLocal8Bit().data());
+ return res;
+ case 5:
+ fprintf(stderr, "Malformed interfaceID value in %s!\n", (const char*)input.toLocal8Bit().data());
+ return res;
+ case 6:
+ fprintf(stderr, "Malformed eventsID value in %s!\n", (const char*)input.toLocal8Bit().data());
+ return res;
+
+ default:
+ fprintf(stderr, "Unknown error writing IDL from %s\n", (const char*)input.toLocal8Bit().data());
+ return 7;
+ }
+ }
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+int main(int argc, char **argv)
+{
+ return QT_PREPEND_NAMESPACE(runIdc)(argc, argv);
+}
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
new file mode 100644
index 0000000..ae8a76e
--- /dev/null
+++ b/src/tools/moc/generator.cpp
@@ -0,0 +1,1312 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "generator.h"
+#include "outputrevision.h"
+#include "utils.h"
+#include <QtCore/qmetatype.h>
+#include <stdio.h>
+
+QT_BEGIN_NAMESPACE
+
+// if the flags change, you MUST to change it in qmetaobject.cpp too
+enum PropertyFlags {
+ Invalid = 0x00000000,
+ Readable = 0x00000001,
+ Writable = 0x00000002,
+ Resettable = 0x00000004,
+ EnumOrFlag = 0x00000008,
+ StdCppSet = 0x00000100,
+// Override = 0x00000200,
+ Designable = 0x00001000,
+ ResolveDesignable = 0x00002000,
+ Scriptable = 0x00004000,
+ ResolveScriptable = 0x00008000,
+ Stored = 0x00010000,
+ ResolveStored = 0x00020000,
+ Editable = 0x00040000,
+ ResolveEditable = 0x00080000,
+ User = 0x00100000,
+ ResolveUser = 0x00200000,
+ Notify = 0x00400000
+};
+enum MethodFlags {
+ AccessPrivate = 0x00,
+ AccessProtected = 0x01,
+ AccessPublic = 0x02,
+ MethodMethod = 0x00,
+ MethodSignal = 0x04,
+ MethodSlot = 0x08,
+ MethodConstructor = 0x0c,
+ MethodCompatibility = 0x10,
+ MethodCloned = 0x20,
+ MethodScriptable = 0x40
+};
+
+uint qvariant_nameToType(const char* name)
+{
+ if (!name)
+ return 0;
+
+ if (strcmp(name, "QVariant") == 0)
+ return 0xffffffff;
+ if (strcmp(name, "QCString") == 0)
+ return QMetaType::QByteArray;
+ if (strcmp(name, "Q_LLONG") == 0)
+ return QMetaType::LongLong;
+ if (strcmp(name, "Q_ULLONG") == 0)
+ return QMetaType::ULongLong;
+ if (strcmp(name, "QIconSet") == 0)
+ return QMetaType::QIcon;
+
+ uint tp = QMetaType::type(name);
+ return tp < QMetaType::User ? tp : 0;
+}
+
+/*
+ Returns true if the type is a QVariant types.
+*/
+bool isVariantType(const char* type)
+{
+ return qvariant_nameToType(type) != 0;
+}
+
+Generator::Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, FILE *outfile)
+ : out(outfile), cdef(classDef), metaTypes(metaTypes)
+{
+ if (cdef->superclassList.size())
+ purestSuperClass = cdef->superclassList.first().first;
+}
+
+static inline int lengthOfEscapeSequence(const QByteArray &s, int i)
+{
+ if (s.at(i) != '\\' || i >= s.length() - 1)
+ return 1;
+ const int startPos = i;
+ ++i;
+ char ch = s.at(i);
+ if (ch == 'x') {
+ ++i;
+ while (i < s.length() && is_hex_char(s.at(i)))
+ ++i;
+ } else if (is_octal_char(ch)) {
+ while (i < startPos + 4
+ && i < s.length()
+ && is_octal_char(s.at(i))) {
+ ++i;
+ }
+ } else { // single character escape sequence
+ i = qMin(i + 1, s.length());
+ }
+ return i - startPos;
+}
+
+int Generator::strreg(const char *s)
+{
+ int idx = 0;
+ if (!s)
+ s = "";
+ for (int i = 0; i < strings.size(); ++i) {
+ const QByteArray &str = strings.at(i);
+ if (str == s)
+ return idx;
+ idx += str.length() + 1;
+ for (int i = 0; i < str.length(); ++i) {
+ if (str.at(i) == '\\') {
+ int cnt = lengthOfEscapeSequence(str, i) - 1;
+ idx -= cnt;
+ i += cnt;
+ }
+ }
+ }
+ strings.append(s);
+ return idx;
+}
+
+void Generator::generateCode()
+{
+ bool isQt = (cdef->classname == "Qt");
+ bool isQObject = (cdef->classname == "QObject");
+ bool isConstructible = !cdef->constructorList.isEmpty();
+
+//
+// build the data array
+//
+ int i = 0;
+
+
+ // filter out undeclared enumerators and sets
+ {
+ QList<EnumDef> enumList;
+ for (i = 0; i < cdef->enumList.count(); ++i) {
+ EnumDef def = cdef->enumList.at(i);
+ if (cdef->enumDeclarations.contains(def.name)) {
+ enumList += def;
+ }
+ QByteArray alias = cdef->flagAliases.value(def.name);
+ if (cdef->enumDeclarations.contains(alias)) {
+ def.name = alias;
+ enumList += def;
+ }
+ }
+ cdef->enumList = enumList;
+ }
+
+
+ QByteArray qualifiedClassNameIdentifier = cdef->qualified;
+ qualifiedClassNameIdentifier.replace(':', '_');
+
+ int index = 12;
+ fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData());
+ fprintf(out, "\n // content:\n");
+ fprintf(out, " %4d, // revision\n", 2);
+ fprintf(out, " %4d, // classname\n", strreg(cdef->qualified));
+ fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0);
+ index += cdef->classInfoList.count() * 2;
+
+ int methodCount = cdef->signalList.count() + cdef->slotList.count() + cdef->methodList.count();
+ fprintf(out, " %4d, %4d, // methods\n", methodCount, methodCount ? index : 0);
+ index += methodCount * 5;
+ fprintf(out, " %4d, %4d, // properties\n", cdef->propertyList.count(), cdef->propertyList.count() ? index : 0);
+ index += cdef->propertyList.count() * 3;
+ if(cdef->notifyableProperties)
+ index += cdef->propertyList.count();
+ fprintf(out, " %4d, %4d, // enums/sets\n", cdef->enumList.count(), cdef->enumList.count() ? index : 0);
+
+ int enumsIndex = index;
+ for (i = 0; i < cdef->enumList.count(); ++i)
+ index += 4 + (cdef->enumList.at(i).values.count() * 2);
+ fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? cdef->constructorList.count() : 0,
+ isConstructible ? index : 0);
+
+//
+// Build classinfo array
+//
+ generateClassInfos();
+
+//
+// Build signals array first, otherwise the signal indices would be wrong
+//
+ generateFunctions(cdef->signalList, "signal", MethodSignal);
+
+//
+// Build slots array
+//
+ generateFunctions(cdef->slotList, "slot", MethodSlot);
+
+//
+// Build method array
+//
+ generateFunctions(cdef->methodList, "method", MethodMethod);
+
+
+//
+// Build property array
+//
+ generateProperties();
+
+//
+// Build enums array
+//
+ generateEnums(enumsIndex);
+
+//
+// Build constructors array
+//
+ if (isConstructible)
+ generateFunctions(cdef->constructorList, "constructor", MethodConstructor);
+
+//
+// Terminate data array
+//
+ fprintf(out, "\n 0 // eod\n};\n\n");
+
+//
+// Build stringdata array
+//
+ fprintf(out, "static const char qt_meta_stringdata_%s[] = {\n", qualifiedClassNameIdentifier.constData());
+ fprintf(out, " \"");
+ int col = 0;
+ int len = 0;
+ for (i = 0; i < strings.size(); ++i) {
+ QByteArray s = strings.at(i);
+ len = s.length();
+ if (col && col + len >= 72) {
+ fprintf(out, "\"\n \"");
+ col = 0;
+ } else if (len && s.at(0) >= '0' && s.at(0) <= '9') {
+ fprintf(out, "\"\"");
+ len += 2;
+ }
+ int idx = 0;
+ while (idx < s.length()) {
+ if (idx > 0) {
+ col = 0;
+ fprintf(out, "\"\n \"");
+ }
+ int spanLen = qMin(70, s.length() - idx);
+ // don't cut escape sequences at the end of a line
+ int backSlashPos = s.lastIndexOf('\\', idx + spanLen - 1);
+ if (backSlashPos >= idx) {
+ int escapeLen = lengthOfEscapeSequence(s, backSlashPos);
+ spanLen = qBound(spanLen, backSlashPos + escapeLen - idx, s.length() - idx);
+ }
+ fwrite(s.constData() + idx, 1, spanLen, out);
+ idx += spanLen;
+ col += spanLen;
+ }
+
+ fputs("\\0", out);
+ col += len + 2;
+ }
+ fprintf(out, "\"\n};\n\n");
+
+
+//
+// Generate internal qt_static_metacall() function
+//
+ if (isConstructible)
+ generateStaticMetacall(qualifiedClassNameIdentifier);
+
+//
+// Build extra array
+//
+ QList<QByteArray> extraList;
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ const PropertyDef &p = cdef->propertyList.at(i);
+ if (!isVariantType(p.type) && !metaTypes.contains(p.type)) {
+ int s = p.type.lastIndexOf("::");
+ if (s > 0) {
+ QByteArray scope = p.type.left(s);
+ if (scope != "Qt" && scope != cdef->classname && !extraList.contains(scope))
+ extraList += scope;
+ }
+ }
+ }
+ if (!extraList.isEmpty()) {
+ fprintf(out, "static const QMetaObject *qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData());
+ for (int i = 0; i < extraList.count(); ++i) {
+ if (i)
+ fprintf(out, ",\n ");
+ fprintf(out, " &%s::staticMetaObject", extraList.at(i).constData());
+ }
+ fprintf(out, ",0\n};\n\n");
+ }
+
+ if (isConstructible || !extraList.isEmpty()) {
+ fprintf(out, "static const QMetaObjectExtraData qt_meta_extradata2_%s = {\n ",
+ qualifiedClassNameIdentifier.constData());
+ if (extraList.isEmpty())
+ fprintf(out, "0, ");
+ else
+ fprintf(out, "qt_meta_extradata_%s, ", qualifiedClassNameIdentifier.constData());
+ if (!isConstructible)
+ fprintf(out, "0");
+ else
+ fprintf(out, "%s_qt_static_metacall", qualifiedClassNameIdentifier.constData());
+ fprintf(out, " \n};\n\n");
+ }
+
+//
+// Finally create and initialize the static meta object
+//
+
+ if (isQt)
+ fprintf(out, "const QMetaObject QObject::staticQtMetaObject = {\n");
+ else
+ fprintf(out, "const QMetaObject %s::staticMetaObject = {\n", cdef->qualified.constData());
+
+ if (isQObject)
+ fprintf(out, " { 0, ");
+ else if (cdef->superclassList.size())
+ fprintf(out, " { &%s::staticMetaObject, ", purestSuperClass.constData());
+ else
+ fprintf(out, " { 0, ");
+ fprintf(out, "qt_meta_stringdata_%s,\n qt_meta_data_%s, ",
+ qualifiedClassNameIdentifier.constData(), qualifiedClassNameIdentifier.constData());
+ if (!isConstructible && extraList.isEmpty())
+ fprintf(out, "0 }\n");
+ else
+ fprintf(out, "&qt_meta_extradata2_%s }\n", qualifiedClassNameIdentifier.constData());
+ fprintf(out, "};\n");
+
+ if (isQt || !cdef->hasQObject)
+ return;
+
+ fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return &staticMetaObject;\n}\n",
+ cdef->qualified.constData());
+//
+// Generate smart cast function
+//
+ fprintf(out, "\nvoid *%s::qt_metacast(const char *_clname)\n{\n", cdef->qualified.constData());
+ fprintf(out, " if (!_clname) return 0;\n");
+ fprintf(out, " if (!strcmp(_clname, qt_meta_stringdata_%s))\n"
+ " return static_cast<void*>(const_cast< %s*>(this));\n",
+ qualifiedClassNameIdentifier.constData(), cdef->classname.constData());
+ for (int i = 1; i < cdef->superclassList.size(); ++i) { // for all superclasses but the first one
+ if (cdef->superclassList.at(i).second == FunctionDef::Private)
+ continue;
+ const char *cname = cdef->superclassList.at(i).first;
+ fprintf(out, " if (!strcmp(_clname, \"%s\"))\n return static_cast< %s*>(const_cast< %s*>(this));\n",
+ cname, cname, cdef->classname.constData());
+ }
+ for (int i = 0; i < cdef->interfaceList.size(); ++i) {
+ const QList<ClassDef::Interface> &iface = cdef->interfaceList.at(i);
+ for (int j = 0; j < iface.size(); ++j) {
+ fprintf(out, " if (!strcmp(_clname, %s))\n return ", iface.at(j).interfaceId.constData());
+ for (int k = j; k >= 0; --k)
+ fprintf(out, "static_cast< %s*>(", iface.at(k).className.constData());
+ fprintf(out, "const_cast< %s*>(this)%s;\n",
+ cdef->classname.constData(), QByteArray(j+1, ')').constData());
+ }
+ }
+ if (!purestSuperClass.isEmpty() && !isQObject) {
+ QByteArray superClass = purestSuperClass;
+ // workaround for VC6
+ if (superClass.contains("::")) {
+ fprintf(out, " typedef %s QMocSuperClass;\n", superClass.constData());
+ superClass = "QMocSuperClass";
+ }
+ fprintf(out, " return %s::qt_metacast(_clname);\n", superClass.constData());
+ } else {
+ fprintf(out, " return 0;\n");
+ }
+ fprintf(out, "}\n");
+
+//
+// Generate internal qt_metacall() function
+//
+ generateMetacall();
+
+//
+// Generate internal signal functions
+//
+ for (int signalindex = 0; signalindex < cdef->signalList.size(); ++signalindex)
+ generateSignal(&cdef->signalList[signalindex], signalindex);
+}
+
+
+void Generator::generateClassInfos()
+{
+ if (cdef->classInfoList.isEmpty())
+ return;
+
+ fprintf(out, "\n // classinfo: key, value\n");
+
+ for (int i = 0; i < cdef->classInfoList.size(); ++i) {
+ const ClassInfoDef &c = cdef->classInfoList.at(i);
+ fprintf(out, " %4d, %4d,\n", strreg(c.name), strreg(c.value));
+ }
+}
+
+void Generator::generateFunctions(QList<FunctionDef>& list, const char *functype, int type)
+{
+ if (list.isEmpty())
+ return;
+ fprintf(out, "\n // %ss: signature, parameters, type, tag, flags\n", functype);
+
+ for (int i = 0; i < list.count(); ++i) {
+ const FunctionDef &f = list.at(i);
+
+ QByteArray sig = f.name + '(';
+ QByteArray arguments;
+
+ for (int j = 0; j < f.arguments.count(); ++j) {
+ const ArgumentDef &a = f.arguments.at(j);
+ if (j) {
+ sig += ",";
+ arguments += ",";
+ }
+ sig += a.normalizedType;
+ arguments += a.name;
+ }
+ sig += ')';
+
+ char flags = type;
+ if (f.access == FunctionDef::Private)
+ flags |= AccessPrivate;
+ else if (f.access == FunctionDef::Public)
+ flags |= AccessPublic;
+ else if (f.access == FunctionDef::Protected)
+ flags |= AccessProtected;
+ if (f.access == FunctionDef::Private)
+ flags |= AccessPrivate;
+ else if (f.access == FunctionDef::Public)
+ flags |= AccessPublic;
+ else if (f.access == FunctionDef::Protected)
+ flags |= AccessProtected;
+ if (f.isCompat)
+ flags |= MethodCompatibility;
+ if (f.wasCloned)
+ flags |= MethodCloned;
+ if (f.isScriptable)
+ flags |= MethodScriptable;
+ fprintf(out, " %4d, %4d, %4d, %4d, 0x%02x,\n", strreg(sig),
+ strreg(arguments), strreg(f.normalizedType), strreg(f.tag), flags);
+ }
+}
+
+void Generator::generateProperties()
+{
+ //
+ // specify get function, for compatibiliy we accept functions
+ // returning pointers, or const char * for QByteArray.
+ //
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ PropertyDef &p = cdef->propertyList[i];
+ if (p.read.isEmpty())
+ continue;
+ for (int j = 0; j < cdef->publicList.count(); ++j) {
+ const FunctionDef &f = cdef->publicList.at(j);
+ if (f.name != p.read)
+ continue;
+ if (!f.isConst) // get functions must be const
+ continue;
+ if (f.arguments.size()) // and must not take any arguments
+ continue;
+ PropertyDef::Specification spec = PropertyDef::ValueSpec;
+ QByteArray tmp = f.normalizedType;
+ if (p.type == "QByteArray" && tmp == "const char *")
+ tmp = "QByteArray";
+ if (tmp.left(6) == "const ")
+ tmp = tmp.mid(6);
+ if (p.type != tmp && tmp.endsWith('*')) {
+ tmp.chop(1);
+ spec = PropertyDef::PointerSpec;
+ } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
+ spec = PropertyDef::ReferenceSpec;
+ }
+ if (p.type != tmp)
+ continue;
+ p.gspec = spec;
+ break;
+ }
+ if(!p.notify.isEmpty()) {
+ int notifyId = -1;
+ for (int j = 0; j < cdef->signalList.count(); ++j) {
+ const FunctionDef &f = cdef->signalList.at(j);
+ if(f.name != p.notify) {
+ continue;
+ } else {
+ notifyId = j /* Signal indexes start from 0 */;
+ break;
+ }
+ }
+ p.notifyId = notifyId;
+ }
+ }
+
+ //
+ // Create meta data
+ //
+
+ if (cdef->propertyList.count())
+ fprintf(out, "\n // properties: name, type, flags\n");
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ const PropertyDef &p = cdef->propertyList.at(i);
+ uint flags = Invalid;
+ if (!isVariantType(p.type)) {
+ flags |= EnumOrFlag;
+ } else {
+ flags |= qvariant_nameToType(p.type) << 24;
+ }
+ if (!p.read.isEmpty())
+ flags |= Readable;
+ if (!p.write.isEmpty()) {
+ flags |= Writable;
+ if (p.stdCppSet())
+ flags |= StdCppSet;
+ }
+ if (!p.reset.isEmpty())
+ flags |= Resettable;
+
+// if (p.override)
+// flags |= Override;
+
+ if (p.designable.isEmpty())
+ flags |= ResolveDesignable;
+ else if (p.designable != "false")
+ flags |= Designable;
+
+ if (p.scriptable.isEmpty())
+ flags |= ResolveScriptable;
+ else if (p.scriptable != "false")
+ flags |= Scriptable;
+
+ if (p.stored.isEmpty())
+ flags |= ResolveStored;
+ else if (p.stored != "false")
+ flags |= Stored;
+
+ if (p.editable.isEmpty())
+ flags |= ResolveEditable;
+ else if (p.editable != "false")
+ flags |= Editable;
+
+ if (p.user.isEmpty())
+ flags |= ResolveUser;
+ else if (p.user != "false")
+ flags |= User;
+
+ if (p.notifyId != -1)
+ flags |= Notify;
+
+ fprintf(out, " %4d, %4d, 0x%.8x,\n",
+ strreg(p.name),
+ strreg(p.type),
+ flags);
+ }
+
+ if(cdef->notifyableProperties) {
+ fprintf(out, "\n // properties: notify_signal_id\n");
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ const PropertyDef &p = cdef->propertyList.at(i);
+ if(p.notifyId == -1)
+ fprintf(out, " %4d,\n",
+ 0);
+ else
+ fprintf(out, " %4d,\n",
+ p.notifyId);
+ }
+ }
+}
+
+void Generator::generateEnums(int index)
+{
+ if (cdef->enumDeclarations.isEmpty())
+ return;
+
+ fprintf(out, "\n // enums: name, flags, count, data\n");
+ index += 4 * cdef->enumList.count();
+ int i;
+ for (i = 0; i < cdef->enumList.count(); ++i) {
+ const EnumDef &e = cdef->enumList.at(i);
+ fprintf(out, " %4d, 0x%.1x, %4d, %4d,\n",
+ strreg(e.name),
+ cdef->enumDeclarations.value(e.name) ? 1 : 0,
+ e.values.count(),
+ index);
+ index += e.values.count() * 2;
+ }
+
+ fprintf(out, "\n // enum data: key, value\n");
+ for (i = 0; i < cdef->enumList.count(); ++i) {
+ const EnumDef &e = cdef->enumList.at(i);
+ for (int j = 0; j < e.values.count(); ++j) {
+ const QByteArray &val = e.values.at(j);
+ fprintf(out, " %4d, uint(%s::%s),\n",
+ strreg(val),
+ cdef->qualified.constData(),
+ val.constData());
+ }
+ }
+}
+
+void Generator::generateMetacall()
+{
+ bool isQObject = (cdef->classname == "QObject");
+
+ fprintf(out, "\nint %s::qt_metacall(QMetaObject::Call _c, int _id, void **_a)\n{\n",
+ cdef->qualified.constData());
+
+ if (!purestSuperClass.isEmpty() && !isQObject) {
+ QByteArray superClass = purestSuperClass;
+ // workaround for VC6
+ if (superClass.contains("::")) {
+ fprintf(out, " typedef %s QMocSuperClass;\n", superClass.constData());
+ superClass = "QMocSuperClass";
+ }
+ fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData());
+ }
+
+ fprintf(out, " if (_id < 0)\n return _id;\n");
+ fprintf(out, " ");
+
+ bool needElse = false;
+ QList<FunctionDef> methodList;
+ methodList += cdef->signalList;
+ methodList += cdef->slotList;
+ methodList += cdef->methodList;
+
+ if (methodList.size()) {
+ needElse = true;
+ fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n ");
+ fprintf(out, "switch (_id) {\n");
+ for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
+ const FunctionDef &f = methodList.at(methodindex);
+ fprintf(out, " case %d: ", methodindex);
+ if (f.normalizedType.size())
+ fprintf(out, "{ %s _r = ", noRef(f.normalizedType).constData());
+ if (f.inPrivateClass.size())
+ fprintf(out, "%s->", f.inPrivateClass.constData());
+ fprintf(out, "%s(", f.name.constData());
+ int offset = 1;
+ for (int j = 0; j < f.arguments.count(); ++j) {
+ const ArgumentDef &a = f.arguments.at(j);
+ if (j)
+ fprintf(out, ",");
+ fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))",a.typeNameForCast.constData(), offset++);
+ }
+ fprintf(out, ");");
+ if (f.normalizedType.size())
+ fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = _r; } ",
+ noRef(f.normalizedType).constData());
+ fprintf(out, " break;\n");
+ }
+ fprintf(out, " default: ;\n");
+ fprintf(out, " }\n");
+ }
+ if (methodList.size())
+ fprintf(out, " _id -= %d;\n }", methodList.size());
+
+ if (cdef->propertyList.size()) {
+ bool needGet = false;
+ bool needTempVarForGet = false;
+ bool needSet = false;
+ bool needReset = false;
+ bool needDesignable = false;
+ bool needScriptable = false;
+ bool needStored = false;
+ bool needEditable = false;
+ bool needUser = false;
+ for (int i = 0; i < cdef->propertyList.size(); ++i) {
+ const PropertyDef &p = cdef->propertyList.at(i);
+ needGet |= !p.read.isEmpty();
+ if (!p.read.isEmpty())
+ needTempVarForGet |= (p.gspec != PropertyDef::PointerSpec
+ && p.gspec != PropertyDef::ReferenceSpec);
+
+ needSet |= !p.write.isEmpty();
+ needReset |= !p.reset.isEmpty();
+ needDesignable |= p.designable.endsWith(')');
+ needScriptable |= p.scriptable.endsWith(')');
+ needStored |= p.stored.endsWith(')');
+ needEditable |= p.editable.endsWith(')');
+ needUser |= p.user.endsWith(')');
+ }
+ bool needAnything = needGet
+ | needSet
+ | needReset
+ | needDesignable
+ | needScriptable
+ | needStored
+ | needEditable
+ | needUser;
+ if (!needAnything)
+ goto skip_properties;
+ fprintf(out, "\n#ifndef QT_NO_PROPERTIES\n ");
+
+ if (needElse)
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::ReadProperty) {\n");
+ if (needGet) {
+ if (needTempVarForGet)
+ fprintf(out, " void *_v = _a[0];\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (p.read.isEmpty())
+ continue;
+ if (p.gspec == PropertyDef::PointerSpec)
+ fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s())); break;\n",
+ propindex, p.read.constData());
+ else if (p.gspec == PropertyDef::ReferenceSpec)
+ fprintf(out, " case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s())); break;\n",
+ propindex, p.read.constData());
+ else if (cdef->enumDeclarations.value(p.type, false))
+ fprintf(out, " case %d: *reinterpret_cast<int*>(_v) = QFlag(%s()); break;\n",
+ propindex, p.read.constData());
+ else
+ fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s(); break;\n",
+ propindex, p.type.constData(), p.read.constData());
+ }
+ fprintf(out, " }\n");
+ }
+
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::WriteProperty) {\n");
+
+ if (needSet) {
+ fprintf(out, " void *_v = _a[0];\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (p.write.isEmpty())
+ continue;
+ if (cdef->enumDeclarations.value(p.type, false)) {
+ fprintf(out, " case %d: %s(QFlag(*reinterpret_cast<int*>(_v))); break;\n",
+ propindex, p.write.constData());
+ } else {
+ fprintf(out, " case %d: %s(*reinterpret_cast< %s*>(_v)); break;\n",
+ propindex, p.write.constData(), p.type.constData());
+ }
+ }
+ fprintf(out, " }\n");
+ }
+
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::ResetProperty) {\n");
+ if (needReset) {
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (!p.reset.endsWith(')'))
+ continue;
+ fprintf(out, " case %d: %s; break;\n",
+ propindex, p.reset.constData());
+ }
+ fprintf(out, " }\n");
+ }
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::QueryPropertyDesignable) {\n");
+ if (needDesignable) {
+ fprintf(out, " bool *_b = reinterpret_cast<bool*>(_a[0]);\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (!p.designable.endsWith(')'))
+ continue;
+ fprintf(out, " case %d: *_b = %s; break;\n",
+ propindex, p.designable.constData());
+ }
+ fprintf(out, " }\n");
+ }
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::QueryPropertyScriptable) {\n");
+ if (needScriptable) {
+ fprintf(out, " bool *_b = reinterpret_cast<bool*>(_a[0]);\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (!p.scriptable.endsWith(')'))
+ continue;
+ fprintf(out, " case %d: *_b = %s; break;\n",
+ propindex, p.scriptable.constData());
+ }
+ fprintf(out, " }\n");
+ }
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::QueryPropertyStored) {\n");
+ if (needStored) {
+ fprintf(out, " bool *_b = reinterpret_cast<bool*>(_a[0]);\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (!p.stored.endsWith(')'))
+ continue;
+ fprintf(out, " case %d: *_b = %s; break;\n",
+ propindex, p.stored.constData());
+ }
+ fprintf(out, " }\n");
+ }
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::QueryPropertyEditable) {\n");
+ if (needEditable) {
+ fprintf(out, " bool *_b = reinterpret_cast<bool*>(_a[0]);\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (!p.editable.endsWith(')'))
+ continue;
+ fprintf(out, " case %d: *_b = %s; break;\n",
+ propindex, p.editable.constData());
+ }
+ fprintf(out, " }\n");
+ }
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+
+ fprintf(out, " else ");
+ fprintf(out, "if (_c == QMetaObject::QueryPropertyUser) {\n");
+ if (needUser) {
+ fprintf(out, " bool *_b = reinterpret_cast<bool*>(_a[0]);\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
+ const PropertyDef &p = cdef->propertyList.at(propindex);
+ if (!p.user.endsWith(')'))
+ continue;
+ fprintf(out, " case %d: *_b = %s; break;\n",
+ propindex, p.user.constData());
+ }
+ fprintf(out, " }\n");
+ }
+ fprintf(out,
+ " _id -= %d;\n"
+ " }", cdef->propertyList.count());
+
+
+ fprintf(out, "\n#endif // QT_NO_PROPERTIES");
+ }
+ skip_properties:
+ if (methodList.size() || cdef->signalList.size() || cdef->propertyList.size())
+ fprintf(out, "\n ");
+ fprintf(out,"return _id;\n}\n");
+}
+
+void Generator::generateStaticMetacall(const QByteArray &prefix)
+{
+ bool isQObject = (cdef->classname == "QObject");
+
+ fprintf(out, "static int %s_qt_static_metacall(QMetaObject::Call _c, int _id, void **_a)\n{\n",
+ prefix.constData());
+
+ fprintf(out, " if (_c == QMetaObject::CreateInstance) {\n");
+ fprintf(out, " switch (_id) {\n");
+ for (int ctorindex = 0; ctorindex < cdef->constructorList.count(); ++ctorindex) {
+ fprintf(out, " case %d: { %s *_r = new %s(", ctorindex,
+ cdef->classname.constData(), cdef->classname.constData());
+ const FunctionDef &f = cdef->constructorList.at(ctorindex);
+ int offset = 1;
+ for (int j = 0; j < f.arguments.count(); ++j) {
+ const ArgumentDef &a = f.arguments.at(j);
+ if (j)
+ fprintf(out, ",");
+ fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))", a.typeNameForCast.constData(), offset++);
+ }
+ fprintf(out, ");\n");
+ fprintf(out, " if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break;\n");
+ }
+ fprintf(out, " }\n");
+ fprintf(out, " _id -= %d;\n", cdef->constructorList.count());
+ fprintf(out, " return _id;\n");
+ fprintf(out, " }\n");
+
+ if (!isQObject)
+ fprintf(out, " _id = %s::staticMetaObject.superClass()->static_metacall(_c, _id, _a);\n", cdef->classname.constData());
+
+ fprintf(out, " if (_id < 0)\n return _id;\n");
+
+ fprintf(out, " return _id;\n");
+ fprintf(out, "}\n\n");
+}
+
+void Generator::generateSignal(FunctionDef *def,int index)
+{
+ if (def->wasCloned || def->isAbstract)
+ return;
+ fprintf(out, "\n// SIGNAL %d\n%s %s::%s(",
+ index, def->type.name.constData(), cdef->qualified.constData(), def->name.constData());
+
+ QByteArray thisPtr = "this";
+ const char *constQualifier = "";
+
+ if (def->isConst) {
+ thisPtr = "const_cast< ";
+ thisPtr += cdef->qualified;
+ thisPtr += " *>(this)";
+ constQualifier = "const";
+ }
+
+ if (def->arguments.isEmpty() && def->normalizedType.isEmpty()) {
+ fprintf(out, ")%s\n{\n"
+ " QMetaObject::activate(%s, &staticMetaObject, %d, 0);\n"
+ "}\n", constQualifier, thisPtr.constData(), index);
+ return;
+ }
+
+ int offset = 1;
+ for (int j = 0; j < def->arguments.count(); ++j) {
+ const ArgumentDef &a = def->arguments.at(j);
+ if (j)
+ fprintf(out, ", ");
+ fprintf(out, "%s _t%d%s", a.type.name.constData(), offset++, a.rightType.constData());
+ }
+ fprintf(out, ")%s\n{\n", constQualifier);
+ if (def->type.name.size() && def->normalizedType.size())
+ fprintf(out, " %s _t0;\n", noRef(def->normalizedType).constData());
+
+ fprintf(out, " void *_a[] = { ");
+ if (def->normalizedType.isEmpty()) {
+ fprintf(out, "0");
+ } else {
+ if (def->returnTypeIsVolatile)
+ fprintf(out, "const_cast<void*>(reinterpret_cast<const volatile void*>(&_t0))");
+ else
+ fprintf(out, "const_cast<void*>(reinterpret_cast<const void*>(&_t0))");
+ }
+ int i;
+ for (i = 1; i < offset; ++i)
+ if (def->arguments.at(i - 1).type.isVolatile)
+ fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(&_t%d))", i);
+ else
+ fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(&_t%d))", i);
+ fprintf(out, " };\n");
+ int n = 0;
+ for (i = 0; i < def->arguments.count(); ++i)
+ if (def->arguments.at(i).isDefault)
+ ++n;
+ if (n)
+ fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, %d, _a);\n", thisPtr.constData(), index, index + n);
+ else
+ fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index);
+ if (def->normalizedType.size())
+ fprintf(out, " return _t0;\n");
+ fprintf(out, "}\n");
+}
+
+//
+// Functions used when generating QMetaObject directly
+//
+// Much of this code is copied from the corresponding
+// C++ code-generating functions; we can change the
+// two generators so that more of the code is shared.
+// The key difference from the C++ code generator is
+// that instead of calling fprintf(), we append bytes
+// to a buffer.
+//
+
+QMetaObject *Generator::generateMetaObject(bool ignoreProperties)
+{
+//
+// build the data array
+//
+
+ // filter out undeclared enumerators and sets
+ {
+ QList<EnumDef> enumList;
+ for (int i = 0; i < cdef->enumList.count(); ++i) {
+ EnumDef def = cdef->enumList.at(i);
+ if (cdef->enumDeclarations.contains(def.name)) {
+ enumList += def;
+ }
+ QByteArray alias = cdef->flagAliases.value(def.name);
+ if (cdef->enumDeclarations.contains(alias)) {
+ def.name = alias;
+ enumList += def;
+ }
+ }
+ cdef->enumList = enumList;
+ }
+
+ int index = 10;
+ meta_data
+ << 1 // revision
+ << strreg(cdef->qualified) // classname
+ << cdef->classInfoList.count() << (cdef->classInfoList.count() ? index : 0) // classinfo
+ ;
+ index += cdef->classInfoList.count() * 2;
+
+ int methodCount = cdef->signalList.count() + cdef->slotList.count() + cdef->methodList.count();
+ meta_data << methodCount << (methodCount ? index : 0); // methods
+ index += methodCount * 5;
+ if (!ignoreProperties) {
+ meta_data << cdef->propertyList.count() << (cdef->propertyList.count() ? index : 0); // properties
+ index += cdef->propertyList.count() * 3;
+ } else {
+ meta_data << 0 << 0; // properties
+ }
+ meta_data << cdef->enumList.count() << (cdef->enumList.count() ? index : 0); // enums/sets
+
+//
+// Build classinfo array
+//
+ _generateClassInfos();
+
+//
+// Build signals array first, otherwise the signal indices would be wrong
+//
+ _generateFunctions(cdef->signalList, MethodSignal);
+
+//
+// Build slots array
+//
+ _generateFunctions(cdef->slotList, MethodSlot);
+
+//
+// Build method array
+//
+ _generateFunctions(cdef->methodList, MethodMethod);
+
+
+//
+// Build property array
+//
+ if (!ignoreProperties)
+ _generateProperties();
+
+//
+// Build enums array
+//
+ _generateEnums(index);
+
+//
+// Terminate data array
+//
+ meta_data << 0;
+
+//
+// Build stringdata array
+//
+ QVector<char> string_data;
+ for (int i = 0; i < strings.size(); ++i) {
+ const char *s = strings.at(i).constData();
+ char c;
+ do {
+ c = *(s++);
+ string_data << c;
+ } while (c != '\0');
+ }
+
+//
+// Finally create and initialize the static meta object
+//
+ const int meta_object_offset = 0;
+ const int meta_object_size = sizeof(QMetaObject);
+ const int meta_data_offset = meta_object_offset + meta_object_size;
+ const int meta_data_size = meta_data.count() * sizeof(uint);
+ const int string_data_offset = meta_data_offset + meta_data_size;
+ const int string_data_size = string_data.count();
+ const int total_size = string_data_offset + string_data_size;
+
+ char *blob = new char[total_size];
+
+ char *string_data_output = blob + string_data_offset;
+ const char *string_data_src = string_data.constData();
+ for (int i = 0; i < string_data.count(); ++i)
+ string_data_output[i] = string_data_src[i];
+
+ uint *meta_data_output = reinterpret_cast<uint *>(blob + meta_data_offset);
+ const uint *meta_data_src = meta_data.constData();
+ for (int i = 0; i < meta_data.count(); ++i)
+ meta_data_output[i] = meta_data_src[i];
+
+ QMetaObject *meta_object = new (blob + meta_object_offset)QMetaObject;
+ meta_object->d.superdata = 0;
+ meta_object->d.stringdata = string_data_output;
+ meta_object->d.data = meta_data_output;
+ meta_object->d.extradata = 0;
+ return meta_object;
+}
+
+void Generator::_generateClassInfos()
+{
+ for (int i = 0; i < cdef->classInfoList.size(); ++i) {
+ const ClassInfoDef &c = cdef->classInfoList.at(i);
+ meta_data << strreg(c.name) << strreg(c.value);
+ }
+}
+
+void Generator::_generateFunctions(QList<FunctionDef> &list, int type)
+{
+ for (int i = 0; i < list.count(); ++i) {
+ const FunctionDef &f = list.at(i);
+
+ QByteArray sig = f.name + '(';
+ QByteArray arguments;
+
+ for (int j = 0; j < f.arguments.count(); ++j) {
+ const ArgumentDef &a = f.arguments.at(j);
+ if (j) {
+ sig += ",";
+ arguments += ",";
+ }
+ sig += a.normalizedType;
+ arguments += a.name;
+ }
+ sig += ')';
+
+ char flags = type;
+ if (f.access == FunctionDef::Private)
+ flags |= AccessPrivate;
+ else if (f.access == FunctionDef::Public)
+ flags |= AccessPublic;
+ else if (f.access == FunctionDef::Protected)
+ flags |= AccessProtected;
+ if (f.access == FunctionDef::Private)
+ flags |= AccessPrivate;
+ else if (f.access == FunctionDef::Public)
+ flags |= AccessPublic;
+ else if (f.access == FunctionDef::Protected)
+ flags |= AccessProtected;
+ if (f.isCompat)
+ flags |= MethodCompatibility;
+ if (f.wasCloned)
+ flags |= MethodCloned;
+ if (f.isScriptable)
+ flags |= MethodScriptable;
+
+ meta_data << strreg(sig)
+ << strreg(arguments)
+ << strreg(f.normalizedType)
+ << strreg(f.tag)
+ << flags;
+ }
+}
+
+void Generator::_generateEnums(int index)
+{
+ index += 4 * cdef->enumList.count();
+ int i;
+ for (i = 0; i < cdef->enumList.count(); ++i) {
+ const EnumDef &e = cdef->enumList.at(i);
+ meta_data << strreg(e.name) << (cdef->enumDeclarations.value(e.name) ? 1 : 0)
+ << e.values.count() << index;
+ index += e.values.count() * 2;
+ }
+
+ for (i = 0; i < cdef->enumList.count(); ++i) {
+ const EnumDef &e = cdef->enumList.at(i);
+ for (int j = 0; j < e.values.count(); ++j) {
+ const QByteArray &val = e.values.at(j);
+ meta_data << strreg(val) << 0; // we don't know the value itself
+ }
+ }
+}
+
+void Generator::_generateProperties()
+{
+ //
+ // specify get function, for compatibiliy we accept functions
+ // returning pointers, or const char * for QByteArray.
+ //
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ PropertyDef &p = cdef->propertyList[i];
+ if (p.read.isEmpty())
+ continue;
+ for (int j = 0; j < cdef->publicList.count(); ++j) {
+ const FunctionDef &f = cdef->publicList.at(j);
+ if (f.name != p.read)
+ continue;
+ if (!f.isConst) // get functions must be const
+ continue;
+ if (f.arguments.size()) // and must not take any arguments
+ continue;
+ PropertyDef::Specification spec = PropertyDef::ValueSpec;
+ QByteArray tmp = f.normalizedType;
+ if (p.type == "QByteArray" && tmp == "const char *")
+ tmp = "QByteArray";
+ if (tmp.left(6) == "const ")
+ tmp = tmp.mid(6);
+ if (p.type != tmp && tmp.endsWith('*')) {
+ tmp.chop(1);
+ spec = PropertyDef::PointerSpec;
+ } else if (f.type.name.endsWith('&')) { // raw type, not normalized type
+ spec = PropertyDef::ReferenceSpec;
+ }
+ if (p.type != tmp)
+ continue;
+ p.gspec = spec;
+ break;
+ }
+ }
+
+
+ //
+ // Create meta data
+ //
+
+ for (int i = 0; i < cdef->propertyList.count(); ++i) {
+ const PropertyDef &p = cdef->propertyList.at(i);
+ uint flags = Invalid;
+ if (!isVariantType(p.type)) {
+ flags |= EnumOrFlag;
+ } else {
+ flags |= qvariant_nameToType(p.type) << 24;
+ }
+ if (!p.read.isEmpty())
+ flags |= Readable;
+ if (!p.write.isEmpty()) {
+ flags |= Writable;
+ if (p.stdCppSet())
+ flags |= StdCppSet;
+ }
+ if (!p.reset.isEmpty())
+ flags |= Resettable;
+
+// if (p.override)
+// flags |= Override;
+
+ if (p.designable.isEmpty())
+ flags |= ResolveDesignable;
+ else if (p.designable != "false")
+ flags |= Designable;
+
+ if (p.scriptable.isEmpty())
+ flags |= ResolveScriptable;
+ else if (p.scriptable != "false")
+ flags |= Scriptable;
+
+ if (p.stored.isEmpty())
+ flags |= ResolveStored;
+ else if (p.stored != "false")
+ flags |= Stored;
+
+ if (p.editable.isEmpty())
+ flags |= ResolveEditable;
+ else if (p.editable != "false")
+ flags |= Editable;
+
+ if (p.user.isEmpty())
+ flags |= ResolveUser;
+ else if (p.user != "false")
+ flags |= User;
+
+ meta_data << strreg(p.name) << strreg(p.type) << flags;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/moc/generator.h b/src/tools/moc/generator.h
new file mode 100644
index 0000000..d64eddb
--- /dev/null
+++ b/src/tools/moc/generator.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GENERATOR_H
+#define GENERATOR_H
+
+#include "moc.h"
+
+QT_BEGIN_NAMESPACE
+
+class Generator
+{
+ FILE *out;
+ ClassDef *cdef;
+ QVector<uint> meta_data;
+public:
+ Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, FILE *outfile = 0);
+ void generateCode();
+ QMetaObject *generateMetaObject(bool ignoreProperties);
+private:
+ void generateClassInfos();
+ void generateFunctions(QList<FunctionDef> &list, const char *functype, int type);
+ void generateEnums(int index);
+ void generateProperties();
+ void generateMetacall();
+ void generateStaticMetacall(const QByteArray &prefix);
+ void generateSignal(FunctionDef *def, int index);
+
+ // used by binary QMetaObject generator
+ void _generateClassInfos();
+ void _generateFunctions(QList<FunctionDef> &list, int type);
+ void _generateEnums(int index);
+ void _generateProperties();
+
+ int strreg(const char *); // registers a string and returns its id
+ QList<QByteArray> strings;
+ QByteArray purestSuperClass;
+ QList<QByteArray> metaTypes;
+};
+
+QT_END_NAMESPACE
+
+#endif // GENERATOR_H
diff --git a/src/tools/moc/keywords.cpp b/src/tools/moc/keywords.cpp
new file mode 100644
index 0000000..2a4fbf9
--- /dev/null
+++ b/src/tools/moc/keywords.cpp
@@ -0,0 +1,979 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// auto generated
+// DO NOT EDIT.
+
+static const short keyword_trans[][128] = {
+ {0,0,0,0,0,0,0,0,0,525,522,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 525,252,523,526,0,38,239,524,25,26,236,234,30,235,27,237,
+ 22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43,
+ 0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+ 8,21,8,8,8,8,8,8,8,8,8,31,527,32,238,8,
+ 0,1,2,3,4,5,6,7,8,9,8,8,10,11,12,13,
+ 14,8,15,16,17,18,19,20,8,8,8,36,245,37,248,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,192,0,173,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,240,0,0,0,0,0,287,
+ 0,0,341,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,109,0,0,0,0,0,0,280,0,0,0,121,0,0,80,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,229,0,0,0,0,0,0,0,0,0,312,
+ 0,0,0,0,0,0,0,0,0,44,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,327,0,133,0,
+ 0,0,0,0,0,0,0,0,168,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,308,0,0,339,
+ 0,0,116,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,326,0,0,0,0,0,0,0,198,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,125,0,0,0,227,0,0,0,0,0,0,0,0,0,253,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,150,0,0,163,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,290,222,0,0,461,0,0,0,
+ 0,0,0,0,55,0,0,330,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,97,0,0,94,0,0,0,0,0,0,0,
+ 0,0,107,0,0,0,0,0,0,89,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,140,0,
+ 0,0,0,194,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,144,0,0,0,0,0,208,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,283,0,0,0,0,335,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,485,0,0,0,0,0,0,0,0,0,0,357,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,36,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,33,0,263,272,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,273,264,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,42,0,0,0,28,0,
+ 530,530,530,530,530,530,530,530,530,530,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,40,0,0,0,32,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,259,37,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,136,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,176,0,66,0,0,0,0,0,0,
+ 0,0,0,0,353,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,249,81,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,82,345,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,113,0,0,0,0,92,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,95,0,0,0,0,0,0,
+ 0,0,104,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,319,110,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,141,0,0,0,0,0,0,
+ 0,0,0,302,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,151,0,0,0,0,0,156,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 169,0,0,0,182,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,203,0,0,170,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,199,0,0,0,
+ 0,0,0,0,294,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,317,0,0,209,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,298,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,223,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,321,0,0,0,0,0,230,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,276,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,277,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,256,278,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,529,0,0,0,0,528,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,258,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,274,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,261,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,242,0,0,0,0,0,0,0,0,0,0,0,0,0,246,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,262,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,275,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,458,0,0,0,300,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,439,388,378,383,364,0,448,0,0,0,0,0,358,
+ 370,0,0,436,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,475,0,0,0,0,0,372,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,418,396,0,0,401,0,0,0,410,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,513,0,437,0,0,0,465,0,0,471,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,450,0,506,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,497,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,486,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+};
+
+static const struct
+{
+ Token token;
+ short next;
+ char defchar;
+ short defnext;
+ Token ident;
+} keywords[] = {
+ {NOTOKEN, 0, 0, 0, NOTOKEN},
+ {CHARACTER, 1, 0, 0, NOTOKEN},
+ {CHARACTER, 2, 0, 0, NOTOKEN},
+ {CHARACTER, 3, 0, 0, NOTOKEN},
+ {CHARACTER, 4, 0, 0, NOTOKEN},
+ {CHARACTER, 5, 0, 0, NOTOKEN},
+ {CHARACTER, 6, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 111, 350, NOTOKEN},
+ {CHARACTER, 0, 0, 0, NOTOKEN},
+ {CHARACTER, 7, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 111, 295, NOTOKEN},
+ {CHARACTER, 0, 117, 186, NOTOKEN},
+ {CHARACTER, 8, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 112, 215, NOTOKEN},
+ {CHARACTER, 9, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 101, 65, NOTOKEN},
+ {CHARACTER, 10, 0, 0, NOTOKEN},
+ {CHARACTER, 11, 0, 0, NOTOKEN},
+ {CHARACTER, 12, 0, 0, NOTOKEN},
+ {CHARACTER, 13, 0, 0, NOTOKEN},
+ {CHARACTER, 14, 0, 0, NOTOKEN},
+ {CHARACTER, 15, 0, 0, NOTOKEN},
+ {DIGIT, 0, 0, 0, NOTOKEN},
+ {LANGLE, 16, 0, 0, NOTOKEN},
+ {RANGLE, 17, 0, 0, NOTOKEN},
+ {LPAREN, 0, 0, 0, NOTOKEN},
+ {RPAREN, 0, 0, 0, NOTOKEN},
+ {DOT, 18, 0, 0, NOTOKEN},
+ {INCOMPLETE, 0, 46, 29, NOTOKEN},
+ {ELIPSIS, 0, 0, 0, NOTOKEN},
+ {COMMA, 0, 0, 0, NOTOKEN},
+ {LBRACK, 0, 0, 0, NOTOKEN},
+ {RBRACK, 0, 0, 0, NOTOKEN},
+ {LBRACK, 0, 58, 35, NOTOKEN},
+ {COLON, 19, 0, 0, NOTOKEN},
+ {LANGLE_SCOPE, 0, 0, 0, NOTOKEN},
+ {LBRACE, 0, 0, 0, NOTOKEN},
+ {RBRACE, 0, 0, 0, NOTOKEN},
+ {PERCENT, 20, 0, 0, NOTOKEN},
+ {EQ, 0, 61, 267, NOTOKEN},
+ {SCOPE, 0, 0, 0, NOTOKEN},
+ {SEMIC, 0, 0, 0, NOTOKEN},
+ {DOTSTAR, 0, 0, 0, NOTOKEN},
+ {QUESTION, 0, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 110, 45, CHARACTER},
+ {CHARACTER, 0, 97, 46, CHARACTER},
+ {CHARACTER, 0, 109, 47, CHARACTER},
+ {CHARACTER, 0, 105, 48, CHARACTER},
+ {CHARACTER, 0, 99, 49, CHARACTER},
+ {CHARACTER, 0, 95, 50, CHARACTER},
+ {CHARACTER, 0, 99, 51, CHARACTER},
+ {CHARACTER, 0, 97, 52, CHARACTER},
+ {CHARACTER, 0, 115, 53, CHARACTER},
+ {CHARACTER, 0, 116, 54, CHARACTER},
+ {DYNAMIC_CAST, 0, 0, 0, CHARACTER},
+ {CHARACTER, 21, 0, 0, CHARACTER},
+ {CHARACTER, 0, 116, 57, CHARACTER},
+ {CHARACTER, 0, 105, 58, CHARACTER},
+ {CHARACTER, 0, 99, 59, CHARACTER},
+ {STATIC, 0, 95, 60, CHARACTER},
+ {CHARACTER, 0, 99, 61, CHARACTER},
+ {CHARACTER, 0, 97, 62, CHARACTER},
+ {CHARACTER, 0, 115, 63, CHARACTER},
+ {CHARACTER, 0, 116, 64, CHARACTER},
+ {STATIC_CAST, 0, 0, 0, CHARACTER},
+ {CHARACTER, 22, 0, 0, CHARACTER},
+ {CHARACTER, 0, 110, 67, CHARACTER},
+ {CHARACTER, 0, 116, 68, CHARACTER},
+ {CHARACTER, 0, 101, 69, CHARACTER},
+ {CHARACTER, 0, 114, 70, CHARACTER},
+ {CHARACTER, 0, 112, 71, CHARACTER},
+ {CHARACTER, 0, 114, 72, CHARACTER},
+ {CHARACTER, 0, 101, 73, CHARACTER},
+ {CHARACTER, 0, 116, 74, CHARACTER},
+ {CHARACTER, 0, 95, 75, CHARACTER},
+ {CHARACTER, 0, 99, 76, CHARACTER},
+ {CHARACTER, 0, 97, 77, CHARACTER},
+ {CHARACTER, 0, 115, 78, CHARACTER},
+ {CHARACTER, 0, 116, 79, CHARACTER},
+ {REINTERPRET_CAST, 0, 0, 0, CHARACTER},
+ {CHARACTER, 23, 0, 0, CHARACTER},
+ {CHARACTER, 24, 0, 0, CHARACTER},
+ {CHARACTER, 0, 116, 83, CHARACTER},
+ {CONST, 0, 95, 84, CHARACTER},
+ {CHARACTER, 0, 99, 85, CHARACTER},
+ {CHARACTER, 0, 97, 86, CHARACTER},
+ {CHARACTER, 0, 115, 87, CHARACTER},
+ {CHARACTER, 0, 116, 88, CHARACTER},
+ {CONST_CAST, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 112, 90, CHARACTER},
+ {CHARACTER, 0, 101, 91, CHARACTER},
+ {CHARACTER, 25, 0, 0, CHARACTER},
+ {CHARACTER, 0, 100, 93, CHARACTER},
+ {TYPEID, 0, 0, 0, CHARACTER},
+ {CHARACTER, 26, 0, 0, CHARACTER},
+ {CHARACTER, 0, 115, 96, CHARACTER},
+ {THIS, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 109, 98, CHARACTER},
+ {CHARACTER, 0, 112, 99, CHARACTER},
+ {CHARACTER, 0, 108, 100, CHARACTER},
+ {CHARACTER, 0, 97, 101, CHARACTER},
+ {CHARACTER, 0, 116, 102, CHARACTER},
+ {CHARACTER, 0, 101, 103, CHARACTER},
+ {TEMPLATE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 111, 105, CHARACTER},
+ {CHARACTER, 0, 119, 106, CHARACTER},
+ {THROW, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 121, 108, CHARACTER},
+ {TRY, 0, 0, 0, CHARACTER},
+ {CHARACTER, 27, 0, 0, CHARACTER},
+ {CHARACTER, 0, 99, 111, CHARACTER},
+ {CHARACTER, 0, 104, 112, CHARACTER},
+ {CATCH, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 114, CHARACTER},
+ {CHARACTER, 0, 102, 115, CHARACTER},
+ {TYPEDEF, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 117, CHARACTER},
+ {CHARACTER, 0, 101, 118, CHARACTER},
+ {CHARACTER, 0, 110, 119, CHARACTER},
+ {CHARACTER, 0, 100, 120, CHARACTER},
+ {FRIEND, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 97, 122, CHARACTER},
+ {CHARACTER, 0, 115, 123, CHARACTER},
+ {CHARACTER, 0, 115, 124, CHARACTER},
+ {CLASS, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 109, 126, CHARACTER},
+ {CHARACTER, 0, 101, 127, CHARACTER},
+ {CHARACTER, 0, 115, 128, CHARACTER},
+ {CHARACTER, 0, 112, 129, CHARACTER},
+ {CHARACTER, 0, 97, 130, CHARACTER},
+ {CHARACTER, 0, 99, 131, CHARACTER},
+ {CHARACTER, 0, 101, 132, CHARACTER},
+ {NAMESPACE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 117, 134, CHARACTER},
+ {CHARACTER, 0, 109, 135, CHARACTER},
+ {ENUM, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 117, 137, CHARACTER},
+ {CHARACTER, 0, 99, 138, CHARACTER},
+ {CHARACTER, 0, 116, 139, CHARACTER},
+ {STRUCT, 0, 0, 0, CHARACTER},
+ {CHARACTER, 28, 0, 0, CHARACTER},
+ {CHARACTER, 0, 111, 142, CHARACTER},
+ {CHARACTER, 0, 110, 143, CHARACTER},
+ {UNION, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 114, 145, CHARACTER},
+ {CHARACTER, 0, 116, 146, CHARACTER},
+ {CHARACTER, 0, 117, 147, CHARACTER},
+ {CHARACTER, 0, 97, 148, CHARACTER},
+ {CHARACTER, 0, 108, 149, CHARACTER},
+ {VIRTUAL, 0, 0, 0, CHARACTER},
+ {CHARACTER, 29, 0, 0, CHARACTER},
+ {CHARACTER, 0, 118, 152, CHARACTER},
+ {CHARACTER, 0, 97, 153, CHARACTER},
+ {CHARACTER, 0, 116, 154, CHARACTER},
+ {CHARACTER, 0, 101, 155, CHARACTER},
+ {PRIVATE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 116, 157, CHARACTER},
+ {CHARACTER, 0, 101, 158, CHARACTER},
+ {CHARACTER, 0, 99, 159, CHARACTER},
+ {CHARACTER, 0, 116, 160, CHARACTER},
+ {CHARACTER, 0, 101, 161, CHARACTER},
+ {CHARACTER, 0, 100, 162, CHARACTER},
+ {PROTECTED, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 98, 164, CHARACTER},
+ {CHARACTER, 0, 108, 165, CHARACTER},
+ {CHARACTER, 0, 105, 166, CHARACTER},
+ {CHARACTER, 0, 99, 167, CHARACTER},
+ {PUBLIC, 0, 0, 0, CHARACTER},
+ {CHARACTER, 30, 0, 0, CHARACTER},
+ {CHARACTER, 31, 0, 0, CHARACTER},
+ {CHARACTER, 0, 114, 171, CHARACTER},
+ {CHARACTER, 0, 116, 172, CHARACTER},
+ {EXPORT, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 116, 174, CHARACTER},
+ {CHARACTER, 0, 111, 175, CHARACTER},
+ {AUTO, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 177, CHARACTER},
+ {CHARACTER, 0, 115, 178, CHARACTER},
+ {CHARACTER, 0, 116, 179, CHARACTER},
+ {CHARACTER, 0, 101, 180, CHARACTER},
+ {CHARACTER, 0, 114, 181, CHARACTER},
+ {REGISTER, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 183, CHARACTER},
+ {CHARACTER, 0, 114, 184, CHARACTER},
+ {CHARACTER, 0, 110, 185, CHARACTER},
+ {EXTERN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 116, 187, CHARACTER},
+ {CHARACTER, 0, 97, 188, CHARACTER},
+ {CHARACTER, 0, 98, 189, CHARACTER},
+ {CHARACTER, 0, 108, 190, CHARACTER},
+ {CHARACTER, 0, 101, 191, CHARACTER},
+ {MUTABLE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 109, 193, CHARACTER},
+ {ASM, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 195, CHARACTER},
+ {CHARACTER, 0, 110, 196, CHARACTER},
+ {CHARACTER, 0, 103, 197, CHARACTER},
+ {USING, 0, 0, 0, CHARACTER},
+ {CHARACTER, 32, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 200, CHARACTER},
+ {CHARACTER, 0, 110, 201, CHARACTER},
+ {CHARACTER, 0, 101, 202, CHARACTER},
+ {INLINE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 204, CHARACTER},
+ {CHARACTER, 0, 99, 205, CHARACTER},
+ {CHARACTER, 0, 105, 206, CHARACTER},
+ {CHARACTER, 0, 116, 207, CHARACTER},
+ {EXPLICIT, 0, 0, 0, CHARACTER},
+ {CHARACTER, 33, 0, 0, CHARACTER},
+ {CHARACTER, 0, 97, 210, CHARACTER},
+ {CHARACTER, 0, 116, 211, CHARACTER},
+ {CHARACTER, 0, 105, 212, CHARACTER},
+ {CHARACTER, 0, 108, 213, CHARACTER},
+ {CHARACTER, 0, 101, 214, CHARACTER},
+ {VOLATILE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 216, CHARACTER},
+ {CHARACTER, 0, 114, 217, CHARACTER},
+ {CHARACTER, 0, 97, 218, CHARACTER},
+ {CHARACTER, 0, 116, 219, CHARACTER},
+ {CHARACTER, 0, 111, 220, CHARACTER},
+ {CHARACTER, 0, 114, 221, CHARACTER},
+ {OPERATOR, 0, 0, 0, CHARACTER},
+ {CHARACTER, 34, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 224, CHARACTER},
+ {CHARACTER, 0, 111, 225, CHARACTER},
+ {CHARACTER, 0, 102, 226, CHARACTER},
+ {SIZEOF, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 119, 228, CHARACTER},
+ {NEW, 0, 0, 0, CHARACTER},
+ {CHARACTER, 35, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 231, CHARACTER},
+ {CHARACTER, 0, 116, 232, CHARACTER},
+ {CHARACTER, 0, 101, 233, CHARACTER},
+ {DELETE, 0, 0, 0, CHARACTER},
+ {PLUS, 36, 0, 0, NOTOKEN},
+ {MINUS, 37, 0, 0, NOTOKEN},
+ {STAR, 0, 61, 257, NOTOKEN},
+ {SLASH, 38, 0, 0, NOTOKEN},
+ {HAT, 0, 61, 260, NOTOKEN},
+ {AND, 39, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 116, 241, CHARACTER},
+ {CHARACTER, 40, 0, 0, CHARACTER},
+ {CHARACTER, 0, 110, 243, CHARACTER},
+ {CHARACTER, 0, 100, 244, CHARACTER},
+ {AND, 0, 0, 0, CHARACTER},
+ {OR, 41, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 114, 247, CHARACTER},
+ {OR, 0, 0, 0, CHARACTER},
+ {TILDE, 0, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 112, 250, CHARACTER},
+ {CHARACTER, 0, 108, 251, CHARACTER},
+ {TILDE, 0, 0, 0, CHARACTER},
+ {NOT, 0, 61, 268, NOTOKEN},
+ {CHARACTER, 0, 116, 254, CHARACTER},
+ {NOT, 0, 95, 269, CHARACTER},
+ {PLUS_EQ, 0, 0, 0, NOTOKEN},
+ {MINUS_EQ, 0, 0, 0, NOTOKEN},
+ {STAR_EQ, 0, 0, 0, NOTOKEN},
+ {SLASH_EQ, 0, 0, 0, NOTOKEN},
+ {PERCENT_EQ, 0, 0, 0, NOTOKEN},
+ {HAT_EQ, 0, 0, 0, NOTOKEN},
+ {AND_EQ, 0, 0, 0, NOTOKEN},
+ {OR_EQ, 0, 0, 0, NOTOKEN},
+ {LTLT, 0, 61, 266, NOTOKEN},
+ {GTGT, 0, 61, 265, NOTOKEN},
+ {GTGT_EQ, 0, 0, 0, NOTOKEN},
+ {LTLT_EQ, 0, 0, 0, NOTOKEN},
+ {EQEQ, 0, 0, 0, NOTOKEN},
+ {NE, 0, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 101, 270, CHARACTER},
+ {CHARACTER, 0, 113, 271, CHARACTER},
+ {NE, 0, 0, 0, CHARACTER},
+ {LE, 0, 0, 0, NOTOKEN},
+ {GE, 0, 0, 0, NOTOKEN},
+ {ANDAND, 0, 0, 0, NOTOKEN},
+ {OROR, 0, 0, 0, NOTOKEN},
+ {INCR, 0, 0, 0, NOTOKEN},
+ {DECR, 0, 0, 0, NOTOKEN},
+ {ARROW, 0, 42, 279, NOTOKEN},
+ {ARROW_STAR, 0, 0, 0, NOTOKEN},
+ {CHARACTER, 0, 97, 281, CHARACTER},
+ {CHARACTER, 0, 114, 282, CHARACTER},
+ {CHAR, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 104, 284, CHARACTER},
+ {CHARACTER, 0, 97, 285, CHARACTER},
+ {CHARACTER, 0, 114, 286, CHARACTER},
+ {WCHAR, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 111, 288, CHARACTER},
+ {CHARACTER, 0, 108, 289, CHARACTER},
+ {BOOL, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 111, 291, CHARACTER},
+ {CHARACTER, 0, 114, 292, CHARACTER},
+ {CHARACTER, 0, 116, 293, CHARACTER},
+ {SHORT, 0, 0, 0, CHARACTER},
+ {INT, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 110, 296, CHARACTER},
+ {CHARACTER, 0, 103, 297, CHARACTER},
+ {LONG, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 110, 299, CHARACTER},
+ {CHARACTER, 42, 0, 0, CHARACTER},
+ {CHARACTER, 0, 100, 301, CHARACTER},
+ {SIGNED, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 303, CHARACTER},
+ {CHARACTER, 0, 103, 304, CHARACTER},
+ {CHARACTER, 0, 110, 305, CHARACTER},
+ {CHARACTER, 0, 101, 306, CHARACTER},
+ {CHARACTER, 0, 100, 307, CHARACTER},
+ {UNSIGNED, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 111, 309, CHARACTER},
+ {CHARACTER, 0, 97, 310, CHARACTER},
+ {CHARACTER, 0, 116, 311, CHARACTER},
+ {FLOAT, 0, 0, 0, CHARACTER},
+ {DO, 0, 117, 313, CHARACTER},
+ {CHARACTER, 0, 98, 314, CHARACTER},
+ {CHARACTER, 0, 108, 315, CHARACTER},
+ {CHARACTER, 0, 101, 316, CHARACTER},
+ {DOUBLE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 100, 318, CHARACTER},
+ {VOID, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 320, CHARACTER},
+ {CASE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 97, 322, CHARACTER},
+ {CHARACTER, 0, 117, 323, CHARACTER},
+ {CHARACTER, 0, 108, 324, CHARACTER},
+ {CHARACTER, 0, 116, 325, CHARACTER},
+ {DEFAULT, 0, 0, 0, CHARACTER},
+ {IF, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 115, 328, CHARACTER},
+ {CHARACTER, 0, 101, 329, CHARACTER},
+ {ELSE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 331, CHARACTER},
+ {CHARACTER, 0, 116, 332, CHARACTER},
+ {CHARACTER, 0, 99, 333, CHARACTER},
+ {CHARACTER, 0, 104, 334, CHARACTER},
+ {SWITCH, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 336, CHARACTER},
+ {CHARACTER, 0, 108, 337, CHARACTER},
+ {CHARACTER, 0, 101, 338, CHARACTER},
+ {WHILE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 114, 340, CHARACTER},
+ {FOR, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 101, 342, CHARACTER},
+ {CHARACTER, 0, 97, 343, CHARACTER},
+ {CHARACTER, 0, 107, 344, CHARACTER},
+ {BREAK, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 105, 346, CHARACTER},
+ {CHARACTER, 0, 110, 347, CHARACTER},
+ {CHARACTER, 0, 117, 348, CHARACTER},
+ {CHARACTER, 0, 101, 349, CHARACTER},
+ {CONTINUE, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 116, 351, CHARACTER},
+ {CHARACTER, 0, 111, 352, CHARACTER},
+ {GOTO, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 117, 354, CHARACTER},
+ {CHARACTER, 0, 114, 355, CHARACTER},
+ {CHARACTER, 0, 110, 356, CHARACTER},
+ {RETURN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 43, 0, 0, CHARACTER},
+ {CHARACTER, 0, 66, 359, CHARACTER},
+ {CHARACTER, 0, 74, 360, CHARACTER},
+ {CHARACTER, 0, 69, 361, CHARACTER},
+ {CHARACTER, 0, 67, 362, CHARACTER},
+ {CHARACTER, 0, 84, 363, CHARACTER},
+ {Q_OBJECT_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 65, 365, CHARACTER},
+ {CHARACTER, 0, 68, 366, CHARACTER},
+ {CHARACTER, 0, 71, 367, CHARACTER},
+ {CHARACTER, 0, 69, 368, CHARACTER},
+ {CHARACTER, 0, 84, 369, CHARACTER},
+ {Q_GADGET_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 82, 371, CHARACTER},
+ {CHARACTER, 44, 0, 0, CHARACTER},
+ {CHARACTER, 0, 80, 373, CHARACTER},
+ {CHARACTER, 0, 69, 374, CHARACTER},
+ {CHARACTER, 0, 82, 375, CHARACTER},
+ {CHARACTER, 0, 84, 376, CHARACTER},
+ {CHARACTER, 0, 89, 377, CHARACTER},
+ {Q_PROPERTY_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 78, 379, CHARACTER},
+ {CHARACTER, 0, 85, 380, CHARACTER},
+ {CHARACTER, 0, 77, 381, CHARACTER},
+ {CHARACTER, 0, 83, 382, CHARACTER},
+ {Q_ENUMS_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 76, 384, CHARACTER},
+ {CHARACTER, 0, 65, 385, CHARACTER},
+ {CHARACTER, 0, 71, 386, CHARACTER},
+ {CHARACTER, 0, 83, 387, CHARACTER},
+ {Q_FLAGS_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 69, 389, CHARACTER},
+ {CHARACTER, 0, 67, 390, CHARACTER},
+ {CHARACTER, 0, 76, 391, CHARACTER},
+ {CHARACTER, 0, 65, 392, CHARACTER},
+ {CHARACTER, 0, 82, 393, CHARACTER},
+ {CHARACTER, 0, 69, 394, CHARACTER},
+ {CHARACTER, 0, 95, 395, CHARACTER},
+ {CHARACTER, 45, 0, 0, CHARACTER},
+ {CHARACTER, 0, 76, 397, CHARACTER},
+ {CHARACTER, 0, 65, 398, CHARACTER},
+ {CHARACTER, 0, 71, 399, CHARACTER},
+ {CHARACTER, 0, 83, 400, CHARACTER},
+ {Q_DECLARE_FLAGS_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 78, 402, CHARACTER},
+ {CHARACTER, 0, 84, 403, CHARACTER},
+ {CHARACTER, 0, 69, 404, CHARACTER},
+ {CHARACTER, 0, 82, 405, CHARACTER},
+ {CHARACTER, 0, 70, 406, CHARACTER},
+ {CHARACTER, 0, 65, 407, CHARACTER},
+ {CHARACTER, 0, 67, 408, CHARACTER},
+ {CHARACTER, 0, 69, 409, CHARACTER},
+ {Q_DECLARE_INTERFACE_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 69, 411, CHARACTER},
+ {CHARACTER, 0, 84, 412, CHARACTER},
+ {CHARACTER, 0, 65, 413, CHARACTER},
+ {CHARACTER, 0, 84, 414, CHARACTER},
+ {CHARACTER, 0, 89, 415, CHARACTER},
+ {CHARACTER, 0, 80, 416, CHARACTER},
+ {CHARACTER, 0, 69, 417, CHARACTER},
+ {Q_DECLARE_METATYPE_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 88, 419, CHARACTER},
+ {CHARACTER, 0, 84, 420, CHARACTER},
+ {CHARACTER, 0, 69, 421, CHARACTER},
+ {CHARACTER, 0, 78, 422, CHARACTER},
+ {CHARACTER, 0, 83, 423, CHARACTER},
+ {CHARACTER, 0, 73, 424, CHARACTER},
+ {CHARACTER, 0, 79, 425, CHARACTER},
+ {CHARACTER, 0, 78, 426, CHARACTER},
+ {CHARACTER, 0, 95, 427, CHARACTER},
+ {CHARACTER, 0, 73, 428, CHARACTER},
+ {CHARACTER, 0, 78, 429, CHARACTER},
+ {CHARACTER, 0, 84, 430, CHARACTER},
+ {CHARACTER, 0, 69, 431, CHARACTER},
+ {CHARACTER, 0, 82, 432, CHARACTER},
+ {CHARACTER, 0, 70, 433, CHARACTER},
+ {CHARACTER, 0, 65, 434, CHARACTER},
+ {CHARACTER, 0, 67, 435, CHARACTER},
+ {CHARACTER, 0, 69, 409, CHARACTER},
+ {CHARACTER, 46, 0, 0, CHARACTER},
+ {CHARACTER, 0, 84, 438, CHARACTER},
+ {CHARACTER, 0, 83, 387, CHARACTER},
+ {CHARACTER, 0, 76, 440, CHARACTER},
+ {CHARACTER, 0, 65, 441, CHARACTER},
+ {CHARACTER, 0, 83, 442, CHARACTER},
+ {CHARACTER, 0, 83, 443, CHARACTER},
+ {CHARACTER, 0, 73, 444, CHARACTER},
+ {CHARACTER, 0, 78, 445, CHARACTER},
+ {CHARACTER, 0, 70, 446, CHARACTER},
+ {CHARACTER, 0, 79, 447, CHARACTER},
+ {Q_CLASSINFO_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 78, 449, CHARACTER},
+ {CHARACTER, 47, 0, 0, CHARACTER},
+ {CHARACTER, 0, 69, 451, CHARACTER},
+ {CHARACTER, 0, 82, 452, CHARACTER},
+ {CHARACTER, 0, 70, 453, CHARACTER},
+ {CHARACTER, 0, 65, 454, CHARACTER},
+ {CHARACTER, 0, 67, 455, CHARACTER},
+ {CHARACTER, 0, 69, 456, CHARACTER},
+ {CHARACTER, 0, 83, 457, CHARACTER},
+ {Q_INTERFACES_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 108, 459, CHARACTER},
+ {CHARACTER, 0, 115, 460, CHARACTER},
+ {SIGNALS, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 111, 462, CHARACTER},
+ {CHARACTER, 0, 116, 463, CHARACTER},
+ {CHARACTER, 0, 115, 464, CHARACTER},
+ {SLOTS, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 71, 466, CHARACTER},
+ {CHARACTER, 0, 78, 467, CHARACTER},
+ {CHARACTER, 0, 65, 468, CHARACTER},
+ {CHARACTER, 0, 76, 469, CHARACTER},
+ {Q_SIGNAL_TOKEN, 0, 83, 470, CHARACTER},
+ {Q_SIGNALS_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 79, 472, CHARACTER},
+ {CHARACTER, 0, 84, 473, CHARACTER},
+ {Q_SLOT_TOKEN, 0, 83, 474, CHARACTER},
+ {Q_SLOTS_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 86, 476, CHARACTER},
+ {CHARACTER, 0, 65, 477, CHARACTER},
+ {CHARACTER, 0, 84, 478, CHARACTER},
+ {CHARACTER, 0, 69, 479, CHARACTER},
+ {CHARACTER, 0, 95, 480, CHARACTER},
+ {CHARACTER, 0, 83, 481, CHARACTER},
+ {CHARACTER, 0, 76, 482, CHARACTER},
+ {CHARACTER, 0, 79, 483, CHARACTER},
+ {CHARACTER, 0, 84, 484, CHARACTER},
+ {Q_PRIVATE_SLOT_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 48, 0, 0, CHARACTER},
+ {CHARACTER, 0, 77, 487, CHARACTER},
+ {CHARACTER, 0, 79, 488, CHARACTER},
+ {CHARACTER, 0, 67, 489, CHARACTER},
+ {CHARACTER, 0, 95, 490, CHARACTER},
+ {CHARACTER, 0, 67, 491, CHARACTER},
+ {CHARACTER, 0, 79, 492, CHARACTER},
+ {CHARACTER, 0, 77, 493, CHARACTER},
+ {CHARACTER, 0, 80, 494, CHARACTER},
+ {CHARACTER, 0, 65, 495, CHARACTER},
+ {CHARACTER, 0, 84, 496, CHARACTER},
+ {Q_MOC_COMPAT_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 95, 498, CHARACTER},
+ {CHARACTER, 0, 83, 499, CHARACTER},
+ {CHARACTER, 0, 85, 500, CHARACTER},
+ {CHARACTER, 0, 80, 501, CHARACTER},
+ {CHARACTER, 0, 80, 502, CHARACTER},
+ {CHARACTER, 0, 79, 503, CHARACTER},
+ {CHARACTER, 0, 82, 504, CHARACTER},
+ {CHARACTER, 0, 84, 505, CHARACTER},
+ {Q_QT3_SUPPORT_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 79, 507, CHARACTER},
+ {CHARACTER, 0, 75, 508, CHARACTER},
+ {CHARACTER, 0, 65, 509, CHARACTER},
+ {CHARACTER, 0, 66, 510, CHARACTER},
+ {CHARACTER, 0, 76, 511, CHARACTER},
+ {CHARACTER, 0, 69, 512, CHARACTER},
+ {Q_INVOKABLE_TOKEN, 0, 0, 0, CHARACTER},
+ {CHARACTER, 0, 82, 514, CHARACTER},
+ {CHARACTER, 0, 73, 515, CHARACTER},
+ {CHARACTER, 0, 80, 516, CHARACTER},
+ {CHARACTER, 0, 84, 517, CHARACTER},
+ {CHARACTER, 0, 65, 518, CHARACTER},
+ {CHARACTER, 0, 66, 519, CHARACTER},
+ {CHARACTER, 0, 76, 520, CHARACTER},
+ {CHARACTER, 0, 69, 521, CHARACTER},
+ {Q_SCRIPTABLE_TOKEN, 0, 0, 0, CHARACTER},
+ {NEWLINE, 0, 0, 0, NOTOKEN},
+ {QUOTE, 0, 0, 0, NOTOKEN},
+ {SINGLEQUOTE, 0, 0, 0, NOTOKEN},
+ {WHITESPACE, 0, 0, 0, NOTOKEN},
+ {HASH, 0, 0, 0, HASH},
+ {BACKSLASH, 0, 0, 0, NOTOKEN},
+ {CPP_COMMENT, 0, 0, 0, NOTOKEN},
+ {C_COMMENT, 0, 0, 0, NOTOKEN},
+ {FLOATING_LITERAL, 0, 0, 0, NOTOKEN}
+};
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
new file mode 100644
index 0000000..4aa362d
--- /dev/null
+++ b/src/tools/moc/main.cpp
@@ -0,0 +1,459 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "preprocessor.h"
+#include "moc.h"
+#include "outputrevision.h"
+#include "../../corelib/global/qconfig.cpp"
+#include <QFile>
+#include <QFileInfo>
+#include <QDir>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ This function looks at two file names and returns the name of the
+ infile with a path relative to outfile.
+
+ Examples:
+
+ /tmp/abc, /tmp/bcd -> abc
+ xyz/a/bc, xyz/b/ac -> ../a/bc
+ /tmp/abc, xyz/klm -> /tmp/abc
+ */
+
+static QByteArray combinePath(const char *infile, const char *outfile)
+{
+ QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile));
+ QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile));
+ int numCommonComponents = 0;
+
+ QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
+ QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
+
+ while (!inSplitted.isEmpty() && !outSplitted.isEmpty() &&
+ inSplitted.first() == outSplitted.first()) {
+ inSplitted.removeFirst();
+ outSplitted.removeFirst();
+ numCommonComponents++;
+ }
+
+ if (numCommonComponents < 2)
+ /*
+ The paths don't have the same drive, or they don't have the
+ same root directory. Use an absolute path.
+ */
+ return QFile::encodeName(inFileInfo.absoluteFilePath());
+ /*
+ The paths have something in common. Use a path relative to
+ the output file.
+ */
+ while (!outSplitted.isEmpty()) {
+ outSplitted.removeFirst();
+ inSplitted.prepend(QLatin1String(".."));
+ }
+ inSplitted.append(inFileInfo.fileName());
+ return QFile::encodeName(inSplitted.join(QLatin1String("/")));
+}
+
+
+void error(const char *msg = "Invalid argument")
+{
+ if (msg)
+ fprintf(stderr, "moc: %s\n", msg);
+ fprintf(stderr, "Usage: moc [options] <header-file>\n"
+ " -o<file> write output to file rather than stdout\n"
+ " -I<dir> add dir to the include path for header files\n"
+ " -E preprocess only; do not generate meta object code\n"
+ " -D<macro>[=<def>] define macro, with optional definition\n"
+ " -U<macro> undefine macro\n"
+ " -i do not generate an #include statement\n"
+ " -p<path> path prefix for included file\n"
+ " -f[<file>] force #include, optional file name\n"
+ " -nw do not display warnings\n"
+ " @<file> read additional options from file\n"
+ " -v display version of moc\n");
+ exit(1);
+}
+
+
+static inline bool hasNext(const Symbols &symbols, int i)
+{ return (i < symbols.size()); }
+
+static inline const Symbol &next(const Symbols &symbols, int &i)
+{ return symbols.at(i++); }
+
+
+QByteArray composePreprocessorOutput(const Symbols &symbols) {
+ QByteArray output;
+ int lineNum = 1;
+ Token last = PP_NOTOKEN;
+ Token secondlast = last;
+ int i = 0;
+ while (hasNext(symbols, i)) {
+ Symbol sym = next(symbols, i);
+ switch (sym.token) {
+ case PP_NEWLINE:
+ case PP_WHITESPACE:
+ if (last != PP_WHITESPACE) {
+ secondlast = last;
+ last = PP_WHITESPACE;
+ output += ' ';
+ }
+ continue;
+ case PP_STRING_LITERAL:
+ if (last == PP_STRING_LITERAL)
+ output.chop(1);
+ else if (secondlast == PP_STRING_LITERAL && last == PP_WHITESPACE)
+ output.chop(2);
+ else
+ break;
+ output += sym.lexem().mid(1);
+ secondlast = last;
+ last = PP_STRING_LITERAL;
+ continue;
+ case MOC_INCLUDE_BEGIN:
+ lineNum = 0;
+ continue;
+ case MOC_INCLUDE_END:
+ lineNum = sym.lineNum;
+ continue;
+ default:
+ break;
+ }
+ secondlast = last;
+ last = sym.token;
+
+ const int padding = sym.lineNum - lineNum;
+ if (padding > 0) {
+ output.resize(output.size() + padding);
+ qMemSet(output.data() + output.size() - padding, '\n', padding);
+ lineNum = sym.lineNum;
+ }
+
+ output += sym.lexem();
+ }
+
+ return output;
+}
+
+
+int runMoc(int _argc, char **_argv)
+{
+ bool autoInclude = true;
+ Preprocessor pp;
+ Moc moc;
+ pp.macros["Q_MOC_RUN"];
+ pp.macros["__cplusplus"];
+ QByteArray filename;
+ QByteArray output;
+ FILE *in = 0;
+ FILE *out = 0;
+ bool ignoreConflictingOptions = false;
+
+ QVector<QByteArray> argv;
+ argv.resize(_argc - 1);
+ for (int n = 1; n < _argc; ++n)
+ argv[n - 1] = _argv[n];
+ int argc = argv.count();
+
+ for (int n = 0; n < argv.count(); ++n) {
+ if (argv.at(n).startsWith('@')) {
+ QByteArray optionsFile = argv.at(n);
+ optionsFile.remove(0, 1);
+ if (optionsFile.isEmpty())
+ error("The @ option requires an input file");
+ QFile f(QString::fromLatin1(optionsFile.constData()));
+ if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
+ error("Cannot open options file specified with @");
+ argv.remove(n);
+ while (!f.atEnd()) {
+ QByteArray line = f.readLine().trimmed();
+ if (!line.isEmpty())
+ argv.insert(n++, line);
+ }
+ }
+ }
+
+ // report Qt usage for commercial customers with a "metered license" (currently experimental)
+#if QT_EDITION != QT_EDITION_OPENSOURCE
+#ifdef QT_CONFIGURE_BINARIES_PATH
+ const char *binariesPath = QT_CONFIGURE_BINARIES_PATH;
+ QString reporterPath = QString::fromLocal8Bit(binariesPath) + QDir::separator()
+ + QLatin1String("qtusagereporter");
+#if defined(Q_OS_WIN)
+ reporterPath += QLatin1String(".exe");
+#endif
+ if (QFile::exists(reporterPath))
+ system(qPrintable(reporterPath + QLatin1String(" moc")));
+#endif
+#endif
+
+ argc = argv.count();
+
+ for (int n = 0; n < argc; ++n) {
+ QByteArray arg(argv[n]);
+ if (arg[0] != '-') {
+ if (filename.isEmpty()) {
+ filename = arg;
+ continue;
+ }
+ error("Too many input files specified");
+ }
+ QByteArray opt = arg.mid(1);
+ bool more = (opt.size() > 1);
+ switch (opt[0]) {
+ case 'o': // output redirection
+ if (!more) {
+ if (!(n < argc-1))
+ error("Missing output file name");
+ output = argv[++n];
+ } else
+ output = opt.mid(1);
+ break;
+ case 'E': // only preprocessor
+ pp.preprocessOnly = true;
+ break;
+ case 'i': // no #include statement
+ if (more)
+ error();
+ moc.noInclude = true;
+ autoInclude = false;
+ break;
+ case 'f': // produce #include statement
+ if (ignoreConflictingOptions)
+ break;
+ moc.noInclude = false;
+ autoInclude = false;
+ if (opt[1]) // -fsomething.h
+ moc.includeFiles.append(opt.mid(1));
+ break;
+ case 'p': // include file path
+ if (ignoreConflictingOptions)
+ break;
+ if (!more) {
+ if (!(n < argc-1))
+ error("Missing path name for the -p option.");
+ moc.includePath = argv[++n];
+ } else {
+ moc.includePath = opt.mid(1);
+ }
+ break;
+ case 'I': // produce #include statement
+ if (!more) {
+ if (!(n < argc-1))
+ error("Missing path name for the -I option.");
+ pp.includes += Preprocessor::IncludePath(argv[++n]);
+ } else {
+ pp.includes += Preprocessor::IncludePath(opt.mid(1));
+ }
+ break;
+ case 'F': // minimalistic framework support for the mac
+ if (!more) {
+ if (!(n < argc-1))
+ error("Missing path name for the -F option.");
+ Preprocessor::IncludePath p(argv[++n]);
+ p.isFrameworkPath = true;
+ pp.includes += p;
+ } else {
+ Preprocessor::IncludePath p(opt.mid(1));
+ p.isFrameworkPath = true;
+ pp.includes += p;
+ }
+ break;
+ case 'D': // define macro
+ {
+ QByteArray name;
+ QByteArray value("1");
+ if (!more) {
+ if (n < argc-1)
+ name = argv[++n];
+ } else
+ name = opt.mid(1);
+ int eq = name.indexOf('=');
+ if (eq >= 0) {
+ value = name.mid(eq + 1);
+ name = name.left(eq);
+ }
+ if (name.isEmpty())
+ error("Missing macro name");
+ Macro macro;
+ macro.symbols += Symbol(0, PP_IDENTIFIER, value);
+ pp.macros.insert(name, macro);
+
+ }
+ break;
+ case 'U':
+ {
+ QByteArray macro;
+ if (!more) {
+ if (n < argc-1)
+ macro = argv[++n];
+ } else
+ macro = opt.mid(1);
+ if (macro.isEmpty())
+ error("Missing macro name");
+ pp.macros.remove(macro);
+
+ }
+ break;
+ case 'v': // version number
+ if (more && opt != "version")
+ error();
+ fprintf(stderr, "Qt Meta Object Compiler version %d (Qt %s)\n",
+ mocOutputRevision, QT_VERSION_STR);
+ return 1;
+ case 'n': // don't display warnings
+ if (ignoreConflictingOptions)
+ break;
+ if (opt != "nw")
+ error();
+ moc.displayWarnings = false;
+ break;
+ case 'h': // help
+ if (more && opt != "help")
+ error();
+ else
+ error(0); // 0 means usage only
+ break;
+ case '-':
+ if (more && arg == "--ignore-option-clashes") {
+ // -- ignore all following moc specific options that conflict
+ // with for example gcc, like -pthread conflicting with moc's
+ // -p option.
+ ignoreConflictingOptions = true;
+ break;
+ }
+ // fall through
+ default:
+ error();
+ }
+ }
+
+
+ if (autoInclude) {
+ int ppos = filename.lastIndexOf('.');
+ moc.noInclude = (ppos >= 0
+ && tolower(filename[ppos + 1]) != 'h'
+ && tolower(filename[ppos + 1]) != QDir::separator().toLatin1()
+ );
+ }
+ if (moc.includeFiles.isEmpty()) {
+ if (moc.includePath.isEmpty()) {
+ if (filename.size()) {
+ if (output.size())
+ moc.includeFiles.append(combinePath(filename, output));
+ else
+ moc.includeFiles.append(filename);
+ }
+ } else {
+ moc.includeFiles.append(combinePath(filename, filename));
+ }
+ }
+
+ if (filename.isEmpty()) {
+ filename = "standard input";
+ in = stdin;
+ } else {
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ if (fopen_s(&in, filename.data(), "rb")) {
+#else
+ in = fopen(filename.data(), "rb");
+ if (!in) {
+#endif
+ fprintf(stderr, "moc: %s: No such file\n", (const char*)filename);
+ return 1;
+ }
+ moc.filename = filename;
+ }
+
+ moc.currentFilenames.push(filename);
+
+ // 1. preprocess
+ moc.symbols = pp.preprocessed(moc.filename, in);
+ fclose(in);
+
+ if (!pp.preprocessOnly) {
+ // 2. parse
+ moc.parse();
+ }
+
+ // 3. and output meta object code
+
+ if (output.size()) { // output file specified
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ if (fopen_s(&out, output.data(), "w"))
+#else
+ out = fopen(output.data(), "w"); // create output file
+ if (!out)
+#endif
+ {
+ fprintf(stderr, "moc: Cannot create %s\n", (const char*)output);
+ return 1;
+ }
+ } else { // use stdout
+ out = stdout;
+ }
+
+ if (pp.preprocessOnly) {
+ fprintf(out, "%s\n", composePreprocessorOutput(moc.symbols).constData());
+ } else {
+ if (moc.classList.isEmpty())
+ moc.warning("No relevant classes found. No output generated.");
+ else
+ moc.generate(out);
+ }
+
+ if (output.size())
+ fclose(out);
+
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+int main(int _argc, char **_argv)
+{
+ return QT_PREPEND_NAMESPACE(runMoc)(_argc, _argv);
+}
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
new file mode 100644
index 0000000..a6a0ba1
--- /dev/null
+++ b/src/tools/moc/moc.cpp
@@ -0,0 +1,1230 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "moc.h"
+#include "generator.h"
+#include "qdatetime.h"
+#include "utils.h"
+#include "outputrevision.h"
+
+// for normalizeTypeInternal
+#include <private/qmetaobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+// only moc needs this function
+static QByteArray normalizeType(const char *s, bool fixScope = false)
+{
+ int len = qstrlen(s);
+ char stackbuf[64];
+ char *buf = (len >= 64 ? new char[len + 1] : stackbuf);
+ char *d = buf;
+ char last = 0;
+ while(*s && is_space(*s))
+ s++;
+ while (*s) {
+ while (*s && !is_space(*s))
+ last = *d++ = *s++;
+ while (*s && is_space(*s))
+ s++;
+ if (*s && ((is_ident_char(*s) && is_ident_char(last))
+ || ((*s == ':') && (last == '<')))) {
+ last = *d++ = ' ';
+ }
+ }
+ *d = '\0';
+ QByteArray result;
+ if (strncmp("void", buf, d - buf) != 0)
+ result = normalizeTypeInternal(buf, d, fixScope);
+ if (buf != stackbuf)
+ delete [] buf;
+ return result;
+}
+
+bool Moc::parseClassHead(ClassDef *def)
+{
+ // figure out whether this is a class declaration, or only a
+ // forward or variable declaration.
+ int i = 0;
+ Token token;
+ do {
+ token = lookup(i++);
+ if (token == COLON || token == LBRACE)
+ break;
+ if (token == SEMIC || token == RANGLE)
+ return false;
+ } while (token);
+
+ if (!test(IDENTIFIER)) // typedef struct { ... }
+ return false;
+ QByteArray name = lexem();
+
+ // support "class IDENT name" and "class IDENT(IDENT) name"
+ if (test(LPAREN)) {
+ until(RPAREN);
+ if (!test(IDENTIFIER))
+ return false;
+ name = lexem();
+ } else if (test(IDENTIFIER)) {
+ name = lexem();
+ }
+
+ def->qualified += name;
+ while (test(SCOPE)) {
+ def->qualified += lexem();
+ if (test(IDENTIFIER)) {
+ name = lexem();
+ def->qualified += name;
+ }
+ }
+ def->classname = name;
+ if (test(COLON)) {
+ do {
+ test(VIRTUAL);
+ FunctionDef::Access access = FunctionDef::Public;
+ if (test(PRIVATE))
+ access = FunctionDef::Private;
+ else if (test(PROTECTED))
+ access = FunctionDef::Protected;
+ else
+ test(PUBLIC);
+ test(VIRTUAL);
+ const QByteArray type = parseType().name;
+ // ignore the 'class Foo : BAR(Baz)' case
+ if (test(LPAREN)) {
+ until(RPAREN);
+ } else {
+ def->superclassList += qMakePair(type, access);
+ }
+ } while (test(COMMA));
+ }
+ if (!test(LBRACE))
+ return false;
+ def->begin = index - 1;
+ bool foundRBrace = until(RBRACE);
+ def->end = index;
+ index = def->begin + 1;
+ return foundRBrace;
+}
+
+Type Moc::parseType()
+{
+ Type type;
+ bool hasSignedOrUnsigned = false;
+ bool isVoid = false;
+ type.firstToken = lookup();
+ for (;;) {
+ switch (next()) {
+ case SIGNED:
+ case UNSIGNED:
+ hasSignedOrUnsigned = true;
+ // fall through
+ case CONST:
+ case VOLATILE:
+ type.name += lexem();
+ type.name += ' ';
+ if (lookup(0) == VOLATILE)
+ type.isVolatile = true;
+ continue;
+ case Q_MOC_COMPAT_TOKEN:
+ case Q_QT3_SUPPORT_TOKEN:
+ case Q_INVOKABLE_TOKEN:
+ case Q_SCRIPTABLE_TOKEN:
+ case Q_SIGNALS_TOKEN:
+ case Q_SLOTS_TOKEN:
+ case Q_SIGNAL_TOKEN:
+ case Q_SLOT_TOKEN:
+ type.name += lexem();
+ return type;
+ default:
+ prev();
+ break;
+ }
+ break;
+ }
+ test(ENUM) || test(CLASS) || test(STRUCT);
+ for(;;) {
+ switch (next()) {
+ case IDENTIFIER:
+ // void mySlot(unsigned myArg)
+ if (hasSignedOrUnsigned) {
+ prev();
+ break;
+ }
+ case CHAR:
+ case SHORT:
+ case INT:
+ case LONG:
+ type.name += lexem();
+ // preserve '[unsigned] long long', 'short int', 'long int', 'long double'
+ if (test(LONG) || test(INT) || test(DOUBLE)) {
+ type.name += ' ';
+ prev();
+ continue;
+ }
+ break;
+ case FLOAT:
+ case DOUBLE:
+ case VOID:
+ case BOOL:
+ type.name += lexem();
+ isVoid |= (lookup(0) == VOID);
+ break;
+ default:
+ prev();
+ ;
+ }
+ if (test(LANGLE)) {
+ QByteArray templ = lexemUntil(RANGLE);
+ for (int i = 0; i < templ.size(); ++i) {
+ type.name += templ.at(i);
+ if ((templ.at(i) == '<' && i < templ.size()-1 && templ.at(i+1) == ':')
+ || (templ.at(i) == '>' && i < templ.size()-1 && templ.at(i+1) == '>')) {
+ type.name += ' ';
+ }
+ }
+ }
+ if (test(SCOPE)) {
+ type.name += lexem();
+ type.isScoped = true;
+ } else {
+ break;
+ }
+ }
+ while (test(CONST) || test(VOLATILE) || test(SIGNED) || test(UNSIGNED)
+ || test(STAR) || test(AND)) {
+ type.name += ' ';
+ type.name += lexem();
+ if (lookup(0) == AND)
+ type.referenceType = Type::Reference;
+ else if (lookup(0) == STAR)
+ type.referenceType = Type::Pointer;
+ }
+ // transform stupid things like 'const void' or 'void const' into 'void'
+ if (isVoid && type.referenceType == Type::NoReference) {
+ type.name = "void";
+ }
+ return type;
+}
+
+bool Moc::parseEnum(EnumDef *def)
+{
+ bool isTypdefEnum = false; // typedef enum { ... } Foo;
+
+ if (test(IDENTIFIER)) {
+ def->name = lexem();
+ } else {
+ if (lookup(-1) != TYPEDEF)
+ return false; // anonymous enum
+ isTypdefEnum = true;
+ }
+ if (!test(LBRACE))
+ return false;
+ do {
+ if (lookup() == RBRACE) // accept trailing comma
+ break;
+ next(IDENTIFIER);
+ def->values += lexem();
+ } while (test(EQ) ? until(COMMA) : test(COMMA));
+ next(RBRACE);
+ if (isTypdefEnum) {
+ if (!test(IDENTIFIER))
+ return false;
+ def->name = lexem();
+ }
+ return true;
+}
+
+void Moc::parseFunctionArguments(FunctionDef *def)
+{
+ Q_UNUSED(def);
+ while (hasNext()) {
+ ArgumentDef arg;
+ arg.type = parseType();
+ if (arg.type.name == "void")
+ break;
+ if (test(IDENTIFIER))
+ arg.name = lexem();
+ while (test(LBRACK)) {
+ arg.rightType += lexemUntil(RBRACK);
+ }
+ if (test(CONST) || test(VOLATILE)) {
+ arg.rightType += ' ';
+ arg.rightType += lexem();
+ }
+ arg.normalizedType = normalizeType(arg.type.name + ' ' + arg.rightType);
+ arg.typeNameForCast = normalizeType(noRef(arg.type.name) + "(*)" + arg.rightType);
+ if (test(EQ))
+ arg.isDefault = true;
+ def->arguments += arg;
+ if (!until(COMMA))
+ break;
+ }
+}
+
+bool Moc::testFunctionAttribute(FunctionDef *def)
+{
+ if (index < symbols.size() && testFunctionAttribute(symbols.at(index).token, def)) {
+ ++index;
+ return true;
+ }
+ return false;
+}
+
+bool Moc::testFunctionAttribute(Token tok, FunctionDef *def)
+{
+ switch (tok) {
+ case Q_MOC_COMPAT_TOKEN:
+ case Q_QT3_SUPPORT_TOKEN:
+ def->isCompat = true;
+ return true;
+ case Q_INVOKABLE_TOKEN:
+ def->isInvokable = true;
+ return true;
+ case Q_SIGNAL_TOKEN:
+ def->isSignal = true;
+ return true;
+ case Q_SLOT_TOKEN:
+ def->isSlot = true;
+ return true;
+ case Q_SCRIPTABLE_TOKEN:
+ def->isInvokable = def->isScriptable = true;
+ return true;
+ default: break;
+ }
+ return false;
+}
+
+// returns false if the function should be ignored
+bool Moc::parseFunction(FunctionDef *def, bool inMacro)
+{
+ def->isVirtual = false;
+ while (test(INLINE) || test(STATIC) || test(VIRTUAL)
+ || testFunctionAttribute(def)) {
+ if (lookup() == VIRTUAL)
+ def->isVirtual = true;
+ }
+ bool templateFunction = (lookup() == TEMPLATE);
+ def->type = parseType();
+ if (def->type.name.isEmpty()) {
+ if (templateFunction)
+ error("Template function as signal or slot");
+ else
+ error();
+ }
+ bool scopedFunctionName = false;
+ if (test(LPAREN)) {
+ def->name = def->type.name;
+ scopedFunctionName = def->type.isScoped;
+ def->type = Type("int");
+ } else {
+ Type tempType = parseType();;
+ while (!tempType.name.isEmpty() && lookup() != LPAREN) {
+ if (testFunctionAttribute(def->type.firstToken, def))
+ ; // fine
+ else if (def->type.firstToken == Q_SIGNALS_TOKEN)
+ error();
+ else if (def->type.firstToken == Q_SLOTS_TOKEN)
+ error();
+ else {
+ if (!def->tag.isEmpty())
+ def->tag += ' ';
+ def->tag += def->type.name;
+ }
+ def->type = tempType;
+ tempType = parseType();
+ }
+ next(LPAREN, "Not a signal or slot declaration");
+ def->name = tempType.name;
+ scopedFunctionName = tempType.isScoped;
+ }
+
+ // we don't support references as return types, it's too dangerous
+ if (def->type.referenceType == Type::Reference)
+ def->type = Type("void");
+
+ def->normalizedType = normalizeType(def->type.name);
+
+ if (!test(RPAREN)) {
+ parseFunctionArguments(def);
+ next(RPAREN);
+ }
+
+ // support optional macros with compiler specific options
+ while (test(IDENTIFIER))
+ ;
+
+ def->isConst = test(CONST);
+
+ while (test(IDENTIFIER))
+ ;
+
+ if (inMacro) {
+ next(RPAREN);
+ prev();
+ } else {
+ if (test(THROW)) {
+ next(LPAREN);
+ until(RPAREN);
+ }
+ if (test(SEMIC))
+ ;
+ else if ((def->inlineCode = test(LBRACE)))
+ until(RBRACE);
+ else if ((def->isAbstract = test(EQ)))
+ until(SEMIC);
+ else
+ error();
+ }
+
+ if (scopedFunctionName) {
+ QByteArray msg("Function declaration ");
+ msg += def->name;
+ msg += " contains extra qualification. Ignoring as signal or slot.";
+ warning(msg.constData());
+ return false;
+ }
+ return true;
+}
+
+// like parseFunction, but never aborts with an error
+bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def)
+{
+ def->isVirtual = false;
+ while (test(EXPLICIT) || test(INLINE) || test(STATIC) || test(VIRTUAL)
+ || testFunctionAttribute(def)) {
+ if (lookup() == VIRTUAL)
+ def->isVirtual = true;
+ }
+ bool tilde = test(TILDE);
+ def->type = parseType();
+ if (def->type.name.isEmpty())
+ return false;
+ bool scopedFunctionName = false;
+ if (test(LPAREN)) {
+ def->name = def->type.name;
+ scopedFunctionName = def->type.isScoped;
+ if (def->name == cdef->classname) {
+ def->isDestructor = tilde;
+ def->isConstructor = !tilde;
+ def->type = Type();
+ } else {
+ def->type = Type("int");
+ }
+ } else {
+ Type tempType = parseType();;
+ while (!tempType.name.isEmpty() && lookup() != LPAREN) {
+ if (testFunctionAttribute(def->type.firstToken, def))
+ ; // fine
+ else if (def->type.name == "Q_SIGNAL")
+ def->isSignal = true;
+ else if (def->type.name == "Q_SLOT")
+ def->isSlot = true;
+ else {
+ if (!def->tag.isEmpty())
+ def->tag += ' ';
+ def->tag += def->type.name;
+ }
+ def->type = tempType;
+ tempType = parseType();
+ }
+ if (!test(LPAREN))
+ return false;
+ def->name = tempType.name;
+ scopedFunctionName = tempType.isScoped;
+ }
+
+ // we don't support references as return types, it's too dangerous
+ if (def->type.referenceType == Type::Reference)
+ def->type = Type("void");
+
+ def->normalizedType = normalizeType(def->type.name);
+
+ if (!test(RPAREN)) {
+ parseFunctionArguments(def);
+ if (!test(RPAREN))
+ return false;
+ }
+ def->isConst = test(CONST);
+ if (scopedFunctionName
+ && (def->isSignal || def->isSlot || def->isInvokable)) {
+ QByteArray msg("parsemaybe: Function declaration ");
+ msg += def->name;
+ msg += " contains extra qualification. Ignoring as signal or slot.";
+ warning(msg.constData());
+ return false;
+ }
+ return true;
+}
+
+
+void Moc::parse()
+{
+ QList<NamespaceDef> namespaceList;
+ bool templateClass = false;
+ while (hasNext()) {
+ Token t = next();
+ switch (t) {
+ case NAMESPACE: {
+ int rewind = index;
+ if (test(IDENTIFIER)) {
+ if (test(EQ)) {
+ // namespace Foo = Bar::Baz;
+ until(SEMIC);
+ } else if (!test(SEMIC)) {
+ NamespaceDef def;
+ def.name = lexem();
+ next(LBRACE);
+ def.begin = index - 1;
+ until(RBRACE);
+ def.end = index;
+ index = def.begin + 1;
+ namespaceList += def;
+ index = rewind;
+ }
+ }
+ break;
+ }
+ case SEMIC:
+ case RBRACE:
+ templateClass = false;
+ break;
+ case TEMPLATE:
+ templateClass = true;
+ break;
+ case MOC_INCLUDE_BEGIN:
+ currentFilenames.push(symbol().unquotedLexem());
+ break;
+ case MOC_INCLUDE_END:
+ currentFilenames.pop();
+ break;
+ case Q_DECLARE_INTERFACE_TOKEN:
+ parseDeclareInterface();
+ break;
+ case Q_DECLARE_METATYPE_TOKEN:
+ parseDeclareMetatype();
+ break;
+ case USING:
+ if (test(NAMESPACE)) {
+ while (test(SCOPE) || test(IDENTIFIER))
+ ;
+ next(SEMIC);
+ }
+ break;
+ case CLASS:
+ case STRUCT: {
+ if (currentFilenames.size() <= 1)
+ break;
+
+ ClassDef def;
+ if (!parseClassHead(&def))
+ continue;
+
+ while (inClass(&def) && hasNext()) {
+ if (next() == Q_OBJECT_TOKEN) {
+ def.hasQObject = true;
+ break;
+ }
+ }
+
+ if (!def.hasQObject)
+ continue;
+
+ for (int i = namespaceList.size() - 1; i >= 0; --i)
+ if (inNamespace(&namespaceList.at(i)))
+ def.qualified.prepend(namespaceList.at(i).name + "::");
+
+ knownQObjectClasses.insert(def.classname);
+ knownQObjectClasses.insert(def.qualified);
+
+ continue; }
+ default: break;
+ }
+ if ((t != CLASS && t != STRUCT)|| currentFilenames.size() > 1)
+ continue;
+ ClassDef def;
+ if (parseClassHead(&def)) {
+ FunctionDef::Access access = FunctionDef::Private;
+ for (int i = namespaceList.size() - 1; i >= 0; --i)
+ if (inNamespace(&namespaceList.at(i)))
+ def.qualified.prepend(namespaceList.at(i).name + "::");
+ while (inClass(&def) && hasNext()) {
+ switch ((t = next())) {
+ case PRIVATE:
+ access = FunctionDef::Private;
+ if (test(Q_SIGNALS_TOKEN))
+ error("Signals cannot have access specifier");
+ break;
+ case PROTECTED:
+ access = FunctionDef::Protected;
+ if (test(Q_SIGNALS_TOKEN))
+ error("Signals cannot have access specifier");
+ break;
+ case PUBLIC:
+ access = FunctionDef::Public;
+ if (test(Q_SIGNALS_TOKEN))
+ error("Signals cannot have access specifier");
+ break;
+ case CLASS: {
+ ClassDef nestedDef;
+ if (parseClassHead(&nestedDef)) {
+ while (inClass(&nestedDef) && inClass(&def)) {
+ t = next();
+ if (t >= Q_META_TOKEN_BEGIN && t < Q_META_TOKEN_END)
+ error("Meta object features not supported for nested classes");
+ }
+ }
+ } break;
+ case Q_SIGNALS_TOKEN:
+ parseSignals(&def);
+ break;
+ case Q_SLOTS_TOKEN:
+ switch (lookup(-1)) {
+ case PUBLIC:
+ case PROTECTED:
+ case PRIVATE:
+ parseSlots(&def, access);
+ break;
+ default:
+ error("Missing access specifier for slots");
+ }
+ break;
+ case Q_OBJECT_TOKEN:
+ def.hasQObject = true;
+ if (templateClass)
+ error("Template classes not supported by Q_OBJECT");
+ if (def.classname != "Qt" && def.classname != "QObject" && def.superclassList.isEmpty())
+ error("Class contains Q_OBJECT macro but does not inherit from QObject");
+ break;
+ case Q_GADGET_TOKEN:
+ def.hasQGadget = true;
+ if (templateClass)
+ error("Template classes not supported by Q_GADGET");
+ break;
+ case Q_PROPERTY_TOKEN:
+ parseProperty(&def);
+ break;
+ case Q_ENUMS_TOKEN:
+ parseEnumOrFlag(&def, false);
+ break;
+ case Q_FLAGS_TOKEN:
+ parseEnumOrFlag(&def, true);
+ break;
+ case Q_DECLARE_FLAGS_TOKEN:
+ parseFlag(&def);
+ break;
+ case Q_CLASSINFO_TOKEN:
+ parseClassInfo(&def);
+ break;
+ case Q_INTERFACES_TOKEN:
+ parseInterfaces(&def);
+ break;
+ case Q_PRIVATE_SLOT_TOKEN:
+ parseSlotInPrivate(&def, access);
+ break;
+ case ENUM: {
+ EnumDef enumDef;
+ if (parseEnum(&enumDef))
+ def.enumList += enumDef;
+ } break;
+ default:
+ FunctionDef funcDef;
+ funcDef.access = access;
+ int rewind = index;
+ if (parseMaybeFunction(&def, &funcDef)) {
+ if (funcDef.isConstructor) {
+ if ((access == FunctionDef::Public) && funcDef.isInvokable) {
+ def.constructorList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def.constructorList += funcDef;
+ }
+ }
+ } else if (funcDef.isDestructor) {
+ // don't care about destructors
+ } else {
+ if (access == FunctionDef::Public)
+ def.publicList += funcDef;
+ if (funcDef.isSlot) {
+ def.slotList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def.slotList += funcDef;
+ }
+ } else if (funcDef.isSignal) {
+ def.signalList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def.signalList += funcDef;
+ }
+ } else if (funcDef.isInvokable) {
+ def.methodList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def.methodList += funcDef;
+ }
+ }
+ }
+ } else {
+ index = rewind;
+ }
+ }
+ }
+
+ next(RBRACE);
+
+ if (!def.hasQObject && !def.hasQGadget && def.signalList.isEmpty() && def.slotList.isEmpty()
+ && def.propertyList.isEmpty() && def.enumDeclarations.isEmpty())
+ continue; // no meta object code required
+
+
+ if (!def.hasQObject && !def.hasQGadget)
+ error("Class declarations lacks Q_OBJECT macro.");
+
+ checkSuperClasses(&def);
+
+ classList += def;
+ knownQObjectClasses.insert(def.classname);
+ knownQObjectClasses.insert(def.qualified);
+ }
+ }
+}
+
+void Moc::generate(FILE *out)
+{
+
+ QDateTime dt = QDateTime::currentDateTime();
+ QByteArray dstr = dt.toString().toLatin1();
+ QByteArray fn = filename;
+ int i = filename.length()-1;
+ while (i>0 && filename[i-1] != '/' && filename[i-1] != '\\')
+ --i; // skip path
+ if (i >= 0)
+ fn = filename.mid(i);
+ fprintf(out, "/****************************************************************************\n"
+ "** Meta object code from reading C++ file '%s'\n**\n" , (const char*)fn);
+ fprintf(out, "** Created: %s\n"
+ "** by: The Qt Meta Object Compiler version %d (Qt %s)\n**\n" , dstr.data(), mocOutputRevision, QT_VERSION_STR);
+ fprintf(out, "** WARNING! All changes made in this file will be lost!\n"
+ "*****************************************************************************/\n\n");
+
+
+ if (!noInclude) {
+ if (includePath.size() && includePath.right(1) != "/")
+ includePath += "/";
+ for (int i = 0; i < includeFiles.size(); ++i) {
+ QByteArray inc = includeFiles.at(i);
+ if (inc[0] != '<' && inc[0] != '"') {
+ if (includePath.size() && includePath != "./")
+ inc.prepend(includePath);
+ inc = "\"" + inc + "\"";
+ }
+ fprintf(out, "#include %s\n", inc.constData());
+ }
+ }
+ if (classList.size() && classList.first().classname == "Qt")
+ fprintf(out, "#include <QtCore/qobject.h>\n");
+
+ fprintf(out, "#if !defined(Q_MOC_OUTPUT_REVISION)\n"
+ "#error \"The header file '%s' doesn't include <QObject>.\"\n", (const char *)fn);
+ fprintf(out, "#elif Q_MOC_OUTPUT_REVISION != %d\n", mocOutputRevision);
+ fprintf(out, "#error \"This file was generated using the moc from %s."
+ " It\"\n#error \"cannot be used with the include files from"
+ " this version of Qt.\"\n#error \"(The moc has changed too"
+ " much.)\"\n", QT_VERSION_STR);
+ fprintf(out, "#endif\n\n");
+
+ fprintf(out, "QT_BEGIN_MOC_NAMESPACE\n");
+
+ for (i = 0; i < classList.size(); ++i) {
+ Generator generator(&classList[i], metaTypes, out);
+ generator.generateCode();
+ }
+
+ fprintf(out, "QT_END_MOC_NAMESPACE\n");
+}
+
+
+QList<QMetaObject*> Moc::generate(bool ignoreProperties)
+{
+ QList<QMetaObject*> result;
+ for (int i = 0; i < classList.size(); ++i) {
+ Generator generator(&classList[i], metaTypes);
+ result << generator.generateMetaObject(ignoreProperties);
+ }
+ return result;
+}
+
+void Moc::parseSlots(ClassDef *def, FunctionDef::Access access)
+{
+ next(COLON);
+ while (inClass(def) && hasNext()) {
+ switch (next()) {
+ case PUBLIC:
+ case PROTECTED:
+ case PRIVATE:
+ case Q_SIGNALS_TOKEN:
+ case Q_SLOTS_TOKEN:
+ prev();
+ return;
+ case SEMIC:
+ continue;
+ case FRIEND:
+ until(SEMIC);
+ continue;
+ case USING:
+ error("'using' directive not supported in 'slots' section");
+ default:
+ prev();
+ }
+
+ FunctionDef funcDef;
+ funcDef.access = access;
+ if (!parseFunction(&funcDef))
+ continue;
+ def->slotList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def->slotList += funcDef;
+ }
+ }
+}
+
+void Moc::parseSignals(ClassDef *def)
+{
+ next(COLON);
+ while (inClass(def) && hasNext()) {
+ switch (next()) {
+ case PUBLIC:
+ case PROTECTED:
+ case PRIVATE:
+ case Q_SIGNALS_TOKEN:
+ case Q_SLOTS_TOKEN:
+ prev();
+ return;
+ case SEMIC:
+ continue;
+ case FRIEND:
+ until(SEMIC);
+ continue;
+ case USING:
+ error("'using' directive not supported in 'signals' section");
+ default:
+ prev();
+ }
+ FunctionDef funcDef;
+ funcDef.access = FunctionDef::Protected;
+ parseFunction(&funcDef);
+ if (funcDef.isVirtual)
+ error("Signals cannot be declared virtual");
+ if (funcDef.inlineCode)
+ error("Not a signal declaration");
+ def->signalList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def->signalList += funcDef;
+ }
+ }
+}
+
+
+void Moc::parseProperty(ClassDef *def)
+{
+ next(LPAREN);
+ PropertyDef propDef;
+ QByteArray type = parseType().name;
+ if (type.isEmpty())
+ error();
+ propDef.designable = propDef.scriptable = propDef.stored = "true";
+ propDef.user = "false";
+ /*
+ The Q_PROPERTY construct cannot contain any commas, since
+ commas separate macro arguments. We therefore expect users
+ to type "QMap" instead of "QMap<QString, QVariant>". For
+ coherence, we also expect the same for
+ QValueList<QVariant>, the other template class supported by
+ QVariant.
+ */
+ type = normalizeType(type);
+ if (type == "QMap")
+ type = "QMap<QString,QVariant>";
+ else if (type == "QValueList")
+ type = "QValueList<QVariant>";
+ else if (type == "LongLong")
+ type = "qlonglong";
+ else if (type == "ULongLong")
+ type = "qulonglong";
+ propDef.type = type;
+
+ next();
+ propDef.name = lexem();
+ while (test(IDENTIFIER)) {
+ QByteArray l = lexem();
+ QByteArray v, v2;
+ if (test(LPAREN)) {
+ v = lexemUntil(RPAREN);
+ } else {
+ next(IDENTIFIER);
+ v = lexem();
+ if (test(LPAREN))
+ v2 = lexemUntil(RPAREN);
+ else if (v != "true" && v != "false")
+ v2 = "()";
+ }
+ switch (l[0]) {
+ case 'R':
+ if (l == "READ")
+ propDef.read = v;
+ else if (l == "RESET")
+ propDef.reset = v + v2;
+ else
+ error(2);
+ break;
+ case 'S':
+ if (l == "SCRIPTABLE")
+ propDef.scriptable = v + v2;
+ else if (l == "STORED")
+ propDef.stored = v + v2;
+ else
+ error(2);
+ break;
+ case 'W': if (l != "WRITE") error(2);
+ propDef.write = v;
+ break;
+ case 'D': if (l != "DESIGNABLE") error(2);
+ propDef.designable = v + v2;
+ break;
+ case 'E': if (l != "EDITABLE") error(2);
+ propDef.editable = v + v2;
+ break;
+ case 'N': if (l != "NOTIFY") error(2);
+ propDef.notify = v;
+ break;
+ case 'U': if (l != "USER") error(2);
+ propDef.user = v + v2;
+ break;
+ default:
+ error(2);
+ }
+ }
+ next(RPAREN);
+ if (propDef.read.isNull()) {
+ QByteArray msg;
+ msg += "Property declaration ";
+ msg += propDef.name;
+ msg += " has no READ accessor function. The property will be invalid.";
+ warning(msg.constData());
+ }
+ if(!propDef.notify.isEmpty())
+ def->notifyableProperties++;
+
+ def->propertyList += propDef;
+}
+
+void Moc::parseEnumOrFlag(ClassDef *def, bool isFlag)
+{
+ next(LPAREN);
+ QByteArray identifier;
+ while (test(IDENTIFIER)) {
+ identifier = lexem();
+ while (test(SCOPE) && test(IDENTIFIER)) {
+ identifier += "::";
+ identifier += lexem();
+ }
+ def->enumDeclarations[identifier] = isFlag;
+ }
+ next(RPAREN);
+}
+
+void Moc::parseFlag(ClassDef *def)
+{
+ next(LPAREN);
+ QByteArray flagName, enumName;
+ while (test(IDENTIFIER)) {
+ flagName = lexem();
+ while (test(SCOPE) && test(IDENTIFIER)) {
+ flagName += "::";
+ flagName += lexem();
+ }
+ }
+ next(COMMA);
+ while (test(IDENTIFIER)) {
+ enumName = lexem();
+ while (test(SCOPE) && test(IDENTIFIER)) {
+ enumName += "::";
+ enumName += lexem();
+ }
+ }
+
+ def->flagAliases.insert(enumName, flagName);
+ next(RPAREN);
+}
+
+void Moc::parseClassInfo(ClassDef *def)
+{
+ next(LPAREN);
+ ClassInfoDef infoDef;
+ next(STRING_LITERAL);
+ infoDef.name = symbol().unquotedLexem();
+ next(COMMA);
+ if (test(STRING_LITERAL)) {
+ infoDef.value = symbol().unquotedLexem();
+ } else {
+ // support Q_CLASSINFO("help", QT_TR_NOOP("blah"))
+ next(IDENTIFIER);
+ next(LPAREN);
+ next(STRING_LITERAL);
+ infoDef.value = symbol().unquotedLexem();
+ next(RPAREN);
+ }
+ next(RPAREN);
+ def->classInfoList += infoDef;
+}
+
+void Moc::parseInterfaces(ClassDef *def)
+{
+ next(LPAREN);
+ while (test(IDENTIFIER)) {
+ QList<ClassDef::Interface> iface;
+ iface += ClassDef::Interface(lexem());
+ while (test(SCOPE)) {
+ iface.last().className += lexem();
+ next(IDENTIFIER);
+ iface.last().className += lexem();
+ }
+ while (test(COLON)) {
+ next(IDENTIFIER);
+ iface += ClassDef::Interface(lexem());
+ while (test(SCOPE)) {
+ iface.last().className += lexem();
+ next(IDENTIFIER);
+ iface.last().className += lexem();
+ }
+ }
+ // resolve from classnames to interface ids
+ for (int i = 0; i < iface.count(); ++i) {
+ const QByteArray iid = interface2IdMap.value(iface.at(i).className);
+ if (iid.isEmpty())
+ error("Undefined interface");
+
+ iface[i].interfaceId = iid;
+ }
+ def->interfaceList += iface;
+ }
+ next(RPAREN);
+}
+
+void Moc::parseDeclareInterface()
+{
+ next(LPAREN);
+ QByteArray interface;
+ next(IDENTIFIER);
+ interface += lexem();
+ while (test(SCOPE)) {
+ interface += lexem();
+ next(IDENTIFIER);
+ interface += lexem();
+ }
+ next(COMMA);
+ QByteArray iid;
+ if (test(STRING_LITERAL)) {
+ iid = lexem();
+ } else {
+ next(IDENTIFIER);
+ iid = lexem();
+ }
+ interface2IdMap.insert(interface, iid);
+ next(RPAREN);
+}
+
+void Moc::parseDeclareMetatype()
+{
+ next(LPAREN);
+ QByteArray typeName = lexemUntil(RPAREN);
+ typeName.remove(0, 1);
+ typeName.chop(1);
+ metaTypes.append(typeName);
+}
+
+void Moc::parseSlotInPrivate(ClassDef *def, FunctionDef::Access access)
+{
+ next(LPAREN);
+ FunctionDef funcDef;
+ next(IDENTIFIER);
+ funcDef.inPrivateClass = lexem();
+ // also allow void functions
+ if (test(LPAREN)) {
+ next(RPAREN);
+ funcDef.inPrivateClass += "()";
+ }
+ next(COMMA);
+ funcDef.access = access;
+ parseFunction(&funcDef, true);
+ def->slotList += funcDef;
+ while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
+ funcDef.wasCloned = true;
+ funcDef.arguments.removeLast();
+ def->slotList += funcDef;
+ }
+}
+
+QByteArray Moc::lexemUntil(Token target)
+{
+ int from = index;
+ until(target);
+ QByteArray s;
+ while (from <= index) {
+ QByteArray n = symbols.at(from++-1).lexem();
+ if (s.size() && n.size()
+ && is_ident_char(s.at(s.size()-1))
+ && is_ident_char(n.at(0)))
+ s += ' ';
+ s += n;
+ }
+ return s;
+}
+
+bool Moc::until(Token target) {
+ int braceCount = 0;
+ int brackCount = 0;
+ int parenCount = 0;
+ int angleCount = 0;
+ if (index) {
+ switch(symbols.at(index-1).token) {
+ case LBRACE: ++braceCount; break;
+ case LBRACK: ++brackCount; break;
+ case LPAREN: ++parenCount; break;
+ case LANGLE: ++angleCount; break;
+ default: break;
+ }
+ }
+ while (index < symbols.size()) {
+ Token t = symbols.at(index++).token;
+ switch (t) {
+ case LBRACE: ++braceCount; break;
+ case RBRACE: --braceCount; break;
+ case LBRACK: ++brackCount; break;
+ case RBRACK: --brackCount; break;
+ case LPAREN: ++parenCount; break;
+ case RPAREN: --parenCount; break;
+ case LANGLE: ++angleCount; break;
+ case RANGLE: --angleCount; break;
+ case GTGT: angleCount -= 2; t = RANGLE; break;
+ default: break;
+ }
+ if (t == target
+ && braceCount <= 0
+ && brackCount <= 0
+ && parenCount <= 0
+ && (target != RANGLE || angleCount <= 0))
+ return true;
+
+ if (braceCount < 0 || brackCount < 0 || parenCount < 0
+ || (target == RANGLE && angleCount < 0)) {
+ --index;
+ break;
+ }
+ }
+ return false;
+}
+
+void Moc::checkSuperClasses(ClassDef *def)
+{
+ const QByteArray firstSuperclass = def->superclassList.value(0).first;
+
+ if (!knownQObjectClasses.contains(firstSuperclass)) {
+ // enable once we /require/ include paths
+#if 0
+ QByteArray msg;
+ msg += "Class ";
+ msg += def->className;
+ msg += " contains the Q_OBJECT macro and inherits from ";
+ msg += def->superclassList.value(0);
+ msg += " but that is not a known QObject subclass. You may get compilation errors.";
+ warning(msg.constData());
+#endif
+ return;
+ }
+ for (int i = 1; i < def->superclassList.count(); ++i) {
+ const QByteArray superClass = def->superclassList.at(i).first;
+ if (knownQObjectClasses.contains(superClass)) {
+ QByteArray msg;
+ msg += "Class ";
+ msg += def->classname;
+ msg += " inherits from two QObject subclasses ";
+ msg += firstSuperclass;
+ msg += " and ";
+ msg += superClass;
+ msg += ". This is not supported!";
+ warning(msg.constData());
+ }
+
+ if (interface2IdMap.contains(superClass)) {
+ bool registeredInterface = false;
+ for (int i = 0; i < def->interfaceList.count(); ++i)
+ if (def->interfaceList.at(i).first().className == superClass) {
+ registeredInterface = true;
+ break;
+ }
+
+ if (!registeredInterface) {
+ QByteArray msg;
+ msg += "Class ";
+ msg += def->classname;
+ msg += " implements the interface ";
+ msg += superClass;
+ msg += " but does not list it in Q_INTERFACES. qobject_cast to ";
+ msg += superClass;
+ msg += " will not work!";
+ warning(msg.constData());
+ }
+ }
+ }
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h
new file mode 100644
index 0000000..689104c
--- /dev/null
+++ b/src/tools/moc/moc.h
@@ -0,0 +1,247 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOC_H
+#define MOC_H
+
+#include "parser.h"
+#include <QStringList>
+#include <QMap>
+#include <QPair>
+#include <stdio.h>
+#include <ctype.h>
+
+QT_BEGIN_NAMESPACE
+
+struct QMetaObject;
+
+struct Type
+{
+ enum ReferenceType { NoReference, Reference, Pointer };
+
+ inline Type() : isVolatile(false), isScoped(false), firstToken(NOTOKEN), referenceType(NoReference) {}
+ inline explicit Type(const QByteArray &_name) : name(_name), isVolatile(false), firstToken(NOTOKEN), referenceType(NoReference) {}
+ QByteArray name;
+ uint isVolatile : 1;
+ uint isScoped : 1;
+ Token firstToken;
+ ReferenceType referenceType;
+};
+
+struct EnumDef
+{
+ QByteArray name;
+ QList<QByteArray> values;
+};
+
+struct ArgumentDef
+{
+ ArgumentDef() : isDefault(false) {}
+ Type type;
+ QByteArray rightType, normalizedType, name;
+ QByteArray typeNameForCast; // type name to be used in cast from void * in metacall
+ bool isDefault;
+};
+
+struct FunctionDef
+{
+ FunctionDef(): returnTypeIsVolatile(false), access(Private), isConst(false), isVirtual(false),
+ inlineCode(false), wasCloned(false), isCompat(false), isInvokable(false),
+ isScriptable(false), isSlot(false), isSignal(false),
+ isConstructor(false), isDestructor(false), isAbstract(false) {}
+ Type type;
+ QByteArray normalizedType;
+ QByteArray tag;
+ QByteArray name;
+ bool returnTypeIsVolatile;
+
+ QList<ArgumentDef> arguments;
+
+ enum Access { Private, Protected, Public };
+ Access access;
+ bool isConst;
+ bool isVirtual;
+ bool inlineCode;
+ bool wasCloned;
+
+ QByteArray inPrivateClass;
+ bool isCompat;
+ bool isInvokable;
+ bool isScriptable;
+ bool isSlot;
+ bool isSignal;
+ bool isConstructor;
+ bool isDestructor;
+ bool isAbstract;
+};
+
+struct PropertyDef
+{
+ PropertyDef():notifyId(-1), gspec(ValueSpec){}
+ QByteArray name, type, read, write, reset, designable, scriptable, editable, stored, user, notify;
+ int notifyId;
+ enum Specification { ValueSpec, ReferenceSpec, PointerSpec };
+ Specification gspec;
+ bool stdCppSet() const {
+ QByteArray s("set");
+ s += toupper(name[0]);
+ s += name.mid(1);
+ return (s == write);
+ }
+};
+
+
+struct ClassInfoDef
+{
+ QByteArray name;
+ QByteArray value;
+};
+
+struct ClassDef {
+ ClassDef():
+ hasQObject(false), hasQGadget(false), notifyableProperties(0){}
+ QByteArray classname;
+ QByteArray qualified;
+ QList<QPair<QByteArray, FunctionDef::Access> > superclassList;
+
+ struct Interface
+ {
+ inline explicit Interface(const QByteArray &_className)
+ : className(_className) {}
+ QByteArray className;
+ QByteArray interfaceId;
+ };
+ QList<QList<Interface> >interfaceList;
+
+ bool hasQObject;
+ bool hasQGadget;
+
+ QList<FunctionDef> constructorList;
+ QList<FunctionDef> signalList, slotList, methodList, publicList;
+ int notifyableProperties;
+ QList<PropertyDef> propertyList;
+ QList<ClassInfoDef> classInfoList;
+ QMap<QByteArray, bool> enumDeclarations;
+ QList<EnumDef> enumList;
+ QMap<QByteArray, QByteArray> flagAliases;
+
+ int begin;
+ int end;
+};
+
+struct NamespaceDef {
+ QByteArray name;
+ int begin;
+ int end;
+};
+
+class Moc : public Parser
+{
+public:
+ Moc()
+ : noInclude(false), generatedCode(false)
+ {}
+
+ QByteArray filename;
+
+ bool noInclude;
+ bool generatedCode;
+ QByteArray includePath;
+ QList<QByteArray> includeFiles;
+ QList<ClassDef> classList;
+ QMap<QByteArray, QByteArray> interface2IdMap;
+ QList<QByteArray> metaTypes;
+ QSet<QByteArray> knownQObjectClasses;
+
+ void parse();
+ void generate(FILE *out);
+ QList<QMetaObject*> generate(bool ignoreProperties);
+
+ bool parseClassHead(ClassDef *def);
+ inline bool inClass(const ClassDef *def) const {
+ return index > def->begin && index < def->end - 1;
+ }
+
+ inline bool inNamespace(const NamespaceDef *def) const {
+ return index > def->begin && index < def->end - 1;
+ }
+
+ Type parseType();
+
+ bool parseEnum(EnumDef *def);
+
+ bool parseFunction(FunctionDef *def, bool inMacro = false);
+ bool parseMaybeFunction(const ClassDef *cdef, FunctionDef *def);
+
+ void parseSlots(ClassDef *def, FunctionDef::Access access);
+ void parseSignals(ClassDef *def);
+ void parseProperty(ClassDef *def);
+ void parseEnumOrFlag(ClassDef *def, bool isFlag);
+ void parseFlag(ClassDef *def);
+ void parseClassInfo(ClassDef *def);
+ void parseInterfaces(ClassDef *def);
+ void parseDeclareInterface();
+ void parseDeclareMetatype();
+ void parseSlotInPrivate(ClassDef *def, FunctionDef::Access access);
+
+ void parseFunctionArguments(FunctionDef *def);
+
+ QByteArray lexemUntil(Token);
+ bool until(Token);
+
+ // test for Q_INVOCABLE, Q_SCRIPTABLE, etc. and set the flags
+ // in FunctionDef accordingly
+ bool testFunctionAttribute(FunctionDef *def);
+ bool testFunctionAttribute(Token tok, FunctionDef *def);
+
+ void checkSuperClasses(ClassDef *def);
+};
+
+inline QByteArray noRef(const QByteArray &type)
+{
+ if (type.endsWith('&'))
+ return type.left(type.length()-1);
+ return type;
+}
+
+QT_END_NAMESPACE
+
+#endif // MOC_H
diff --git a/src/tools/moc/moc.pri b/src/tools/moc/moc.pri
new file mode 100644
index 0000000..b689a35
--- /dev/null
+++ b/src/tools/moc/moc.pri
@@ -0,0 +1,16 @@
+
+INCLUDEPATH += $$PWD
+
+HEADERS = $$PWD/moc.h \
+ $$PWD/preprocessor.h \
+ $$PWD/parser.h \
+ $$PWD/symbols.h \
+ $$PWD/token.h \
+ $$PWD/utils.h \
+ $$PWD/generator.h \
+ $$PWD/outputrevision.h
+SOURCES = $$PWD/moc.cpp \
+ $$PWD/preprocessor.cpp \
+ $$PWD/generator.cpp \
+ $$PWD/parser.cpp \
+ $$PWD/token.cpp
diff --git a/src/tools/moc/moc.pro b/src/tools/moc/moc.pro
new file mode 100644
index 0000000..0b8ddbe
--- /dev/null
+++ b/src/tools/moc/moc.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+TARGET = moc
+
+DEFINES += QT_MOC
+DESTDIR = ../../../bin
+INCLUDEPATH += .
+DEPENDPATH += .
+LIBS =
+OBJECTS_DIR = .
+
+include(moc.pri)
+HEADERS += qdatetime_p.h
+SOURCES += main.cpp
+include(../bootstrap/bootstrap.pri)
+
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
+include(../../qt_targets.pri)
diff --git a/src/tools/moc/mwerks_mac.cpp b/src/tools/moc/mwerks_mac.cpp
new file mode 100644
index 0000000..ae8defa
--- /dev/null
+++ b/src/tools/moc/mwerks_mac.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifdef MOC_MWERKS_PLUGIN
+
+#include "mwerks_mac.h"
+#include "qt_mac.h"
+
+/* compiler headers */
+#include "DropInCompilerLinker.h"
+#include "CompilerMapping.h"
+#include "CWPluginErrors.h"
+
+/* standard headers */
+#include <stdio.h>
+#include <string.h>
+
+QT_BEGIN_NAMESPACE
+
+//qglobal.cpp
+const unsigned char * p_str(const char * c);
+QCString pstring2qstring(const unsigned char *c);
+
+#if CW_USE_PRAGMA_EXPORT
+#pragma export on
+#endif
+
+CWPLUGIN_ENTRY(CWPlugin_GetDropInFlags)(const DropInFlags** flags, long* flagsSize)
+{
+ static const DropInFlags sFlags = {
+ kCurrentDropInFlagsVersion,
+ CWDROPINCOMPILERTYPE,
+ DROPINCOMPILERLINKERAPIVERSION_7,
+ kCompAlwaysReload|kCompRequiresProjectBuildStartedMsg,
+ Lang_C_CPP,
+ DROPINCOMPILERLINKERAPIVERSION
+ };
+ *flags = &sFlags;
+ *flagsSize = sizeof(sFlags);
+ return cwNoErr;
+}
+
+
+
+CWPLUGIN_ENTRY(CWPlugin_GetDropInName)(const char** dropinName)
+{
+ static const char sDropInName[] = "McMoc";
+ *dropinName = sDropInName;
+ return cwNoErr;
+}
+
+CWPLUGIN_ENTRY(CWPlugin_GetDisplayName)(const char** displayName)
+{
+ static const char sDisplayName[] = "McMoc";
+ *displayName = sDisplayName;
+ return cwNoErr;
+}
+
+CWPLUGIN_ENTRY(CWPlugin_GetTargetList)(const CWTargetList** targetList)
+{
+ static CWDataType sCPU = targetCPUAny;
+ static CWDataType sOS = targetOSMacintosh;
+ static CWTargetList sTargetList = {kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS};
+ *targetList = &sTargetList;
+ return cwNoErr;
+}
+
+CWPLUGIN_ENTRY(CWPlugin_GetDefaultMappingList)(const CWExtMapList** defaultMappingList)
+{
+ static CWExtensionMapping sExtension[] = { {'TEXT', ".mocs", kPrecompile } };
+ static CWExtMapList sExtensionMapList = {kCurrentCWExtMapListVersion, 3, sExtension};
+ *defaultMappingList = &sExtensionMapList;
+ return cwNoErr;
+}
+
+#if CW_USE_PRAGMA_EXPORT
+#pragma export off
+#endif
+typedef short CWFileRef;
+
+static int line_count = 0;
+moc_status do_moc(CWPluginContext, const QCString &, const QCString &, CWFileSpec *, bool);
+
+static CWResult mocify(CWPluginContext context, const QCString &source)
+{
+ CWDisplayLines(context, line_count++);
+
+ source.stripWhiteSpace();
+
+ CWResult err;
+ bool dotmoc=false;
+ QCString stem = source, ext;
+ int dotpos = stem.findRev('.');
+ if(dotpos != -1) {
+ ext = stem.right(stem.length() - (dotpos+1));
+ stem = stem.left(dotpos);
+ if(ext == "cpp")
+ dotmoc = true;
+ } else {
+ //whoa!
+ }
+ QCString dest;
+ if(dotmoc)
+ dest = stem + ".moc";
+ else
+ dest = "moc_" + stem + ".cpp";
+
+ //moc it
+ CWFileSpec destSpec;
+ moc_status mocd = do_moc(context, source, dest, &destSpec, dotmoc);
+
+#if 0
+ QCString derr = "Weird";
+ switch(mocd) {
+ case moc_success: derr = "Success"; break;
+ case moc_parse_error: derr = "Parser Error"; break;
+ case moc_no_qobject:derr = "No QOBJECT"; break;
+ case moc_not_time: derr = "Not Time"; break;
+ case moc_no_source: derr = "No Source"; break;
+ case moc_general_error: derr = "General Error"; break;
+ }
+ char dmsg[200];
+ sprintf(dmsg, "\"%s\" %s", source.data(), derr.data());
+ CWReportMessage(context, NULL, dmsg, NULL, messagetypeError, 0);
+#endif
+
+ //handle project
+ if(mocd == moc_no_qobject) {
+ char msg[400];
+ sprintf(msg, "\"%s\" No relevant classes found. No output generated.", source.data());
+ CWReportMessage(context, NULL, msg, NULL, messagetypeWarning, 0);
+ } else if ((mocd == moc_success || mocd == moc_not_time) && !dotmoc)
+ {
+ long whichFile;
+ CWNewProjectEntryInfo ei;
+ memset(&ei, '\0', sizeof(ei));
+ ei.groupPath = "QtGenerated";
+ err = CWAddProjectEntry(context, &destSpec, true, &ei, &whichFile);
+ if (!CWSUCCESS(err))
+ {
+ char msg[200];
+ sprintf(msg, "\"%s\" not added", dest.data());
+ CWReportMessage(context, NULL, msg, NULL, messagetypeWarning, 0);
+ }
+ if(mocd == moc_success)
+ CWSetModDate(context, &destSpec, NULL, true);
+ }
+ return cwNoErr;
+}
+
+pascal short main(CWPluginContext context)
+{
+ short result;
+ long request;
+
+ if (CWGetPluginRequest(context, &request) != cwNoErr)
+ return cwErrRequestFailed;
+ result = cwErrInvalidParameter;
+
+ /* dispatch on compiler request */
+ switch (request)
+ {
+ case reqInitCompiler:
+ case reqTermCompiler:
+ result = cwNoErr;
+ break;
+
+ case reqCompile:
+ {
+ line_count = 0;
+ const char *files = NULL;
+ long filelen;
+ CWGetMainFileText(context, &files, &filelen);
+ const char *beg = files;
+ for(int x = 0; x < filelen; x++) {
+ if(*(files++) == '\r') {
+ char file[1024];
+ memcpy(file, beg, files - beg);
+ file[(files-beg)-1] = '\0';
+ mocify(context, file);
+ beg = files;
+ }
+ }
+ if(beg != files) {
+ char file[1024];
+ memcpy(file, beg, files - beg);
+ file[(files-beg)] = '\0';
+ mocify(context, file);
+ }
+
+ result = cwNoErr;
+ break;
+ }
+ }
+
+ /* return result code */
+ return result;
+}
+
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/tools/moc/mwerks_mac.h b/src/tools/moc/mwerks_mac.h
new file mode 100644
index 0000000..bca0829
--- /dev/null
+++ b/src/tools/moc/mwerks_mac.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MWERKS_MAC_H
+#define MWERKS_MAC_H
+
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_OS_MAC
+
+#define macintosh
+
+/*make moc a plugin*/
+enum moc_status {
+ moc_success = 1,
+ moc_parse_error = 2,
+ moc_no_qobject = 3,
+ moc_not_time = 4,
+ moc_no_source = 5,
+ moc_general_error = 6
+};
+
+#endif
+
+QT_END_NAMESPACE
+
+#endif // MWERKS_MAC_H
diff --git a/src/tools/moc/outputrevision.h b/src/tools/moc/outputrevision.h
new file mode 100644
index 0000000..1e1d640
--- /dev/null
+++ b/src/tools/moc/outputrevision.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OUTPUTREVISION_H
+#define OUTPUTREVISION_H
+
+// if the output revision changes, you MUST change it in qobjectdefs.h too
+enum { mocOutputRevision = 61 }; // moc format output revision
+
+#endif // OUTPUTREVISION_H
diff --git a/src/tools/moc/parser.cpp b/src/tools/moc/parser.cpp
new file mode 100644
index 0000000..b6c3f63
--- /dev/null
+++ b/src/tools/moc/parser.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "parser.h"
+#include "utils.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef USE_LEXEM_STORE
+Symbol::LexemStore Symbol::lexemStore;
+#endif
+
+static const char *error_msg = 0;
+
+#ifdef Q_CC_MSVC
+#define ErrorFormatString "%s(%d): "
+#else
+#define ErrorFormatString "%s:%d: "
+#endif
+
+void Parser::error(int rollback) {
+ index -= rollback;
+ error();
+}
+void Parser::error(const char *msg) {
+ if (msg || error_msg)
+ qWarning(ErrorFormatString "Error: %s",
+ currentFilenames.top().constData(), symbol().lineNum, msg?msg:error_msg);
+ else
+ qWarning(ErrorFormatString "Parse error at \"%s\"",
+ currentFilenames.top().constData(), symbol().lineNum, symbol().lexem().data());
+ exit(EXIT_FAILURE);
+}
+
+void Parser::warning(const char *msg) {
+ if (displayWarnings && msg)
+ fprintf(stderr, ErrorFormatString "Warning: %s\n",
+ currentFilenames.top().constData(), qMax(0, index > 0 ? symbol().lineNum : 0), msg);
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h
new file mode 100644
index 0000000..c49f3cf
--- /dev/null
+++ b/src/tools/moc/parser.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <QStack>
+#include "symbols.h"
+
+QT_BEGIN_NAMESPACE
+
+class Parser
+{
+public:
+ Parser():index(0), displayWarnings(true){}
+ Symbols symbols;
+ int index;
+ bool displayWarnings;
+
+ QStack<QByteArray> currentFilenames;
+
+ inline bool hasNext() const { return (index < symbols.size()); }
+ inline Token next() { if (index >= symbols.size()) return NOTOKEN; return symbols.at(index++).token; }
+ bool test(Token);
+ void next(Token);
+ void next(Token, const char *msg);
+ inline void prev() {--index;}
+ inline Token lookup(int k = 1);
+ inline const Symbol &symbol_lookup(int k = 1) { return symbols.at(index-1+k);}
+ inline Token token() { return symbols.at(index-1).token;}
+ inline QByteArray lexem() { return symbols.at(index-1).lexem();}
+ inline QByteArray unquotedLexem() { return symbols.at(index-1).unquotedLexem();}
+ inline const Symbol &symbol() { return symbols.at(index-1);}
+
+ void error(int rollback);
+ void error(const char *msg = 0);
+ void warning(const char * = 0);
+
+};
+
+inline bool Parser::test(Token token)
+{
+ if (index < symbols.size() && symbols.at(index).token == token) {
+ ++index;
+ return true;
+ }
+ return false;
+}
+
+inline Token Parser::lookup(int k)
+{
+ const int l = index - 1 + k;
+ return l < symbols.size() ? symbols.at(l).token : NOTOKEN;
+}
+
+inline void Parser::next(Token token)
+{
+ if (!test(token))
+ error();
+}
+
+inline void Parser::next(Token token, const char *msg)
+{
+ if (!test(token))
+ error(msg);
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/tools/moc/ppkeywords.cpp b/src/tools/moc/ppkeywords.cpp
new file mode 100644
index 0000000..1e4f063
--- /dev/null
+++ b/src/tools/moc/ppkeywords.cpp
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// auto generated
+// DO NOT EDIT.
+
+static const short pp_keyword_trans[][128] = {
+ {0,0,0,0,0,0,0,0,0,98,12,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 98,76,96,13,0,60,62,97,9,10,58,56,11,57,102,59,
+ 6,6,6,6,6,6,6,6,6,6,92,0,7,81,8,91,
+ 0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 1,1,1,1,1,1,1,1,1,1,1,0,101,0,61,1,
+ 0,1,2,3,4,1,1,1,1,1,1,1,1,1,5,1,
+ 1,1,1,1,1,1,1,1,1,1,1,0,68,0,71,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,79,87,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,88,80,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,93,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,14,34,0,0,0,20,0,0,0,0,0,0,
+ 0,0,0,0,0,22,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,21,0,0,0,0,0,0,0,44,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,27,0,0,0,0,0,0,0,0,0,30,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,35,0,40,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,36,0,0,0,0,0,0,
+ 0,0,0,38,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,100,0,0,0,0,99,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,65,0,0,0,0,0,0,0,0,0,0,0,0,0,69,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 103,103,103,103,103,103,103,103,103,103,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
+};
+
+static const struct
+{
+ PP_Token token;
+ short next;
+ char defchar;
+ short defnext;
+ PP_Token ident;
+} pp_keywords[] = {
+ {PP_NOTOKEN, 0, 0, 0, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 0, 0, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 105, 63, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 111, 72, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 101, 50, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 111, 77, PP_NOTOKEN},
+ {PP_DIGIT, 0, 0, 0, PP_NOTOKEN},
+ {PP_LANGLE, 1, 0, 0, PP_NOTOKEN},
+ {PP_RANGLE, 2, 0, 0, PP_NOTOKEN},
+ {PP_LPAREN, 0, 0, 0, PP_NOTOKEN},
+ {PP_RPAREN, 0, 0, 0, PP_NOTOKEN},
+ {PP_COMMA, 0, 0, 0, PP_NOTOKEN},
+ {PP_NEWLINE, 0, 0, 0, PP_NOTOKEN},
+ {PP_HASH, 3, 0, 0, PP_HASH},
+ {PP_HASH, 0, 101, 15, PP_HASH},
+ {PP_HASH, 0, 102, 16, PP_HASH},
+ {PP_HASH, 0, 105, 17, PP_HASH},
+ {PP_HASH, 0, 110, 18, PP_HASH},
+ {PP_HASH, 0, 101, 19, PP_HASH},
+ {PP_DEFINE, 0, 0, 0, PP_HASH},
+ {PP_HASH, 4, 0, 0, PP_HASH},
+ {PP_IF, 5, 0, 0, PP_HASH},
+ {PP_HASH, 0, 110, 23, PP_HASH},
+ {PP_HASH, 0, 100, 24, PP_HASH},
+ {PP_HASH, 0, 101, 25, PP_HASH},
+ {PP_HASH, 0, 102, 26, PP_HASH},
+ {PP_UNDEF, 0, 0, 0, PP_HASH},
+ {PP_HASH, 0, 101, 28, PP_HASH},
+ {PP_HASH, 0, 102, 29, PP_HASH},
+ {PP_IFDEF, 0, 0, 0, PP_HASH},
+ {PP_HASH, 0, 100, 31, PP_HASH},
+ {PP_HASH, 0, 101, 32, PP_HASH},
+ {PP_HASH, 0, 102, 33, PP_HASH},
+ {PP_IFNDEF, 0, 0, 0, PP_HASH},
+ {PP_HASH, 6, 0, 0, PP_HASH},
+ {PP_HASH, 7, 0, 0, PP_HASH},
+ {PP_HASH, 0, 102, 37, PP_HASH},
+ {PP_ELIF, 0, 0, 0, PP_HASH},
+ {PP_HASH, 0, 101, 39, PP_HASH},
+ {PP_ELSE, 0, 0, 0, PP_HASH},
+ {PP_HASH, 0, 100, 41, PP_HASH},
+ {PP_HASH, 0, 105, 42, PP_HASH},
+ {PP_HASH, 0, 102, 43, PP_HASH},
+ {PP_ENDIF, 0, 0, 0, PP_HASH},
+ {PP_HASH, 0, 99, 45, PP_HASH},
+ {PP_HASH, 0, 108, 46, PP_HASH},
+ {PP_HASH, 0, 117, 47, PP_HASH},
+ {PP_HASH, 0, 100, 48, PP_HASH},
+ {PP_HASH, 0, 101, 49, PP_HASH},
+ {PP_INCLUDE, 0, 0, 0, PP_HASH},
+ {PP_CHARACTER, 0, 102, 51, PP_CHARACTER},
+ {PP_CHARACTER, 0, 105, 52, PP_CHARACTER},
+ {PP_CHARACTER, 0, 110, 53, PP_CHARACTER},
+ {PP_CHARACTER, 0, 101, 54, PP_CHARACTER},
+ {PP_CHARACTER, 0, 100, 55, PP_CHARACTER},
+ {PP_DEFINED, 0, 0, 0, PP_CHARACTER},
+ {PP_PLUS, 0, 0, 0, PP_NOTOKEN},
+ {PP_MINUS, 0, 0, 0, PP_NOTOKEN},
+ {PP_STAR, 0, 0, 0, PP_NOTOKEN},
+ {PP_SLASH, 8, 0, 0, PP_NOTOKEN},
+ {PP_PERCENT, 0, 58, 94, PP_NOTOKEN},
+ {PP_HAT, 0, 0, 0, PP_NOTOKEN},
+ {PP_AND, 0, 38, 89, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 116, 64, PP_CHARACTER},
+ {PP_CHARACTER, 9, 0, 0, PP_CHARACTER},
+ {PP_CHARACTER, 0, 110, 66, PP_CHARACTER},
+ {PP_CHARACTER, 0, 100, 67, PP_CHARACTER},
+ {PP_AND, 0, 0, 0, PP_CHARACTER},
+ {PP_OR, 0, 124, 90, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 114, 70, PP_CHARACTER},
+ {PP_OR, 0, 0, 0, PP_CHARACTER},
+ {PP_TILDE, 0, 0, 0, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 109, 73, PP_CHARACTER},
+ {PP_CHARACTER, 0, 112, 74, PP_CHARACTER},
+ {PP_CHARACTER, 0, 108, 75, PP_CHARACTER},
+ {PP_TILDE, 0, 0, 0, PP_CHARACTER},
+ {PP_NOT, 0, 61, 83, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 116, 78, PP_CHARACTER},
+ {PP_NOT, 0, 95, 84, PP_CHARACTER},
+ {PP_LTLT, 0, 0, 0, PP_NOTOKEN},
+ {PP_GTGT, 0, 0, 0, PP_NOTOKEN},
+ {PP_INCOMPLETE, 0, 61, 82, PP_NOTOKEN},
+ {PP_EQEQ, 0, 0, 0, PP_NOTOKEN},
+ {PP_NE, 0, 0, 0, PP_NOTOKEN},
+ {PP_CHARACTER, 0, 101, 85, PP_CHARACTER},
+ {PP_CHARACTER, 0, 113, 86, PP_CHARACTER},
+ {PP_NE, 0, 0, 0, PP_CHARACTER},
+ {PP_LE, 0, 0, 0, PP_NOTOKEN},
+ {PP_GE, 0, 0, 0, PP_NOTOKEN},
+ {PP_ANDAND, 0, 0, 0, PP_NOTOKEN},
+ {PP_OROR, 0, 0, 0, PP_NOTOKEN},
+ {PP_QUESTION, 0, 0, 0, PP_NOTOKEN},
+ {PP_COLON, 0, 0, 0, PP_NOTOKEN},
+ {PP_HASHHASH, 0, 0, 0, PP_NOTOKEN},
+ {PP_INCOMPLETE, 0, 37, 95, PP_NOTOKEN},
+ {PP_INCOMPLETE, 0, 58, 93, PP_NOTOKEN},
+ {PP_QUOTE, 0, 0, 0, PP_NOTOKEN},
+ {PP_SINGLEQUOTE, 0, 0, 0, PP_NOTOKEN},
+ {PP_WHITESPACE, 0, 0, 0, PP_NOTOKEN},
+ {PP_CPP_COMMENT, 0, 0, 0, PP_NOTOKEN},
+ {PP_C_COMMENT, 0, 0, 0, PP_NOTOKEN},
+ {PP_BACKSLASH, 0, 0, 0, PP_NOTOKEN},
+ {PP_INCOMPLETE, 10, 0, 0, PP_NOTOKEN},
+ {PP_FLOATING_LITERAL, 0, 0, 0, PP_NOTOKEN}
+};
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
new file mode 100644
index 0000000..45cbbfd
--- /dev/null
+++ b/src/tools/moc/preprocessor.cpp
@@ -0,0 +1,978 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "preprocessor.h"
+#include "utils.h"
+#include <QStringList>
+#include <QFile>
+#include <QDir>
+#include <QFileInfo>
+
+QT_BEGIN_NAMESPACE
+
+#include "ppkeywords.cpp"
+#include "keywords.cpp"
+
+// transform \r\n into \n
+// \r into \n (os9 style)
+// backslash-newlines into newlines
+static QByteArray cleaned(const QByteArray &input)
+{
+ QByteArray result;
+ result.reserve(input.size());
+ const char *data = input;
+ char *output = result.data();
+
+ int newlines = 0;
+ while (*data) {
+ while (*data && is_space(*data))
+ ++data;
+ bool takeLine = (*data == '#');
+ if (*data == '%' && *(data+1) == ':') {
+ takeLine = true;
+ ++data;
+ }
+ if (takeLine) {
+ *output = '#';
+ ++output;
+ do ++data; while (*data && is_space(*data));
+ }
+ while (*data) {
+ // handle \\\n, \\\r\n and \\\r
+ if (*data == '\\') {
+ if (*(data + 1) == '\r') {
+ ++data;
+ }
+ if (*data && (*(data + 1) == '\n' || (*data) == '\r')) {
+ ++newlines;
+ data += 1;
+ if (*data != '\r')
+ data += 1;
+ continue;
+ }
+ } else if (*data == '\r' && *(data + 1) == '\n') { // reduce \r\n to \n
+ ++data;
+ }
+
+ char ch = *data;
+ if (ch == '\r') // os9: replace \r with \n
+ ch = '\n';
+ *output = ch;
+ ++output;
+
+ if (*data == '\n') {
+ // output additional newlines to keep the correct line-numbering
+ // for the lines following the backslash-newline sequence(s)
+ while (newlines) {
+ *output = '\n';
+ ++output;
+ --newlines;
+ }
+ ++data;
+ break;
+ }
+ ++data;
+ }
+ }
+ result.resize(output - result.constData());
+ return result;
+}
+
+bool Preprocessor::preprocessOnly = false;
+void Preprocessor::skipUntilEndif()
+{
+ while(index < symbols.size() - 1 && symbols.at(index).token != PP_ENDIF){
+ switch (symbols.at(index).token) {
+ case PP_IF:
+ case PP_IFDEF:
+ case PP_IFNDEF:
+ ++index;
+ skipUntilEndif();
+ break;
+ default:
+ ;
+ }
+ ++index;
+ }
+}
+
+bool Preprocessor::skipBranch()
+{
+ while (index < symbols.size() - 1
+ && (symbols.at(index).token != PP_ENDIF
+ && symbols.at(index).token != PP_ELIF
+ && symbols.at(index).token != PP_ELSE)
+ ){
+ switch (symbols.at(index).token) {
+ case PP_IF:
+ case PP_IFDEF:
+ case PP_IFNDEF:
+ ++index;
+ skipUntilEndif();
+ break;
+ default:
+ ;
+ }
+ ++index;
+ }
+ return (index < symbols.size() - 1);
+}
+
+
+enum TokenizeMode { TokenizeCpp, TokenizePreprocessor, PreparePreprocessorStatement, TokenizePreprocessorStatement, TokenizeInclude };
+static Symbols tokenize(const QByteArray &input, int lineNum = 1, TokenizeMode mode = TokenizeCpp)
+{
+ Symbols symbols;
+ const char *begin = input;
+ const char *data = begin;
+ while (*data) {
+ if (mode == TokenizeCpp) {
+ int column = 0;
+
+ const char *lexem = data;
+ int state = 0;
+ Token token = NOTOKEN;
+ for (;;) {
+ if (static_cast<signed char>(*data) < 0) {
+ ++data;
+ continue;
+ }
+ int nextindex = keywords[state].next;
+ int next = 0;
+ if (*data == keywords[state].defchar)
+ next = keywords[state].defnext;
+ else if (!state || nextindex)
+ next = keyword_trans[nextindex][(int)*data];
+ if (!next)
+ break;
+ state = next;
+ token = keywords[state].token;
+ ++data;
+ }
+
+ // suboptimal, is_ident_char should use a table
+ if (keywords[state].ident && is_ident_char(*data))
+ token = keywords[state].ident;
+
+ if (token == NOTOKEN) {
+ // an error really
+ ++data;
+ continue;
+ }
+
+ ++column;
+
+ if (token > SPECIAL_TREATMENT_MARK) {
+ switch (token) {
+ case QUOTE:
+ data = skipQuote(data);
+ token = STRING_LITERAL;
+ // concatenate multi-line strings for easier
+ // STRING_LITERAAL handling in moc
+ if (!Preprocessor::preprocessOnly
+ && !symbols.isEmpty()
+ && symbols.last().token == STRING_LITERAL) {
+
+ QByteArray newString = symbols.last().unquotedLexem();
+ newString += input.mid(lexem - begin + 1, data - lexem - 2);
+ newString.prepend('\"');
+ newString.append('\"');
+ symbols.last() = Symbol(symbols.last().lineNum,
+ STRING_LITERAL,
+ newString);
+ continue;
+ }
+ break;
+ case SINGLEQUOTE:
+ while (*data && (*data != '\''
+ || (*(data-1)=='\\'
+ && *(data-2)!='\\')))
+ ++data;
+ if (*data)
+ ++data;
+ token = CHARACTER_LITERAL;
+ break;
+ case LANGLE_SCOPE:
+ // split <:: into two tokens, < and ::
+ token = LANGLE;
+ data -= 2;
+ break;
+ case DIGIT:
+ while (is_digit_char(*data))
+ ++data;
+ if (!*data || *data != '.') {
+ token = INTEGER_LITERAL;
+ if (data - lexem == 1 &&
+ (*data == 'x' || *data == 'X')
+ && *lexem == '0') {
+ ++data;
+ while (is_hex_char(*data))
+ ++data;
+ }
+ break;
+ }
+ token = FLOATING_LITERAL;
+ ++data;
+ // fall through
+ case FLOATING_LITERAL:
+ while (is_digit_char(*data))
+ ++data;
+ if (*data == '+' || *data == '-')
+ ++data;
+ if (*data == 'e' || *data == 'E') {
+ ++data;
+ while (is_digit_char(*data))
+ ++data;
+ }
+ if (*data == 'f' || *data == 'F'
+ || *data == 'l' || *data == 'L')
+ ++data;
+ break;
+ case HASH:
+ if (column == 1) {
+ mode = PreparePreprocessorStatement;
+ while (*data && (*data == ' ' || *data == '\t'))
+ ++data;
+ if (is_ident_char(*data))
+ mode = TokenizePreprocessorStatement;
+ continue;
+ }
+ break;
+ case NEWLINE:
+ ++lineNum;
+ continue;
+ case BACKSLASH:
+ {
+ const char *rewind = data;
+ while (*data && (*data == ' ' || *data == '\t'))
+ ++data;
+ if (*data && *data == '\n') {
+ ++data;
+ continue;
+ }
+ data = rewind;
+ } break;
+ case CHARACTER:
+ while (is_ident_char(*data))
+ ++data;
+ token = IDENTIFIER;
+ break;
+ case C_COMMENT:
+ if (*data) {
+ if (*data == '\n')
+ ++lineNum;
+ ++data;
+ if (*data) {
+ if (*data == '\n')
+ ++lineNum;
+ ++data;
+ }
+ }
+ while (*data && (*(data-1) != '/' || *(data-2) != '*')) {
+ if (*data == '\n')
+ ++lineNum;
+ ++data;
+ }
+ token = WHITESPACE; // one comment, one whitespace
+ // fall through;
+ case WHITESPACE:
+ if (column == 1)
+ column = 0;
+ while (*data && (*data == ' ' || *data == '\t'))
+ ++data;
+ if (Preprocessor::preprocessOnly) // tokenize whitespace
+ break;
+ continue;
+ case CPP_COMMENT:
+ while (*data && *data != '\n')
+ ++data;
+ continue; // ignore safely, the newline is a separator
+ default:
+ continue; //ignore
+ }
+ }
+#ifdef USE_LEXEM_STORE
+ if (!Preprocessor::preprocessOnly
+ && token != IDENTIFIER
+ && token != STRING_LITERAL
+ && token != FLOATING_LITERAL
+ && token != INTEGER_LITERAL)
+ symbols += Symbol(lineNum, token);
+ else
+#endif
+ symbols += Symbol(lineNum, token, input, lexem-begin, data-lexem);
+
+ } else { // Preprocessor
+
+ const char *lexem = data;
+ int state = 0;
+ Token token = NOTOKEN;
+ if (mode == TokenizePreprocessorStatement) {
+ state = pp_keyword_trans[0][(int)'#'];
+ mode = TokenizePreprocessor;
+ }
+ for (;;) {
+ if (static_cast<signed char>(*data) < 0) {
+ ++data;
+ continue;
+ }
+
+ int nextindex = pp_keywords[state].next;
+ int next = 0;
+ if (*data == pp_keywords[state].defchar)
+ next = pp_keywords[state].defnext;
+ else if (!state || nextindex)
+ next = pp_keyword_trans[nextindex][(int)*data];
+ if (!next)
+ break;
+ state = next;
+ token = pp_keywords[state].token;
+ ++data;
+ }
+ // suboptimal, is_ident_char should use a table
+ if (pp_keywords[state].ident && is_ident_char(*data))
+ token = pp_keywords[state].ident;
+
+ switch (token) {
+ case NOTOKEN:
+ ++data;
+ break;
+ case PP_IFDEF:
+ symbols += Symbol(lineNum, PP_IF);
+ symbols += Symbol(lineNum, PP_DEFINED);
+ continue;
+ case PP_IFNDEF:
+ symbols += Symbol(lineNum, PP_IF);
+ symbols += Symbol(lineNum, PP_NOT);
+ symbols += Symbol(lineNum, PP_DEFINED);
+ continue;
+ case PP_INCLUDE:
+ mode = TokenizeInclude;
+ break;
+ case PP_QUOTE:
+ data = skipQuote(data);
+ token = PP_STRING_LITERAL;
+ break;
+ case PP_SINGLEQUOTE:
+ while (*data && (*data != '\''
+ || (*(data-1)=='\\'
+ && *(data-2)!='\\')))
+ ++data;
+ if (*data)
+ ++data;
+ token = PP_CHARACTER_LITERAL;
+ break;
+ case PP_DIGIT:
+ while (is_digit_char(*data))
+ ++data;
+ if (!*data || *data != '.') {
+ token = PP_INTEGER_LITERAL;
+ if (data - lexem == 1 &&
+ (*data == 'x' || *data == 'X')
+ && *lexem == '0') {
+ ++data;
+ while (is_hex_char(*data))
+ ++data;
+ }
+ break;
+ }
+ token = PP_FLOATING_LITERAL;
+ ++data;
+ // fall through
+ case PP_FLOATING_LITERAL:
+ while (is_digit_char(*data))
+ ++data;
+ if (*data == '+' || *data == '-')
+ ++data;
+ if (*data == 'e' || *data == 'E') {
+ ++data;
+ while (is_digit_char(*data))
+ ++data;
+ }
+ if (*data == 'f' || *data == 'F'
+ || *data == 'l' || *data == 'L')
+ ++data;
+ break;
+ case PP_CHARACTER:
+ if (mode == PreparePreprocessorStatement) {
+ // rewind entire token to begin
+ data = lexem;
+ mode = TokenizePreprocessorStatement;
+ continue;
+ }
+ while (is_ident_char(*data))
+ ++data;
+ token = PP_IDENTIFIER;
+ break;
+ case PP_C_COMMENT:
+ if (*data) {
+ if (*data == '\n')
+ ++lineNum;
+ ++data;
+ if (*data) {
+ if (*data == '\n')
+ ++lineNum;
+ ++data;
+ }
+ }
+ while (*data && (*(data-1) != '/' || *(data-2) != '*')) {
+ if (*data == '\n')
+ ++lineNum;
+ ++data;
+ }
+ token = PP_WHITESPACE; // one comment, one whitespace
+ // fall through;
+ case PP_WHITESPACE:
+ while (*data && (*data == ' ' || *data == '\t'))
+ ++data;
+ continue; // the preprocessor needs no whitespace
+ case PP_CPP_COMMENT:
+ while (*data && *data != '\n')
+ ++data;
+ continue; // ignore safely, the newline is a separator
+ case PP_NEWLINE:
+ ++lineNum;
+ mode = TokenizeCpp;
+ break;
+ case PP_BACKSLASH:
+ {
+ const char *rewind = data;
+ while (*data && (*data == ' ' || *data == '\t'))
+ ++data;
+ if (*data && *data == '\n') {
+ ++data;
+ continue;
+ }
+ data = rewind;
+ } break;
+ case PP_LANGLE:
+ if (mode != TokenizeInclude)
+ break;
+ token = PP_STRING_LITERAL;
+ while (*data && *data != '\n' && *(data-1) != '>')
+ ++data;
+ break;
+ default:
+ break;
+ }
+ if (mode == PreparePreprocessorStatement)
+ continue;
+#ifdef USE_LEXEM_STORE
+ if (token != PP_IDENTIFIER
+ && token != PP_STRING_LITERAL
+ && token != PP_FLOATING_LITERAL
+ && token != PP_INTEGER_LITERAL)
+ symbols += Symbol(lineNum, token);
+ else
+#endif
+ symbols += Symbol(lineNum, token, input, lexem-begin, data-lexem);
+ }
+ }
+ symbols += Symbol(); // eof symbol
+ return symbols;
+}
+
+void Preprocessor::substituteMacro(const MacroName &macro, Symbols &substituted, MacroSafeSet safeset)
+{
+ Symbols saveSymbols = symbols;
+ int saveIndex = index;
+
+ symbols = macros.value(macro).symbols;
+ index = 0;
+
+ safeset += macro;
+ substituteUntilNewline(substituted, safeset);
+
+ symbols = saveSymbols;
+ index = saveIndex;
+}
+
+
+
+void Preprocessor::substituteUntilNewline(Symbols &substituted, MacroSafeSet safeset)
+{
+ while (hasNext()) {
+ Token token = next();
+ if (token == PP_IDENTIFIER) {
+ MacroName macro = symbol();
+ if (macros.contains(macro) && !safeset.contains(macro)) {
+ substituteMacro(macro, substituted, safeset);
+ continue;
+ }
+ } else if (token == PP_DEFINED) {
+ test(PP_LPAREN);
+ next(PP_IDENTIFIER);
+ Symbol definedOrNotDefined = symbol();
+ definedOrNotDefined.token = macros.contains(definedOrNotDefined)? PP_MOC_TRUE : PP_MOC_FALSE;
+ substituted += definedOrNotDefined;
+ test(PP_RPAREN);
+ continue;
+ } else if (token == PP_NEWLINE) {
+ substituted += symbol();
+ break;
+ }
+ substituted += symbol();
+ }
+}
+
+
+class PP_Expression : public Parser
+{
+public:
+ int value() { index = 0; return unary_expression_lookup() ? conditional_expression() : 0; }
+
+ int conditional_expression();
+ int logical_OR_expression();
+ int logical_AND_expression();
+ int inclusive_OR_expression();
+ int exclusive_OR_expression();
+ int AND_expression();
+ int equality_expression();
+ int relational_expression();
+ int shift_expression();
+ int additive_expression();
+ int multiplicative_expression();
+ int unary_expression();
+ bool unary_expression_lookup();
+ int primary_expression();
+ bool primary_expression_lookup();
+};
+
+int PP_Expression::conditional_expression()
+{
+ int value = logical_OR_expression();
+ if (test(PP_QUESTION)) {
+ int alt1 = conditional_expression();
+ int alt2 = test(PP_COLON) ? conditional_expression() : 0;
+ return value ? alt1 : alt2;
+ }
+ return value;
+}
+
+int PP_Expression::logical_OR_expression()
+{
+ int value = logical_AND_expression();
+ if (test(PP_OROR))
+ return logical_OR_expression() || value;
+ return value;
+}
+
+int PP_Expression::logical_AND_expression()
+{
+ int value = inclusive_OR_expression();
+ if (test(PP_ANDAND))
+ return logical_AND_expression() && value;
+ return value;
+}
+
+int PP_Expression::inclusive_OR_expression()
+{
+ int value = exclusive_OR_expression();
+ if (test(PP_OR))
+ return value | inclusive_OR_expression();
+ return value;
+}
+
+int PP_Expression::exclusive_OR_expression()
+{
+ int value = AND_expression();
+ if (test(PP_HAT))
+ return value ^ exclusive_OR_expression();
+ return value;
+}
+
+int PP_Expression::AND_expression()
+{
+ int value = equality_expression();
+ if (test(PP_AND))
+ return value & AND_expression();
+ return value;
+}
+
+int PP_Expression::equality_expression()
+{
+ int value = relational_expression();
+ switch (next()) {
+ case PP_EQEQ:
+ return value == equality_expression();
+ case PP_NE:
+ return value != equality_expression();
+ default:
+ prev();
+ return value;
+ }
+}
+
+int PP_Expression::relational_expression()
+{
+ int value = shift_expression();
+ switch (next()) {
+ case PP_LANGLE:
+ return value < relational_expression();
+ case PP_RANGLE:
+ return value > relational_expression();
+ case PP_LE:
+ return value <= relational_expression();
+ case PP_GE:
+ return value >= relational_expression();
+ default:
+ prev();
+ return value;
+ }
+}
+
+int PP_Expression::shift_expression()
+{
+ int value = additive_expression();
+ switch (next()) {
+ case PP_LTLT:
+ return value << shift_expression();
+ case PP_GTGT:
+ return value >> shift_expression();
+ default:
+ prev();
+ return value;
+ }
+}
+
+int PP_Expression::additive_expression()
+{
+ int value = multiplicative_expression();
+ switch (next()) {
+ case PP_PLUS:
+ return value + additive_expression();
+ case PP_MINUS:
+ return value - additive_expression();
+ default:
+ prev();
+ return value;
+ }
+}
+
+int PP_Expression::multiplicative_expression()
+{
+ int value = unary_expression();
+ switch (next()) {
+ case PP_STAR:
+ return value * multiplicative_expression();
+ case PP_PERCENT:
+ {
+ int remainder = multiplicative_expression();
+ return remainder ? value % remainder : 0;
+ }
+ case PP_SLASH:
+ {
+ int div = multiplicative_expression();
+ return div ? value / div : 0;
+ }
+ default:
+ prev();
+ return value;
+ };
+}
+
+int PP_Expression::unary_expression()
+{
+ switch (next()) {
+ case PP_PLUS:
+ return unary_expression();
+ case PP_MINUS:
+ return -unary_expression();
+ case PP_NOT:
+ return !unary_expression();
+ case PP_TILDE:
+ return ~unary_expression();
+ case PP_MOC_TRUE:
+ return 1;
+ case PP_MOC_FALSE:
+ return 0;
+ default:
+ prev();
+ return primary_expression();
+ }
+}
+
+bool PP_Expression::unary_expression_lookup()
+{
+ Token t = lookup();
+ return (primary_expression_lookup()
+ || t == PP_PLUS
+ || t == PP_MINUS
+ || t == PP_NOT
+ || t == PP_TILDE
+ || t == PP_DEFINED);
+}
+
+int PP_Expression::primary_expression()
+{
+ int value;
+ if (test(PP_LPAREN)) {
+ value = conditional_expression();
+ test(PP_RPAREN);
+ } else {
+ next();
+ value = lexem().toInt(0, 0);
+ }
+ return value;
+}
+
+bool PP_Expression::primary_expression_lookup()
+{
+ Token t = lookup();
+ return (t == PP_IDENTIFIER
+ || t == PP_INTEGER_LITERAL
+ || t == PP_FLOATING_LITERAL
+ || t == PP_MOC_TRUE
+ || t == PP_MOC_FALSE
+ || t == PP_LPAREN);
+}
+
+int Preprocessor::evaluateCondition()
+{
+ PP_Expression expression;
+ expression.currentFilenames = currentFilenames;
+
+ substituteUntilNewline(expression.symbols);
+
+ return expression.value();
+}
+
+void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed)
+{
+ currentFilenames.push(filename);
+ preprocessed.reserve(preprocessed.size() + symbols.size());
+ while (hasNext()) {
+ Token token = next();
+
+ switch (token) {
+ case PP_INCLUDE:
+ {
+ int lineNum = symbol().lineNum;
+ QByteArray include;
+ bool local = false;
+ if (test(PP_STRING_LITERAL)) {
+ local = lexem().startsWith('\"');
+ include = unquotedLexem();
+ } else
+ continue;
+ until(PP_NEWLINE);
+
+ // #### stringery
+ QFileInfo fi;
+ if (local)
+ fi.setFile(QFileInfo(QString::fromLocal8Bit(filename)).dir(), QString::fromLocal8Bit(include));
+ for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) {
+ const IncludePath &p = Preprocessor::includes.at(j);
+ if (p.isFrameworkPath) {
+ const int slashPos = include.indexOf('/');
+ if (slashPos == -1)
+ continue;
+ QByteArray frameworkCandidate = include.left(slashPos);
+ frameworkCandidate.append(".framework/Headers/");
+ fi.setFile(QString::fromLocal8Bit(p.path + "/" + frameworkCandidate), QString::fromLocal8Bit(include.mid(slashPos + 1)));
+ } else {
+ fi.setFile(QString::fromLocal8Bit(p.path), QString::fromLocal8Bit(include));
+ }
+ // try again, maybe there's a file later in the include paths with the same name
+ // (186067)
+ if (fi.isDir()) {
+ fi = QFileInfo();
+ continue;
+ }
+ }
+
+ if (!fi.exists() || fi.isDir())
+ continue;
+ include = fi.canonicalFilePath().toLocal8Bit();
+
+ if (Preprocessor::preprocessedIncludes.contains(include))
+ continue;
+ Preprocessor::preprocessedIncludes.insert(include);
+
+ QFile file(QString::fromLocal8Bit(include));
+ if (!file.open(QFile::ReadOnly))
+ continue;
+
+ QByteArray input = file.readAll();
+ file.close();
+ if (input.isEmpty())
+ continue;
+
+ Symbols saveSymbols = symbols;
+ int saveIndex = index;
+
+ // phase 1: get rid of backslash-newlines
+ input = cleaned(input);
+
+ // phase 2: tokenize for the preprocessor
+ symbols = tokenize(input);
+ input.clear();
+
+ index = 0;
+
+ // phase 3: preprocess conditions and substitute macros
+ preprocessed += Symbol(0, MOC_INCLUDE_BEGIN, include);
+ preprocess(include, preprocessed);
+ preprocessed += Symbol(lineNum, MOC_INCLUDE_END, include);
+
+ symbols = saveSymbols;
+ index = saveIndex;
+ continue;
+ }
+ case PP_DEFINE:
+ {
+ next(IDENTIFIER);
+ QByteArray name = lexem();
+ int start = index;
+ until(PP_NEWLINE);
+ Macro macro;
+ macro.symbols.reserve(index - start - 1);
+ for (int i = start; i < index - 1; ++i)
+ macro.symbols += symbols.at(i);
+ macros.insert(name, macro);
+ continue;
+ }
+ case PP_UNDEF: {
+ next(IDENTIFIER);
+ QByteArray name = lexem();
+ until(PP_NEWLINE);
+ macros.remove(name);
+ continue;
+ }
+ case PP_IDENTIFIER:
+ {
+// if (macros.contains(symbol()))
+// ;
+ }
+ // we _could_ easily substitute macros by the following
+ // four lines, but we choose not to.
+ /*
+ if (macros.contains(sym.lexem())) {
+ preprocessed += substitute(macros, symbols, i);
+ continue;
+ }
+ */
+ break;
+ case PP_HASH:
+ until(PP_NEWLINE);
+ continue; // skip unknown preprocessor statement
+ case PP_IFDEF:
+ case PP_IFNDEF:
+ case PP_IF:
+ while (!evaluateCondition()) {
+ if (!skipBranch())
+ break;
+ if (test(PP_ELIF)) {
+ } else {
+ until(PP_NEWLINE);
+ break;
+ }
+ }
+ continue;
+ case PP_ELIF:
+ case PP_ELSE:
+ skipUntilEndif();
+ // fall through
+ case PP_ENDIF:
+ until(PP_NEWLINE);
+ continue;
+ case SIGNALS:
+ case SLOTS: {
+ Symbol sym = symbol();
+ if (macros.contains("QT_NO_KEYWORDS"))
+ sym.token = IDENTIFIER;
+ else
+ sym.token = (token == SIGNALS ? Q_SIGNALS_TOKEN : Q_SLOTS_TOKEN);
+ preprocessed += sym;
+ } continue;
+ default:
+ break;
+ }
+ preprocessed += symbol();
+ }
+
+ currentFilenames.pop();
+}
+
+Symbols Preprocessor::preprocessed(const QByteArray &filename, FILE *file)
+{
+ QFile qfile;
+ qfile.open(file, QFile::ReadOnly);
+ QByteArray input = qfile.readAll();
+ if (input.isEmpty())
+ return symbols;
+
+ // phase 1: get rid of backslash-newlines
+ input = cleaned(input);
+
+ // phase 2: tokenize for the preprocessor
+ symbols = tokenize(input);
+
+#if 0
+ for (int j = 0; j < symbols.size(); ++j)
+ fprintf(stderr, "line %d: %s(%s)\n",
+ symbols[j].lineNum,
+ symbols[j].lexem().constData(),
+ tokenTypeName(symbols[j].token));
+#endif
+
+ // phase 3: preprocess conditions and substitute macros
+ Symbols result;
+ preprocess(filename, result);
+
+#if 0
+ for (int j = 0; j < result.size(); ++j)
+ fprintf(stderr, "line %d: %s(%s)\n",
+ result[j].lineNum,
+ result[j].lexem().constData(),
+ tokenTypeName(result[j].token));
+#endif
+
+ return result;
+}
+
+void Preprocessor::until(Token t)
+{
+ while(hasNext() && next() != t)
+ ;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h
new file mode 100644
index 0000000..cb713d2
--- /dev/null
+++ b/src/tools/moc/preprocessor.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PREPROCESSOR_H
+#define PREPROCESSOR_H
+
+#include "parser.h"
+#include <QList>
+#include <QSet>
+#include <stdio.h>
+
+QT_BEGIN_NAMESPACE
+
+struct Macro
+{
+ Symbols symbols;
+};
+
+#ifdef USE_LEXEM_STORE
+typedef QByteArray MacroName;
+#else
+typedef SubArray MacroName;
+#endif
+typedef QHash<MacroName, Macro> Macros;
+typedef QVector<MacroName> MacroSafeSet;
+
+
+class Preprocessor : public Parser
+{
+public:
+ Preprocessor(){}
+ static bool preprocessOnly;
+ struct IncludePath
+ {
+ inline explicit IncludePath(const QByteArray &_path)
+ : path(_path), isFrameworkPath(false) {}
+ QByteArray path;
+ bool isFrameworkPath;
+ };
+ QList<IncludePath> includes;
+ QList<QByteArray> frameworks;
+ QSet<QByteArray> preprocessedIncludes;
+ Macros macros;
+ Symbols preprocessed(const QByteArray &filename, FILE *file);
+
+
+ void skipUntilEndif();
+ bool skipBranch();
+
+ void substituteMacro(const MacroName &macro, Symbols &substituted, MacroSafeSet safeset = MacroSafeSet());
+ void substituteUntilNewline(Symbols &substituted, MacroSafeSet safeset = MacroSafeSet());
+
+ int evaluateCondition();
+
+
+private:
+ void until(Token);
+
+ void preprocess(const QByteArray &filename, Symbols &preprocessed);
+};
+
+QT_END_NAMESPACE
+
+#endif // PREPROCESSOR_H
diff --git a/src/tools/moc/symbols.h b/src/tools/moc/symbols.h
new file mode 100644
index 0000000..b8ccf78
--- /dev/null
+++ b/src/tools/moc/symbols.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SYMBOLS_H
+#define SYMBOLS_H
+
+#include "token.h"
+#include <QString>
+#include <QHash>
+#include <QVector>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+//#define USE_LEXEM_STORE
+
+struct SubArray
+{
+ inline SubArray():from(0),len(-1){}
+ inline SubArray(const QByteArray &a):array(a),from(0), len(a.size()){}
+ inline SubArray(const char *s):array(s),from(0) { len = array.size(); }
+ inline SubArray(const QByteArray &a, int from, int len):array(a), from(from), len(len){}
+ QByteArray array;
+ int from, len;
+ inline bool operator==(const SubArray &other) const {
+ if (len != other.len)
+ return false;
+ for (int i = 0; i < len; ++i)
+ if (array.at(from + i) != other.array.at(other.from + i))
+ return false;
+ return true;
+ }
+};
+
+inline uint qHash(const SubArray &key)
+{
+ const uchar *p = reinterpret_cast<const uchar *>(key.array.data() + key.from);
+ int n = key.len;
+ uint h = 0;
+ uint g;
+
+ while (n--) {
+ h = (h << 4) + *p++;
+ if ((g = (h & 0xf0000000)) != 0)
+ h ^= g >> 23;
+ h &= ~g;
+ }
+ return h;
+}
+
+
+struct Symbol
+{
+
+#ifdef USE_LEXEM_STORE
+ typedef QHash<SubArray, QHashDummyValue> LexemStore;
+ static LexemStore lexemStore;
+
+ inline Symbol() : lineNum(-1),token(NOTOKEN){}
+ inline Symbol(int lineNum, Token token):
+ lineNum(lineNum), token(token){}
+ inline Symbol(int lineNum, Token token, const QByteArray &lexem):
+ lineNum(lineNum), token(token),lex(lexem){}
+ inline Symbol(int lineNum, Token token, const QByteArray &lexem, int from, int len):
+ lineNum(lineNum), token(token){
+ LexemStore::const_iterator it = lexemStore.constFind(SubArray(lexem, from, len));
+
+ if (it != lexemStore.constEnd()) {
+ lex = it.key().array;
+ } else {
+ lex = lexem.mid(from, len);
+ lexemStore.insert(lex, QHashDummyValue());
+ }
+ }
+ int lineNum;
+ Token token;
+ inline QByteArray unquotedLexem() const { return lex.mid(1, lex.length()-2); }
+ inline QByteArray lexem() const { return lex; }
+ inline operator QByteArray() const { return lex; }
+ QByteArray lex;
+
+#else
+
+ inline Symbol() : lineNum(-1),token(NOTOKEN), from(0),len(-1) {}
+ inline Symbol(int lineNum, Token token):
+ lineNum(lineNum), token(token), from(0), len(-1) {}
+ inline Symbol(int lineNum, Token token, const QByteArray &lexem):
+ lineNum(lineNum), token(token), lex(lexem), from(0) { len = lex.size(); }
+ inline Symbol(int lineNum, Token token, const QByteArray &lexem, int from, int len):
+ lineNum(lineNum), token(token),lex(lexem),from(from), len(len){}
+ int lineNum;
+ Token token;
+ inline QByteArray lexem() const { return lex.mid(from, len); }
+ inline QByteArray unquotedLexem() const { return lex.mid(from+1, len-2); }
+ inline operator QByteArray() const { return lex.mid(from, len); }
+ inline operator SubArray() const { return SubArray(lex, from, len); }
+ QByteArray lex;
+ int from, len;
+
+#endif
+};
+Q_DECLARE_TYPEINFO(Symbol, Q_MOVABLE_TYPE);
+
+
+typedef QVector<Symbol> Symbols;
+
+QT_END_NAMESPACE
+
+#endif // SYMBOLS_H
diff --git a/src/tools/moc/token.cpp b/src/tools/moc/token.cpp
new file mode 100644
index 0000000..46345e7
--- /dev/null
+++ b/src/tools/moc/token.cpp
@@ -0,0 +1,222 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "token.h"
+
+QT_BEGIN_NAMESPACE
+
+#if defined(DEBUG_MOC)
+const char *tokenTypeName(Token t)
+{
+ switch (t) {
+ case NOTOKEN: return "NOTOKEN";
+ case IDENTIFIER: return "IDENTIFIER";
+ case INTEGER_LITERAL: return "INTEGER_LITERAL";
+ case CHARACTER_LITERAL: return "CHARACTER_LITERAL";
+ case STRING_LITERAL: return "STRING_LITERAL";
+ case BOOLEAN_LITERAL: return "BOOLEAN_LITERAL";
+ case HEADER_NAME: return "HEADER_NAME";
+ case LANGLE: return "LANGLE";
+ case RANGLE: return "RANGLE";
+ case LPAREN: return "LPAREN";
+ case RPAREN: return "RPAREN";
+ case ELIPSIS: return "ELIPSIS";
+ case LBRACK: return "LBRACK";
+ case RBRACK: return "RBRACK";
+ case LBRACE: return "LBRACE";
+ case RBRACE: return "RBRACE";
+ case EQ: return "EQ";
+ case SCOPE: return "SCOPE";
+ case SEMIC: return "SEMIC";
+ case COLON: return "COLON";
+ case DOTSTAR: return "DOTSTAR";
+ case QUESTION: return "QUESTION";
+ case DOT: return "DOT";
+ case DYNAMIC_CAST: return "DYNAMIC_CAST";
+ case STATIC_CAST: return "STATIC_CAST";
+ case REINTERPRET_CAST: return "REINTERPRET_CAST";
+ case CONST_CAST: return "CONST_CAST";
+ case TYPEID: return "TYPEID";
+ case THIS: return "THIS";
+ case TEMPLATE: return "TEMPLATE";
+ case THROW: return "THROW";
+ case TRY: return "TRY";
+ case CATCH: return "CATCH";
+ case TYPEDEF: return "TYPEDEF";
+ case FRIEND: return "FRIEND";
+ case CLASS: return "CLASS";
+ case NAMESPACE: return "NAMESPACE";
+ case ENUM: return "ENUM";
+ case STRUCT: return "STRUCT";
+ case UNION: return "UNION";
+ case VIRTUAL: return "VIRTUAL";
+ case PRIVATE: return "PRIVATE";
+ case PROTECTED: return "PROTECTED";
+ case PUBLIC: return "PUBLIC";
+ case EXPORT: return "EXPORT";
+ case AUTO: return "AUTO";
+ case REGISTER: return "REGISTER";
+ case EXTERN: return "EXTERN";
+ case MUTABLE: return "MUTABLE";
+ case ASM: return "ASM";
+ case USING: return "USING";
+ case INLINE: return "INLINE";
+ case EXPLICIT: return "EXPLICIT";
+ case STATIC: return "STATIC";
+ case CONST: return "CONST";
+ case VOLATILE: return "VOLATILE";
+ case OPERATOR: return "OPERATOR";
+ case SIZEOF: return "SIZEOF";
+ case NEW: return "NEW";
+ case DELETE: return "DELETE";
+ case PLUS: return "PLUS";
+ case MINUS: return "MINUS";
+ case STAR: return "STAR";
+ case SLASH: return "SLASH";
+ case PERCENT: return "PERCENT";
+ case HAT: return "HAT";
+ case AND: return "AND";
+ case OR: return "OR";
+ case TILDE: return "TILDE";
+ case NOT: return "NOT";
+ case PLUS_EQ: return "PLUS_EQ";
+ case MINUS_EQ: return "MINUS_EQ";
+ case STAR_EQ: return "STAR_EQ";
+ case SLASH_EQ: return "SLASH_EQ";
+ case PERCENT_EQ: return "PERCENT_EQ";
+ case HAT_EQ: return "HAT_EQ";
+ case AND_EQ: return "AND_EQ";
+ case OR_EQ: return "OR_EQ";
+ case LTLT: return "LTLT";
+ case GTGT: return "GTGT";
+ case GTGT_EQ: return "GTGT_EQ";
+ case LTLT_EQ: return "LTLT_EQ";
+ case EQEQ: return "EQEQ";
+ case NE: return "NE";
+ case LE: return "LE";
+ case GE: return "GE";
+ case ANDAND: return "ANDAND";
+ case OROR: return "OROR";
+ case INCR: return "INCR";
+ case DECR: return "DECR";
+ case COMMA: return "COMMA";
+ case ARROW_STAR: return "ARROW_STAR";
+ case ARROW: return "ARROW";
+ case CHAR: return "CHAR";
+ case WCHAR: return "WCHAR";
+ case BOOL: return "BOOL";
+ case SHORT: return "SHORT";
+ case INT: return "INT";
+ case LONG: return "LONG";
+ case SIGNED: return "SIGNED";
+ case UNSIGNED: return "UNSIGNED";
+ case FLOAT: return "FLOAT";
+ case DOUBLE: return "DOUBLE";
+ case VOID: return "VOID";
+ case CASE: return "CASE";
+ case DEFAULT: return "DEFAULT";
+ case IF: return "IF";
+ case ELSE: return "ELSE";
+ case SWITCH: return "SWITCH";
+ case WHILE: return "WHILE";
+ case DO: return "DO";
+ case FOR: return "FOR";
+ case BREAK: return "BREAK";
+ case CONTINUE: return "CONTINUE";
+ case GOTO: return "GOTO";
+ case SIGNALS: return "SIGNALS";
+ case SLOTS: return "SLOTS";
+ case RETURN: return "RETURN";
+ case Q_OBJECT_TOKEN: return "Q_OBJECT_TOKEN";
+ case Q_GADGET_TOKEN: return "Q_GADGET_TOKEN";
+ case Q_PROPERTY_TOKEN: return "Q_PROPERTY_TOKEN";
+ case Q_ENUMS_TOKEN: return "Q_ENUMS_TOKEN";
+ case Q_FLAGS_TOKEN: return "Q_FLAGS_TOKEN";
+ case Q_DECLARE_FLAGS_TOKEN: return "Q_DECLARE_FLAGS_TOKEN";
+ case Q_DECLARE_INTERFACE_TOKEN: return "Q_DECLARE_INTERFACE_TOKEN";
+ case Q_CLASSINFO_TOKEN: return "Q_CLASSINFO_TOKEN";
+ case Q_INTERFACES_TOKEN: return "Q_INTERFACES_TOKEN";
+ case Q_SIGNALS_TOKEN: return "Q_SIGNALS_TOKEN";
+ case Q_SLOTS_TOKEN: return "Q_SLOTS_TOKEN";
+ case Q_SIGNAL_TOKEN: return "Q_SIGNAL_TOKEN";
+ case Q_SLOT_TOKEN: return "Q_SLOT_TOKEN";
+ case Q_PRIVATE_SLOT_TOKEN: return "Q_PRIVATE_SLOT_TOKEN";
+ case SPECIAL_TREATMENT_MARK: return "SPECIAL_TREATMENT_MARK";
+ case MOC_INCLUDE_BEGIN: return "MOC_INCLUDE_BEGIN";
+ case MOC_INCLUDE_END: return "MOC_INCLUDE_END";
+ case CPP_COMMENT: return "CPP_COMMENT";
+ case C_COMMENT: return "C_COMMENT";
+ case FLOATING_LITERAL: return "FLOATING_LITERAL";
+ case HASH: return "HASH";
+ case QUOTE: return "QUOTE";
+ case SINGLEQUOTE: return "SINGLEQUOTE";
+ case DIGIT: return "DIGIT";
+ case CHARACTER: return "CHARACTER";
+ case NEWLINE: return "NEWLINE";
+ case WHITESPACE: return "WHITESPACE";
+ case BACKSLASH: return "BACKSLASH";
+ case INCOMPLETE: return "INCOMPLETE";
+ case PP_DEFINE: return "PP_DEFINE";
+ case PP_UNDEF: return "PP_UNDEF";
+ case PP_IF: return "PP_IF";
+ case PP_IFDEF: return "PP_IFDEF";
+ case PP_IFNDEF: return "PP_IFNDEF";
+ case PP_ELIF: return "PP_ELIF";
+ case PP_ELSE: return "PP_ELSE";
+ case PP_ENDIF: return "PP_ENDIF";
+ case PP_INCLUDE: return "PP_INCLUDE";
+ case PP_HASHHASH: return "PP_HASHHASH";
+ case PP_HASH: return "PP_HASH";
+ case PP_DEFINED: return "PP_DEFINED";
+ case PP_INCOMPLETE: return "PP_INCOMPLETE";
+ case PP_MOC_TRUE: return "PP_MOC_TRUE";
+ case PP_MOC_FALSE: return "PP_MOC_FALSE";
+ case Q_DECLARE_METATYPE_TOKEN: return "Q_DECLARE_METATYPE_TOKEN";
+ case Q_MOC_COMPAT_TOKEN: return "Q_MOC_COMPAT_TOKEN";
+ case Q_QT3_SUPPORT_TOKEN: return "Q_QT3_SUPPORT_TOKEN";
+ case Q_INVOKABLE_TOKEN: return "Q_INVOKABLE_TOKEN";
+ case Q_SCRIPTABLE_TOKEN: return "Q_SCRIPTABLE_TOKEN";
+ }
+ return "";
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/tools/moc/token.h b/src/tools/moc/token.h
new file mode 100644
index 0000000..13c9a1d
--- /dev/null
+++ b/src/tools/moc/token.h
@@ -0,0 +1,274 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TOKEN_H
+#define TOKEN_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+enum Token {
+ NOTOKEN,
+ IDENTIFIER,
+ INTEGER_LITERAL,
+ CHARACTER_LITERAL,
+ STRING_LITERAL,
+ BOOLEAN_LITERAL,
+ HEADER_NAME,
+ LANGLE,
+ RANGLE,
+ LPAREN,
+ RPAREN,
+ ELIPSIS,
+ LBRACK,
+ RBRACK,
+ LBRACE,
+ RBRACE,
+ EQ,
+ SCOPE,
+ SEMIC,
+ COLON,
+ DOTSTAR,
+ QUESTION,
+ DOT,
+ DYNAMIC_CAST,
+ STATIC_CAST,
+ REINTERPRET_CAST,
+ CONST_CAST,
+ TYPEID,
+ THIS,
+ TEMPLATE,
+ THROW,
+ TRY,
+ CATCH,
+ TYPEDEF,
+ FRIEND,
+ CLASS,
+ NAMESPACE,
+ ENUM,
+ STRUCT,
+ UNION,
+ VIRTUAL,
+ PRIVATE,
+ PROTECTED,
+ PUBLIC,
+ EXPORT,
+ AUTO,
+ REGISTER,
+ EXTERN,
+ MUTABLE,
+ ASM,
+ USING,
+ INLINE,
+ EXPLICIT,
+ STATIC,
+ CONST,
+ VOLATILE,
+ OPERATOR,
+ SIZEOF,
+ NEW,
+ DELETE,
+ PLUS,
+ MINUS,
+ STAR,
+ SLASH,
+ PERCENT,
+ HAT,
+ AND,
+ OR,
+ TILDE,
+ NOT,
+ PLUS_EQ,
+ MINUS_EQ,
+ STAR_EQ,
+ SLASH_EQ,
+ PERCENT_EQ,
+ HAT_EQ,
+ AND_EQ,
+ OR_EQ,
+ LTLT,
+ GTGT,
+ GTGT_EQ,
+ LTLT_EQ,
+ EQEQ,
+ NE,
+ LE,
+ GE,
+ ANDAND,
+ OROR,
+ INCR,
+ DECR,
+ COMMA,
+ ARROW_STAR,
+ ARROW,
+ CHAR,
+ WCHAR,
+ BOOL,
+ SHORT,
+ INT,
+ LONG,
+ SIGNED,
+ UNSIGNED,
+ FLOAT,
+ DOUBLE,
+ VOID,
+ CASE,
+ DEFAULT,
+ IF,
+ ELSE,
+ SWITCH,
+ WHILE,
+ DO,
+ FOR,
+ BREAK,
+ CONTINUE,
+ GOTO,
+ SIGNALS,
+ SLOTS,
+ RETURN,
+ Q_META_TOKEN_BEGIN,
+ Q_OBJECT_TOKEN = Q_META_TOKEN_BEGIN,
+ Q_GADGET_TOKEN,
+ Q_PROPERTY_TOKEN,
+ Q_ENUMS_TOKEN,
+ Q_FLAGS_TOKEN,
+ Q_DECLARE_FLAGS_TOKEN,
+ Q_DECLARE_INTERFACE_TOKEN,
+ Q_DECLARE_METATYPE_TOKEN,
+ Q_CLASSINFO_TOKEN,
+ Q_INTERFACES_TOKEN,
+ Q_SIGNALS_TOKEN,
+ Q_SLOTS_TOKEN,
+ Q_SIGNAL_TOKEN,
+ Q_SLOT_TOKEN,
+ Q_PRIVATE_SLOT_TOKEN,
+ Q_MOC_COMPAT_TOKEN,
+ Q_QT3_SUPPORT_TOKEN,
+ Q_INVOKABLE_TOKEN,
+ Q_SCRIPTABLE_TOKEN,
+ Q_META_TOKEN_END,
+ SPECIAL_TREATMENT_MARK = Q_META_TOKEN_END,
+ MOC_INCLUDE_BEGIN,
+ MOC_INCLUDE_END,
+ CPP_COMMENT,
+ C_COMMENT,
+ FLOATING_LITERAL,
+ HASH,
+ QUOTE,
+ SINGLEQUOTE,
+ LANGLE_SCOPE,
+ DIGIT,
+ CHARACTER,
+ NEWLINE,
+ WHITESPACE,
+ BACKSLASH,
+ INCOMPLETE,
+
+ PP_DEFINE,
+ PP_UNDEF,
+ PP_IF,
+ PP_IFDEF,
+ PP_IFNDEF,
+ PP_ELIF,
+ PP_ELSE,
+ PP_ENDIF,
+ PP_INCLUDE,
+ PP_HASHHASH,
+ PP_HASH,
+ PP_DEFINED,
+ PP_INCOMPLETE,
+
+ PP_MOC_TRUE,
+ PP_MOC_FALSE,
+
+ PP_NOTOKEN = NOTOKEN,
+ PP_IDENTIFIER = IDENTIFIER,
+ PP_INTEGER_LITERAL = INTEGER_LITERAL,
+ PP_CHARACTER_LITERAL = CHARACTER_LITERAL,
+ PP_STRING_LITERAL = STRING_LITERAL,
+ PP_LANGLE = LANGLE,
+ PP_RANGLE = RANGLE,
+ PP_LPAREN = LPAREN,
+ PP_RPAREN = RPAREN,
+ PP_COMMA = COMMA,
+ PP_PLUS = PLUS,
+ PP_MINUS = MINUS,
+ PP_STAR = STAR,
+ PP_SLASH = SLASH,
+ PP_PERCENT = PERCENT,
+ PP_HAT = HAT,
+ PP_AND = AND,
+ PP_OR = OR,
+ PP_TILDE = TILDE,
+ PP_NOT = NOT,
+ PP_LTLT = LTLT,
+ PP_GTGT = GTGT,
+ PP_EQEQ = EQEQ,
+ PP_NE = NE,
+ PP_LE = LE,
+ PP_GE = GE,
+ PP_ANDAND = ANDAND,
+ PP_OROR = OROR,
+ PP_QUESTION = QUESTION,
+ PP_COLON = COLON,
+ PP_FLOATING_LITERAL = FLOATING_LITERAL,
+ PP_QUOTE = QUOTE,
+ PP_SINGLEQUOTE = SINGLEQUOTE,
+ PP_DIGIT = DIGIT,
+ PP_CHARACTER = CHARACTER,
+ PP_WHITESPACE = WHITESPACE,
+ PP_NEWLINE = NEWLINE,
+ PP_CPP_COMMENT = CPP_COMMENT,
+ PP_C_COMMENT = C_COMMENT,
+ PP_BACKSLASH = BACKSLASH
+};
+
+// for debugging only
+#if defined(DEBUG_MOC)
+const char *tokenTypeName(Token t);
+#endif
+
+typedef Token PP_Token;
+
+QT_END_NAMESPACE
+
+#endif // TOKEN_H
diff --git a/src/tools/moc/util/generate.sh b/src/tools/moc/util/generate.sh
new file mode 100755
index 0000000..215b8cb
--- /dev/null
+++ b/src/tools/moc/util/generate.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+qmake
+make
+cat licenseheader.txt > ../keywords.cpp
+cat licenseheader.txt > ../ppkeywords.cpp
+./generate_keywords >> ../keywords.cpp
+./generate_keywords preprocessor >> ../ppkeywords.cpp
diff --git a/src/tools/moc/util/generate_keywords.cpp b/src/tools/moc/util/generate_keywords.cpp
new file mode 100644
index 0000000..116be2b
--- /dev/null
+++ b/src/tools/moc/util/generate_keywords.cpp
@@ -0,0 +1,468 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include <qbytearray.h>
+#include <qlist.h>
+
+struct Keyword
+{
+ const char *lexem;
+ const char *token;
+};
+
+static const Keyword pp_keywords[] = {
+ { "<", "PP_LANGLE" },
+ { ">", "PP_RANGLE" },
+ { "(", "PP_LPAREN"},
+ { ")", "PP_RPAREN"},
+ { ",", "PP_COMMA"},
+ { "\n", "PP_NEWLINE"},
+ { "#define", "PP_DEFINE"},
+ { "#if", "PP_IF"},
+ { "#undef", "PP_UNDEF"},
+ { "#ifdef", "PP_IFDEF"},
+ { "#ifndef", "PP_IFNDEF"},
+ { "#elif", "PP_ELIF"},
+ { "#else", "PP_ELSE"},
+ { "#endif", "PP_ENDIF"},
+ { "#include", "PP_INCLUDE"},
+ { "defined", "PP_DEFINED"},
+ { "+", "PP_PLUS" },
+ { "-", "PP_MINUS" },
+ { "*", "PP_STAR" },
+ { "/", "PP_SLASH" },
+ { "%", "PP_PERCENT" },
+ { "^", "PP_HAT" },
+ { "&", "PP_AND" },
+ { "bitand", "PP_AND" },
+ { "|", "PP_OR" },
+ { "bitor", "PP_OR" },
+ { "~", "PP_TILDE" },
+ { "compl", "PP_TILDE" },
+ { "!", "PP_NOT" },
+ { "not", "PP_NOT" },
+ { "<<", "PP_LTLT" },
+ { ">>", "PP_GTGT" },
+ { "==", "PP_EQEQ" },
+ { "!=", "PP_NE" },
+ { "not_eq", "PP_NE" },
+ { "<=", "PP_LE" },
+ { ">=", "PP_GE" },
+ { "&&", "PP_ANDAND" },
+ { "||", "PP_OROR" },
+ { "?", "PP_QUESTION" },
+ { ":", "PP_COLON" },
+ { "##", "PP_HASHHASH"},
+ { "%:%:", "PP_HASHHASH"},
+ { "#", "PP_HASH"},
+ { "\"", "PP_QUOTE"},
+ { "\'", "PP_SINGLEQUOTE"},
+ { " ", "PP_WHITESPACE" },
+ { "\t", "PP_WHITESPACE" },
+ { "//", "PP_CPP_COMMENT" },
+ { "/*", "PP_C_COMMENT" },
+ { "\\", "PP_BACKSLASH" },
+ { 0, "PP_NOTOKEN"}
+};
+
+static const Keyword keywords[] = {
+ { "<", "LANGLE" },
+ { ">", "RANGLE" },
+ { "(", "LPAREN" },
+ { ")", "RPAREN" },
+ { "...", "ELIPSIS" },
+ { ",", "COMMA" },
+ { "[", "LBRACK" },
+ { "]", "RBRACK" },
+ { "<:", "LBRACK" },
+ { ":>", "RBRACK" },
+ { "<::", "LANGLE_SCOPE" },
+ { "{", "LBRACE" },
+ { "<%", "LBRACE" },
+ { "}", "RBRACE" },
+ { "%>", "RBRACE" },
+ { "=", "EQ" },
+ { "::", "SCOPE" },
+ { ";", "SEMIC" },
+ { ":", "COLON" },
+ { ".*", "DOTSTAR" },
+ { "?", "QUESTION" },
+ { ".", "DOT" },
+ { "dynamic_cast", "DYNAMIC_CAST" },
+ { "static_cast", "STATIC_CAST" },
+ { "reinterpret_cast", "REINTERPRET_CAST" },
+ { "const_cast", "CONST_CAST" },
+ { "typeid", "TYPEID" },
+ { "this", "THIS" },
+ { "template", "TEMPLATE" },
+ { "throw", "THROW" },
+ { "try", "TRY" },
+ { "catch", "CATCH" },
+ { "typedef", "TYPEDEF" },
+ { "friend", "FRIEND" },
+ { "class", "CLASS" },
+ { "namespace", "NAMESPACE" },
+ { "enum", "ENUM" },
+ { "struct", "STRUCT" },
+ { "union", "UNION" },
+ { "virtual", "VIRTUAL" },
+ { "private", "PRIVATE" },
+ { "protected", "PROTECTED" },
+ { "public", "PUBLIC" },
+ { "export", "EXPORT" },
+ { "auto", "AUTO" },
+ { "register", "REGISTER" },
+ { "extern", "EXTERN" },
+ { "mutable", "MUTABLE" },
+ { "asm", "ASM" },
+ { "using", "USING" },
+ { "inline", "INLINE" },
+ { "explicit", "EXPLICIT" },
+ { "static", "STATIC" },
+ { "const", "CONST" },
+ { "volatile", "VOLATILE" },
+ { "operator", "OPERATOR" },
+ { "sizeof", "SIZEOF" },
+ { "new", "NEW" },
+ { "delete", "DELETE" },
+ { "+", "PLUS" },
+ { "-", "MINUS" },
+ { "*", "STAR" },
+ { "/", "SLASH" },
+ { "%", "PERCENT" },
+ { "^", "HAT" },
+ { "&", "AND" },
+ { "bitand", "AND" },
+ { "|", "OR" },
+ { "bitor", "OR" },
+ { "~", "TILDE" },
+ { "compl", "TILDE" },
+ { "!", "NOT" },
+ { "not", "NOT" },
+ { "+=", "PLUS_EQ" },
+ { "-=", "MINUS_EQ" },
+ { "*=", "STAR_EQ" },
+ { "/=", "SLASH_EQ" },
+ { "%=", "PERCENT_EQ" },
+ { "^=", "HAT_EQ" },
+ { "&=", "AND_EQ" },
+ { "|=", "OR_EQ" },
+ { "<<", "LTLT" },
+ { ">>", "GTGT" },
+ { ">>=", "GTGT_EQ" },
+ { "<<=", "LTLT_EQ" },
+ { "==", "EQEQ" },
+ { "!=", "NE" },
+ { "not_eq", "NE" },
+ { "<=", "LE" },
+ { ">=", "GE" },
+ { "&&", "ANDAND" },
+ { "||", "OROR" },
+ { "++", "INCR" },
+ { "--", "DECR" },
+ { ",", "COMMA" },
+ { "->*", "ARROW_STAR" },
+ { "->", "ARROW" },
+ { "char", "CHAR" },
+ { "wchar", "WCHAR" },
+ { "bool", "BOOL" },
+ { "short", "SHORT" },
+ { "int", "INT" },
+ { "long", "LONG" },
+ { "signed", "SIGNED" },
+ { "unsigned", "UNSIGNED" },
+ { "float", "FLOAT" },
+ { "double", "DOUBLE" },
+ { "void", "VOID" },
+ { "case", "CASE" },
+ { "default", "DEFAULT" },
+ { "if", "IF" },
+ { "else", "ELSE" },
+ { "switch", "SWITCH" },
+ { "while", "WHILE" },
+ { "do", "DO" },
+ { "for", "FOR" },
+ { "break", "BREAK" },
+ { "continue", "CONTINUE" },
+ { "goto", "GOTO" },
+ { "return", "RETURN" },
+ { "Q_OBJECT", "Q_OBJECT_TOKEN" },
+ { "Q_GADGET", "Q_GADGET_TOKEN" },
+ { "Q_PROPERTY", "Q_PROPERTY_TOKEN" },
+ { "Q_ENUMS", "Q_ENUMS_TOKEN" },
+ { "Q_FLAGS", "Q_FLAGS_TOKEN" },
+ { "Q_DECLARE_FLAGS", "Q_DECLARE_FLAGS_TOKEN" },
+ { "Q_DECLARE_INTERFACE", "Q_DECLARE_INTERFACE_TOKEN" },
+ { "Q_DECLARE_METATYPE", "Q_DECLARE_METATYPE_TOKEN" },
+ { "Q_DECLARE_EXTENSION_INTERFACE", "Q_DECLARE_INTERFACE_TOKEN" },
+ { "Q_SETS", "Q_FLAGS_TOKEN" },
+ { "Q_CLASSINFO", "Q_CLASSINFO_TOKEN" },
+ { "Q_INTERFACES", "Q_INTERFACES_TOKEN" },
+ { "signals", "SIGNALS" },
+ { "slots", "SLOTS" },
+ { "Q_SIGNALS", "Q_SIGNALS_TOKEN" },
+ { "Q_SLOTS", "Q_SLOTS_TOKEN" },
+ { "Q_PRIVATE_SLOT", "Q_PRIVATE_SLOT_TOKEN" },
+ { "QT_MOC_COMPAT", "Q_MOC_COMPAT_TOKEN" },
+ { "QT3_SUPPORT", "Q_QT3_SUPPORT_TOKEN" },
+ { "Q_INVOKABLE", "Q_INVOKABLE_TOKEN" },
+ { "Q_SIGNAL", "Q_SIGNAL_TOKEN" },
+ { "Q_SLOT", "Q_SLOT_TOKEN" },
+ { "Q_SCRIPTABLE", "Q_SCRIPTABLE_TOKEN" },
+
+ { "\n", "NEWLINE" },
+ { "\"", "QUOTE" },
+ { "\'", "SINGLEQUOTE" },
+ { " ", "WHITESPACE" },
+ { "\t", "WHITESPACE" },
+ { "#", "HASH" },
+ { "\\", "BACKSLASH" },
+ { "//", "CPP_COMMENT" },
+ { "/*", "C_COMMENT" },
+ { 0, "NOTOKEN"}
+};
+
+
+inline bool is_ident_start(char s)
+{
+ return ((s >= 'a' && s <= 'z')
+ || (s >= 'A' && s <= 'Z')
+ || s == '_'
+ );
+}
+
+inline bool is_ident_char(char s)
+{
+ return ((s >= 'a' && s <= 'z')
+ || (s >= 'A' && s <= 'Z')
+ || (s >= '0' && s <= '9')
+ || s == '_'
+ );
+}
+struct State
+{
+ State(const char* token):token(token), nextindex(0),
+ defchar(0), defnext(0), ident(0) {
+ memset( next, 0, sizeof(next));
+ }
+ QByteArray token;
+ int next[128];
+ int nextindex;
+
+ char defchar;
+ int defnext;
+
+ const char *ident;
+
+ bool operator==(const State& o) const
+ {
+ return (token == o.token
+ && nextindex == o.nextindex
+ && defchar == o.defchar
+ && defnext == o.defnext
+ && ident == o.ident);
+ }
+};
+
+void newState(QList<State> &states, const char *token, const char *lexem, bool pre)
+{
+ const char * ident = 0;
+ if (is_ident_start(*lexem))
+ ident = pre?"PP_CHARACTER" : "CHARACTER";
+ else if (*lexem == '#')
+ ident = pre?"PP_HASH" : "HASH";
+
+ int state = 0;
+ while (*lexem) {
+ int next = states[state].next[(int)*lexem];
+ if (!next) {
+ const char * t = 0;
+ if (ident)
+ t = ident;
+ else
+ t = pre?"PP_INCOMPLETE":"INCOMPLETE";
+ next = states.size();
+ states += State(t);
+ states[state].next[(int)*lexem] = next;
+ states[next].ident = ident;
+ }
+ state = next;
+ ++lexem;
+ if (ident && !is_ident_char(*lexem))
+ ident = 0;
+ }
+ states[state].token = token;
+}
+
+void newState(QList<State> &states, const char *token, char lexem)
+{
+ int next = states[0].next[(int)lexem];
+ if (!next) {
+ next = states.size();
+ states += State(token);
+ states[0].next[(int)lexem] = next;
+ } else {
+ states[next].token = token;
+ }
+}
+
+
+void makeTable(const Keyword keywords[])
+{
+ int i,c;
+ bool pre = (keywords == pp_keywords);
+ QList<State> states;
+ states += State(pre?"PP_NOTOKEN":"NOTOKEN");
+
+ // identifiers
+ for (c = 'a'; c <= 'z'; ++c)
+ newState(states, pre?"PP_CHARACTER":"CHARACTER", c);
+ for (c = 'A'; c <= 'Z'; ++c)
+ newState(states, pre?"PP_CHARACTER":"CHARACTER", c);
+ c = '_';
+ newState(states, pre?"PP_CHARACTER":"CHARACTER", c);
+
+ // add digits
+ for (c = '0'; c <= '9'; ++c)
+ newState(states, pre?"PP_DIGIT":"DIGIT", c);
+
+ // keywords
+ for (i = 0; keywords[i].lexem; ++i)
+ newState(states, keywords[i].token, keywords[i].lexem, pre);
+
+ // some floats
+ for (c = '0'; c <= '9'; ++c)
+ newState(states, pre?"PP_FLOATING_LITERAL":"FLOATING_LITERAL",
+ QByteArray(".") + char(c), pre);
+
+ // simplify table with default transitions
+ int transindex = -1;
+ for (i = 0; i < states.size(); ++i) {
+ int n = 0;
+ int defchar = -1;
+ for (c = 0; c < 128; ++c)
+ if (states[i].next[c]) {
+ ++n;
+ defchar = c;
+ }
+ if (!n)
+ continue;
+ if (n == 1) {
+ states[i].defnext = states[i].next[defchar];
+ states[i].defchar = defchar;
+ continue;
+ }
+ states[i].nextindex = ++transindex;
+ }
+
+#if 1
+ // compress table
+ int j, k;
+ for (i = 0; i < states.size(); ++i) {
+ for (j = i + 1; j < states.size(); ++j) {
+ if ( states[i] == states[j] ) {
+ for (k = 0; k < states.size(); ++k) {
+ if (states[k].defnext == j)
+ states[k].defnext = i;
+ if (states[k].defnext > j)
+ --states[k].defnext;
+ for (c = 0; c < 128; ++c) {
+ if (states[k].next[c] == j)
+ states[k].next[c] = i;
+ if (states[k].next[c] > j)
+ --states[k].next[c];
+ }
+ }
+ states.removeAt(j);
+ --j;
+ }
+ }
+ }
+#endif
+ printf("static const short %skeyword_trans[][128] = {\n",
+ pre?"pp_":"");
+ for (i = 0; i < states.size(); ++i) {
+ if (i && !states[i].nextindex)
+ continue;
+ printf("%s {", i?",\n":"");
+ for (c = 0; c < 128; ++c)
+ printf("%s%s%d",
+ c?",":"",
+ (!c || c%16)?"":"\n ",
+ states[i].next[c]
+ );
+ printf("}");
+ }
+ printf("\n};\n\n");
+
+ printf("static const struct\n{\n"
+ " %sToken token;\n"
+ " short next;\n"
+ " char defchar;\n"
+ " short defnext;\n"
+ " %sToken ident;\n"
+ "} %skeywords[] = {\n",
+ pre ? "PP_":"",
+ pre ? "PP_":"",
+ pre ? "pp_":"");
+ for (i = 0; i < states.size(); ++i) {
+ printf("%s {%s, %d, %d, %d, %s}",
+ i?",\n":"",
+ states[i].token.data(),
+ states[i].nextindex,
+ states[i].defchar,
+ states[i].defnext,
+ states[i].ident?states[i].ident:(pre?"PP_NOTOKEN":"NOTOKEN"));
+ }
+ printf("\n};\n");
+}
+
+int main(int argc, char **)
+{
+ printf("// auto generated\n"
+ "// DO NOT EDIT.\n\n");
+ if ( argc > 1 )
+ makeTable(pp_keywords);
+ else
+ makeTable(keywords);
+ return 0;
+}
diff --git a/src/tools/moc/util/generate_keywords.pro b/src/tools/moc/util/generate_keywords.pro
new file mode 100644
index 0000000..8dff744
--- /dev/null
+++ b/src/tools/moc/util/generate_keywords.pro
@@ -0,0 +1,13 @@
+######################################################################
+# Automatically generated by qmake (1.08a) Mon Feb 23 13:08:28 2004
+######################################################################
+
+TEMPLATE = app
+CONFIG -= moc
+mac:CONFIG -= app_bundle
+INCLUDEPATH += .
+
+# Input
+SOURCES += generate_keywords.cpp
+CONFIG += qt create_prl link_prl
+OBJECTS_DIR=.obj/debug-shared
diff --git a/src/tools/moc/util/licenseheader.txt b/src/tools/moc/util/licenseheader.txt
new file mode 100644
index 0000000..6812109
--- /dev/null
+++ b/src/tools/moc/util/licenseheader.txt
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
diff --git a/src/tools/moc/utils.h b/src/tools/moc/utils.h
new file mode 100644
index 0000000..2dffc43
--- /dev/null
+++ b/src/tools/moc/utils.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+inline bool is_whitespace(char s)
+{
+ return (s == ' ' || s == '\t' || s == '\n');
+}
+
+inline bool is_space(char s)
+{
+ return (s == ' ' || s == '\t');
+}
+
+inline bool is_ident_start(char s)
+{
+ return ((s >= 'a' && s <= 'z')
+ || (s >= 'A' && s <= 'Z')
+ || s == '_'
+ );
+}
+
+inline bool is_ident_char(char s)
+{
+ return ((s >= 'a' && s <= 'z')
+ || (s >= 'A' && s <= 'Z')
+ || (s >= '0' && s <= '9')
+ || s == '_'
+ );
+}
+
+inline bool is_digit_char(char s)
+{
+ return (s >= '0' && s <= '9');
+}
+
+inline bool is_octal_char(char s)
+{
+ return (s >= '0' && s <= '7');
+}
+
+inline bool is_hex_char(char s)
+{
+ return ((s >= 'a' && s <= 'f')
+ || (s >= 'A' && s <= 'F')
+ || (s >= '0' && s <= '9')
+ );
+}
+
+inline const char *skipQuote(const char *data)
+{
+ while (*data && (*data != '\"')) {
+ if (*data == '\\') {
+ ++data;
+ if (!*data) break;
+ }
+ ++data;
+ }
+
+ if (*data) //Skip last quote
+ ++data;
+ return data;
+}
+
+QT_END_NAMESPACE
+
+#endif // UTILS_H
diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp
new file mode 100644
index 0000000..2999e3b
--- /dev/null
+++ b/src/tools/rcc/main.cpp
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <rcc.h>
+#include "../../corelib/kernel/qcorecmdlineargs_p.h"
+
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+#include <QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+void showHelp(const QString &argv0, const QString &error)
+{
+ fprintf(stderr, "Qt resource compiler\n");
+ if (!error.isEmpty())
+ fprintf(stderr, "%s: %s\n", qPrintable(argv0), qPrintable(error));
+ fprintf(stderr, "Usage: %s [options] <inputs>\n\n"
+ "Options:\n"
+ " -o file write output to file rather than stdout\n"
+ " -name name create an external initialization function with name\n"
+ " -threshold level threshold to consider compressing files\n"
+ " -compress level compress input files by level\n"
+ " -root path prefix resource access path with root path\n"
+ " -no-compress disable all compression\n"
+ " -binary output a binary file for use as a dynamic resource\n"
+ " -namespace turn off namespace macros\n"
+ " -project Output a resource file containing all\n"
+ " files from the current directory\n"
+ " -version display version\n"
+ " -help display this information\n",
+ qPrintable(argv0));
+}
+
+void dumpRecursive(const QDir &dir, QTextStream &out)
+{
+ QFileInfoList entries = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot
+ | QDir::NoSymLinks);
+ foreach (QFileInfo entry, entries) {
+ if (entry.isDir()) {
+ dumpRecursive(entry.filePath(), out);
+ } else {
+ out << QLatin1String("<file>")
+ << entry.filePath()
+ << QLatin1String("</file>\n");
+ }
+ }
+}
+
+int createProject(const QString &outFileName)
+{
+ QDir currentDir = QDir::current();
+ QString currentDirName = currentDir.dirName();
+ if (currentDirName.isEmpty())
+ currentDirName = QLatin1String("root");
+
+ QFile file;
+ bool isOk = false;
+ if (outFileName.isEmpty()) {
+ isOk = file.open(stdout, QFile::WriteOnly | QFile::Text);
+ } else {
+ file.setFileName(outFileName);
+ isOk = file.open(QFile::WriteOnly | QFile::Text);
+ }
+ if (!isOk) {
+ fprintf(stderr, "Unable to open %s: %s\n",
+ outFileName.isEmpty() ? qPrintable(outFileName) : "standard output",
+ qPrintable(file.errorString()));
+ return 1;
+ }
+
+ QTextStream out(&file);
+ out << QLatin1String("<!DOCTYPE RCC><RCC version=\"1.0\">\n"
+ "<qresource>\n");
+
+ // use "." as dir to get relative file pathes
+ dumpRecursive(QDir(QLatin1String(".")), out);
+
+ out << QLatin1String("</qresource>\n"
+ "</RCC>\n");
+
+ return 0;
+}
+
+int runRcc(int argc, char *argv[])
+{
+ QString outFilename;
+ bool helpRequested = false;
+ bool list = false;
+ bool projectRequested = false;
+ QStringList filenamesIn;
+
+ QStringList args = qCmdLineArgs(argc, argv);
+
+ RCCResourceLibrary library;
+
+ //parse options
+ QString errorMsg;
+ for (int i = 1; i < args.count() && errorMsg.isEmpty(); i++) {
+ if (args[i].isEmpty())
+ continue;
+ if (args[i][0] == QLatin1Char('-')) { // option
+ QString opt = args[i];
+ if (opt == QLatin1String("-o")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing output name");
+ break;
+ }
+ outFilename = args[++i];
+ } else if (opt == QLatin1String("-name")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing target name");
+ break;
+ }
+ library.setInitName(args[++i]);
+ } else if (opt == QLatin1String("-root")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing root path");
+ break;
+ }
+ library.setResourceRoot(QDir::cleanPath(args[++i]));
+ if (library.resourceRoot().isEmpty()
+ || library.resourceRoot().at(0) != QLatin1Char('/'))
+ errorMsg = QLatin1String("Root must start with a /");
+ } else if (opt == QLatin1String("-compress")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing compression level");
+ break;
+ }
+ library.setCompressLevel(args[++i].toInt());
+ } else if (opt == QLatin1String("-threshold")) {
+ if (!(i < argc-1)) {
+ errorMsg = QLatin1String("Missing compression threshold");
+ break;
+ }
+ library.setCompressThreshold(args[++i].toInt());
+ } else if (opt == QLatin1String("-binary")) {
+ library.setFormat(RCCResourceLibrary::Binary);
+ } else if (opt == QLatin1String("-namespace")) {
+ library.setUseNameSpace(!library.useNameSpace());
+ } else if (opt == QLatin1String("-verbose")) {
+ library.setVerbose(true);
+ } else if (opt == QLatin1String("-list")) {
+ list = true;
+ } else if (opt == QLatin1String("-version") || opt == QLatin1String("-v")) {
+ fprintf(stderr, "Qt Resource Compiler version %s\n", QT_VERSION_STR);
+ return 1;
+ } else if (opt == QLatin1String("-help") || opt == QLatin1String("-h")) {
+ helpRequested = true;
+ } else if (opt == QLatin1String("-no-compress")) {
+ library.setCompressLevel(-2);
+ } else if (opt == QLatin1String("-project")) {
+ projectRequested = true;
+ } else {
+ errorMsg = QString::fromLatin1("Unknown option: '%1'").arg(args[i]);
+ }
+ } else {
+ if (!QFile::exists(args[i])) {
+ qWarning("%s: File does not exist '%s'",
+ qPrintable(args[0]), qPrintable(args[i]));
+ return 1;
+ }
+ filenamesIn.append(args[i]);
+ }
+ }
+
+ if (projectRequested && !helpRequested) {
+ return createProject(outFilename);
+ }
+
+ if (!filenamesIn.size() || !errorMsg.isEmpty() || helpRequested) {
+ showHelp(args[0], errorMsg);
+ return 1;
+ }
+ QFile errorDevice;
+ errorDevice.open(stderr, QIODevice::WriteOnly|QIODevice::Text);
+
+ if (library.verbose())
+ errorDevice.write("Qt resource compiler\n");
+
+ library.setInputFiles(filenamesIn);
+
+ if (!library.readFiles(list, errorDevice))
+ return 1;
+
+ // open output
+ QFile out;
+ QIODevice::OpenMode mode = QIODevice::WriteOnly;
+ if (library.format() == RCCResourceLibrary::C_Code)
+ mode |= QIODevice::Text;
+
+ if (outFilename.isEmpty() || outFilename == QLatin1String("-")) {
+ // using this overload close() only flushes.
+ out.open(stdout, mode);
+ } else {
+ out.setFileName(outFilename);
+ if (!out.open(mode)) {
+ const QString msg = QString::fromUtf8("Unable to open %1 for writing: %2\n").arg(outFilename).arg(out.errorString());
+ errorDevice.write(msg.toUtf8());
+ return 1;
+ }
+ }
+
+ // do the task
+ if (list) {
+ const QStringList data = library.dataFiles();
+ for (int i = 0; i < data.size(); ++i) {
+ out.write(qPrintable(QDir::cleanPath(data.at(i))));
+ out.write("\n");
+ }
+ return 0;
+ }
+
+ return library.output(out, errorDevice) ? 0 : 1;
+}
+
+QT_END_NAMESPACE
+
+int main(int argc, char *argv[])
+{
+ return QT_PREPEND_NAMESPACE(runRcc)(argc, argv);
+}
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
new file mode 100644
index 0000000..2a0f8c3
--- /dev/null
+++ b/src/tools/rcc/rcc.cpp
@@ -0,0 +1,967 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "rcc.h"
+
+#include <QtCore/QByteArray>
+#include <QtCore/QDateTime>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <QtCore/QFile>
+#include <QtCore/QIODevice>
+#include <QtCore/QLocale>
+#include <QtCore/QStack>
+
+#include <QtXml/QDomDocument>
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ CONSTANT_USENAMESPACE = 1,
+ CONSTANT_COMPRESSLEVEL_DEFAULT = -1,
+ CONSTANT_COMPRESSTHRESHOLD_DEFAULT = 70
+};
+
+
+#define writeString(s) write(s, sizeof(s))
+
+void RCCResourceLibrary::write(const char *str, int len)
+{
+ --len; // trailing \0 on string literals...
+ int n = m_out.size();
+ m_out.resize(n + len);
+ memcpy(m_out.data() + n, str, len);
+}
+
+void RCCResourceLibrary::writeByteArray(const QByteArray &other)
+{
+ m_out.append(other);
+}
+
+static inline QString msgOpenReadFailed(const QString &fname, const QString &why)
+{
+ return QString::fromUtf8("Unable to open %1 for reading: %2\n").arg(fname).arg(why);
+}
+
+
+///////////////////////////////////////////////////////////
+//
+// RCCFileInfo
+//
+///////////////////////////////////////////////////////////
+
+class RCCFileInfo
+{
+public:
+ enum Flags
+ {
+ NoFlags = 0x00,
+ Compressed = 0x01,
+ Directory = 0x02
+ };
+
+ RCCFileInfo(const QString &name = QString(), const QFileInfo &fileInfo = QFileInfo(),
+ QLocale::Language language = QLocale::C,
+ QLocale::Country country = QLocale::AnyCountry,
+ uint flags = NoFlags,
+ int compressLevel = CONSTANT_COMPRESSLEVEL_DEFAULT,
+ int compressThreshold = CONSTANT_COMPRESSTHRESHOLD_DEFAULT);
+ ~RCCFileInfo();
+
+ QString resourceName() const;
+
+public:
+ qint64 writeDataBlob(RCCResourceLibrary &lib, qint64 offset, QString *errorMessage);
+ qint64 writeDataName(RCCResourceLibrary &, qint64 offset);
+ void writeDataInfo(RCCResourceLibrary &lib);
+
+ int m_flags;
+ QString m_name;
+ QLocale::Language m_language;
+ QLocale::Country m_country;
+ QFileInfo m_fileInfo;
+ RCCFileInfo *m_parent;
+ QHash<QString, RCCFileInfo*> m_children;
+ int m_compressLevel;
+ int m_compressThreshold;
+
+ qint64 m_nameOffset;
+ qint64 m_dataOffset;
+ qint64 m_childOffset;
+};
+
+RCCFileInfo::RCCFileInfo(const QString &name, const QFileInfo &fileInfo,
+ QLocale::Language language, QLocale::Country country, uint flags,
+ int compressLevel, int compressThreshold)
+{
+ m_name = name;
+ m_fileInfo = fileInfo;
+ m_language = language;
+ m_country = country;
+ m_flags = flags;
+ m_parent = 0;
+ m_nameOffset = 0;
+ m_dataOffset = 0;
+ m_childOffset = 0;
+ m_compressLevel = compressLevel;
+ m_compressThreshold = compressThreshold;
+}
+
+RCCFileInfo::~RCCFileInfo()
+{
+ qDeleteAll(m_children);
+}
+
+QString RCCFileInfo::resourceName() const
+{
+ QString resource = m_name;
+ for (RCCFileInfo *p = m_parent; p; p = p->m_parent)
+ resource = resource.prepend(p->m_name + QLatin1Char('/'));
+ return QLatin1Char(':') + resource;
+}
+
+void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
+{
+ const bool text = (lib.m_format == RCCResourceLibrary::C_Code);
+ //some info
+ if (text) {
+ if (m_language != QLocale::C) {
+ lib.writeString(" // ");
+ lib.writeByteArray(resourceName().toLocal8Bit());
+ lib.writeString(" [");
+ lib.writeByteArray(QByteArray::number(m_country));
+ lib.writeString("::");
+ lib.writeByteArray(QByteArray::number(m_language));
+ lib.writeString("[\n ");
+ } else {
+ lib.writeString(" // ");
+ lib.writeByteArray(resourceName().toLocal8Bit());
+ lib.writeString("\n ");
+ }
+ }
+
+ //pointer data
+ if (m_flags & RCCFileInfo::Directory) {
+ // name offset
+ lib.writeNumber4(m_nameOffset);
+
+ // flags
+ lib.writeNumber2(m_flags);
+
+ // child count
+ lib.writeNumber4(m_children.size());
+
+ // first child offset
+ lib.writeNumber4(m_childOffset);
+ } else {
+ // name offset
+ lib.writeNumber4(m_nameOffset);
+
+ // flags
+ lib.writeNumber2(m_flags);
+
+ // locale
+ lib.writeNumber2(m_country);
+ lib.writeNumber2(m_language);
+
+ //data offset
+ lib.writeNumber4(m_dataOffset);
+ }
+ if (text)
+ lib.writeChar('\n');
+}
+
+qint64 RCCFileInfo::writeDataBlob(RCCResourceLibrary &lib, qint64 offset,
+ QString *errorMessage)
+{
+ const bool text = (lib.m_format == RCCResourceLibrary::C_Code);
+
+ //capture the offset
+ m_dataOffset = offset;
+
+ //find the data to be written
+ QFile file(m_fileInfo.absoluteFilePath());
+ if (!file.open(QFile::ReadOnly)) {
+ *errorMessage = msgOpenReadFailed(m_fileInfo.absoluteFilePath(), file.errorString());
+ return 0;
+ }
+ QByteArray data = file.readAll();
+
+#ifndef QT_NO_COMPRESS
+ // Check if compression is useful for this file
+ if (m_compressLevel != 0 && data.size() != 0) {
+ QByteArray compressed =
+ qCompress(reinterpret_cast<uchar *>(data.data()), data.size(), m_compressLevel);
+
+ int compressRatio = int(100.0 * (data.size() - compressed.size()) / data.size());
+ if (compressRatio >= m_compressThreshold) {
+ data = compressed;
+ m_flags |= Compressed;
+ }
+ }
+#endif // QT_NO_COMPRESS
+
+ // some info
+ if (text) {
+ lib.writeString(" // ");
+ lib.writeByteArray(m_fileInfo.absoluteFilePath().toLocal8Bit());
+ lib.writeString("\n ");
+ }
+
+ // write the length
+
+ lib.writeNumber4(data.size());
+ if (text)
+ lib.writeString("\n ");
+ offset += 4;
+
+ // write the payload
+ const char *p = data.constData();
+ if (text) {
+ for (int i = data.size(), j = 0; --i >= 0; --j) {
+ lib.writeHex(*p++);
+ if (j == 0) {
+ lib.writeString("\n ");
+ j = 16;
+ }
+ }
+ } else {
+ for (int i = data.size(); --i >= 0; )
+ lib.writeChar(*p++);
+ }
+ offset += data.size();
+
+ // done
+ if (text)
+ lib.writeString("\n ");
+ return offset;
+}
+
+qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset)
+{
+ const bool text = (lib.m_format == RCCResourceLibrary::C_Code);
+
+ // capture the offset
+ m_nameOffset = offset;
+
+ // some info
+ if (text) {
+ lib.writeString(" // ");
+ lib.writeByteArray(m_name.toLocal8Bit());
+ lib.writeString("\n ");
+ }
+
+ // write the length
+ lib.writeNumber2(m_name.length());
+ if (text)
+ lib.writeString("\n ");
+ offset += 2;
+
+ // write the hash
+ lib.writeNumber4(qHash(m_name));
+ if (text)
+ lib.writeString("\n ");
+ offset += 4;
+
+ // write the m_name
+ const QChar *unicode = m_name.unicode();
+ for (int i = 0; i < m_name.length(); ++i) {
+ lib.writeNumber2(unicode[i].unicode());
+ if (text && i % 16 == 0)
+ lib.writeString("\n ");
+ }
+ offset += m_name.length()*2;
+
+ // done
+ if (text)
+ lib.writeString("\n ");
+ return offset;
+}
+
+
+///////////////////////////////////////////////////////////
+//
+// RCCResourceLibrary
+//
+///////////////////////////////////////////////////////////
+
+RCCResourceLibrary::Strings::Strings() :
+ TAG_RCC(QLatin1String("RCC")),
+ TAG_RESOURCE(QLatin1String("qresource")),
+ TAG_FILE(QLatin1String("file")),
+ ATTRIBUTE_LANG(QLatin1String("lang")),
+ ATTRIBUTE_PREFIX(QLatin1String("prefix")),
+ ATTRIBUTE_ALIAS(QLatin1String("alias")),
+ ATTRIBUTE_THRESHOLD(QLatin1String("threshold")),
+ ATTRIBUTE_COMPRESS(QLatin1String("compress"))
+{
+}
+
+RCCResourceLibrary::RCCResourceLibrary()
+ : m_root(0),
+ m_format(C_Code),
+ m_verbose(false),
+ m_compressLevel(CONSTANT_COMPRESSLEVEL_DEFAULT),
+ m_compressThreshold(CONSTANT_COMPRESSTHRESHOLD_DEFAULT),
+ m_treeOffset(0),
+ m_namesOffset(0),
+ m_dataOffset(0),
+ m_useNameSpace(CONSTANT_USENAMESPACE),
+ m_errorDevice(0)
+{
+ m_out.reserve(30 * 1000 * 1000);
+}
+
+RCCResourceLibrary::~RCCResourceLibrary()
+{
+ delete m_root;
+}
+
+bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice,
+ const QString &fname, QString currentPath, bool ignoreErrors)
+{
+ Q_ASSERT(m_errorDevice);
+ const QChar slash = QLatin1Char('/');
+ if (!currentPath.isEmpty() && !currentPath.endsWith(slash))
+ currentPath += slash;
+
+ QDomDocument document;
+ {
+ QString errorMsg;
+ int errorLine = 0;
+ int errorColumn = 0;
+ if (!document.setContent(inputDevice, &errorMsg, &errorLine, &errorColumn)) {
+ if (ignoreErrors)
+ return true;
+ const QString msg = QString::fromUtf8("RCC Parse Error: '%1' Line: %2 Column: %3 [%4]\n").arg(fname).arg(errorLine).arg(errorColumn).arg(errorMsg);
+ m_errorDevice->write(msg.toUtf8());
+ return false;
+ }
+ }
+
+ QDomElement domRoot = document.firstChildElement(m_strings.TAG_RCC).toElement();
+ if (!domRoot.isNull() && domRoot.tagName() == m_strings.TAG_RCC) {
+ for (QDomNode node = domRoot.firstChild(); !node.isNull(); node = node.nextSibling()) {
+ if (!node.isElement())
+ continue;
+
+ QDomElement child = node.toElement();
+ if (!child.isNull() && child.tagName() == m_strings.TAG_RESOURCE) {
+ QLocale::Language language = QLocale::c().language();
+ QLocale::Country country = QLocale::c().country();
+
+ if (child.hasAttribute(m_strings.ATTRIBUTE_LANG)) {
+ QString attribute = child.attribute(m_strings.ATTRIBUTE_LANG);
+ QLocale lang = QLocale(attribute);
+ language = lang.language();
+ if (2 == attribute.length()) {
+ // Language only
+ country = QLocale::AnyCountry;
+ } else {
+ country = lang.country();
+ }
+ }
+
+ QString prefix;
+ if (child.hasAttribute(m_strings.ATTRIBUTE_PREFIX))
+ prefix = child.attribute(m_strings.ATTRIBUTE_PREFIX);
+ if (!prefix.startsWith(slash))
+ prefix.prepend(slash);
+ if (!prefix.endsWith(slash))
+ prefix += slash;
+
+ for (QDomNode res = child.firstChild(); !res.isNull(); res = res.nextSibling()) {
+ if (res.isElement() && res.toElement().tagName() == m_strings.TAG_FILE) {
+
+ QString fileName(res.firstChild().toText().data());
+ if (fileName.isEmpty()) {
+ const QString msg = QString::fromUtf8("RCC: Warning: Null node in XML of '%1'\n").arg(fname);
+ m_errorDevice->write(msg.toUtf8());
+ }
+ QString alias;
+ if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_ALIAS))
+ alias = res.toElement().attribute(m_strings.ATTRIBUTE_ALIAS);
+ else
+ alias = fileName;
+
+ int compressLevel = m_compressLevel;
+ if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_COMPRESS))
+ compressLevel = res.toElement().attribute(m_strings.ATTRIBUTE_COMPRESS).toInt();
+ int compressThreshold = m_compressThreshold;
+ if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_THRESHOLD))
+ compressThreshold = res.toElement().attribute(m_strings.ATTRIBUTE_THRESHOLD).toInt();
+
+ // Special case for -no-compress. Overrides all other settings.
+ if (m_compressLevel == -2)
+ compressLevel = 0;
+
+ alias = QDir::cleanPath(alias);
+ while (alias.startsWith(QLatin1String("../")))
+ alias.remove(0, 3);
+ alias = QDir::cleanPath(m_resourceRoot) + prefix + alias;
+
+ QString absFileName = fileName;
+ if (QDir::isRelativePath(absFileName))
+ absFileName.prepend(currentPath);
+ QFileInfo file(absFileName);
+ if (!file.exists()) {
+ m_failedResources.push_back(absFileName);
+ const QString msg = QString::fromUtf8("RCC: Error in '%1': Cannot find file '%2'\n").arg(fname).arg(fileName);
+ m_errorDevice->write(msg.toUtf8());
+ if (ignoreErrors)
+ continue;
+ else
+ return false;
+ } else if (file.isFile()) {
+ const bool arc = addFile(alias, RCCFileInfo(alias.section(slash, -1), file, language, country,
+ RCCFileInfo::NoFlags, compressLevel, compressThreshold));
+ if (!arc)
+ m_failedResources.push_back(absFileName);
+ } else {
+ QDir dir;
+ if (file.isDir()) {
+ dir.setPath(file.filePath());
+ } else {
+ dir.setPath(file.path());
+ dir.setNameFilters(QStringList(file.fileName()));
+ if (alias.endsWith(file.fileName()))
+ alias = alias.left(alias.length()-file.fileName().length());
+ }
+ if (!alias.endsWith(slash))
+ alias += slash;
+ QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ it.next();
+ QFileInfo child(it.fileInfo());
+ if (child.fileName() != QLatin1String(".") && child.fileName() != QLatin1String("..")) {
+ const bool arc = addFile(alias + child.fileName(),
+ RCCFileInfo(child.fileName(), child, language, country,
+ RCCFileInfo::NoFlags, compressLevel, compressThreshold));
+ if (!arc)
+ m_failedResources.push_back(child.fileName());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (m_root == 0) {
+ const QString msg = QString::fromUtf8("RCC: Warning: No resources in '%1'.\n").arg(fname);
+ m_errorDevice->write(msg.toUtf8());
+ if (!ignoreErrors && m_format == Binary) {
+ // create dummy entry, otherwise loading qith QResource will crash
+ m_root = new RCCFileInfo(QString(), QFileInfo(),
+ QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ }
+ }
+
+ return true;
+}
+
+bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file)
+{
+ Q_ASSERT(m_errorDevice);
+ if (file.m_fileInfo.size() > 0xffffffff) {
+ const QString msg = QString::fromUtf8("File too big: %1\n").arg(file.m_fileInfo.absoluteFilePath());
+ m_errorDevice->write(msg.toUtf8());
+ return false;
+ }
+ if (!m_root)
+ m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+
+ RCCFileInfo *parent = m_root;
+ const QStringList nodes = alias.split(QLatin1Char('/'));
+ for (int i = 1; i < nodes.size()-1; ++i) {
+ const QString node = nodes.at(i);
+ if (node.isEmpty())
+ continue;
+ if (!parent->m_children.contains(node)) {
+ RCCFileInfo *s = new RCCFileInfo(node, QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory);
+ s->m_parent = parent;
+ parent->m_children.insert(node, s);
+ parent = s;
+ } else {
+ parent = parent->m_children[node];
+ }
+ }
+
+ const QString filename = nodes.at(nodes.size()-1);
+ RCCFileInfo *s = new RCCFileInfo(file);
+ s->m_parent = parent;
+ parent->m_children.insertMulti(filename, s);
+ return true;
+}
+
+void RCCResourceLibrary::reset()
+{
+ if (m_root) {
+ delete m_root;
+ m_root = 0;
+ }
+ m_errorDevice = 0;
+ m_failedResources.clear();
+}
+
+
+bool RCCResourceLibrary::readFiles(bool ignoreErrors, QIODevice &errorDevice)
+{
+ reset();
+ m_errorDevice = &errorDevice;
+ //read in data
+ if (m_verbose) {
+ const QString msg = QString::fromUtf8("Processing %1 files [%2]\n")
+ .arg(m_fileNames.size()).arg(static_cast<int>(ignoreErrors));
+ m_errorDevice->write(msg.toUtf8());
+ }
+ for (int i = 0; i < m_fileNames.size(); ++i) {
+ QFile fileIn;
+ QString fname = m_fileNames.at(i);
+ QString pwd;
+ if (fname == QLatin1String("-")) {
+ fname = QLatin1String("(stdin)");
+ pwd = QDir::currentPath();
+ fileIn.setFileName(fname);
+ if (!fileIn.open(stdin, QIODevice::ReadOnly)) {
+ m_errorDevice->write(msgOpenReadFailed(fname, fileIn.errorString()).toUtf8());
+ return false;
+ }
+ } else {
+ pwd = QFileInfo(fname).path();
+ fileIn.setFileName(fname);
+ if (!fileIn.open(QIODevice::ReadOnly)) {
+ m_errorDevice->write(msgOpenReadFailed(fname, fileIn.errorString()).toUtf8());
+ return false;
+ }
+ }
+ if (m_verbose) {
+ const QString msg = QString::fromUtf8("Interpreting %1\n").arg(fname);
+ m_errorDevice->write(msg.toUtf8());
+ }
+
+ if (!interpretResourceFile(&fileIn, fname, pwd, ignoreErrors))
+ return false;
+ }
+ return true;
+}
+
+QStringList RCCResourceLibrary::dataFiles() const
+{
+ QStringList ret;
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return ret;
+ pending.push(m_root);
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin();
+ it != file->m_children.end(); ++it) {
+ RCCFileInfo *child = it.value();
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ ret.append(child->m_fileInfo.filePath());
+ }
+ }
+ return ret;
+}
+
+// Determine map of resource identifier (':/newPrefix/images/p1.png') to file via recursion
+static void resourceDataFileMapRecursion(const RCCFileInfo *m_root, const QString &path, RCCResourceLibrary::ResourceDataFileMap &m)
+{
+ typedef QHash<QString, RCCFileInfo*>::const_iterator ChildConstIterator;
+ const QChar slash = QLatin1Char('/');
+ const ChildConstIterator cend = m_root->m_children.constEnd();
+ for (ChildConstIterator it = m_root->m_children.constBegin(); it != cend; ++it) {
+ const RCCFileInfo *child = it.value();
+ QString childName = path;
+ childName += slash;
+ childName += child->m_name;
+ if (child->m_flags & RCCFileInfo::Directory) {
+ resourceDataFileMapRecursion(child, childName, m);
+ } else {
+ m.insert(childName, child->m_fileInfo.filePath());
+ }
+ }
+}
+
+RCCResourceLibrary::ResourceDataFileMap RCCResourceLibrary::resourceDataFileMap() const
+{
+ ResourceDataFileMap rc;
+ if (m_root)
+ resourceDataFileMapRecursion(m_root, QString(QLatin1Char(':')), rc);
+ return rc;
+}
+
+bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice)
+{
+ m_errorDevice = &errorDevice;
+ //write out
+ if (m_verbose)
+ m_errorDevice->write("Outputting code\n");
+ if (!writeHeader()) {
+ m_errorDevice->write("Could not write header\n");
+ return false;
+ }
+ if (m_root) {
+ if (!writeDataBlobs()) {
+ m_errorDevice->write("Could not write data blobs.\n");
+ return false;
+ }
+ if (!writeDataNames()) {
+ m_errorDevice->write("Could not write file names\n");
+ return false;
+ }
+ if (!writeDataStructure()) {
+ m_errorDevice->write("Could not write data tree\n");
+ return false;
+ }
+ }
+ if (!writeInitializer()) {
+ m_errorDevice->write("Could not write footer\n");
+ return false;
+ }
+ outDevice.write(m_out, m_out.size());
+ return true;
+}
+
+void RCCResourceLibrary::writeHex(quint8 tmp)
+{
+ const char * const digits = "0123456789abcdef";
+ writeChar('0');
+ writeChar('x');
+ if (tmp < 16) {
+ writeChar(digits[tmp]);
+ } else {
+ writeChar(digits[tmp >> 4]);
+ writeChar(digits[tmp & 0xf]);
+ }
+ writeChar(',');
+}
+
+void RCCResourceLibrary::writeNumber2(quint16 number)
+{
+ if (m_format == RCCResourceLibrary::Binary) {
+ writeChar(number >> 8);
+ writeChar(number);
+ } else {
+ writeHex(number >> 8);
+ writeHex(number);
+ }
+}
+
+void RCCResourceLibrary::writeNumber4(quint32 number)
+{
+ if (m_format == RCCResourceLibrary::Binary) {
+ writeChar(number >> 24);
+ writeChar(number >> 16);
+ writeChar(number >> 8);
+ writeChar(number);
+ } else {
+ writeHex(number >> 24);
+ writeHex(number >> 16);
+ writeHex(number >> 8);
+ writeHex(number);
+ }
+}
+
+bool RCCResourceLibrary::writeHeader()
+{
+ if (m_format == C_Code) {
+ writeString("/****************************************************************************\n");
+ writeString("** Resource object code\n");
+ writeString("**\n");
+ writeString("** Created: ");
+ writeByteArray(QDateTime::currentDateTime().toString().toLatin1());
+ writeString("\n** by: The Resource Compiler for Qt version ");
+ writeByteArray(QT_VERSION_STR);
+ writeString("\n**\n");
+ writeString("** WARNING! All changes made in this file will be lost!\n");
+ writeString( "*****************************************************************************/\n\n");
+ writeString("#include <QtCore/qglobal.h>\n\n");
+ } else if (m_format == Binary) {
+ writeString("qres");
+ writeNumber4(0);
+ writeNumber4(0);
+ writeNumber4(0);
+ writeNumber4(0);
+ }
+ return true;
+}
+
+bool RCCResourceLibrary::writeDataBlobs()
+{
+ Q_ASSERT(m_errorDevice);
+ if (m_format == C_Code)
+ writeString("static const unsigned char qt_resource_data[] = {\n");
+ else if (m_format == Binary)
+ m_dataOffset = m_out.size();
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return false;
+
+ pending.push(m_root);
+ qint64 offset = 0;
+ QString errorMessage;
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin();
+ it != file->m_children.end(); ++it) {
+ RCCFileInfo *child = it.value();
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ else {
+ offset = child->writeDataBlob(*this, offset, &errorMessage);
+ if (offset == 0)
+ m_errorDevice->write(errorMessage.toUtf8());
+ }
+ }
+ }
+ if (m_format == C_Code)
+ writeString("\n};\n\n");
+ return true;
+}
+
+bool RCCResourceLibrary::writeDataNames()
+{
+ if (m_format == C_Code)
+ writeString("static const unsigned char qt_resource_name[] = {\n");
+ else if (m_format == Binary)
+ m_namesOffset = m_out.size();
+
+ QHash<QString, int> names;
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return false;
+
+ pending.push(m_root);
+ qint64 offset = 0;
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ for (QHash<QString, RCCFileInfo*>::iterator it = file->m_children.begin();
+ it != file->m_children.end(); ++it) {
+ RCCFileInfo *child = it.value();
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ if (names.contains(child->m_name)) {
+ child->m_nameOffset = names.value(child->m_name);
+ } else {
+ names.insert(child->m_name, offset);
+ offset = child->writeDataName(*this, offset);
+ }
+ }
+ }
+ if (m_format == C_Code)
+ writeString("\n};\n\n");
+ return true;
+}
+
+static bool qt_rcc_compare_hash(const RCCFileInfo *left, const RCCFileInfo *right)
+{
+ return qHash(left->m_name) < qHash(right->m_name);
+}
+
+bool RCCResourceLibrary::writeDataStructure()
+{
+ if (m_format == C_Code)
+ writeString("static const unsigned char qt_resource_struct[] = {\n");
+ else if (m_format == Binary)
+ m_treeOffset = m_out.size();
+ QStack<RCCFileInfo*> pending;
+
+ if (!m_root)
+ return false;
+
+ //calculate the child offsets (flat)
+ pending.push(m_root);
+ int offset = 1;
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+ file->m_childOffset = offset;
+
+ //sort by hash value for binary lookup
+ QList<RCCFileInfo*> m_children = file->m_children.values();
+ qSort(m_children.begin(), m_children.end(), qt_rcc_compare_hash);
+
+ //write out the actual data now
+ for (int i = 0; i < m_children.size(); ++i) {
+ RCCFileInfo *child = m_children.at(i);
+ ++offset;
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ }
+ }
+
+ //write out the structure (ie iterate again!)
+ pending.push(m_root);
+ m_root->writeDataInfo(*this);
+ while (!pending.isEmpty()) {
+ RCCFileInfo *file = pending.pop();
+
+ //sort by hash value for binary lookup
+ QList<RCCFileInfo*> m_children = file->m_children.values();
+ qSort(m_children.begin(), m_children.end(), qt_rcc_compare_hash);
+
+ //write out the actual data now
+ for (int i = 0; i < m_children.size(); ++i) {
+ RCCFileInfo *child = m_children.at(i);
+ child->writeDataInfo(*this);
+ if (child->m_flags & RCCFileInfo::Directory)
+ pending.push(child);
+ }
+ }
+ if (m_format == C_Code)
+ writeString("\n};\n\n");
+
+ return true;
+}
+
+void RCCResourceLibrary::writeMangleNamespaceFunction(const QByteArray &name)
+{
+ if (m_useNameSpace) {
+ writeString("QT_MANGLE_NAMESPACE(");
+ writeByteArray(name);
+ writeChar(')');
+ } else {
+ writeByteArray(name);
+ }
+}
+
+void RCCResourceLibrary::writeAddNamespaceFunction(const QByteArray &name)
+{
+ if (m_useNameSpace) {
+ writeString("QT_PREPEND_NAMESPACE(");
+ writeByteArray(name);
+ writeChar(')');
+ } else {
+ writeByteArray(name);
+ }
+}
+
+bool RCCResourceLibrary::writeInitializer()
+{
+ if (m_format == C_Code) {
+ //write("\nQT_BEGIN_NAMESPACE\n");
+ QString initName = m_initName;
+ if (!initName.isEmpty()) {
+ initName.prepend(QLatin1Char('_'));
+ initName.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_]")), QLatin1String("_"));
+ }
+
+ //init
+ if (m_useNameSpace)
+ writeString("QT_BEGIN_NAMESPACE\n\n");
+ if (m_root) {
+ writeString("extern bool qRegisterResourceData\n "
+ "(int, const unsigned char *, "
+ "const unsigned char *, const unsigned char *);\n\n");
+ writeString("extern bool qUnregisterResourceData\n "
+ "(int, const unsigned char *, "
+ "const unsigned char *, const unsigned char *);\n\n");
+ }
+ if (m_useNameSpace)
+ writeString("QT_END_NAMESPACE\n\n\n");
+ QString initResources = QLatin1String("qInitResources");
+ initResources += initName;
+ writeString("int ");
+ writeMangleNamespaceFunction(initResources.toLatin1());
+ writeString("()\n{\n");
+
+ if (m_root) {
+ writeString(" ");
+ writeAddNamespaceFunction("qRegisterResourceData");
+ writeString("\n (0x01, qt_resource_struct, "
+ "qt_resource_name, qt_resource_data);\n");
+ }
+ writeString(" return 1;\n");
+ writeString("}\n\n");
+ writeString("Q_CONSTRUCTOR_FUNCTION(");
+ writeMangleNamespaceFunction(initResources.toLatin1());
+ writeString(")\n\n");
+
+ //cleanup
+ QString cleanResources = QLatin1String("qCleanupResources");
+ cleanResources += initName;
+ writeString("int ");
+ writeMangleNamespaceFunction(cleanResources.toLatin1());
+ writeString("()\n{\n");
+ if (m_root) {
+ writeString(" ");
+ writeAddNamespaceFunction("qUnregisterResourceData");
+ writeString("\n (0x01, qt_resource_struct, "
+ "qt_resource_name, qt_resource_data);\n");
+ }
+ writeString(" return 1;\n");
+ writeString("}\n\n");
+ writeString("Q_DESTRUCTOR_FUNCTION(");
+ writeMangleNamespaceFunction(cleanResources.toLatin1());
+ writeString(")\n\n");
+ } else if (m_format == Binary) {
+ int i = 4;
+ char *p = m_out.data();
+ p[i++] = 0; // 0x01
+ p[i++] = 0;
+ p[i++] = 0;
+ p[i++] = 1;
+
+ p[i++] = (m_treeOffset >> 24) & 0xff;
+ p[i++] = (m_treeOffset >> 16) & 0xff;
+ p[i++] = (m_treeOffset >> 8) & 0xff;
+ p[i++] = (m_treeOffset >> 0) & 0xff;
+
+ p[i++] = (m_dataOffset >> 24) & 0xff;
+ p[i++] = (m_dataOffset >> 16) & 0xff;
+ p[i++] = (m_dataOffset >> 8) & 0xff;
+ p[i++] = (m_dataOffset >> 0) & 0xff;
+
+ p[i++] = (m_namesOffset >> 24) & 0xff;
+ p[i++] = (m_namesOffset >> 16) & 0xff;
+ p[i++] = (m_namesOffset >> 8) & 0xff;
+ p[i++] = (m_namesOffset >> 0) & 0xff;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h
new file mode 100644
index 0000000..a802fa0
--- /dev/null
+++ b/src/tools/rcc/rcc.h
@@ -0,0 +1,153 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RCC_H
+#define RCC_H
+
+#include <QtCore/QStringList>
+#include <QtCore/QHash>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class RCCFileInfo;
+class QIODevice;
+class QTextStream;
+
+
+class RCCResourceLibrary
+{
+ RCCResourceLibrary(const RCCResourceLibrary &);
+ RCCResourceLibrary &operator=(const RCCResourceLibrary &);
+
+public:
+ RCCResourceLibrary();
+ ~RCCResourceLibrary();
+
+ bool output(QIODevice &out, QIODevice &errorDevice);
+
+ bool readFiles(bool ignoreErrors, QIODevice &errorDevice);
+
+ enum Format { Binary, C_Code };
+ void setFormat(Format f) { m_format = f; }
+ Format format() const { return m_format; }
+
+ void setInputFiles(const QStringList &files) { m_fileNames = files; }
+ QStringList inputFiles() const { return m_fileNames; }
+
+ QStringList dataFiles() const;
+
+ // Return a map of resource identifier (':/newPrefix/images/p1.png') to file.
+ typedef QHash<QString, QString> ResourceDataFileMap;
+ ResourceDataFileMap resourceDataFileMap() const;
+
+ void setVerbose(bool b) { m_verbose = b; }
+ bool verbose() const { return m_verbose; }
+
+ void setInitName(const QString &name) { m_initName = name; }
+ QString initName() const { return m_initName; }
+
+ void setCompressLevel(int c) { m_compressLevel = c; }
+ int compressLevel() const { return m_compressLevel; }
+
+ void setCompressThreshold(int t) { m_compressThreshold = t; }
+ int compressThreshold() const { return m_compressThreshold; }
+
+ void setResourceRoot(const QString &root) { m_resourceRoot = root; }
+ QString resourceRoot() const { return m_resourceRoot; }
+
+ void setUseNameSpace(bool v) { m_useNameSpace = v; }
+ bool useNameSpace() const { return m_useNameSpace; }
+
+ QStringList failedResources() const { return m_failedResources; }
+
+private:
+ struct Strings {
+ Strings();
+ const QString TAG_RCC;
+ const QString TAG_RESOURCE;
+ const QString TAG_FILE;
+ const QString ATTRIBUTE_LANG;
+ const QString ATTRIBUTE_PREFIX;
+ const QString ATTRIBUTE_ALIAS;
+ const QString ATTRIBUTE_THRESHOLD;
+ const QString ATTRIBUTE_COMPRESS;
+ };
+ friend class RCCFileInfo;
+ void reset();
+ bool addFile(const QString &alias, const RCCFileInfo &file);
+ bool interpretResourceFile(QIODevice *inputDevice, const QString &file,
+ QString currentPath = QString(), bool ignoreErrors = false);
+ bool writeHeader();
+ bool writeDataBlobs();
+ bool writeDataNames();
+ bool writeDataStructure();
+ bool writeInitializer();
+ void writeMangleNamespaceFunction(const QByteArray &name);
+ void writeAddNamespaceFunction(const QByteArray &name);
+ void writeHex(quint8 number);
+ void writeNumber2(quint16 number);
+ void writeNumber4(quint32 number);
+ void writeChar(char c) { m_out.append(c); }
+ void writeByteArray(const QByteArray &);
+ void write(const char *, int len);
+
+ const Strings m_strings;
+ RCCFileInfo *m_root;
+ QStringList m_fileNames;
+ QString m_resourceRoot;
+ QString m_initName;
+ Format m_format;
+ bool m_verbose;
+ int m_compressLevel;
+ int m_compressThreshold;
+ int m_treeOffset;
+ int m_namesOffset;
+ int m_dataOffset;
+ bool m_useNameSpace;
+ QStringList m_failedResources;
+ QIODevice *m_errorDevice;
+ QByteArray m_out;
+};
+
+QT_END_NAMESPACE
+
+#endif // RCC_H
diff --git a/src/tools/rcc/rcc.pri b/src/tools/rcc/rcc.pri
new file mode 100644
index 0000000..534f2ac
--- /dev/null
+++ b/src/tools/rcc/rcc.pri
@@ -0,0 +1,3 @@
+INCLUDEPATH += $$PWD
+HEADERS += $$PWD/rcc.h
+SOURCES += $$PWD/rcc.cpp
diff --git a/src/tools/rcc/rcc.pro b/src/tools/rcc/rcc.pro
new file mode 100644
index 0000000..edc85a1
--- /dev/null
+++ b/src/tools/rcc/rcc.pro
@@ -0,0 +1,16 @@
+TEMPLATE = app
+TARGET = rcc
+
+DESTDIR = ../../../bin
+DEFINES += QT_RCC
+INCLUDEPATH += .
+DEPENDPATH += .
+
+include(rcc.pri)
+HEADERS += ../../corelib/kernel/qcorecmdlineargs_p.h
+SOURCES += main.cpp
+include(../bootstrap/bootstrap.pri)
+
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
+include(../../qt_targets.pri)
diff --git a/src/tools/uic/cpp/cpp.pri b/src/tools/uic/cpp/cpp.pri
new file mode 100644
index 0000000..49c71a6
--- /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 0000000..69390ce
--- /dev/null
+++ b/src/tools/uic/cpp/cppextractimages.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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, "Could not create resource file\n");
+ return;
+ }
+
+ QFileInfo fi(m_option.qrcOutputFile);
+ QDir dir = fi.absoluteDir();
+ if (!dir.exists(QLatin1String("images")) && !dir.mkdir(QLatin1String("images"))) {
+ fprintf(stderr, "Could not create image dir\n");
+ 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, "Could not create image file %s: %s", 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(), 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 0000000..d864369
--- /dev/null
+++ b/src/tools/uic/cpp/cppextractimages.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..a3d3fa3
--- /dev/null
+++ b/src/tools/uic/cpp/cppwritedeclaration.cpp
@@ -0,0 +1,279 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..c8f3590
--- /dev/null
+++ b/src/tools/uic/cpp/cppwritedeclaration.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..53b108f
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondata.cpp
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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)
+{
+ writeImage(output, option.indent, image);
+}
+
+void WriteIconData::writeImage(QTextStream &output, const QString &indent, 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 << "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;
+ }
+
+ if (column++ >= 511 && 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 0000000..d7f8f8f
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondata.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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, 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 0000000..ffe4046
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondeclaration.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..b30d5f5
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteicondeclaration.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..b5a9e12
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteiconinitialization.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..2afd3f6
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteiconinitialization.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..8b061cd
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -0,0 +1,340 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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("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.");
+#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("Warning: generated header '%s' for class '%s'.", 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 0000000..8b79041
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteincludes.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..ed06006
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -0,0 +1,2919 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 isIconFormat44(const DomResourceIcon *i) {
+ return i->hasElementNormalOff() || i->hasElementNormalOn() ||
+ i->hasElementDisabledOff() || i->hasElementDisabledOn() ||
+ i->hasElementActiveOff() || i->hasElementActiveOn() ||
+ i->hasElementSelectedOff() || i->hasElementSelectedOn();
+ }
+
+ // 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: 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: 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
+{
+ 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("()");
+ }
+}
+
+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";
+ writeSetter(indent, objectName, setter, value, str);
+ if (ifndefMac)
+ str << "#endif\n";
+ return;
+ }
+ }
+ if (suppressDefault)
+ return;
+ // get default
+ if (m_state[p] & HasDefaultFunction) {
+ writeSetter(indent, objectName, setter, m_functions[p], str);
+ return;
+ }
+ if (m_state[p] & HasDefaultValue) {
+ 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_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly),
+ m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly),
+ m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly),
+ m_activateScripts(activateScripts), m_layoutWidget(false)
+{
+}
+
+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' isn't a valid widget\n", b.objName.toLatin1().data());
+ continue;
+ } else if (!m_registeredWidgets.contains(b.buddy)) {
+ fprintf(stderr, "'%s' isn't a valid widget\n", 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_delayedActionInitialization.isEmpty()) {
+ 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 (m_widgetChain.top()
+ && m_widgetChain.top()->attributeClass() != QLatin1String("QMainWindow")
+ && !m_uic->isContainer(m_widgetChain.top()->attributeClass()))
+ 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 (className == QLatin1String("QWidget")) {
+ 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' isn't a valid widget\n", 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, "Warning: Creating button group `%s'\n", 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);
+ } 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;
+ }
+ }
+
+ // 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, "Warning: action `%s' not declared\n", 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") && buttonGroupWidget) { // Q3ButtonGroup support
+ 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 (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;
+}
+
+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)) {
+ const QString pixmap = QLatin1String("QPixmap");
+ m_output << m_indent << "QIcon " << iconName << ";\n";
+ if (i->hasElementNormalOff())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOff()->text()) << ", QIcon::Normal, QIcon::Off);\n";
+ if (i->hasElementNormalOn())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementNormalOn()->text()) << ", QIcon::Normal, QIcon::On);\n";
+ if (i->hasElementDisabledOff())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOff()->text()) << ", QIcon::Disabled, QIcon::Off);\n";
+ if (i->hasElementDisabledOn())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementDisabledOn()->text()) << ", QIcon::Disabled, QIcon::On);\n";
+ if (i->hasElementActiveOff())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOff()->text()) << ", QIcon::Active, QIcon::Off);\n";
+ if (i->hasElementActiveOn())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementActiveOn()->text()) << ", QIcon::Active, QIcon::On);\n";
+ if (i->hasElementSelectedOff())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOff()->text()) << ", QIcon::Selected, QIcon::Off);\n";
+ if (i->hasElementSelectedOn())
+ m_output << m_indent << iconName << ".addPixmap(" << pixCall(pixmap, i->elementSelectedOn()->text()) << ", QIcon::Selected, QIcon::On);\n";
+ } 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' isn't a valid widget\n", 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() << "Warning: Unknown icon format encountered. The ui-file was generated with a too-recent version of Designer.";
+ 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, "invalid database connection\n");
+ 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, "invalid database connection\n");
+ 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 (QString str, directives)
+ map[str] = true;
+
+ if (map.size() == 1) {
+ outputStream << "#ifndef " << map.constBegin().key() << endl;
+ return;
+ }
+
+ outputStream << "#if";
+ bool doOr = false;
+ foreach (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 0000000..a2b54b1
--- /dev/null
+++ b/src/tools/uic/cpp/cppwriteinitialization.h
@@ -0,0 +1,371 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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;
+
+ 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;
+};
+
+} // 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 0000000..d221278
--- /dev/null
+++ b/src/tools/uic/customwidgetsinfo.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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;
+}
+
+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 0000000..5890335
--- /dev/null
+++ b/src/tools/uic/customwidgetsinfo.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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;
+
+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 0000000..d8d8aea
--- /dev/null
+++ b/src/tools/uic/databaseinfo.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..854c8fb
--- /dev/null
+++ b/src/tools/uic/databaseinfo.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..b587890
--- /dev/null
+++ b/src/tools/uic/driver.cpp
@@ -0,0 +1,378 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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, "Warning: name %s is already used\n", qPrintable(instanceName));
+ }
+
+ 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 0000000..b440632
--- /dev/null
+++ b/src/tools/uic/driver.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..ed16a7a
--- /dev/null
+++ b/src/tools/uic/globaldefs.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..3d0a6f1
--- /dev/null
+++ b/src/tools/uic/main.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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;
+ }
+
+ // report Qt usage for commercial customers with a "metered license" (currently experimental)
+#if QT_EDITION != QT_EDITION_OPENSOURCE
+#ifdef QT_CONFIGURE_BINARIES_PATH
+ const char *binariesPath = QT_CONFIGURE_BINARIES_PATH;
+ QString reporterPath = QString::fromLocal8Bit(binariesPath);
+ reporterPath += QDir::separator();
+ reporterPath += QLatin1String("qtusagereporter");
+#if defined(Q_OS_WIN)
+ reporterPath += QLatin1String(".exe");
+#endif
+ if (QFile::exists(reporterPath))
+ system(qPrintable(reporterPath + QLatin1String(" uic")));
+#endif
+#endif
+
+ 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 0000000..931ca59
--- /dev/null
+++ b/src/tools/uic/option.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef OPTION_H
+#define OPTION_H
+
+#include <QtCore/QString>
+
+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 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),
+ implicitIncludes(1),
+ generator(CppGenerator),
+ prefix(QLatin1String("Ui_"))
+ { indent.fill(QLatin1Char(' '), 4); }
+};
+
+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 0000000..0bb60e9
--- /dev/null
+++ b/src/tools/uic/treewalker.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..6c1777f
--- /dev/null
+++ b/src/tools/uic/treewalker.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..69d0c53
--- /dev/null
+++ b/src/tools/uic/ui4.cpp
@@ -0,0 +1,11132 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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_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_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;
+ }
+ 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());
+
+ 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()));
+
+ 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_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_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("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("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 (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 0000000..fa70573
--- /dev/null
+++ b/src/tools/uic/ui4.h
@@ -0,0 +1,3791 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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; }
+
+ // 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;
+
+ // 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 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_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 0000000..6e0d731
--- /dev/null
+++ b/src/tools/uic/uic.cpp
@@ -0,0 +1,382 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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, "uic: Error in line %llu, column %llu : %s\n",
+ reader.lineNumber(), reader.columnNumber(),
+ reader.errorString().toAscii().constData());
+ }
+
+ 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::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 0000000..902626f
--- /dev/null
+++ b/src/tools/uic/uic.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 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 0000000..3f0bab0
--- /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 0000000..9b63d42
--- /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 0000000..fe2d8ed
--- /dev/null
+++ b/src/tools/uic/utils.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..e44ca13
--- /dev/null
+++ b/src/tools/uic/validator.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 0000000..804c47e
--- /dev/null
+++ b/src/tools/uic/validator.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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
diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp
new file mode 100644
index 0000000..a5723dd
--- /dev/null
+++ b/src/tools/uic3/converter.cpp
@@ -0,0 +1,1305 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include "parser.h"
+#include "domtool.h"
+#include "ui4.h"
+#include "widgetinfo.h"
+#include "globaldefs.h"
+#include "qt3to4.h"
+#include "utils.h"
+#include "option.h"
+#include "cppextractimages.h"
+
+#include <QtDebug>
+#include <QFile>
+#include <QHash>
+#include <QPair>
+#include <QStringList>
+#include <QDateTime>
+#include <QRegExp>
+#include <QSizePolicy>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+QT_BEGIN_NAMESPACE
+
+enum { warnHeaderGeneration = 0 };
+
+#define CONVERT_PROPERTY(o, n) \
+ do { \
+ if (name == QLatin1String(o) \
+ && !WidgetInfo::isValidProperty(className, (o)) \
+ && WidgetInfo::isValidProperty(className, (n))) { \
+ prop->setAttributeName((n)); \
+ } \
+ } while (0)
+
+static QString classNameForObjectName(const QDomElement &widget, const QString &objectName)
+{
+ QList<QDomElement> widgetStack;
+ widgetStack.append(widget);
+ while (!widgetStack.isEmpty()) {
+ QDomElement w = widgetStack.takeFirst();
+ QDomElement child = w.firstChild().toElement();
+ while (!child.isNull()) {
+ if (child.tagName() == QLatin1String("property")
+ && child.attribute(QLatin1String("name")) == QLatin1String("name")) {
+ QDomElement name = child.firstChild().toElement();
+ DomString str;
+ str.read(name);
+ if (str.text() == objectName)
+ return w.attribute(QLatin1String("class"));
+ } else if (child.tagName() == QLatin1String("widget")
+ || child.tagName() == QLatin1String("vbox")
+ || child.tagName() == QLatin1String("hbox")
+ || child.tagName() == QLatin1String("grid")) {
+ widgetStack.prepend(child);
+ }
+ child = child.nextSibling().toElement();
+ }
+ }
+ return QString();
+}
+
+// Check for potential KDE classes like
+// K3ListView or KLineEdit as precise as possible
+static inline bool isKDEClass(const QString &className)
+{
+ if (className.indexOf(QLatin1Char(':')) != -1)
+ return false;
+ const int size = className.size();
+ if (size < 3 || className.at(0) != QLatin1Char('K'))
+ return false;
+ // K3ListView
+ if (className.at(1) == QLatin1Char('3')) {
+ if (size < 4)
+ return false;
+ return className.at(2).isUpper() && className.at(3).isLower();
+ }
+ // KLineEdit
+ return className.at(1) .isUpper() && className.at(2).isLower();
+}
+
+DomUI *Ui3Reader::generateUi4(const QDomElement &widget, bool implicitIncludes)
+{
+ QDomNodeList nl;
+ candidateCustomWidgets.clear();
+
+ QString objClass = getClassName(widget);
+ if (objClass.isEmpty())
+ return 0;
+ QString objName = getObjectName(widget);
+
+ DomUI *ui = new DomUI;
+ ui->setAttributeVersion(QLatin1String("4.0"));
+
+ QString pixmapFunction = QLatin1String("qPixmapFromMimeSource");
+ QStringList ui_tabstops;
+ QStringList ui_custom_slots;
+ QList<DomInclude*> ui_includes;
+ QList<DomWidget*> ui_toolbars;
+ QList<DomWidget*> ui_menubars;
+ QList<DomAction*> ui_action_list;
+ QList<DomActionGroup*> ui_action_group_list;
+ QList<DomCustomWidget*> ui_customwidget_list;
+ QList<DomConnection*> ui_connection_list;
+ QList<QPair<int, int> > ui_connection_lineinfo_list;
+ QString author, comment, exportMacro;
+ QString klass;
+
+ for (QDomElement n = root.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ QString tagName = n.tagName().toLower();
+
+ if (tagName == QLatin1String("tabstops")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("tabstop")) {
+ QString name = n2.firstChild().toText().data();
+ ui_tabstops.append(name);
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("pixmapfunction")) {
+ pixmapFunction = n.firstChild().toText().data();
+ } else if (tagName == QLatin1String("class")) {
+ klass = n.firstChild().toText().data();
+ } else if (tagName == QLatin1String("author")) {
+ author = n.firstChild().toText().data();
+ } else if (tagName == QLatin1String("comment")) {
+ comment = n.firstChild().toText().data();
+ } else if (tagName == QLatin1String("exportmacro")) {
+ exportMacro = n.firstChild().toText().data();
+ } else if ( n.tagName() == QLatin1String("includehints") ) {
+ QDomElement n2 = n.firstChild().toElement();
+ while ( !n2.isNull() ) {
+ if ( n2.tagName() == QLatin1String("includehint") ) {
+ QString name = n2.firstChild().toText().data();
+
+ DomInclude *incl = new DomInclude();
+ incl->setText(fixHeaderName(name));
+ incl->setAttributeLocation(n.attribute(QLatin1String("location"), QLatin1String("local")));
+ ui_includes.append(incl);
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("includes")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("include")) {
+ QString name = n2.firstChild().toText().data();
+ if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) == QLatin1String("in declaration")) {
+ if (name.right(5) == QLatin1String(".ui.h"))
+ continue;
+
+ DomInclude *incl = new DomInclude();
+ incl->setText(fixHeaderName(name));
+ incl->setAttributeLocation(n2.attribute(QLatin1String("location"), QLatin1String("global")));
+ ui_includes.append(incl);
+ }
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("include")) {
+ QString name = n.firstChild().toText().data();
+ if (n.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) == QLatin1String("in declaration")) {
+ if (name.right(5) == QLatin1String(".ui.h"))
+ continue;
+
+ DomInclude *incl = new DomInclude();
+ incl->setText(fixHeaderName(name));
+ incl->setAttributeLocation(n.attribute(QLatin1String("location"), QLatin1String("global")));
+ ui_includes.append(incl);
+ }
+ } else if (tagName == QLatin1String("layoutdefaults")) {
+ QString margin = n.attribute(QLatin1String("margin"));
+ QString spacing = n.attribute(QLatin1String("spacing"));
+
+ DomLayoutDefault *layoutDefault = new DomLayoutDefault();
+
+ if (!margin.isEmpty())
+ layoutDefault->setAttributeMargin(margin.toInt());
+
+ if (!spacing.isEmpty())
+ layoutDefault->setAttributeSpacing(spacing.toInt());
+
+ ui->setElementLayoutDefault(layoutDefault);
+ } else if (tagName == QLatin1String("layoutfunctions")) {
+ QString margin = n.attribute(QLatin1String("margin"));
+ QString spacing = n.attribute(QLatin1String("spacing"));
+
+ DomLayoutFunction *layoutDefault = new DomLayoutFunction();
+
+ if (!margin.isEmpty())
+ layoutDefault->setAttributeMargin(margin);
+
+ if (!spacing.isEmpty())
+ layoutDefault->setAttributeSpacing(spacing);
+
+ ui->setElementLayoutFunction(layoutDefault);
+ } else if (tagName == QLatin1String("images")) {
+ QDomNodeList nl = n.elementsByTagName(QLatin1String("image"));
+ QList<DomImage*> ui_image_list;
+ for (int i=0; i<(int)nl.length(); i++) {
+ QDomElement e = nl.item(i).toElement();
+
+ QDomElement tmp = e.firstChild().toElement();
+ if (tmp.tagName().toLower() != QLatin1String("data"))
+ continue;
+
+ // create the image
+ DomImage *img = new DomImage();
+ img->setAttributeName(e.attribute(QLatin1String("name")));
+
+ // create the data
+ DomImageData *data = new DomImageData();
+ img->setElementData(data);
+
+ if (tmp.hasAttribute(QLatin1String("format")))
+ data->setAttributeFormat(tmp.attribute(QLatin1String("format"), QLatin1String("PNG")));
+
+ if (tmp.hasAttribute(QLatin1String("length")))
+ data->setAttributeLength(tmp.attribute(QLatin1String("length")).toInt());
+
+ data->setText(tmp.firstChild().toText().data());
+
+ ui_image_list.append(img);
+ QString format = img->elementData()->attributeFormat();
+ QString extension = format.left(format.indexOf('.')).toLower();
+ m_imageMap[img->attributeName()] = img->attributeName() + QLatin1Char('.') + extension;
+ }
+
+ if (ui_image_list.size()) {
+ DomImages *images = new DomImages();
+ images->setElementImage(ui_image_list);
+ ui->setElementImages(images);
+ }
+ } else if (tagName == QLatin1String("actions")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ QString tag = n2.tagName().toLower();
+
+ if (tag == QLatin1String("action")) {
+ DomAction *action = new DomAction();
+ action->read(n2);
+
+ QList<DomProperty*> properties = action->elementProperty();
+ QString actionName = fixActionProperties(properties);
+ action->setAttributeName(actionName);
+ action->setElementProperty(properties);
+
+ if (actionName.isEmpty()) {
+ delete action;
+ } else
+ ui_action_list.append(action);
+ } else if (tag == QLatin1String("actiongroup")) {
+ DomActionGroup *g= new DomActionGroup();
+ g->read(n2);
+
+ fixActionGroup(g);
+ ui_action_group_list.append(g);
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("toolbars")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("toolbar")) {
+ DomWidget *tb = createWidget(n2, QLatin1String("QToolBar"));
+ ui_toolbars.append(tb);
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("menubar")) {
+ DomWidget *tb = createWidget(n, QLatin1String("QMenuBar"));
+ ui_menubars.append(tb);
+ } else if (tagName == QLatin1String("customwidgets")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("customwidget")) {
+
+ DomCustomWidget *customWidget = new DomCustomWidget;
+ customWidget->read(n2);
+
+ if (!customWidget->hasElementExtends())
+ customWidget->setElementExtends(QLatin1String("QWidget"));
+
+ QDomElement n3 = n2.firstChild().toElement();
+ QString cl;
+
+ QList<DomPropertyData*> ui_property_list;
+
+ while (!n3.isNull()) {
+ QString tagName = n3.tagName().toLower();
+
+ if (tagName == QLatin1String("property")) {
+ DomPropertyData *p = new DomPropertyData();
+ p->read(n3);
+
+ ui_property_list.append(p);
+ }
+
+ n3 = n3.nextSibling().toElement();
+ }
+
+ if (ui_property_list.size()) {
+ DomProperties *properties = new DomProperties();
+ properties->setElementProperty(ui_property_list);
+ customWidget->setElementProperties(properties);
+ }
+
+ ui_customwidget_list.append(customWidget);
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("connections")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("connection")) {
+
+ DomConnection *connection = new DomConnection;
+ connection->read(n2);
+
+ QString signal = fixMethod(connection->elementSignal());
+ QString slot = fixMethod(connection->elementSlot());
+ connection->setElementSignal(signal);
+ connection->setElementSlot(slot);
+
+ ui_connection_list.append(connection);
+ ui_connection_lineinfo_list.append(
+ QPair<int, int>(n2.lineNumber(), n2.columnNumber()));
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ } else if (tagName == QLatin1String("slots")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("slot")) {
+ QString name = n2.firstChild().toText().data();
+ ui_custom_slots.append(fixMethod(Parser::cleanArgs(name)));
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ }
+ }
+
+ // validate the connections
+ for (int i = 0; i < ui_connection_list.size(); ++i) {
+ DomConnection *conn = ui_connection_list.at(i);
+ QPair<int, int> lineinfo = ui_connection_lineinfo_list.at(i);
+ QString sender = conn->elementSender();
+ QString senderClass = fixClassName(classNameForObjectName(widget, sender));
+ QString signal = conn->elementSignal();
+ QString receiver = conn->elementReceiver();
+ QString receiverClass = fixClassName(classNameForObjectName(widget, receiver));
+ QString slot = conn->elementSlot();
+
+ if (!WidgetInfo::isValidSignal(senderClass, signal)) {
+ errorInvalidSignal(signal, sender, senderClass,
+ lineinfo.first, lineinfo.second);
+ } else if (!WidgetInfo::isValidSlot(receiverClass, slot)) {
+ bool resolved = false;
+ if (objName == receiver) {
+ // see if it's a custom slot
+ foreach (QString cs, ui_custom_slots) {
+ if (cs == slot) {
+ resolved = true;
+ break;
+ }
+ }
+ }
+ if (!resolved) {
+ errorInvalidSlot(slot, receiver, receiverClass,
+ lineinfo.first, lineinfo.second);
+ }
+ }
+ }
+
+ DomWidget *w = createWidget(widget);
+ Q_ASSERT(w != 0);
+
+ QList<DomWidget*> l = w->elementWidget();
+ l += ui_toolbars;
+ l += ui_menubars;
+ w->setElementWidget(l);
+
+ if (ui_action_group_list.size())
+ w->setElementActionGroup(ui_action_group_list);
+
+ if (ui_action_list.size())
+ w->setElementAction(ui_action_list);
+
+ ui->setElementWidget(w);
+
+ if (klass.isEmpty())
+ klass = w->attributeName();
+
+ ui->setElementClass(klass);
+ ui->setElementAuthor(author);
+ ui->setElementComment(comment);
+ ui->setElementExportMacro(exportMacro);
+
+ if (!ui->elementImages())
+ ui->setElementPixmapFunction(pixmapFunction);
+
+ for (int i=0; i<ui_customwidget_list.size(); ++i) {
+ const QString name = ui_customwidget_list.at(i)->elementClass();
+ if (candidateCustomWidgets.contains(name))
+ candidateCustomWidgets.remove(name);
+ }
+
+
+ QMapIterator<QString, bool> it(candidateCustomWidgets);
+ while (it.hasNext()) {
+ it.next();
+
+ const QString customClass = it.key();
+ QString baseClass;
+
+ if (customClass.endsWith(QLatin1String("ListView")))
+ baseClass = QLatin1String("Q3ListView");
+ else if (customClass.endsWith(QLatin1String("ListBox")))
+ baseClass = QLatin1String("Q3ListBox");
+ else if (customClass.endsWith(QLatin1String("IconView")))
+ baseClass = QLatin1String("Q3IconView");
+ else if (customClass.endsWith(QLatin1String("ComboBox")))
+ baseClass = QLatin1String("QComboBox");
+
+ if (baseClass.isEmpty())
+ continue;
+
+ DomCustomWidget *customWidget = new DomCustomWidget();
+ customWidget->setElementClass(customClass);
+ customWidget->setElementExtends(baseClass);
+
+ // Magic header generation feature for legacy KDE forms
+ // (for example, filesharing/advanced/kcm_sambaconf/share.ui)
+ if (implicitIncludes && isKDEClass(customClass)) {
+ QString header = customClass.toLower();
+ header += QLatin1String(".h");
+ DomHeader *domHeader = new DomHeader;
+ domHeader->setText(header);
+ domHeader->setAttributeLocation(QLatin1String("global"));
+ customWidget->setElementHeader(domHeader);
+ if (warnHeaderGeneration) {
+ const QString msg = QString::fromUtf8("Warning: generated header '%1' for class '%2'.").arg(header).arg(customClass);
+ qWarning("%s", qPrintable(msg));
+ }
+ }
+ ui_customwidget_list.append(customWidget);
+ }
+
+ if (ui_customwidget_list.size()) {
+ DomCustomWidgets *customWidgets = new DomCustomWidgets();
+ customWidgets->setElementCustomWidget(ui_customwidget_list);
+ ui->setElementCustomWidgets(customWidgets);
+ }
+
+ if (ui_tabstops.size()) {
+ DomTabStops *tabStops = new DomTabStops();
+ tabStops->setElementTabStop(ui_tabstops);
+ ui->setElementTabStops(tabStops);
+ }
+
+ if (ui_includes.size()) {
+ DomIncludes *includes = new DomIncludes();
+ includes->setElementInclude(ui_includes);
+ ui->setElementIncludes(includes);
+ }
+
+ if (ui_connection_list.size()) {
+ DomConnections *connections = new DomConnections();
+ connections->setElementConnection(ui_connection_list);
+ ui->setElementConnections(connections);
+ }
+
+ ui->setAttributeStdSetDef(stdsetdef);
+
+ if (m_extractImages) {
+ Option opt;
+ opt.extractImages = m_extractImages;
+ opt.qrcOutputFile = m_qrcOutputFile;
+ CPP::ExtractImages(opt).acceptUI(ui);
+
+ ui->clearElementImages();
+
+ DomResources *res = ui->elementResources();
+ if (!res) {
+ res = new DomResources();
+ }
+ DomResource *incl = new DomResource();
+ incl->setAttributeLocation(m_qrcOutputFile);
+ QList<DomResource *> inclList = res->elementInclude();
+ inclList.append(incl);
+ res->setElementInclude(inclList);
+ if (!ui->elementResources())
+ ui->setElementResources(res);
+ }
+
+ return ui;
+}
+
+
+
+QString Ui3Reader::fixActionProperties(QList<DomProperty*> &properties,
+ bool isActionGroup)
+{
+ QString objectName;
+
+ QMutableListIterator<DomProperty*> it(properties);
+ while (it.hasNext()) {
+ DomProperty *prop = it.next();
+ QString name = prop->attributeName();
+
+ if (name == QLatin1String("name")) {
+ objectName = prop->elementCstring();
+ } else if (isActionGroup && name == QLatin1String("exclusive")) {
+ // continue
+ } else if (isActionGroup) {
+ errorInvalidProperty(name, objectName, isActionGroup ? QLatin1String("QActionGroup") : QLatin1String("QAction"), -1, -1);
+ delete prop;
+ it.remove();
+ } else if (name == QLatin1String("menuText")) {
+ prop->setAttributeName(QLatin1String("text"));
+ } else if (name == QLatin1String("text")) {
+ prop->setAttributeName(QLatin1String("iconText"));
+ } else if (name == QLatin1String("iconSet")) {
+ prop->setAttributeName(QLatin1String("icon"));
+ } else if (name == QLatin1String("accel")) {
+ prop->setAttributeName(QLatin1String("shortcut"));
+ } else if (name == QLatin1String("toggleAction")) {
+ prop->setAttributeName(QLatin1String("checkable"));
+ } else if (name == QLatin1String("on")) {
+ prop->setAttributeName(QLatin1String("checked"));
+ } else if (!WidgetInfo::isValidProperty(QLatin1String("QAction"), name)) {
+ errorInvalidProperty(name, objectName, isActionGroup ? QLatin1String("QActionGroup") : QLatin1String("QAction"), -1, -1);
+ delete prop;
+ it.remove();
+ }
+ }
+
+ return objectName;
+}
+
+void Ui3Reader::fixActionGroup(DomActionGroup *g)
+{
+ QList<DomActionGroup*> groups = g->elementActionGroup();
+ for (int i=0; i<groups.size(); ++i) {
+ fixActionGroup(groups.at(i));
+ }
+
+ QList<DomAction*> actions = g->elementAction();
+ for (int i=0; i<actions.size(); ++i) {
+ DomAction *a = actions.at(i);
+
+ QList<DomProperty*> properties = a->elementProperty();
+ QString name = fixActionProperties(properties);
+ a->setElementProperty(properties);
+
+ if (name.size())
+ a->setAttributeName(name);
+ }
+
+ QList<DomProperty*> properties = g->elementProperty();
+ QString name = fixActionProperties(properties, true);
+ g->setElementProperty(properties);
+
+ if (name.size())
+ g->setAttributeName(name);
+}
+
+QString Ui3Reader::fixClassName(const QString &className) const
+{
+ return m_porting->renameClass(className);
+}
+
+QString Ui3Reader::fixHeaderName(const QString &headerName) const
+{
+ return m_porting->renameHeader(headerName);
+}
+
+DomWidget *Ui3Reader::createWidget(const QDomElement &w, const QString &widgetClass)
+{
+ DomWidget *ui_widget = new DomWidget;
+
+ QString className = widgetClass;
+ if (className.isEmpty())
+ className = w.attribute(QLatin1String("class"));
+ className = fixClassName(className);
+
+ if ((className.endsWith(QLatin1String("ListView")) && className != QLatin1String("Q3ListView"))
+ || (className.endsWith(QLatin1String("ListBox")) && className != QLatin1String("Q3ListBox"))
+ || (className.endsWith(QLatin1String("ComboBox")) && className != QLatin1String("QComboBox"))
+ || (className.endsWith(QLatin1String("IconView")) && className != QLatin1String("Q3IconView")))
+ candidateCustomWidgets.insert(className, true);
+
+ bool isMenu = (className == QLatin1String("QMenuBar") || className == QLatin1String("QMenu"));
+
+ ui_widget->setAttributeClass(className);
+
+ QList<DomWidget*> ui_child_list;
+ QList<DomRow*> ui_row_list;
+ QList<DomColumn*> ui_column_list;
+ QList<DomItem*> ui_item_list;
+ QList<DomProperty*> ui_property_list;
+ QList<DomProperty*> ui_attribute_list;
+ QList<DomLayout*> ui_layout_list;
+ QList<DomActionRef*> ui_action_list;
+ QList<DomWidget*> ui_mainwindow_child_list;
+
+ createProperties(w, &ui_property_list, className);
+ createAttributes(w, &ui_attribute_list, className);
+
+ DomWidget *ui_mainWindow = 0;
+ DomWidget *ui_centralWidget = 0;
+ if (className == QLatin1String("QMainWindow") || className == QLatin1String("Q3MainWindow")) {
+ ui_centralWidget = new DomWidget;
+ ui_centralWidget->setAttributeClass(QLatin1String("QWidget"));
+ ui_mainwindow_child_list.append(ui_centralWidget);
+ ui_mainWindow = ui_widget;
+ }
+
+ QDomElement e = w.firstChild().toElement();
+ const bool inQ3ToolBar = className == QLatin1String("Q3ToolBar");
+ while (!e.isNull()) {
+ QString t = e.tagName().toLower();
+ if (t == QLatin1String("vbox") || t == QLatin1String("hbox") || t == QLatin1String("grid")) {
+ DomLayout *lay = createLayout(e);
+ Q_ASSERT(lay != 0);
+
+ if (ui_layout_list.isEmpty()) {
+ ui_layout_list.append(lay);
+ } else {
+ // it's not possible to have more than one layout for widget!
+ delete lay;
+ }
+ } else if (t == QLatin1String("spacer")) {
+ // hmm, spacer as child of a widget.. it doesn't make sense, so skip it!
+ } else if (t == QLatin1String("widget")) {
+ DomWidget *ui_child = createWidget(e);
+ Q_ASSERT(ui_child != 0);
+
+ bool isLayoutWidget = ui_child->attributeClass() == QLatin1String("QLayoutWidget");
+ if (isLayoutWidget)
+ ui_child->setAttributeClass(QLatin1String("QWidget"));
+
+ foreach (DomLayout *layout, ui_child->elementLayout()) {
+ fixLayoutMargin(layout);
+ }
+
+ QString widgetClass = ui_child->attributeClass();
+ if (widgetClass == QLatin1String("QMenuBar") || widgetClass == QLatin1String("QToolBar")
+ || widgetClass == QLatin1String("QStatusBar")) {
+ ui_mainwindow_child_list.append(ui_child);
+ } else {
+ ui_child_list.append(ui_child);
+ }
+
+ if (inQ3ToolBar) {
+ DomActionRef *ui_action_ref = new DomActionRef();
+ ui_action_ref->setAttributeName(ui_child->attributeName());
+ ui_action_list.append(ui_action_ref);
+ }
+ } else if (t == QLatin1String("action")) {
+ DomActionRef *a = new DomActionRef();
+ a->read(e);
+ ui_action_list.append(a);
+ } else if (t == QLatin1String("separator")) {
+ DomActionRef *a = new DomActionRef();
+ a->setAttributeName(QLatin1String("separator"));
+ ui_action_list.append(a);
+ } else if (t == QLatin1String("property")) {
+ // skip the property it is already handled by createProperties
+
+ QString name = e.attribute(QLatin1String("name")); // change the varname this widget
+ if (name == QLatin1String("name"))
+ ui_widget->setAttributeName(DomTool::readProperty(w, QLatin1String("name"), QVariant()).toString());
+ } else if (t == QLatin1String("row")) {
+ DomRow *row = new DomRow();
+ row->read(e);
+ ui_row_list.append(row);
+ } else if (t == QLatin1String("column")) {
+ DomColumn *column = new DomColumn();
+ column->read(e);
+ ui_column_list.append(column);
+ } else if (isMenu && t == QLatin1String("item")) {
+ QString text = e.attribute(QLatin1String("text"));
+ QString name = e.attribute(QLatin1String("name"));
+ QString accel = e.attribute(QLatin1String("accel"));
+
+ QList<DomProperty*> properties;
+
+ DomProperty *atitle = new DomProperty();
+ atitle->setAttributeName(QLatin1String("title"));
+ DomString *str = new DomString();
+ str->setText(text);
+ atitle->setElementString(str);
+ properties.append(atitle);
+
+ DomWidget *menu = createWidget(e, QLatin1String("QMenu"));
+ menu->setAttributeName(name);
+ menu->setElementProperty(properties);
+ ui_child_list.append(menu);
+
+ DomActionRef *a = new DomActionRef();
+ a->setAttributeName(name);
+ ui_action_list.append(a);
+
+ } else if (t == QLatin1String("item")) {
+ DomItem *item = new DomItem();
+ item->read(e);
+ ui_item_list.append(item);
+ }
+
+ e = e.nextSibling().toElement();
+ }
+
+ ui_widget->setElementProperty(ui_property_list);
+ ui_widget->setElementAttribute(ui_attribute_list);
+
+ if (ui_centralWidget != 0) {
+ Q_ASSERT(ui_mainWindow != 0);
+ ui_mainWindow->setElementWidget(ui_mainwindow_child_list);
+ ui_widget = ui_centralWidget;
+ }
+
+ ui_widget->setElementWidget(ui_child_list);
+ ui_widget->setElementAddAction(ui_action_list);
+ ui_widget->setElementRow(ui_row_list);
+ ui_widget->setElementColumn(ui_column_list);
+ ui_widget->setElementItem(ui_item_list);
+ ui_widget->setElementLayout(ui_layout_list);
+
+ //ui_widget->setAttributeName(p->elementCstring());
+
+ return ui_mainWindow ? ui_mainWindow : ui_widget;
+}
+
+DomLayout *Ui3Reader::createLayout(const QDomElement &w)
+{
+ DomLayout *lay = new DomLayout();
+
+ QList<DomLayoutItem*> ui_item_list;
+ QList<DomProperty*> ui_property_list;
+ QList<DomProperty*> ui_attribute_list;
+
+ QString tagName = w.tagName().toLower();
+
+ QString className;
+ if (tagName == QLatin1String("vbox"))
+ className = QLatin1String("QVBoxLayout");
+ else if (tagName == QLatin1String("hbox"))
+ className = QLatin1String("QHBoxLayout");
+ else
+ className = QLatin1String("QGridLayout");
+
+ lay->setAttributeClass(className);
+
+ createProperties(w, &ui_property_list, className);
+ createAttributes(w, &ui_attribute_list, className);
+
+ QDomElement e = w.firstChild().toElement();
+ while (!e.isNull()) {
+ QString t = e.tagName().toLower();
+ if (t == QLatin1String("vbox")
+ || t == QLatin1String("hbox")
+ || t == QLatin1String("grid")
+ || t == QLatin1String("spacer")
+ || t == QLatin1String("widget")) {
+ DomLayoutItem *lay_item = createLayoutItem(e);
+ Q_ASSERT(lay_item != 0);
+ ui_item_list.append(lay_item);
+ }
+
+ e = e.nextSibling().toElement();
+ }
+
+ lay->setElementItem(ui_item_list);
+ lay->setElementProperty(ui_property_list);
+ lay->setElementAttribute(ui_attribute_list);
+
+ return lay;
+}
+
+DomLayoutItem *Ui3Reader::createLayoutItem(const QDomElement &e)
+{
+ DomLayoutItem *lay_item = new DomLayoutItem;
+
+ QString tagName = e.tagName().toLower();
+ if (tagName == QLatin1String("widget")) {
+ DomWidget *ui_widget = createWidget(e);
+ Q_ASSERT(ui_widget != 0);
+
+ if (ui_widget->attributeClass() == QLatin1String("QLayoutWidget")
+ && ui_widget->elementLayout().size() == 1) {
+ QList<DomLayout*> layouts = ui_widget->elementLayout();
+
+ ui_widget->setElementLayout(QList<DomLayout*>());
+ delete ui_widget;
+
+ DomLayout *layout = layouts.first();
+ fixLayoutMargin(layout);
+ lay_item->setElementLayout(layout);
+ } else {
+ if (ui_widget->attributeClass() == QLatin1String("QLayoutWidget"))
+ ui_widget->setAttributeClass(QLatin1String("QWidget"));
+
+ lay_item->setElementWidget(ui_widget);
+ }
+ } else if (tagName == QLatin1String("spacer")) {
+ DomSpacer *ui_spacer = new DomSpacer();
+ QList<DomProperty*> properties;
+
+ QByteArray name = DomTool::readProperty(e, QLatin1String("name"), QLatin1String("spacer")).toByteArray();
+
+ Variant var;
+ var.createSize(0, 0);
+
+ QVariant def = qVariantFromValue(var);
+
+ Size size = asVariant(DomTool::readProperty(e, QLatin1String("sizeHint"), def)).size;
+ QString sizeType = QLatin1String("QSizePolicy::") + DomTool::readProperty(e, QLatin1String("sizeType"), QLatin1String("Expanding")).toString();
+ QString orientation = QLatin1String("Qt::") + DomTool::readProperty(e, QLatin1String("orientation"), QLatin1String("Horizontal")).toString();
+
+ ui_spacer->setAttributeName(QLatin1String(name));
+
+ DomProperty *prop = 0;
+
+ // sizeHint
+ prop = new DomProperty();
+ prop->setAttributeName(QLatin1String("sizeHint"));
+ prop->setElementSize(new DomSize());
+ prop->elementSize()->setElementWidth(size.width);
+ prop->elementSize()->setElementHeight(size.height);
+ properties.append(prop);
+
+ // sizeType
+ prop = new DomProperty();
+ prop->setAttributeName(QLatin1String("sizeType"));
+ prop->setElementEnum(sizeType);
+ properties.append(prop);
+
+ // orientation
+ prop = new DomProperty();
+ prop->setAttributeName(QLatin1String("orientation"));
+ prop->setElementEnum(orientation);
+ properties.append(prop);
+
+ ui_spacer->setElementProperty(properties);
+ lay_item->setElementSpacer(ui_spacer);
+ } else {
+ DomLayout *ui_layout = createLayout(e);
+ Q_ASSERT(ui_layout != 0);
+
+ fixLayoutMargin(ui_layout);
+ lay_item->setElementLayout(ui_layout);
+ }
+
+ if (e.hasAttribute(QLatin1String("row")))
+ lay_item->setAttributeRow(e.attribute(QLatin1String("row")).toInt());
+ if (e.hasAttribute(QLatin1String("column")))
+ lay_item->setAttributeColumn(e.attribute(QLatin1String("column")).toInt());
+ if (e.hasAttribute(QLatin1String("rowspan")))
+ lay_item->setAttributeRowSpan(e.attribute(QLatin1String("rowspan")).toInt());
+ if (e.hasAttribute(QLatin1String("colspan")))
+ lay_item->setAttributeColSpan(e.attribute(QLatin1String("colspan")).toInt());
+
+ return lay_item;
+}
+
+void Ui3Reader::fixLayoutMargin(DomLayout *ui_layout)
+{
+ Q_UNUSED(ui_layout)
+}
+
+static void addBooleanFontSubProperty(QDomDocument &doc,
+ const QString &name, const QString &value,
+ QDomElement &fontElement)
+{
+ if (value == QLatin1String("true") || value == QLatin1String("1")) {
+ QDomElement child = doc.createElement(name);
+ child.appendChild(doc.createTextNode(QLatin1String("true")));
+ fontElement.appendChild(child);
+ } else {
+ if (value == QLatin1String("false") || value == QLatin1String("0")) {
+ QDomElement child = doc.createElement(name);
+ child.appendChild(doc.createTextNode(QLatin1String("false")));
+ fontElement.appendChild(child);
+ }
+ }
+}
+
+QDomElement Ui3Reader::findDerivedFontProperties(const QDomElement &n) const
+{
+ bool italic = false;
+ bool bold = false;
+ bool underline = false;
+ bool strikeout = false;
+ bool family = false;
+ bool pointsize = false;
+
+ QDomDocument doc = n.ownerDocument();
+ QDomElement result = doc.createElement(QLatin1String("font"));
+
+ QDomNode pn = n.parentNode();
+ while (!pn.isNull()) {
+ for (QDomElement e = pn.firstChild().toElement(); !e.isNull(); e = e.nextSibling().toElement()) {
+ if (e.tagName().toLower() == QLatin1String("property") &&
+ e.attribute(QLatin1String("name")) == QLatin1String("font")) {
+ QDomElement f = e.firstChild().toElement();
+ for (QDomElement fp = f.firstChild().toElement(); !fp.isNull(); fp = fp.nextSibling().toElement()) {
+ QString name = fp.tagName().toLower();
+ QString text = fp.text();
+ if (!italic && name == QLatin1String("italic")) {
+ italic = true;
+ addBooleanFontSubProperty(doc, name, text, result);
+ } else if (!bold && name == QLatin1String("bold")) {
+ bold = true;
+ addBooleanFontSubProperty(doc, name, text, result);
+ } else if (!underline && name == QLatin1String("underline")) {
+ underline = true;
+ addBooleanFontSubProperty(doc, name, text, result);
+ } else if (!strikeout && name == QLatin1String("strikeout")) {
+ strikeout = true;
+ addBooleanFontSubProperty(doc, name, text, result);
+ } else if (!family && name == QLatin1String("family")) {
+ family = true;
+ QDomElement child = doc.createElement(name);
+ child.appendChild(doc.createTextNode(text));
+ result.appendChild(child);
+ } else if (!pointsize && name == QLatin1String("pointsize")) {
+ pointsize = true;
+ QDomElement child = doc.createElement(name);
+ child.appendChild(doc.createTextNode(text));
+ result.appendChild(child);
+ }
+ }
+ }
+ }
+ pn = pn.parentNode();
+ }
+
+ return result;
+}
+
+void Ui3Reader::createProperties(const QDomElement &n, QList<DomProperty*> *properties,
+ const QString &className)
+{
+ QString objectName;
+
+ bool wordWrapFound = false;
+
+ for (QDomElement e=n.firstChild().toElement(); !e.isNull(); e = e.nextSibling().toElement()) {
+ if (e.tagName().toLower() == QLatin1String("property")) {
+ QString name = e.attribute(QLatin1String("name"));
+
+ // changes in QPalette
+ if (name == QLatin1String("colorGroup")
+ || name == QLatin1String("paletteForegroundColor")
+ || name == QLatin1String("paletteBackgroundColor")
+ || name == QLatin1String("backgroundMode")
+ || name == QLatin1String("backgroundOrigin")
+ || name == QLatin1String("paletteBackgroundPixmap")
+ || name == QLatin1String("backgroundBrush")) {
+ errorInvalidProperty(name, objectName, className, n.lineNumber(), n.columnNumber());
+ continue;
+ }
+
+ // changes in QFrame
+ if (name == QLatin1String("contentsRect")) {
+ errorInvalidProperty(name, objectName, className, n.lineNumber(), n.columnNumber());
+ continue;
+ }
+
+ // changes in QWidget
+ if (name == QLatin1String("underMouse")
+ || name == QLatin1String("ownFont")) {
+ errorInvalidProperty(name, objectName, className, n.lineNumber(), n.columnNumber());
+ continue;
+ }
+
+ if (name == QLatin1String("font")) {
+ QDomElement f = e.firstChild().toElement();
+ e.appendChild(findDerivedFontProperties(f));
+ e.removeChild(f);
+ }
+
+ DomProperty *prop = readProperty(e);
+ if (!prop)
+ continue;
+
+ if (prop->kind() == DomProperty::String) {
+ QDomNodeList comments = e.elementsByTagName(QLatin1String("comment"));
+ if (comments.length()) {
+ QString comment = comments.item(0).firstChild().toText().data();
+ if (!comment.isEmpty())
+ prop->elementString()->setAttributeComment(comment);
+ }
+ }
+
+ // objectName
+ if (name == QLatin1String("name")) {
+ objectName = prop->elementCstring();
+ continue;
+ }
+
+ if (className == QLatin1String("Line")
+ && prop->attributeName() == QLatin1String("orientation")) {
+ delete prop;
+ continue;
+ }
+
+ if (className.mid(1) == QLatin1String("LineEdit")) {
+ if (name == QLatin1String("hasMarkedText")) {
+ prop->setAttributeName(QLatin1String("hasSelectedText"));
+ } else if (name == QLatin1String("edited")) {
+ prop->setAttributeName(QLatin1String("modified"));
+ } else if (name == QLatin1String("markedText")) {
+ prop->setAttributeName(QLatin1String("selectedText"));
+ }
+ }
+
+ if (className.endsWith(QLatin1String("ComboBox"))) {
+ CONVERT_PROPERTY(QLatin1String("currentItem"), QLatin1String("currentIndex"));
+ CONVERT_PROPERTY(QLatin1String("insertionPolicy"), QLatin1String("insertPolicy"));
+ }
+
+ if (className == QLatin1String("QToolBar")) {
+ if (name == QLatin1String("label")) {
+ prop->setAttributeName(QLatin1String("windowTitle"));
+ }
+ }
+
+ CONVERT_PROPERTY(QLatin1String("customWhatsThis"), QLatin1String("whatsThis"));
+ CONVERT_PROPERTY(QLatin1String("icon"), QLatin1String("windowIcon"));
+ CONVERT_PROPERTY(QLatin1String("iconText"), QLatin1String("windowIconText"));
+ CONVERT_PROPERTY(QLatin1String("caption"), QLatin1String("windowTitle"));
+
+ if (name == QLatin1String("name")) {
+ continue; // skip the property name
+ }
+
+ if (name == QLatin1String("accel")) {
+ prop->setAttributeName(QLatin1String("shortcut"));
+ }
+
+ CONVERT_PROPERTY(QLatin1String("pixmap"), QLatin1String("icon"));
+ CONVERT_PROPERTY(QLatin1String("iconSet"), QLatin1String("icon"));
+ CONVERT_PROPERTY(QLatin1String("textLabel"), QLatin1String("text"));
+
+ CONVERT_PROPERTY(QLatin1String("toggleButton"), QLatin1String("checkable"));
+ CONVERT_PROPERTY(QLatin1String("on"), QLatin1String("checked"));
+
+ CONVERT_PROPERTY(QLatin1String("maxValue"), QLatin1String("maximum"));
+ CONVERT_PROPERTY(QLatin1String("minValue"), QLatin1String("minimum"));
+ CONVERT_PROPERTY(QLatin1String("lineStep"), QLatin1String("singleStep"));
+
+ // QSlider
+ CONVERT_PROPERTY(QLatin1String("tickmarks"), QLatin1String("tickPosition"));
+
+ name = prop->attributeName(); // sync the name
+
+ if (className == QLatin1String("QLabel") && name == QLatin1String("alignment")) {
+ QString v = prop->elementSet();
+
+ if (v.contains(QRegExp(QLatin1String("\\bWordBreak\\b"))))
+ wordWrapFound = true;
+ }
+
+
+ // resolve the flags and enumerator
+ if (prop->kind() == DomProperty::Set) {
+ QStringList flags = prop->elementSet().split(QLatin1Char('|'));
+ QStringList v;
+ foreach (QString fl, flags) {
+ QString e = WidgetInfo::resolveEnumerator(className, fl);
+ if (e.isEmpty()) {
+ e = m_porting->renameEnumerator(className + QLatin1String("::") + fl);
+ }
+
+ if (e.isEmpty()) {
+ fprintf(stderr, "uic3: flag '%s' for widget '%s' is not supported\n", fl.latin1(), className.latin1());
+ continue;
+ }
+
+ v.append(e);
+ }
+
+ if (v.isEmpty()) {
+ delete prop;
+ continue;
+ }
+
+ prop->setElementSet(v.join(QLatin1String("|")));
+ } else if (prop->kind() == DomProperty::Enum) {
+ QString e = WidgetInfo::resolveEnumerator(className, prop->elementEnum());
+ if (e.isEmpty()) {
+ e = m_porting->renameEnumerator(className + QLatin1String("::") + prop->elementEnum());
+ }
+
+ if (e.isEmpty()) {
+ fprintf(stderr, "uic3: enumerator '%s' for widget '%s' is not supported\n",
+ prop->elementEnum().latin1(), className.latin1());
+
+ delete prop;
+ continue;
+ }
+ prop->setElementEnum(e);
+ }
+
+
+ if (className.size()
+ && !(className == QLatin1String("QLabel") && name == QLatin1String("buddy"))
+ && !(name == QLatin1String("buttonGroupId"))
+ && !(name == QLatin1String("frameworkCode"))
+ && !(name == QLatin1String("database"))) {
+ if (!WidgetInfo::isValidProperty(className, name)) {
+ errorInvalidProperty(name, objectName, className, n.lineNumber(), n.columnNumber());
+ delete prop;
+ } else {
+ properties->append(prop);
+ }
+ } else {
+ properties->append(prop);
+ }
+ }
+ }
+ if (className == QLatin1String("QLabel")) {
+ DomProperty *wordWrap = new DomProperty();
+ wordWrap->setAttributeName(QLatin1String("wordWrap"));
+ if (wordWrapFound)
+ wordWrap->setElementBool(QLatin1String("true"));
+ else
+ wordWrap->setElementBool(QLatin1String("false"));
+ properties->append(wordWrap);
+ }
+}
+
+static int toQt4SizePolicy(int qt3SizePolicy)
+{
+ if (qt3SizePolicy == 2) // qt 3 Ignored value
+ return QSizePolicy::Ignored;
+ return qt3SizePolicy;
+}
+
+DomProperty *Ui3Reader::readProperty(const QDomElement &e)
+{
+ QString name = e.firstChild().toElement().tagName().toLower();
+
+ if (name == QLatin1String("class")) // skip class
+ name = e.firstChild().nextSibling().toElement().tagName().toLower();
+
+ DomProperty *p = new DomProperty;
+ p->read(e);
+
+ if (p->kind() == DomProperty::Number) {
+ QString value = e.firstChild().toElement().firstChild().nodeValue();
+
+ if (value.contains(QLatin1Char('.'))) {
+ p->setElementDouble(value.toDouble());
+ }
+ } else if (p->kind() == DomProperty::Pixmap) {
+ DomResourcePixmap *domPix = p->elementPixmap();
+ if (m_extractImages) {
+ QString imageFile = domPix->text() + QLatin1String(".xpm");
+ if (m_imageMap.contains(domPix->text()))
+ imageFile = m_imageMap.value(domPix->text());
+ domPix->setAttributeResource(m_qrcOutputFile);
+ domPix->setText(QLatin1String(":/") + nameOfClass + QLatin1String("/images/") + imageFile);
+ }
+ } else if (p->kind() == DomProperty::SizePolicy) {
+ DomSizePolicy *sp = p->elementSizePolicy();
+ if (sp) {
+ if (sp->hasElementHSizeType())
+ sp->setElementHSizeType(toQt4SizePolicy(sp->elementHSizeType()));
+ if (sp->hasElementVSizeType())
+ sp->setElementVSizeType(toQt4SizePolicy(sp->elementVSizeType()));
+ }
+ } else if (p->kind() == DomProperty::Unknown) {
+ delete p;
+ p = 0;
+ }
+
+ return p;
+}
+
+void Ui3Reader::createAttributes(const QDomElement &n, QList<DomProperty*> *properties,
+ const QString &className)
+{
+ Q_UNUSED(className);
+
+ for (QDomElement e=n.firstChild().toElement(); !e.isNull(); e = e.nextSibling().toElement()) {
+ if (e.tagName().toLower() == QLatin1String("attribute")) {
+ QString name = e.attribute(QLatin1String("name"));
+
+ DomProperty *prop = readProperty(e);
+ if (!prop)
+ continue;
+
+ properties->append(prop);
+ }
+ }
+}
+
+QString Ui3Reader::fixDeclaration(const QString &d) const
+{
+ QString text;
+
+ int i = 0;
+ while (i < d.size()) {
+ QChar ch = d.at(i);
+
+ if (ch.isLetter() || ch == QLatin1Char('_')) {
+ int start = i;
+ while (i < d.size() && (d.at(i).isLetterOrNumber() || d.at(i) == QLatin1Char('_')))
+ ++i;
+
+ text += fixClassName(d.mid(start, i-start));
+ } else {
+ text += ch;
+ ++i;
+ }
+ }
+
+ return text;
+}
+
+/*
+ fixes a (possible composite) type name
+*/
+QString Ui3Reader::fixType(const QString &t) const
+{
+ QString newText = t;
+ //split type name on <>*& and whitespace
+ QStringList typeNames = t.split(QRegExp(QLatin1String("<|>|\\*|&| ")), QString::SkipEmptyParts);
+ foreach(QString typeName , typeNames) {
+ QString newName = fixClassName(typeName);
+ if( newName != typeName ) {
+ newText.replace(typeName, newName);
+ }
+ }
+ return newText;
+}
+
+QString Ui3Reader::fixMethod(const QString &method) const
+{
+ const QByteArray normalized = QMetaObject::normalizedSignature(method.toLatin1());
+ QByteArray result;
+ int index = normalized.indexOf('(');
+ if (index == -1)
+ return QLatin1String(normalized);
+ result.append(normalized.left(++index));
+ int limit = normalized.length()-1;
+ while (index < limit) {
+ QByteArray type;
+ while ((index < limit) && (normalized.at(index) != ','))
+ type.append(normalized.at(index++));
+ result.append(fixType(QLatin1String(type)).toLatin1());
+ if ((index < limit) && (normalized.at(index) == ','))
+ result.append(normalized.at(index++));
+ }
+ result.append(normalized.mid(index));
+ return QLatin1String(result);
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/deps.cpp b/src/tools/uic3/deps.cpp
new file mode 100644
index 0000000..e621f25
--- /dev/null
+++ b/src/tools/uic3/deps.cpp
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+
+#include <QDomElement>
+#include <QFile>
+
+QT_BEGIN_NAMESPACE
+
+void Ui3Reader::computeDeps(const QDomElement &e,
+ QStringList &globalIncludes,
+ QStringList &localIncludes, bool impl)
+{
+ QDomNodeList nl;
+
+ // additional includes (local or global) and forward declaractions
+ nl = e.toElement().elementsByTagName(QLatin1String("include"));
+ for (int i = 0; i < (int) nl.length(); i++) {
+ QDomElement n2 = nl.item(i).toElement();
+ QString s = n2.firstChild().toText().data();
+
+ if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
+ continue;
+
+ if (impl && n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
+ continue;
+
+ if (n2.attribute(QLatin1String("location")) != QLatin1String("local"))
+ globalIncludes += s;
+ else
+ localIncludes += s;
+ }
+
+ // do the local includes afterwards, since global includes have priority on clashes
+ nl = e.toElement().elementsByTagName(QLatin1String("header"));
+ for (int i = 0; i < (int) nl.length(); i++) {
+ QDomElement n2 = nl.item(i).toElement();
+ QString s = n2.firstChild().toText().data();
+ if (n2.attribute(QLatin1String("location")) == QLatin1String("local") && !globalIncludes.contains(s)) {
+ if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
+ continue;
+
+ if (impl && n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
+ continue;
+
+ localIncludes += s;
+ }
+ }
+
+ // additional custom widget headers
+ nl = e.toElement().elementsByTagName(QLatin1String("header"));
+ for (int i = 0; i < (int) nl.length(); i++) {
+ QDomElement n2 = nl.item(i).toElement();
+ QString s = n2.firstChild().toText().data();
+
+ if (n2.attribute(QLatin1String("location")) != QLatin1String("local"))
+ globalIncludes += s;
+ else
+ localIncludes += s;
+ }
+
+ { // fix globalIncludes
+ globalIncludes = unique(globalIncludes);
+ QMutableStringListIterator it(globalIncludes);
+ while (it.hasNext()) {
+ QString v = it.next();
+
+ if (v.isEmpty()) {
+ it.remove();
+ continue;
+ }
+
+ it.setValue(fixHeaderName(v));
+ }
+ }
+
+ { // fix the localIncludes
+ localIncludes = unique(localIncludes);
+ QMutableStringListIterator it(localIncludes);
+ while (it.hasNext()) {
+ QString v = it.next();
+
+ if (v.isEmpty()) {
+ it.remove();
+ continue;
+ }
+
+ it.setValue(fixHeaderName(v));
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/domtool.cpp b/src/tools/uic3/domtool.cpp
new file mode 100644
index 0000000..ce2e2f6
--- /dev/null
+++ b/src/tools/uic3/domtool.cpp
@@ -0,0 +1,587 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "domtool.h"
+
+#include <QSizePolicy>
+#include <QColor>
+#include <QCursor>
+#include <QDateTime>
+#include <QRect>
+#include <QSize>
+#include <QFont>
+#include <QDomElement>
+#include <QByteArray>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*
+ \class DomTool
+ \brief The DomTool class provides static functions for Qt Designer
+ and uic.
+
+ A collection of static functions used by Resource (part of the
+ designer) and Uic.
+
+*/
+
+/*
+ Returns the contents of property \a name of object \a e as
+ a variant or the variant passed as \a defValue if the property does
+ not exist. The \a comment is passed on to the elementToVariant()
+ function.
+
+ \sa hasProperty()
+*/
+QVariant DomTool::readProperty(const QDomElement& e, const QString& name, const QVariant& defValue, QString& comment)
+{
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("property")) {
+ if (n.attribute(QLatin1String("name")) != name)
+ continue;
+ return elementToVariant(n.firstChild().toElement(), defValue, comment);
+ }
+ }
+ return defValue;
+}
+
+
+/*
+ \overload
+ */
+QVariant DomTool::readProperty(const QDomElement& e, const QString& name, const QVariant& defValue)
+{
+ QString comment;
+ return readProperty(e, name, defValue, comment);
+}
+
+/*
+ Returns whether object \a e defines property \a name or not.
+
+ \sa readProperty()
+ */
+bool DomTool::hasProperty(const QDomElement& e, const QString& name)
+{
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("property")) {
+ if (n.attribute(QLatin1String("name")) != name)
+ continue;
+ return true;
+ }
+ }
+ return false;
+}
+
+/*
+ Returns a list of the names of the properties of the given \a type
+ found in the element \a e.
+*/
+QStringList DomTool::propertiesOfType(const QDomElement& e, const QString& type)
+{
+ QStringList result;
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("property")) {
+ QDomElement n2 = n.firstChild().toElement();
+ if (n2.tagName() == type)
+ result += n.attribute(QLatin1String("name"));
+ }
+ }
+ return result;
+}
+
+
+/*
+ \overload
+*/
+QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValue)
+{
+ QString dummy;
+ return elementToVariant(e, defValue, dummy);
+}
+
+/*
+ Interprets element \a e as a variant and returns the result of the
+ interpretation, extracting the data as a text element is the \a
+ comment matches the tag name. If the interpretation fails the \a
+ defValue is returned instead.
+ */
+QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValue, QString &comment)
+{
+ Q_UNUSED(defValue);
+
+ QVariant v;
+ Variant var;
+
+ if (e.tagName() == QLatin1String("rect")) {
+ QDomElement n3 = e.firstChild().toElement();
+ int x = 0, y = 0, w = 0, h = 0;
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("x"))
+ x = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("y"))
+ y = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("width"))
+ w = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("height"))
+ h = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ var.createRect(x, y, w, h);
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("point")) {
+ QDomElement n3 = e.firstChild().toElement();
+ int x = 0, y = 0;
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("x"))
+ x = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("y"))
+ y = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ var.createPoint(x,y);
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("size")) {
+ QDomElement n3 = e.firstChild().toElement();
+ int w = 0, h = 0;
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("width"))
+ w = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("height"))
+ h = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ var.createSize(w, h);
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("color")) {
+ var.color = readColor(e);
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("font")) {
+ QDomElement n3 = e.firstChild().toElement();
+ Font f;
+ f.init();
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("family"))
+ f.family = qstrdup(n3.firstChild().toText().data().toLatin1());
+ else if (n3.tagName() == QLatin1String("pointsize"))
+ f.pointsize = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("bold"))
+ f.bold = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("italic"))
+ f.italic = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("underline"))
+ f.underline = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("strikeout"))
+ f.strikeout = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ var.font = f;
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("string")) {
+ v = QVariant(e.firstChild().toText().data());
+ QDomElement n = e;
+ n = n.nextSibling().toElement();
+ if (n.tagName() == QLatin1String("comment"))
+ comment = n.firstChild().toText().data();
+ } else if (e.tagName() == QLatin1String("cstring")) {
+ v = QVariant(e.firstChild().toText().data().toAscii());
+ } else if (e.tagName() == QLatin1String("number")) {
+ bool ok = true;
+ v = QVariant(e.firstChild().toText().data().toInt(&ok));
+ if (!ok)
+ v = QVariant(e.firstChild().toText().data().toDouble());
+ } else if (e.tagName() == QLatin1String("bool")) {
+ QString t = e.firstChild().toText().data();
+ v = QVariant(t == QLatin1String("true") || t == QLatin1String("1"));
+ } else if (e.tagName() == QLatin1String("pixmap")) {
+ v = QVariant(e.firstChild().toText().data());
+ } else if (e.tagName() == QLatin1String("iconset")) {
+ v = QVariant(e.firstChild().toText().data());
+ } else if (e.tagName() == QLatin1String("image")) {
+ v = QVariant(e.firstChild().toText().data());
+ } else if (e.tagName() == QLatin1String("enum")) {
+ v = QVariant(e.firstChild().toText().data());
+ } else if (e.tagName() == QLatin1String("set")) {
+ v = QVariant(e.firstChild().toText().data());
+ } else if (e.tagName() == QLatin1String("sizepolicy")) {
+ QDomElement n3 = e.firstChild().toElement();
+ var.createSizePolicy();
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("hsizetype"))
+ var.sizePolicy.hsizetype = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("vsizetype"))
+ var.sizePolicy.vsizetype = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("horstretch"))
+ var.sizePolicy.horstretch = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("verstretch"))
+ var.sizePolicy.verstretch = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("cursor")) {
+ var.createCursor(e.firstChild().toText().data().toInt());
+ qVariantSetValue(v, var);
+ } else if (e.tagName() == QLatin1String("stringlist")) {
+ QStringList lst;
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement())
+ lst << n.firstChild().toText().data();
+ v = QVariant(lst);
+ } else if (e.tagName() == QLatin1String("date")) {
+ QDomElement n3 = e.firstChild().toElement();
+ int y, m, d;
+ y = m = d = 0;
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("year"))
+ y = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("month"))
+ m = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("day"))
+ d = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ v = QVariant(QDate(y, m, d));
+ } else if (e.tagName() == QLatin1String("time")) {
+ QDomElement n3 = e.firstChild().toElement();
+ int h, m, s;
+ h = m = s = 0;
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("hour"))
+ h = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("minute"))
+ m = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("second"))
+ s = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ v = QVariant(QTime(h, m, s));
+ } else if (e.tagName() == QLatin1String("datetime")) {
+ QDomElement n3 = e.firstChild().toElement();
+ int h, mi, s, y, mo, d ;
+ h = mi = s = y = mo = d = 0;
+ while (!n3.isNull()) {
+ if (n3.tagName() == QLatin1String("hour"))
+ h = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("minute"))
+ mi = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("second"))
+ s = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("year"))
+ y = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("month"))
+ mo = n3.firstChild().toText().data().toInt();
+ else if (n3.tagName() == QLatin1String("day"))
+ d = n3.firstChild().toText().data().toInt();
+ n3 = n3.nextSibling().toElement();
+ }
+ v = QVariant(QDateTime(QDate(y, mo, d), QTime(h, mi, s)));
+ }
+
+ return v;
+}
+
+
+/* Returns the color which is returned in the dom element \a e.
+ */
+
+Color DomTool::readColor(const QDomElement &e)
+{
+ QDomElement n = e.firstChild().toElement();
+ int r= 0, g = 0, b = 0;
+ while (!n.isNull()) {
+ if (n.tagName() == QLatin1String("red"))
+ r = n.firstChild().toText().data().toInt();
+ else if (n.tagName() == QLatin1String("green"))
+ g = n.firstChild().toText().data().toInt();
+ else if (n.tagName() == QLatin1String("blue"))
+ b = n.firstChild().toText().data().toInt();
+ n = n.nextSibling().toElement();
+ }
+
+ Color c;
+ c.init(r, g, b);
+ return c;
+}
+
+/*
+ Returns the contents of attribute \a name of object \a e as
+ a variant or the variant passed as \a defValue if the attribute does
+ not exist. The \a comment is passed to the elementToVariant()
+ function.
+
+ \sa hasAttribute()
+ */
+QVariant DomTool::readAttribute(const QDomElement& e, const QString& name, const QVariant& defValue, QString& comment)
+{
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("attribute")) {
+ if (n.attribute(QLatin1String("name")) != name)
+ continue;
+ return elementToVariant(n.firstChild().toElement(), defValue, comment);
+ }
+ }
+ return defValue;
+}
+
+/*
+ \overload
+*/
+QVariant DomTool::readAttribute(const QDomElement& e, const QString& name, const QVariant& defValue)
+{
+ QString comment;
+ return readAttribute(e, name, defValue, comment);
+}
+
+/*
+ Returns whether object \a e defines attribute \a name or not.
+
+ \sa readAttribute()
+ */
+bool DomTool::hasAttribute(const QDomElement& e, const QString& name)
+{
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("attribute")) {
+ if (n.attribute(QLatin1String("name")) != name)
+ continue;
+ return true;
+ }
+ }
+ return false;
+}
+
+static bool toBool(const QString& s)
+{
+ return s == QLatin1String("true") || s.toInt() != 0;
+}
+
+static double versionToDouble(QString version)
+{
+ version = version.trimmed();
+
+ if (version.isEmpty())
+ return 0.0;
+
+ bool decpt = false;
+ QString num_str;
+ for (int i = 0; i < version.size(); ++i) {
+ char c = version.at(i).toAscii();
+ if ((c < '0' || c > '9') && c != '.')
+ break;
+ if (c == '.') {
+ if (decpt)
+ break;
+ decpt = true;
+ }
+ num_str.append(QLatin1Char(c));
+ }
+
+ return num_str.toDouble();
+}
+
+/*
+ \internal
+
+ Convert Qt 2.x format to Qt 3.x format if necessary.
+*/
+void DomTool::fixDocument(QDomDocument& doc)
+{
+ QDomElement e;
+ QDomNode n;
+ QDomNodeList nl;
+ int i = 0;
+
+ e = doc.firstChild().toElement();
+ if (e.tagName() != QLatin1String("UI"))
+ return;
+
+ // rename classes and properties
+ double version = versionToDouble(e.attribute(QLatin1String("version")));
+
+ nl = e.childNodes();
+ fixAttributes(nl, version);
+
+ // 3.x don't do anything more
+ if (version >= 3.0)
+ return;
+
+ // in versions smaller than 3.0 we need to change more
+
+ e.setAttribute(QLatin1String("version"), 3.0);
+ e.setAttribute(QLatin1String("stdsetdef"), 1);
+ nl = e.elementsByTagName(QLatin1String("property"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ e = nl.item(i).toElement();
+ QString name;
+ QDomElement n2 = e.firstChild().toElement();
+ if (n2.tagName() == QLatin1String("name")) {
+ name = n2.firstChild().toText().data();
+ if (name == QLatin1String("resizeable"))
+ e.setAttribute(QLatin1String("name"), QLatin1String("resizable"));
+ else
+ e.setAttribute(QLatin1String("name"), name);
+ e.removeChild(n2);
+ }
+ bool stdset = toBool(e.attribute(QLatin1String("stdset")));
+ if (stdset || name == QLatin1String("toolTip") || name == QLatin1String("whatsThis") ||
+ name == QLatin1String("buddy") ||
+ e.parentNode().toElement().tagName() == QLatin1String("item") ||
+ e.parentNode().toElement().tagName() == QLatin1String("spacer") ||
+ e.parentNode().toElement().tagName() == QLatin1String("column")
+ )
+ e.removeAttribute(QLatin1String("stdset"));
+ else
+ e.setAttribute(QLatin1String("stdset"), 0);
+ }
+
+ nl = doc.elementsByTagName(QLatin1String("attribute"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ e = nl.item(i).toElement();
+ QString name;
+ QDomElement n2 = e.firstChild().toElement();
+ if (n2.tagName() == QLatin1String("name")) {
+ name = n2.firstChild().toText().data();
+ e.setAttribute(QLatin1String("name"), name);
+ e.removeChild(n2);
+ }
+ }
+
+ nl = doc.elementsByTagName(QLatin1String("image"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ e = nl.item(i).toElement();
+ QString name;
+ QDomElement n2 = e.firstChild().toElement();
+ if (n2.tagName() == QLatin1String("name")) {
+ name = n2.firstChild().toText().data();
+ e.setAttribute(QLatin1String("name"), name);
+ e.removeChild(n2);
+ }
+ }
+
+ nl = doc.elementsByTagName(QLatin1String("widget"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ e = nl.item(i).toElement();
+ QString name;
+ QDomElement n2 = e.firstChild().toElement();
+ if (n2.tagName() == QLatin1String("class")) {
+ name = n2.firstChild().toText().data();
+ e.setAttribute(QLatin1String("class"), name);
+ e.removeChild(n2);
+ }
+ }
+
+}
+
+struct widgetName {
+ widgetName(double v, QString b, QString a)
+ : version(v), before(b), after(a) {}
+ double version;
+ QString before;
+ QString after;
+};
+
+struct propertyName : public widgetName {
+ propertyName(double v, QString b, QString a, QString c = QString())
+ : widgetName(v, b, a), clss(c) {}
+ QString clss;
+};
+
+const int widgs = 1;
+widgetName widgetTable[1] = {
+ widgetName(3.3, QLatin1String("before"), QLatin1String("after")),
+};
+
+const int props = 1;
+propertyName propertyTable[1] = {
+ propertyName(3.0, QLatin1String("resizeable"), QLatin1String("resizable")), // we need to fix a spelling error in 3.0
+};
+
+/*
+ \internal
+*/
+void DomTool::fixAttributes(QDomNodeList &nodes, double version)
+{
+ QDomNode n;
+ QDomNodeList nl;
+ for (int i = 0; i < (int) nodes.count(); ++i) {
+ n = nodes.item(i);
+ fixAttribute(n, version);
+ nl = n.childNodes();
+ fixAttributes(nl, version);
+ }
+}
+
+/*
+ \internal
+*/
+void DomTool::fixAttribute(QDomNode &node, double version)
+{
+ QString tagName = node.toElement().tagName();
+ if (tagName == QLatin1String("widget")) {
+ QString clss = node.toElement().attribute(QLatin1String("class"));
+ for (int i = 0; i < widgs; ++i)
+ if ((version < widgetTable[i].version)
+ && (clss == widgetTable[i].before)) {
+ node.toElement().setAttribute(QLatin1String("class"), propertyTable[i].after);
+ return;
+ }
+ return;
+ }
+ if (tagName == QLatin1String("property")) {
+ QDomElement e = node.parentNode().toElement();
+ QString clss = e.attribute(QLatin1String("class"));
+ QString name = node.toElement().attribute(QLatin1String("name"), QLatin1String(""));
+ for (int i = 0; i < props; ++i)
+ if ((version < propertyTable[i].version)
+ && (clss == propertyTable[i].clss)
+ && (propertyTable[i].before.isNull()
+ || name == propertyTable[i].before)) {
+ node.toElement().setAttribute(QLatin1String("name"), propertyTable[i].after);
+ return;
+ }
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/domtool.h b/src/tools/uic3/domtool.h
new file mode 100644
index 0000000..811c1f9
--- /dev/null
+++ b/src/tools/uic3/domtool.h
@@ -0,0 +1,275 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DOMTOOL_H
+#define DOMTOOL_H
+
+#include <QVariant>
+
+QT_BEGIN_NAMESPACE
+
+class QDomElement;
+class QDomDocument;
+class QDomNode;
+class QDomNodeList;
+
+struct Common
+{
+ int kind;
+
+ enum {
+ Kind_Unknown = 0,
+ Kind_Color,
+ Kind_Point,
+ Kind_Size,
+ Kind_Rect,
+ Kind_Font,
+ Kind_SizePolicy,
+ Kind_Cursor
+ };
+
+ inline void init()
+ { kind = Kind_Unknown; }
+};
+
+struct Color
+{
+ Common common;
+ int red, green, blue;
+
+ inline void init(int r, int g, int b)
+ {
+ common.kind = Common::Kind_Color;
+ red = r;
+ green = g;
+ blue = b;
+ }
+
+ inline bool operator == (const Color &other) const
+ { return red == other.red && green == other.green && blue == other.blue; }
+};
+
+struct Point
+{
+ Common common;
+ int x, y;
+
+ inline void init(int x, int y)
+ {
+ common.kind = Common::Kind_Point;
+ this->x = x;
+ this->y = y;
+ }
+};
+
+struct Size
+{
+ Common common;
+ int width, height;
+
+ inline bool isNull() const
+ { return this->width == 0 && this->height == 0; }
+
+ inline void init(int width, int height)
+ {
+ common.kind = Common::Kind_Size;
+ this->width = width;
+ this->height = height;
+ }
+};
+
+struct Rect
+{
+ Common common;
+ int x, y;
+ int width, height;
+
+ inline void init(int x, int y, int width, int height)
+ {
+ common.kind = Common::Kind_Rect;
+ this->x = x;
+ this->y = y;
+ this->width = width;
+ this->height = height;
+ }
+};
+
+struct Font
+{
+ Common common;
+ char *family;
+ int pointsize;
+ bool bold;
+ bool italic;
+ bool underline;
+ bool strikeout;
+
+ inline void init()
+ {
+ common.kind = Common::Kind_Font;
+ family = 0;
+ pointsize = 0;
+ bold = false;
+ italic = false;
+ underline = false;
+ strikeout = false;
+ }
+};
+
+struct SizePolicy
+{
+ Common common;
+ int hsizetype;
+ int vsizetype;
+ int horstretch;
+ int verstretch;
+
+ inline void init()
+ {
+ common.kind = Common::Kind_SizePolicy;
+ hsizetype = 0;
+ vsizetype = 0;
+ horstretch = 0;
+ verstretch = 0;
+ }
+};
+
+struct Cursor
+{
+ Common common;
+ int shape;
+
+ inline void init(int shape)
+ {
+ common.kind = Common::Kind_Cursor;
+ this->shape = shape;
+ }
+};
+
+union Variant
+{
+ Common common;
+ Color color;
+ Size size;
+ Point point;
+ Rect rect;
+ Font font;
+ SizePolicy sizePolicy;
+ Cursor cursor;
+
+ inline Variant()
+ { common.kind = Common::Kind_Unknown; }
+
+ inline ~Variant()
+ {
+ if (common.kind == Common::Kind_Font) {
+ delete[] font.family;
+ font.family = 0;
+ }
+ }
+
+ inline int kind() const
+ { return common.kind; }
+
+ inline Variant &createColor(int r, int g, int b)
+ { color.init(r, g, b); return *this; }
+
+ inline Variant &createPoint(int x, int y)
+ { point.init(x, y); return *this; }
+
+ inline Variant &createSize(int width, int height)
+ { size.init(width, height); return *this; }
+
+ inline Variant &createRect(int x, int y, int w, int h)
+ { rect.init(x, y, w, h); return *this; }
+
+ inline Variant &createFont()
+ { font.init(); return *this; }
+
+ inline Variant &createSizePolicy()
+ { sizePolicy.init(); return *this; }
+
+ inline Variant &createCursor(int shape)
+ { cursor.init(shape); return *this; }
+};
+
+class DomTool
+{
+public:
+ static QVariant readProperty(const QDomElement& e, const QString& name, const QVariant& defValue);
+ static QVariant readProperty(const QDomElement& e, const QString& name, const QVariant& defValue, QString& comment);
+ static bool hasProperty(const QDomElement& e, const QString& name);
+ static QStringList propertiesOfType(const QDomElement& e, const QString& type);
+ static QVariant elementToVariant(const QDomElement& e, const QVariant& defValue);
+ static QVariant elementToVariant(const QDomElement& e, const QVariant& defValue, QString &comment);
+ static QVariant readAttribute(const QDomElement& e, const QString& name, const QVariant& defValue);
+ static QVariant readAttribute(const QDomElement& e, const QString& name, const QVariant& defValue, QString& comment);
+ static bool hasAttribute(const QDomElement& e, const QString& name);
+ static Color readColor(const QDomElement &e);
+ static void fixDocument(QDomDocument&);
+ static void fixAttributes(QDomNodeList&, double);
+ static void fixAttribute(QDomNode&, double);
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(Size)
+Q_DECLARE_METATYPE(Rect)
+Q_DECLARE_METATYPE(Font)
+Q_DECLARE_METATYPE(SizePolicy)
+Q_DECLARE_METATYPE(Cursor)
+Q_DECLARE_METATYPE(Color)
+Q_DECLARE_METATYPE(Point)
+Q_DECLARE_METATYPE(Common)
+Q_DECLARE_METATYPE(Variant)
+
+QT_BEGIN_NAMESPACE
+
+inline Variant asVariant(const QVariant &v)
+{
+ Variant var;
+ var = qVariantValue<Variant>(v);
+ return var;
+}
+
+QT_END_NAMESPACE
+
+#endif // DOMTOOL_H
diff --git a/src/tools/uic3/embed.cpp b/src/tools/uic3/embed.cpp
new file mode 100644
index 0000000..882328a
--- /dev/null
+++ b/src/tools/uic3/embed.cpp
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include <QFile>
+#include <QImage>
+#include <QStringList>
+#include <QDateTime>
+#include <QFileInfo>
+#include <QVector>
+#include <stdio.h>
+#include <ctype.h>
+
+QT_BEGIN_NAMESPACE
+
+// on embedded, we do not compress image data. Rationale: by mapping
+// the ready-only data directly into memory we are both faster and
+// more memory efficient
+#if defined(Q_WS_QWS) && !defined(QT_NO_IMAGE_COLLECTION_COMPRESSION)
+# define QT_NO_IMAGE_COLLECTION_COMPRESSION
+#elif defined (QT_NO_COMPRESS)
+# define QT_NO_IMAGE_COLLECTION_COMPRESSION
+#endif
+
+struct EmbedImage
+{
+ ~EmbedImage() { delete[] colorTable; }
+
+ int width, height, depth;
+ int numColors;
+ QRgb* colorTable;
+ QString name;
+ QString cname;
+ bool alpha;
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ ulong compressed;
+#endif
+};
+
+static QString convertToCIdentifier( const char *s )
+{
+ QByteArray r = s;
+ int len = r.length();
+ if ( len > 0 && !isalpha( (char)r[0] ) )
+ r[0] = '_';
+ for ( int i=1; i<len; i++ ) {
+ if ( !isalnum( (char)r[i] ) )
+ r[i] = '_';
+ }
+
+ return QString::fromAscii(r);
+}
+
+
+static ulong embedData( QTextStream& out, const uchar* input, int nbytes )
+{
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ QByteArray bazip( qCompress( input, nbytes ) );
+ ulong len = bazip.size();
+#else
+ ulong len = nbytes;
+#endif
+ static const char hexdigits[] = "0123456789abcdef";
+ QString s;
+ for ( int i=0; i<(int)len; i++ ) {
+ if ( (i%14) == 0 ) {
+ s += QLatin1String("\n ");
+ out << s.latin1();
+ s.truncate( 0 );
+ }
+ uint v = (uchar)
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ bazip
+#else
+ input
+#endif
+ [i];
+ s += QLatin1String("0x");
+ s += QLatin1Char(hexdigits[(v >> 4) & 15]);
+ s += QLatin1Char(hexdigits[v & 15]);
+ if ( i < (int)len-1 )
+ s += QLatin1Char(',');
+ }
+ if ( s.length() )
+ out << s.latin1();
+ return len;
+}
+
+static void embedData( QTextStream& out, const QRgb* input, int n )
+{
+ out << hex;
+ const QRgb *v = input;
+ for ( int i=0; i<n; i++ ) {
+ if ( (i%14) == 0 )
+ out << "\n ";
+ out << "0x";
+ out << hex << *v++;
+ if ( i < n-1 )
+ out << ',';
+ }
+ out << dec; // back to decimal mode
+}
+
+void Ui3Reader::embed(const char *project, const QStringList &images)
+{
+
+ QString cProject = convertToCIdentifier( project );
+
+ QStringList::ConstIterator it;
+ out << "/****************************************************************************\n";
+ out << "** Image collection for project '" << project << "'.\n";
+ out << "**\n";
+ out << "** Generated from reading image files: \n";
+ for ( it = images.begin(); it != images.end(); ++it )
+ out << "** " << *it << "\n";
+ out << "**\n";
+ out << "** Created: " << QDateTime::currentDateTime().toString() << "\n";
+ out << "** by: The User Interface Compiler for Qt version " << QT_VERSION_STR << "\n";
+ out << "**\n";
+ out << "** WARNING! All changes made in this file will be lost!\n";
+ out << "****************************************************************************/\n";
+ out << "\n";
+
+ out << "#include <qimage.h>\n";
+ out << "#include <qmime.h>\n";
+ out << "#include <q3mimefactory.h>\n";
+ out << "#include <q3dragobject.h>\n";
+ out << "\n";
+
+ QList<EmbedImage*> list_image;
+ int image_count = 0;
+ for ( it = images.begin(); it != images.end(); ++it ) {
+ QImage img;
+ if ( !img.load( *it ) ) {
+ fprintf( stderr, "uic: cannot load image file %s\n", (*it).latin1() );
+ continue;
+ }
+ EmbedImage *e = new EmbedImage;
+ e->width = img.width();
+ e->height = img.height();
+ e->depth = img.depth();
+ e->numColors = img.numColors();
+ e->colorTable = new QRgb[e->numColors];
+ e->alpha = img.hasAlphaBuffer();
+ QVector<QRgb> ct = img.colorTable();
+ memcpy(e->colorTable, ct.constData(), e->numColors*sizeof(QRgb));
+ QFileInfo fi( *it );
+ e->name = fi.fileName();
+ e->cname = QString::fromLatin1("image_%1").arg( image_count++);
+ list_image.append( e );
+ out << "// " << *it << "\n";
+ QString s;
+ if ( e->depth == 1 )
+ img = img.convertBitOrder(QImage::BigEndian);
+ out << s.sprintf( "static const unsigned char %s_data[] = {",
+ e->cname.latin1() );
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ e->compressed =
+#endif
+ embedData( out, img.bits(), img.numBytes() );
+ out << "\n};\n\n";
+ if ( e->numColors ) {
+ out << s.sprintf( "static const QRgb %s_ctable[] = {",
+ e->cname.latin1() );
+ embedData( out, e->colorTable, e->numColors );
+ out << "\n};\n\n";
+ }
+ }
+
+ if ( !list_image.isEmpty() ) {
+ out << "static const struct EmbedImage {\n"
+ " int width, height, depth;\n"
+ " const unsigned char *data;\n"
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ " ulong compressed;\n"
+#endif
+ " int numColors;\n"
+ " const QRgb *colorTable;\n"
+ " bool alpha;\n"
+ " const char *name;\n"
+ "} embed_image_vec[] = {\n";
+ EmbedImage *e = 0;
+ int i;
+ for (i = 0; i < list_image.count(); ++i) {
+ e = list_image.at(i);
+ out << " { "
+ << e->width << ", "
+ << e->height << ", "
+ << e->depth << ", "
+ << "(const unsigned char*)" << e->cname << "_data, "
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ << e->compressed << ", "
+#endif
+ << e->numColors << ", ";
+ if ( e->numColors )
+ out << e->cname << "_ctable, ";
+ else
+ out << "0, ";
+ if ( e->alpha )
+ out << "true, ";
+ else
+ out << "false, ";
+ out << "\"" << e->name << "\" },\n";
+ delete e;
+ }
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ out << " { 0, 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n";
+#else
+ out << " { 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n";
+#endif
+
+ out << "\n"
+ "static QImage uic_findImage( const QString& name )\n"
+ "{\n"
+ " for ( int i=0; embed_image_vec[i].data; i++ ) {\n"
+ " if ( QString::fromUtf8(embed_image_vec[i].name) == name ) {\n"
+#ifndef QT_NO_IMAGE_COLLECTION_COMPRESSION
+ " QByteArray baunzip;\n"
+ " baunzip = qUncompress( embed_image_vec[i].data, \n"
+ " embed_image_vec[i].compressed );\n"
+ " QImage img((uchar*)baunzip.data(),\n"
+ " embed_image_vec[i].width,\n"
+ " embed_image_vec[i].height,\n"
+ " embed_image_vec[i].depth,\n"
+ " (QRgb*)embed_image_vec[i].colorTable,\n"
+ " embed_image_vec[i].numColors,\n"
+ " QImage::BigEndian\n"
+ " );\n"
+ " img = img.copy();\n"
+#else
+ " QImage img((uchar*)embed_image_vec[i].data,\n"
+ " embed_image_vec[i].width,\n"
+ " embed_image_vec[i].height,\n"
+ " embed_image_vec[i].depth,\n"
+ " (QRgb*)embed_image_vec[i].colorTable,\n"
+ " embed_image_vec[i].numColors,\n"
+ " QImage::BigEndian\n"
+ " );\n"
+#endif
+ " if ( embed_image_vec[i].alpha )\n"
+ " img.setAlphaBuffer(true);\n"
+ " return img;\n"
+ " }\n"
+ " }\n"
+ " return QImage();\n"
+ "}\n\n";
+
+ out << "class MimeSourceFactory_" << cProject << " : public Q3MimeSourceFactory\n";
+ out << "{\n";
+ out << "public:\n";
+ out << " MimeSourceFactory_" << cProject << "() {}\n";
+ out << " ~MimeSourceFactory_" << cProject << "() {}\n";
+ out << " const QMimeSource* data( const QString& abs_name ) const {\n";
+ out << "\tconst QMimeSource* d = Q3MimeSourceFactory::data( abs_name );\n";
+ out << "\tif ( d || abs_name.isNull() ) return d;\n";
+ out << "\tQImage img = uic_findImage( abs_name );\n";
+ out << "\tif ( !img.isNull() )\n";
+ out << "\t ((Q3MimeSourceFactory*)this)->setImage( abs_name, img );\n";
+ out << "\treturn Q3MimeSourceFactory::data( abs_name );\n";
+ out << " };\n";
+ out << "};\n\n";
+
+ out << "static Q3MimeSourceFactory* factory = 0;\n";
+ out << "\n";
+
+ out << "void qInitImages_" << cProject << "()\n";
+ out << "{\n";
+ out << " if ( !factory ) {\n";
+ out << "\tfactory = new MimeSourceFactory_" << cProject << ";\n";
+ out << "\tQ3MimeSourceFactory::defaultFactory()->addFactory( factory );\n";
+ out << " }\n";
+ out << "}\n\n";
+
+ out << "void qCleanupImages_" << cProject << "()\n";
+ out << "{\n";
+ out << " if ( factory ) {\n";
+ out << "\tQ3MimeSourceFactory::defaultFactory()->removeFactory( factory );\n";
+ out << "\tdelete factory;\n";
+ out << "\tfactory = 0;\n";
+ out << " }\n";
+ out << "}\n\n";
+
+ out << "class StaticInitImages_" << cProject << "\n";
+ out << "{\n";
+ out << "public:\n";
+ out << " StaticInitImages_" << cProject << "() { qInitImages_" << cProject << "(); }\n";
+ out << "#if defined(Q_OS_SCO) || defined(Q_OS_UNIXWARE)\n";
+ out << " ~StaticInitImages_" << cProject << "() { }\n";
+ out << "#else\n";
+ out << " ~StaticInitImages_" << cProject << "() { qCleanupImages_" << cProject << "(); }\n";
+ out << "#endif\n";
+ out << "};\n\n";
+
+ out << "static StaticInitImages_" << cProject << " staticImages;\n";
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/form.cpp b/src/tools/uic3/form.cpp
new file mode 100644
index 0000000..d9e968b
--- /dev/null
+++ b/src/tools/uic3/form.cpp
@@ -0,0 +1,921 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include "parser.h"
+#include "domtool.h"
+#include "globaldefs.h"
+
+// uic4
+#include "uic.h"
+#include "ui4.h"
+#include "driver.h"
+#include "option.h"
+
+#include <QStringList>
+#include <QFile>
+#include <QFileInfo>
+#include <QDir>
+#include <QRegExp>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QByteArray combinePath(const char *infile, const char *outfile)
+{
+ QFileInfo inFileInfo(QDir::current(), QFile::decodeName(infile));
+ QFileInfo outFileInfo(QDir::current(), QFile::decodeName(outfile));
+ int numCommonComponents = 0;
+
+ QStringList inSplitted = inFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
+ QStringList outSplitted = outFileInfo.dir().canonicalPath().split(QLatin1Char('/'));
+
+ while (!inSplitted.isEmpty() && !outSplitted.isEmpty() &&
+ inSplitted.first() == outSplitted.first()) {
+ inSplitted.erase(inSplitted.begin());
+ outSplitted.erase(outSplitted.begin());
+ numCommonComponents++;
+ }
+
+ if (numCommonComponents < 2) {
+ /*
+ The paths don't have the same drive, or they don't have the
+ same root directory. Use an absolute path.
+ */
+ return QFile::encodeName(inFileInfo.absoluteFilePath());
+ } else {
+ /*
+ The paths have something in common. Use a path relative to
+ the output file.
+ */
+ while (!outSplitted.isEmpty()) {
+ outSplitted.erase(outSplitted.begin());
+ inSplitted.prepend(QLatin1String(".."));
+ }
+ inSplitted.append(inFileInfo.fileName());
+ return QFile::encodeName(inSplitted.join(QLatin1String("/")));
+ }
+}
+
+/*!
+ Creates a declaration (header file) for the form given in \a e
+
+ \sa createFormImpl()
+*/
+void Ui3Reader::createFormDecl(const QDomElement &e, bool implicitIncludes)
+{
+ QDomElement body = e;
+
+ QDomElement n;
+ QDomNodeList nl;
+ int i;
+ QString objClass = getClassName(e);
+ if (objClass.isEmpty())
+ return;
+ QString objName = getObjectName(e);
+
+ QStringList typeDefs;
+
+ QMap<QString, CustomInclude> customWidgetIncludes;
+
+ /*
+ We are generating a few QImage members that are not strictly
+ necessary in some cases. Ideally, we would use requiredImage,
+ which is computed elsewhere, to keep the generated .h and .cpp
+ files synchronized.
+ */
+
+ // at first the images
+ QMap<QString, int> customWidgets;
+ QStringList forwardDecl;
+ QStringList forwardDecl2;
+ for (n = e; !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName().toLower() == QLatin1String("customwidgets")) {
+ QDomElement n2 = n.firstChild().toElement();
+ while (!n2.isNull()) {
+ if (n2.tagName().toLower() == QLatin1String("customwidget")) {
+ QDomElement n3 = n2.firstChild().toElement();
+ QString cl;
+ while (!n3.isNull()) {
+ QString tagName = n3.tagName().toLower();
+ if (tagName == QLatin1String("class")) {
+ cl = n3.firstChild().toText().data();
+ if (!nofwd)
+ forwardDecl << cl;
+ customWidgets.insert(cl, 0);
+ } else if (tagName == QLatin1String("header")) {
+ CustomInclude ci;
+ ci.header = n3.firstChild().toText().data();
+ ci.location = n3.attribute(QLatin1String("location"), QLatin1String("global"));
+ if (!ci.header.isEmpty())
+ forwardDecl.removeAll(cl);
+ customWidgetIncludes.insert(cl, ci);
+ }
+ n3 = n3.nextSibling().toElement();
+ }
+ }
+ n2 = n2.nextSibling().toElement();
+ }
+ }
+ }
+
+ // register the object and unify its name
+ objName = registerObject(objName);
+ QString protector = objName.toUpper() + QLatin1String("_H");
+ protector.replace(QLatin1String("::"), QLatin1String("_"));
+ out << "#ifndef " << protector << endl;
+ out << "#define " << protector << endl;
+ out << endl;
+
+ out << "#include <qvariant.h>" << endl; // for broken HP-UX compilers
+
+ QStringList globalIncludes, localIncludes;
+
+ {
+ QMap<QString, CustomInclude>::Iterator it = customWidgetIncludes.find(objClass);
+ if (it != customWidgetIncludes.end()) {
+ if ((*it).location == QLatin1String("global"))
+ globalIncludes += (*it).header;
+ else
+ localIncludes += (*it).header;
+ }
+ }
+
+ QStringList::ConstIterator it;
+
+ globalIncludes = unique(globalIncludes);
+ for (it = globalIncludes.constBegin(); it != globalIncludes.constEnd(); ++it) {
+ if (!(*it).isEmpty()) {
+ QString header = fixHeaderName(*it);
+ out << "#include <" << header << ">" << endl;
+ }
+ }
+ localIncludes = unique(localIncludes);
+ for (it = localIncludes.constBegin(); it != localIncludes.constEnd(); ++it) {
+ if (!(*it).isEmpty()) {
+ QString header = fixHeaderName(*it);
+ out << "#include \"" << header << "\"" << endl;
+ }
+ }
+ out << endl;
+
+ bool dbForm = false;
+ registerDatabases(e);
+ dbConnections = unique(dbConnections);
+ if (dbForms[QLatin1String("(default)")].count())
+ dbForm = true;
+ bool subDbForms = false;
+ for (it = dbConnections.constBegin(); it != dbConnections.constEnd(); ++it) {
+ if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) {
+ if (dbForms[(*it)].count()) {
+ subDbForms = true;
+ break;
+ }
+ }
+ }
+
+ // some typedefs, maybe
+ typeDefs = unique(typeDefs);
+ for (it = typeDefs.constBegin(); it != typeDefs.constEnd(); ++it) {
+ if (!(*it).isEmpty())
+ out << "typedef " << *it << ";" << endl;
+ }
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("forward"));
+ for (i = 0; i < (int) nl.length(); i++)
+ forwardDecl2 << fixDeclaration(nl.item(i).toElement().firstChild().toText().data());
+
+ forwardDecl = unique(forwardDecl);
+ for (it = forwardDecl.constBegin(); it != forwardDecl.constEnd(); ++it) {
+ if (!(*it).isEmpty() && (*it) != objClass) {
+ QString forwardName = *it;
+ QStringList forwardNamespaces = forwardName.split(QLatin1String("::"));
+ forwardName = forwardNamespaces.last();
+ forwardNamespaces.removeAt(forwardNamespaces.size()-1);
+
+ QStringList::ConstIterator ns = forwardNamespaces.constBegin();
+ while (ns != forwardNamespaces.constEnd()) {
+ out << "namespace " << *ns << " {" << endl;
+ ++ns;
+ }
+ out << "class " << forwardName << ";" << endl;
+ for (int i = 0; i < (int) forwardNamespaces.count(); i++)
+ out << "}" << endl;
+ }
+ }
+
+ for (it = forwardDecl2.constBegin(); it != forwardDecl2.constEnd(); ++it) {
+ QString fd = *it;
+ fd = fd.trimmed();
+ if (!fd.endsWith(QLatin1String(";")))
+ fd += QLatin1String(";");
+ out << fd << endl;
+ }
+
+ out << endl;
+
+ Driver d;
+ d.option().headerProtection = false;
+ d.option().copyrightHeader = false;
+ d.option().extractImages = m_extractImages;
+ d.option().qrcOutputFile = m_qrcOutputFile;
+ d.option().implicitIncludes = implicitIncludes;
+ if (trmacro.size())
+ d.option().translateFunction = trmacro;
+ DomUI *ui = generateUi4(e, implicitIncludes);
+ d.uic(fileName, ui, &out);
+ delete ui;
+
+ createWrapperDeclContents(e);
+
+ out << "#endif // " << protector << endl;
+}
+
+void Ui3Reader::createWrapperDecl(const QDomElement &e, const QString &convertedUiFile)
+{
+ QString objName = getObjectName(e);
+
+ objName = registerObject(objName);
+ QString protector = objName.toUpper() + QLatin1String("_H");
+ protector.replace(QLatin1String("::"), QLatin1String("_"));
+ out << "#ifndef " << protector << endl;
+ out << "#define " << protector << endl;
+ out << endl;
+ out << "#include \"" << convertedUiFile << "\"" << endl;
+
+ createWrapperDeclContents(e);
+ out << endl;
+ out << "#endif // " << protector << endl;
+}
+
+void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
+{
+ QString objClass = getClassName(e);
+ if (objClass.isEmpty())
+ return;
+
+ QDomNodeList nl;
+ QString exportMacro;
+ int i;
+ QDomElement n;
+ QStringList::ConstIterator it;
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("exportmacro"));
+ if (nl.length() == 1)
+ exportMacro = nl.item(0).firstChild().toText().data();
+
+ QStringList::ConstIterator ns = namespaces.constBegin();
+ while (ns != namespaces.constEnd()) {
+ out << "namespace " << *ns << " {" << endl;
+ ++ns;
+ }
+
+ out << "class ";
+ if (!exportMacro.isEmpty())
+ out << exportMacro << " ";
+ out << bareNameOfClass << " : public " << objClass << ", public Ui::" << bareNameOfClass << endl << "{" << endl;
+
+ /* qmake ignore Q_OBJECT */
+ out << " Q_OBJECT" << endl;
+ out << endl;
+ out << "public:" << endl;
+
+ // constructor
+ if (objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard")) {
+ out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);" << endl;
+ } else if (objClass == QLatin1String("QWidget")) {
+ out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0);" << endl;
+ } else if (objClass == QLatin1String("QMainWindow") || objClass == QLatin1String("Q3MainWindow")) {
+ out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);" << endl;
+ isMainWindow = true;
+ } else {
+ out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0);" << endl;
+ }
+
+ // destructor
+ out << " ~" << bareNameOfClass << "();" << endl;
+ out << endl;
+
+ // database connections
+ dbConnections = unique(dbConnections);
+ bool hadOutput = false;
+ for (it = dbConnections.constBegin(); it != dbConnections.constEnd(); ++it) {
+ if (!(*it).isEmpty()) {
+ // only need pointers to non-default connections
+ if ((*it) != QLatin1String("(default)") && !(*it).isEmpty()) {
+ out << indent << "QSqlDatabase* " << *it << "Connection;" << endl;
+ hadOutput = true;
+ }
+ }
+ }
+ if (hadOutput)
+ out << endl;
+
+ QStringList publicSlots, protectedSlots, privateSlots;
+ QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;
+ QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ n = nl.item(i).toElement();
+ if (n.parentNode().toElement().tagName() != QLatin1String("slots")
+ && n.parentNode().toElement().tagName() != QLatin1String("connections"))
+ continue;
+ if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
+ continue;
+ QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if (functionName.endsWith(QLatin1String(";")))
+ functionName = functionName.left(functionName.length() - 1);
+ QString specifier = n.attribute(QLatin1String("specifier"));
+ QString access = n.attribute(QLatin1String("access"));
+ if (access == QLatin1String(QLatin1String("protected"))) {
+ protectedSlots += functionName;
+ protectedSlotTypes += returnType;
+ protectedSlotSpecifier += specifier;
+ } else if (access == QLatin1String("private")) {
+ privateSlots += functionName;
+ privateSlotTypes += returnType;
+ privateSlotSpecifier += specifier;
+ } else {
+ publicSlots += functionName;
+ publicSlotTypes += returnType;
+ publicSlotSpecifier += specifier;
+ }
+ }
+
+ QStringList publicFuncts, protectedFuncts, privateFuncts;
+ QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;
+ QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ n = nl.item(i).toElement();
+ if (n.parentNode().toElement().tagName() != QLatin1String("functions"))
+ continue;
+ if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
+ continue;
+ QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if (functionName.endsWith(QLatin1String(";")))
+ functionName = functionName.left(functionName.length() - 1);
+ QString specifier = n.attribute(QLatin1String("specifier"));
+ QString access = n.attribute(QLatin1String("access"));
+ if (access == QLatin1String("protected")) {
+ protectedFuncts += functionName;
+ protectedFunctRetTyp += returnType;
+ protectedFunctSpec += specifier;
+ } else if (access == QLatin1String("private")) {
+ privateFuncts += functionName;
+ privateFunctRetTyp += returnType;
+ privateFunctSpec += specifier;
+ } else {
+ publicFuncts += functionName;
+ publicFunctRetTyp += returnType;
+ publicFunctSpec += specifier;
+ }
+ }
+
+ QStringList publicVars, protectedVars, privateVars;
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("variable"));
+ for (i = 0; i < (int)nl.length(); i++) {
+ n = nl.item(i).toElement();
+ // Because of compatibility the next lines have to be commented out.
+ // Someday it should be uncommented.
+ //if (n.parentNode().toElement().tagName() != QLatin1String("variables"))
+ // continue;
+ QString access = n.attribute(QLatin1String("access"), QLatin1String("protected"));
+ QString var = fixDeclaration(n.firstChild().toText().data().trimmed());
+ if (!var.endsWith(QLatin1String(";")))
+ var += QLatin1String(";");
+ if (access == QLatin1String("public"))
+ publicVars += var;
+ else if (access == QLatin1String("private"))
+ privateVars += var;
+ else
+ protectedVars += var;
+ }
+
+ if (!publicVars.isEmpty()) {
+ for (it = publicVars.constBegin(); it != publicVars.constEnd(); ++it)
+ out << indent << *it << endl;
+ out << endl;
+ }
+ if (!publicFuncts.isEmpty())
+ writeFunctionsDecl(publicFuncts, publicFunctRetTyp, publicFunctSpec);
+
+ if (!publicSlots.isEmpty()) {
+ out << "public slots:" << endl;
+ if (!publicSlots.isEmpty())
+ writeFunctionsDecl(publicSlots, publicSlotTypes, publicSlotSpecifier);
+ }
+
+ // find signals
+ QStringList extraSignals;
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("signal"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ n = nl.item(i).toElement();
+ if (n.parentNode().toElement().tagName() != QLatin1String("signals")
+ && n.parentNode().toElement().tagName() != QLatin1String("connections"))
+ continue;
+ if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
+ continue;
+ QString sigName = n.firstChild().toText().data().trimmed();
+ if (sigName.endsWith(QLatin1String(";")))
+ sigName = sigName.left(sigName.length() - 1);
+ extraSignals += fixDeclaration(sigName);
+ }
+
+ // create signals
+ if (!extraSignals.isEmpty()) {
+ out << "signals:" << endl;
+ for (it = extraSignals.constBegin(); it != extraSignals.constEnd(); ++it)
+ out << " void " << (*it) << ";" << endl;
+ out << endl;
+ }
+
+ if (!protectedVars.isEmpty()) {
+ out << "protected:" << endl;
+ for (it = protectedVars.constBegin(); it != protectedVars.constEnd(); ++it)
+ out << indent << *it << endl;
+ out << endl;
+ }
+
+ if (!protectedFuncts.isEmpty()) {
+ if (protectedVars.isEmpty())
+ out << "protected:" << endl;
+
+ writeFunctionsDecl(protectedFuncts, protectedFunctRetTyp, protectedFunctSpec);
+ }
+
+ out << "protected slots:" << endl;
+ out << " virtual void languageChange();" << endl;
+
+ if (!protectedSlots.isEmpty()) {
+ out << endl;
+ writeFunctionsDecl(protectedSlots, protectedSlotTypes, protectedSlotSpecifier);
+ }
+ out << endl;
+
+ // create all private stuff
+ if (!privateFuncts.isEmpty() || !privateVars.isEmpty()) {
+ out << "private:" << endl;
+ if (!privateVars.isEmpty()) {
+ for (it = privateVars.constBegin(); it != privateVars.constEnd(); ++it)
+ out << indent << *it << endl;
+ out << endl;
+ }
+ if (!privateFuncts.isEmpty())
+ writeFunctionsDecl(privateFuncts, privateFunctRetTyp, privateFunctSpec);
+ }
+
+ if (!privateSlots.isEmpty()) {
+ out << "private slots:" << endl;
+ writeFunctionsDecl(privateSlots, privateSlotTypes, privateSlotSpecifier);
+ }
+
+ out << "};" << endl;
+ for (i = 0; i < (int) namespaces.count(); i++)
+ out << "}" << endl;
+
+ out << endl;
+}
+
+void Ui3Reader::writeFunctionsDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst)
+{
+ QStringList::ConstIterator it, it2, it3;
+ for (it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin();
+ it != fuLst.end(); ++it, ++it2, ++it3) {
+ QString signature = *it;
+ QString specifier;
+ QString pure;
+ QString type = *it2;
+ if (type.isEmpty())
+ type = QLatin1String("void");
+ if (*it3 == QLatin1String("static")) {
+ specifier = QLatin1String("static ");
+ } else {
+ if (*it3 != QLatin1String("non virtual") && *it3 != QLatin1String("nonVirtual"))
+ specifier = QLatin1String("virtual ");
+ if (*it3 == QLatin1String("pure virtual") || *it3 == QLatin1String("pureVirtual"))
+ pure = QLatin1String(" = 0");
+ }
+ type.replace(QLatin1String(">>"), QLatin1String("> >"));
+ if (!signature.contains(QLatin1String("operator")))
+ signature.replace(QLatin1String(">>"), QLatin1String("> >"));
+
+ signature = fixDeclaration(signature);
+ type = fixType(type);
+ out << " " << specifier << type << " " << signature << pure << ";" << endl;
+ }
+ out << endl;
+}
+
+/*!
+ Creates an implementation (cpp-file) for the form given in \a e.
+
+ \sa createFormDecl(), createObjectImpl()
+ */
+void Ui3Reader::createFormImpl(const QDomElement &e)
+{
+ QDomElement n;
+ QDomNodeList nl;
+ int i;
+ QString objClass = getClassName(e);
+ if (objClass.isEmpty())
+ return;
+ QString objName = getObjectName(e);
+
+ // generate local and local includes required
+ QStringList globalIncludes, localIncludes;
+ QStringList::Iterator it;
+
+ QMap<QString, CustomInclude> customWidgetIncludes;
+
+ // find additional slots and functions
+ QStringList extraFuncts;
+ QStringList extraFunctTyp;
+ QStringList extraFunctSpecifier;
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ n = nl.item(i).toElement();
+ if (n.parentNode().toElement().tagName() != QLatin1String("slots")
+ && n.parentNode().toElement().tagName() != QLatin1String("connections"))
+ continue;
+ if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
+ continue;
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if (functionName.endsWith(QLatin1String(";")))
+ functionName = functionName.left(functionName.length() - 1);
+ extraFuncts += functionName;
+ extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual"));
+ }
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ n = nl.item(i).toElement();
+ if (n.parentNode().toElement().tagName() != QLatin1String("functions"))
+ continue;
+ if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
+ continue;
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if (functionName.endsWith(QLatin1String(";")))
+ functionName = functionName.left(functionName.length() - 1);
+ extraFuncts += functionName;
+ extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual"));
+ }
+
+ // additional includes (local or global) and forward declaractions
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("include"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ QDomElement n2 = nl.item(i).toElement();
+ QString s = n2.firstChild().toText().data();
+ if (n2.attribute(QLatin1String("location")) != QLatin1String("local")) {
+ if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
+ continue;
+ if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
+ continue;
+ globalIncludes += s;
+ }
+ }
+
+ registerDatabases(e);
+ dbConnections = unique(dbConnections);
+ bool dbForm = false;
+ if (dbForms[QLatin1String("(default)")].count())
+ dbForm = true;
+ bool subDbForms = false;
+ for (it = dbConnections.begin(); it != dbConnections.end(); ++it) {
+ if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) {
+ if (dbForms[(*it)].count()) {
+ subDbForms = true;
+ break;
+ }
+ }
+ }
+
+ // do the local includes afterwards, since global includes have priority on clashes
+ for (i = 0; i < (int) nl.length(); i++) {
+ QDomElement n2 = nl.item(i).toElement();
+ QString s = n2.firstChild().toText().data();
+ if (n2.attribute(QLatin1String("location")) == QLatin1String("local") && !globalIncludes.contains(s)) {
+ if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s))
+ continue;
+ if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation"))
+ continue;
+ localIncludes += s;
+ }
+ }
+
+ // additional custom widget headers
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("header"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ QDomElement n2 = nl.item(i).toElement();
+ QString s = n2.firstChild().toText().data();
+ if (n2.attribute(QLatin1String("location")) != QLatin1String("local"))
+ globalIncludes += s;
+ else
+ localIncludes += s;
+ }
+
+ out << "#include <qvariant.h>" << endl; // first for gcc 2.7.2
+
+ globalIncludes = unique(globalIncludes);
+ for (it = globalIncludes.begin(); it != globalIncludes.end(); ++it) {
+ if (!(*it).isEmpty())
+ out << "#include <" << fixHeaderName(*it) << ">" << endl;
+ }
+
+ if (externPixmaps) {
+ out << "#include <qimage.h>" << endl;
+ out << "#include <qpixmap.h>" << endl << endl;
+ }
+
+ /*
+ Put local includes after all global includes
+ */
+ localIncludes = unique(localIncludes);
+ for (it = localIncludes.begin(); it != localIncludes.end(); ++it) {
+ if (!(*it).isEmpty() && *it != QFileInfo(fileName + QLatin1String(".h")).fileName())
+ out << "#include \"" << fixHeaderName(*it) << "\"" << endl;
+ }
+
+ QString uiDotH = fileName + QLatin1String(".h");
+ if (QFile::exists(uiDotH)) {
+ if (!outputFileName.isEmpty())
+ uiDotH = QString::fromUtf8(combinePath(uiDotH.ascii(), outputFileName.ascii()));
+ out << "#include \"" << uiDotH << "\"" << endl;
+ writeFunctImpl = false;
+ }
+
+ // register the object and unify its name
+ objName = registerObject(objName);
+
+ if (externPixmaps) {
+ pixmapLoaderFunction = QLatin1String("QPixmap::fromMimeSource");
+ }
+
+ // constructor
+ if (objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard")) {
+ out << "/*" << endl;
+ out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;
+ out << " * name 'name' and widget flags set to 'f'." << endl;
+ out << " *" << endl;
+ out << " * The " << objClass.mid(1).toLower() << " will by default be modeless, unless you set 'modal' to" << endl;
+ out << " * true to construct a modal " << objClass.mid(1).toLower() << "." << endl;
+ out << " */" << endl;
+ out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)" << endl;
+ out << " : " << objClass << "(parent, name, modal, fl)";
+ } else if (objClass == QLatin1String("QWidget")) {
+ out << "/*" << endl;
+ out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;
+ out << " * name 'name' and widget flags set to 'f'." << endl;
+ out << " */" << endl;
+ out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, Qt::WindowFlags fl)" << endl;
+ out << " : " << objClass << "(parent, name, fl)";
+ } else if (objClass == QLatin1String("QMainWindow") || objClass == QLatin1String("Q3MainWindow")) {
+ out << "/*" << endl;
+ out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl;
+ out << " * name 'name' and widget flags set to 'f'." << endl;
+ out << " *" << endl;
+ out << " */" << endl;
+ out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, Qt::WindowFlags fl)" << endl;
+ out << " : " << objClass << "(parent, name, fl)";
+ isMainWindow = true;
+ } else {
+ out << "/*" << endl;
+ out << " * Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl;
+ out << " * name 'name'.' " << endl;
+ out << " */" << endl;
+ out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name)" << endl;
+ out << " : " << objClass << "(parent, name)";
+ }
+
+ out << endl;
+
+ out << "{" << endl;
+
+//
+// setup the gui
+//
+ out << indent << "setupUi(this);" << endl << endl;
+
+
+ if (isMainWindow)
+ out << indent << "(void)statusBar();" << endl;
+
+ // database support
+ dbConnections = unique(dbConnections);
+ if (dbConnections.count())
+ out << endl;
+ for (it = dbConnections.begin(); it != dbConnections.end(); ++it) {
+ if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) {
+ out << indent << (*it) << "Connection = QSqlDatabase::database(\"" <<(*it) << "\");" << endl;
+ }
+ }
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("widget"));
+ for (i = 1; i < (int) nl.length(); i++) { // start at 1, 0 is the toplevel widget
+ n = nl.item(i).toElement();
+ QString s = getClassName(n);
+ if ((dbForm || subDbForms) && (s == QLatin1String("QDataBrowser") || s == QLatin1String("QDataView"))) {
+ QString objName = getObjectName(n);
+ QString tab = getDatabaseInfo(n, QLatin1String("table"));
+ QString con = getDatabaseInfo(n, QLatin1String("connection"));
+ out << indent << "QSqlForm* " << objName << "Form = new QSqlForm(this);" << endl;
+ out << indent << objName << "Form->setObjectName(\"" << objName << "Form\");" << endl;
+ QDomElement n2;
+ for (n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement())
+ createFormImpl(n2, objName, con, tab);
+ out << indent << objName << "->setForm(" << objName << "Form);" << endl;
+ }
+ }
+
+ if (extraFuncts.contains(QLatin1String("init()")))
+ out << indent << "init();" << endl;
+
+ // end of constructor
+ out << "}" << endl;
+ out << endl;
+
+ // destructor
+ out << "/*" << endl;
+ out << " * Destroys the object and frees any allocated resources" << endl;
+ out << " */" << endl;
+ out << nameOfClass << "::~" << bareNameOfClass << "()" << endl;
+ out << "{" << endl;
+ if (extraFuncts.contains(QLatin1String("destroy()")))
+ out << indent << "destroy();" << endl;
+ out << indent << "// no need to delete child widgets, Qt does it all for us" << endl;
+ out << "}" << endl;
+ out << endl;
+
+ // handle application events if required
+ bool needFontEventHandler = false;
+ bool needSqlTableEventHandler = false;
+ bool needSqlDataBrowserEventHandler = false;
+ nl = e.elementsByTagName(QLatin1String("widget"));
+ for (i = 0; i < (int) nl.length(); i++) {
+ if (!DomTool::propertiesOfType(nl.item(i).toElement() , QLatin1String("font")).isEmpty())
+ needFontEventHandler = true;
+ QString s = getClassName(nl.item(i).toElement());
+ if (s == QLatin1String("QDataTable") || s == QLatin1String("QDataBrowser")) {
+ if (!isFrameworkCodeGenerated(nl.item(i).toElement()))
+ continue;
+ if (s == QLatin1String("QDataTable"))
+ needSqlTableEventHandler = true;
+ if (s == QLatin1String("QDataBrowser"))
+ needSqlDataBrowserEventHandler = true;
+ }
+ if (needFontEventHandler && needSqlTableEventHandler && needSqlDataBrowserEventHandler)
+ break;
+ }
+
+ out << "/*" << endl;
+ out << " * Sets the strings of the subwidgets using the current" << endl;
+ out << " * language." << endl;
+ out << " */" << endl;
+ out << "void " << nameOfClass << "::languageChange()" << endl;
+ out << "{" << endl;
+ out << " retranslateUi(this);" << endl;
+ out << "}" << endl;
+ out << endl;
+
+ // create stubs for additional slots if necessary
+ if (!extraFuncts.isEmpty() && writeFunctImpl) {
+ it = extraFuncts.begin();
+ QStringList::Iterator it2 = extraFunctTyp.begin();
+ QStringList::Iterator it3 = extraFunctSpecifier.begin();
+ while (it != extraFuncts.end()) {
+ QString type = fixDeclaration(*it2);
+ if (type.isEmpty())
+ type = QLatin1String("void");
+ type = type.simplified();
+ QString fname = fixDeclaration(Parser::cleanArgs(*it));
+ if (!(*it3).startsWith(QLatin1String("pure"))) { // "pure virtual" or "pureVirtual"
+ out << type << " " << nameOfClass << "::" << fname << endl;
+ out << "{" << endl;
+ if (*it != QLatin1String("init()") && *it != QLatin1String("destroy()")) {
+ QRegExp numeric(QLatin1String("^(?:signed|unsigned|u?char|u?short|u?int"
+ "|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float"
+ "|double)$"));
+ QString retVal;
+
+ /*
+ We return some kind of dummy value to shut the
+ compiler up.
+
+ 1. If the type is 'void', we return nothing.
+
+ 2. If the type is 'bool', we return 'false'.
+
+ 3. If the type is 'unsigned long' or
+ 'quint16' or 'double' or similar, we
+ return '0'.
+
+ 4. If the type is 'Foo *', we return '0'.
+
+ 5. If the type is 'Foo &', we create a static
+ variable of type 'Foo' and return it.
+
+ 6. If the type is 'Foo', we assume there's a
+ default constructor and use it.
+ */
+ if (type != QLatin1String("void")) {
+ QStringList toks = type.split(QLatin1String(" "));
+ bool isBasicNumericType =
+ (toks.filter(numeric).count() == toks.count());
+
+ if (type == QLatin1String("bool")) {
+ retVal = QLatin1String("false");
+ } else if (isBasicNumericType || type.endsWith(QLatin1String("*"))) {
+ retVal = QLatin1String("0");
+ } else if (type.endsWith(QLatin1String("&"))) {
+ do {
+ type.chop(1);
+ } while (type.endsWith(QLatin1String(" ")));
+ retVal = QLatin1String("uic_temp_var");
+ out << indent << "static " << type << " " << retVal << ";" << endl;
+ } else {
+ retVal = type + QLatin1String("()");
+ }
+ }
+
+ out << indent << "qWarning(\"" << nameOfClass << "::" << fname << ": Not implemented yet\");" << endl;
+ if (!retVal.isEmpty())
+ out << indent << "return " << retVal << ";" << endl;
+ }
+ out << "}" << endl;
+ out << endl;
+ }
+ ++it;
+ ++it2;
+ ++it3;
+ }
+ }
+}
+
+
+/*! Creates form support implementation code for the widgets given
+ in \a e.
+
+ Traverses recursively over all children.
+ */
+
+void Ui3Reader::createFormImpl(const QDomElement& e, const QString& form, const QString& connection, const QString& table)
+{
+ if (e.tagName() == QLatin1String("widget")
+ && e.attribute(QLatin1String("class")) != QLatin1String("QDataTable")) {
+ QString field = getDatabaseInfo(e, QLatin1String("field"));
+ if (!field.isEmpty()) {
+ if (isWidgetInTable(e, connection, table))
+ out << indent << form << "Form->insert(" << getObjectName(e) << ", " << fixString(field) << ");" << endl;
+ }
+ }
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ createFormImpl(n, form, connection, table);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/main.cpp b/src/tools/uic3/main.cpp
new file mode 100644
index 0000000..d581016
--- /dev/null
+++ b/src/tools/uic3/main.cpp
@@ -0,0 +1,414 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include "domtool.h"
+#include "globaldefs.h"
+
+#include <QApplication>
+#include <QFile>
+#include <QFileInfo>
+#include <QStringList>
+#include <QDateTime>
+#include <QSettings>
+#include <stdio.h>
+#include <stdlib.h>
+
+#if defined Q_WS_WIN
+#include <qt_windows.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+int runUic3(int argc, char * argv[])
+{
+ bool impl = false;
+ bool wrap = false;
+ bool subcl = false;
+ bool extract = false;
+ bool imagecollection = false;
+ bool imagecollection_tmpfile = false;
+ bool convert = false;
+ QStringList images;
+ const char *error = 0;
+ const char* fileName = 0;
+ const char* className = 0;
+ const char* headerFile = 0;
+ const char* convertedUiFile = 0;
+ QByteArray outputFile;
+ QString qrcOutputFile;
+ QByteArray image_tmpfile;
+ const char* projectName = 0;
+ const char* trmacro = 0;
+ bool nofwd = false;
+ bool fix = false;
+ bool deps = false;
+ bool implicitIncludes = true;
+ QByteArray pchFile;
+
+
+ QApplication app(argc, argv, false);
+
+ for (int n = 1; n < argc && error == 0; n++) {
+ QByteArray arg = argv[n];
+ if (arg[0] == '-') { // option
+ QByteArray opt = arg.data() + 1;
+ if (opt[0] == 'o') { // output redirection
+ if (opt[1] == '\0') {
+ if (!(n < argc-1)) {
+ error = "Missing output-file name";
+ break;
+ }
+ outputFile = argv[++n];
+ } else
+ outputFile = opt.data() + 1;
+ } else if (opt[0] == 'i' || opt == "impl") {
+ impl = true;
+ if (opt == "impl" || opt[1] == '\0') {
+ if (!(n < argc-1)) {
+ error = "Missing name of header file";
+ break;
+ }
+ headerFile = argv[++n];
+ } else
+ headerFile = opt.data() + 1;
+ } else if (opt[0] == 'w' || opt == "wrap") {
+ wrap = true;
+ if (opt == "wrap" || opt[1] == '\0') {
+ if (!(n < argc-1)) {
+ error = "Missing name of converted ui file";
+ break;
+ }
+ convertedUiFile = argv[++n];
+ } else
+ convertedUiFile = opt.data() + 1;
+ } else if (opt == "extract") { // output redirection
+ extract = true;
+ if (!(n < argc-1)) {
+ error = "Missing output qrc-file name";
+ break;
+ }
+ qrcOutputFile = QFile::decodeName(argv[++n]);
+ } else if ( opt[0] == 'e' || opt == "embed" ) {
+ imagecollection = true;
+ if ( opt == "embed" || opt[1] == '\0' ) {
+ if ( !(n < argc-1) ) {
+ error = "Missing name of project";
+ break;
+ }
+ projectName = argv[++n];
+ } else {
+ projectName = opt.data() + 1;
+ }
+ if ( argc > n+1 && qstrcmp( argv[n+1], "-f" ) == 0 ) {
+ imagecollection_tmpfile = true;
+ image_tmpfile = argv[n+2];
+ n += 2;
+ }
+ } else if (opt == "d") {
+ deps = true;
+ } else if (opt == "no-implicit-includes") {
+ implicitIncludes = false;
+ } else if (opt == "nofwd") {
+ nofwd = true;
+ } else if (opt == "nounload") {
+ // skip
+ } else if (opt == "convert") {
+ convert = true;
+ } else if (opt == "subdecl") {
+ subcl = true;
+ if (!(n < argc-2)) {
+ error = "Missing arguments";
+ break;
+ }
+ className = argv[++n];
+ headerFile = argv[++n];
+ } else if (opt == "subimpl") {
+ subcl = true;
+ impl = true;
+ if (!(n < argc-2)) {
+ error = "Missing arguments";
+ break;
+ }
+ className = argv[++n];
+ headerFile = argv[++n];
+ } else if (opt == "tr") {
+ if (opt == "tr" || opt[1] == '\0') {
+ if (!(n < argc-1)) {
+ error = "Missing tr macro.";
+ break;
+ }
+ trmacro = argv[++n];
+ } else {
+ trmacro = opt.data() + 1;
+ }
+ } else if (opt == "L") {
+ if (!(n < argc-1)) {
+ error = "Missing plugin path.";
+ break;
+ }
+ ++n; // ignore the next argument
+ } else if (opt == "version") {
+ fprintf(stderr,
+ "Qt User Interface Compiler version %s\n",
+ QT_VERSION_STR);
+ return 1;
+ } else if (opt == "help") {
+ break;
+ } else if (opt == "fix") {
+ fix = true;
+ } else if (opt == "pch") {
+ if (!(n < argc-1)) {
+ error = "Missing name of PCH file";
+ break;
+ }
+ pchFile = argv[++n];
+ } else {
+ error = "Unrecognized option";
+ }
+ } else {
+ if (imagecollection && !imagecollection_tmpfile)
+ images << QLatin1String(argv[n]);
+ else if (fileName) // can handle only one file
+ error = "Too many input files specified";
+ else
+ fileName = argv[n];
+ }
+ }
+
+ if (argc < 2 || error || (!fileName && !imagecollection)) {
+ fprintf(stderr,
+ "Qt User Interface Compiler version %s\n",
+ QT_VERSION_STR);
+ if (error)
+ fprintf(stderr, "uic: %s\n", error);
+
+ fprintf(stderr, "Usage: %s [options] [mode] <uifile>\n\n"
+ "Convert a UI file to version 4:\n"
+ " %s [options] -convert <uifile>\n"
+ "Generate declaration:\n"
+ " %s [options] <uifile>\n"
+ "\t<uiheaderfile> name of the data file\n"
+ " %s [options] -decl <uiheaderfile> <uifile>\n"
+ "\t<uiheaderfile> name of the data file\n"
+ " %s [options] -wrap <converteduifile> <uifile>\n"
+ "\t<converteduifile> name of the converted ui file\n"
+ "Generate implementation:\n"
+ " %s [options] -impl <headerfile> <uifile>\n"
+ "\t<headerfile> name of the declaration file\n"
+ "Generate image collection:\n"
+ " %s [options] -embed <project> <image1> <image2> <image3> ...\n"
+ "or\n"
+ " %s [options] -embed <project> -f <temporary file containing image names>\n"
+ "\t<project> project name\n"
+ "\t<image[1-N]> image files\n"
+ "Generate subclass declaration:\n"
+ " %s [options] -subdecl <subclassname> <baseclassheaderfile> <uifile>\n"
+ "\t<subclassname> name of the subclass to generate\n"
+ "\t<baseclassheaderfile> declaration file of the baseclass\n"
+ "Generate subclass implementation:\n"
+ " %s [options] -subimpl <subclassname> <subclassheaderfile> <uifile>\n"
+ "\t<subclassname> name of the subclass to generate\n"
+ "\t<subclassheaderfile> declaration file of the subclass\n"
+ "Options:\n"
+ "\t-o file Write output to file rather than stdout\n"
+ "\t-extract qrcFile Create resource file and extract embedded images into \"image\" dir\n"
+ "\t-pch file Add #include \"file\" as the first statement in implementation\n"
+ "\t-nofwd Omit forward declarations of custom classes\n"
+ "\t-no-implicit-includes Do not generate #include-directives for custom classes\n"
+ "\t-nounload Don't unload plugins after processing\n"
+ "\t-tr func Use func() instead of tr() for i18n\n"
+ "\t-L path Additional plugin search path\n"
+ "\t-version Display version of uic\n"
+ "\t-help Display this information\n"
+ , argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0], argv[0]
+ );
+ return 1;
+ }
+
+ if (imagecollection_tmpfile) {
+ QFile ifile(QFile::decodeName(image_tmpfile));
+ if (ifile.open(QIODevice::ReadOnly)) {
+ QTextStream ts(&ifile);
+ QString s = ts.read();
+ s = s.simplified();
+ images = s.split(QLatin1Char(' '));
+ for (QStringList::Iterator it = images.begin(); it != images.end(); ++it)
+ *it = (*it).simplified();
+ }
+ }
+
+ QFile fileOut;
+ if (!outputFile.isEmpty()) {
+ fileOut.setFileName(QFile::decodeName(outputFile));
+ if (!fileOut.open(QIODevice::WriteOnly)) {
+ fprintf(stderr, "%s: Could not open output file '%s'\n", argv[0], outputFile.data());
+ return 1;
+ }
+ } else {
+ fileOut.open(QIODevice::WriteOnly, stdout);
+ }
+
+ QTextStream out(&fileOut);
+
+ Ui3Reader ui3(out);
+ ui3.setExtractImages(extract, qrcOutputFile);
+
+ if (projectName && imagecollection) {
+ out.setEncoding(QTextStream::Latin1);
+ ui3.embed(projectName, images);
+ return 0;
+ }
+
+ out.setEncoding(QTextStream::UnicodeUTF8);
+
+ QFile file(QFile::decodeName(fileName));
+ if (!file.open(QIODevice::ReadOnly)) {
+ fprintf(stderr, "%s: Could not open file '%s'\n", argv[0], fileName);
+ return 1;
+ }
+
+ QDomDocument doc;
+ QString errMsg;
+ int errLine;
+ if (!doc.setContent(&file, &errMsg, &errLine)) {
+ fprintf(stderr, "%s: Failed to parse %s: %s in line %d\n", argv[0], fileName, errMsg.latin1(), errLine);
+ return 1;
+ }
+
+ QDomElement e = doc.firstChild().toElement();
+ double version = e.attribute(QLatin1String("version"), QLatin1String("3.0")).toDouble();
+
+ if (version > 3.3) {
+ fprintf(stderr, "%s: File generated with too recent version of Qt Designer (%s vs. %s)\n",
+ argv[0], e.attribute(QLatin1String("version")).latin1(), "3.3");
+ return 1;
+ }
+
+ DomTool::fixDocument(doc);
+
+ if (fix) {
+ out << doc.toString();
+ return 0;
+ }
+
+ if (imagecollection) {
+ out.setEncoding(QTextStream::Latin1);
+ ui3.embed(projectName, images);
+ return 0;
+ } else if (deps) {
+ QStringList globalIncludes, localIncludes;
+ ui3.computeDeps(e, globalIncludes, localIncludes, impl);
+
+ foreach (QString i, globalIncludes)
+ printf("%s\n", i.toLatin1().constData());
+
+ foreach (QString i, localIncludes)
+ printf("%s\n", i.toLatin1().constData());
+
+ if (impl)
+ printf("%s\n", headerFile);
+
+ return 0;
+ } else if (convert) {
+ ui3.generateUi4(QFile::decodeName(fileName), QFile::decodeName(outputFile), doc, implicitIncludes);
+ return 0;
+ }
+
+ QString protector;
+ if (subcl && className && !impl)
+ protector = QString::fromUtf8(className).toUpper() + QLatin1String("_H");
+
+ if (!protector.isEmpty()) {
+ out << "#ifndef " << protector << endl;
+ out << "#define " << protector << endl;
+ }
+
+ if (!pchFile.isEmpty() && impl) {
+ out << "#include \"" << pchFile << "\" // PCH include" << endl;
+ }
+
+ if (headerFile) {
+ out << "#include \"" << headerFile << "\"" << endl << endl;
+ }
+
+ QString convertedUi;
+ if (wrap) {
+ convertedUi = QFile::decodeName(convertedUiFile);
+ int pos = convertedUi.lastIndexOf(QLatin1String(".ui"));
+ if (pos > 0) {
+ convertedUi = convertedUi.mid(0, pos);
+ convertedUi += QLatin1String(".h");
+ }
+ convertedUi = QLatin1String("ui_") + convertedUi;
+ }
+
+ ui3.generate(QFile::decodeName(fileName),
+ QFile::decodeName(outputFile),
+ doc,
+ !impl,
+ subcl,
+ QString::fromUtf8(trmacro),
+ QString::fromUtf8(className),
+ nofwd,
+ implicitIncludes,
+ convertedUi);
+
+ if (!protector.isEmpty()) {
+ out << endl;
+ out << "#endif // " << protector << endl;
+ }
+
+ if (fileOut.error() != QFile::NoError) {
+ fprintf(stderr, "%s: Error writing to file\n", argv[0]);
+ if (!outputFile.isEmpty())
+ remove(outputFile);
+ }
+
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+int main(int argc, char * argv[])
+{
+ return QT_PREPEND_NAMESPACE(runUic3(argc, argv));
+}
diff --git a/src/tools/uic3/object.cpp b/src/tools/uic3/object.cpp
new file mode 100644
index 0000000..b20f3c4
--- /dev/null
+++ b/src/tools/uic3/object.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include "parser.h"
+#include "domtool.h"
+#include "globaldefs.h"
+#include <QRegExp>
+#include <QStringList>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+/*! Extracts a named object property from \a e.
+ */
+QDomElement Ui3Reader::getObjectProperty( const QDomElement& e, const QString& name )
+{
+ QDomElement n;
+ for ( n = e.firstChild().toElement();
+ !n.isNull();
+ n = n.nextSibling().toElement() ) {
+ if ( n.tagName() == QLatin1String("property") && n.toElement().attribute(QLatin1String("name")) == name )
+ return n;
+ }
+ return n;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/parser.cpp b/src/tools/uic3/parser.cpp
new file mode 100644
index 0000000..744dd30
--- /dev/null
+++ b/src/tools/uic3/parser.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "parser.h"
+#include <QObject>
+#include <QStringList>
+
+QT_BEGIN_NAMESPACE
+
+QString Parser::cleanArgs(const QString &func)
+{
+ QString slot(func);
+ int begin = slot.indexOf(QLatin1String("(")) + 1;
+ QString args = slot.mid(begin);
+ args = args.left(args.indexOf(QLatin1String(")")));
+ QStringList lst = args.split(QLatin1Char(','));
+ QString res = slot.left(begin);
+ for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it) {
+ if (it != lst.begin())
+ res += QLatin1String(",");
+ QString arg = *it;
+ int pos = 0;
+ if ((pos = arg.indexOf(QLatin1Char('&'))) != -1) {
+ arg = arg.left(pos + 1);
+ } else if ((pos = arg.indexOf(QLatin1Char('*'))) != -1) {
+ arg = arg.left(pos + 1);
+ } else {
+ arg = arg.simplified();
+ if ((pos = arg.indexOf(QLatin1Char(':'))) != -1)
+ arg = arg.left(pos).simplified() + QLatin1String(":") + arg.mid(pos + 1).simplified();
+ QStringList l = arg.split(QLatin1Char(' '));
+ if (l.count() == 2) {
+ if (l[0] != QLatin1String("const")
+ && l[0] != QLatin1String("unsigned")
+ && l[0] != QLatin1String("var"))
+ arg = l[0];
+ } else if (l.count() == 3) {
+ arg = l[0] + QLatin1String(" ") + l[1];
+ }
+ }
+ res += arg;
+ }
+ res += QLatin1String(")");
+ return res;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/parser.h b/src/tools/uic3/parser.h
new file mode 100644
index 0000000..32eb2f7
--- /dev/null
+++ b/src/tools/uic3/parser.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <QString>
+
+QT_BEGIN_NAMESPACE
+
+class Parser
+{
+public:
+ static QString cleanArgs( const QString &func );
+};
+
+QT_END_NAMESPACE
+
+#endif // PARSER_H
diff --git a/src/tools/uic3/qt3to4.cpp b/src/tools/uic3/qt3to4.cpp
new file mode 100644
index 0000000..9e5b64b
--- /dev/null
+++ b/src/tools/uic3/qt3to4.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qt3to4.h"
+
+#include <QApplication>
+#include <QDir>
+#include <QFile>
+#include <QHash>
+#include <QLibraryInfo>
+#include <QXmlDefaultHandler>
+#include <QXmlSimpleReader>
+
+QT_BEGIN_NAMESPACE
+
+class ContentHandler: public QXmlDefaultHandler
+{
+public:
+ typedef QPair<QString, QString> Rule;
+ typedef QList<Rule> RuleList;
+
+public:
+ ContentHandler() {}
+
+ inline RuleList renamedHeaders() const
+ { return rules(QString::fromLatin1("RenamedHeader")); }
+
+ inline RuleList renamedClasses() const
+ { return rules(QString::fromLatin1("RenamedClass")); }
+
+ inline RuleList renamedEnums() const
+ { return rules(QString::fromLatin1("RenamedEnumvalue")); }
+
+ inline RuleList rules(const QString &kind) const
+ { return m_rules.value(kind); }
+
+ virtual bool startDocument()
+ {
+ m_rules.clear();
+ m_state.current.clear();
+ m_state.kind.clear();
+ m_state.q3.clear();
+ m_state.q4.clear();
+
+ return true;
+ }
+
+ virtual bool startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &attrs)
+ {
+ if (qName == QLatin1String("item")) {
+ m_state.kind = attrs.value(QLatin1String("Type"));
+
+ m_state.current.clear();
+ m_state.q3.clear();
+ m_state.q4.clear();
+
+ if (!m_rules.contains(m_state.kind))
+ m_rules[m_state.kind].clear();
+
+ return true;
+ }
+
+ return true; // ### only if it is a valid tag
+ }
+
+
+ virtual bool endElement(const QString &, const QString &, const QString &qName)
+ {
+ if (qName == QLatin1String("Qt3")) {
+ m_state.q3 = m_state.current.trimmed();
+ } else if (qName == QLatin1String("Qt4")) {
+ m_state.q4 = m_state.current.trimmed();
+ } else if (qName == QLatin1String("item")
+ && (m_state.kind == QLatin1String("RenamedHeader")
+ || m_state.kind == QLatin1String("RenamedEnumvalue")
+ || m_state.kind == QLatin1String("RenamedClass"))) {
+ Rule r(m_state.q3, m_state.q4);
+ m_rules[m_state.kind].append(r);
+ }
+
+ m_state.current.clear();
+ return true;
+ }
+
+ virtual bool characters(const QString &ch)
+ { m_state.current += ch; return true; }
+
+ virtual bool error(const QXmlParseException &e)
+ { Q_UNUSED(e); Q_ASSERT(0); return true; }
+
+ virtual bool fatalError(const QXmlParseException &e)
+ { Q_UNUSED(e); Q_ASSERT(0); return true; }
+
+ virtual bool warning(const QXmlParseException &e)
+ { Q_UNUSED(e); Q_ASSERT(0); return true; }
+
+private:
+ QHash<QString, RuleList> m_rules;
+
+ struct state
+ {
+ QString current;
+ QString kind;
+ QString q3;
+ QString q4;
+ } m_state;
+};
+
+void Porting::readXML(RuleList *renamedHeaders, RuleList *renamedClasses, RuleList *renamedEnums)
+{
+ QString fileName = QLatin1String("q3porting.xml");
+ QString filePath;
+ //check QLibraryInfo::DataPath/filename
+ filePath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::DataPath) + QLatin1String("/") + fileName) ;
+
+ //check QLibraryInfo::PrefixPath/tools/porting/src/filename
+ if (!QFile::exists(filePath))
+ filePath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::PrefixPath) + QLatin1String("/tools/porting/src/") + fileName);
+
+ // for bootstrapping, look in the rules file in a location
+ // relative to where it would be in the source tree
+ if (!QFile::exists(filePath))
+ filePath = QDir::cleanPath(QApplication::instance()->applicationDirPath() + QLatin1String("/../tools/porting/src/") + fileName);
+
+ if (!QFile::exists(filePath)) {
+ fprintf(stderr, "Error: Could not find rules file: %s\n", fileName.toLatin1().constData());
+ Q_ASSERT(0);
+ }
+
+ ContentHandler handler;
+
+ QXmlSimpleReader reader;
+ reader.setContentHandler(&handler);
+ reader.setErrorHandler(&handler);
+
+ QFile file(filePath);
+ file.open(QFile::ReadOnly);
+
+ QXmlInputSource source(file);
+ bool ok = reader.parse(&source);
+ Q_UNUSED(ok);
+ Q_ASSERT(ok);
+
+ if (renamedHeaders)
+ *renamedHeaders = handler.renamedHeaders();
+ if (renamedClasses)
+ *renamedClasses = handler.renamedClasses();
+ if (renamedEnums)
+ *renamedEnums = handler.renamedEnums();
+
+}
+
+Porting::Porting()
+{
+ readXML(&m_renamedHeaders, &m_renamedClasses, &m_renamedEnums);
+}
+
+int Porting::findRule(const RuleList &rules, const QString &q3)
+{
+ for (int i=0; i<rules.count(); ++i)
+ if (rules.at(i).first == q3)
+ return i;
+ return -1;
+}
+
+QString Porting::renameHeader(const QString &headerName) const
+{
+ int index = findRule(m_renamedHeaders, headerName);
+ return index == -1 ? headerName : m_renamedHeaders.at(index).second;
+}
+
+QString Porting::renameClass(const QString &className) const
+{
+ if (className == QLatin1String("QSplitter")) // We don't want a Q3Splitter, ever!
+ return className;
+
+ int index = findRule(m_renamedClasses, className);
+ return index == -1 ? className : m_renamedClasses.at(index).second;
+}
+
+QString Porting::renameEnumerator(const QString &enumName) const
+{
+ int index = findRule(m_renamedEnums, enumName);
+ return index == -1 ? QString() : m_renamedEnums.at(index).second;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/qt3to4.h b/src/tools/uic3/qt3to4.h
new file mode 100644
index 0000000..806a209
--- /dev/null
+++ b/src/tools/uic3/qt3to4.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3TO4_H
+#define QT3TO4_H
+
+#include <QString>
+#include <QList>
+#include <QPair>
+
+QT_BEGIN_NAMESPACE
+
+class Porting
+{
+public:
+ typedef QPair<QString, QString> Rule;
+ typedef QList<Rule> RuleList;
+
+public:
+ Porting();
+
+ inline RuleList renamedHeaders() const
+ { return m_renamedHeaders; }
+
+ inline RuleList renamedClasses() const
+ { return m_renamedClasses; }
+
+ QString renameHeader(const QString &headerName) const;
+ QString renameClass(const QString &className) const;
+ QString renameEnumerator(const QString &enumName) const;
+
+protected:
+ static void readXML(RuleList *renamedHeaders, RuleList *renamedClasses, RuleList *renamedEnums);
+ static int findRule(const RuleList &rules, const QString &q3);
+
+private:
+ RuleList m_renamedHeaders;
+ RuleList m_renamedClasses;
+ RuleList m_renamedEnums;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT3TO4_H
diff --git a/src/tools/uic3/subclassing.cpp b/src/tools/uic3/subclassing.cpp
new file mode 100644
index 0000000..e590ab7
--- /dev/null
+++ b/src/tools/uic3/subclassing.cpp
@@ -0,0 +1,362 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include "parser.h"
+#include "domtool.h"
+#include "globaldefs.h"
+#include <QFile>
+#include <QStringList>
+#include <QDateTime>
+#include <QRegExp>
+#include <stdio.h>
+#include <stdlib.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ Creates a declaration ( headerfile ) for a subclass \a subClass
+ of the form given in \a e
+
+ \sa createSubImpl()
+ */
+void Ui3Reader::createSubDecl( const QDomElement &e, const QString& subClass )
+{
+ QDomElement n;
+ QDomNodeList nl;
+ int i;
+
+ QString objClass = getClassName( e );
+ if ( objClass.isEmpty() )
+ return;
+
+ out << "class " << subClass << " : public " << nameOfClass << endl;
+ out << "{" << endl;
+
+/* tmake ignore Q_OBJECT */
+ out << " Q_OBJECT" << endl;
+ out << endl;
+ out << "public:" << endl;
+
+ // constructor
+ if ( objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard") ) {
+ out << " " << subClass << "( QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0 );" << endl;
+ } else { // standard QWidget
+ out << " " << subClass << "( QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0 );" << endl;
+ }
+
+ // destructor
+ out << " ~" << subClass << "();" << endl;
+ out << endl;
+
+ // find additional functions
+ QStringList publicSlots, protectedSlots, privateSlots;
+ QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;
+ QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;
+ QStringList publicFuncts, protectedFuncts, privateFuncts;
+ QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;
+ QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
+ for ( i = 0; i < (int) nl.length(); i++ ) {
+ n = nl.item(i).toElement();
+ if ( n.parentNode().toElement().tagName() != QLatin1String("slots")
+ && n.parentNode().toElement().tagName() != QLatin1String("connections") )
+ continue;
+ if ( n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++") )
+ continue;
+ QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if ( functionName.endsWith(QLatin1String(";")))
+ functionName = functionName.left( functionName.length() - 1 );
+ QString specifier = n.attribute(QLatin1String("specifier"));
+ QString access = n.attribute(QLatin1String("access"));
+ if ( access == QLatin1String("protected") ) {
+ protectedSlots += functionName;
+ protectedSlotTypes += returnType;
+ protectedSlotSpecifier += specifier;
+ } else if ( access == QLatin1String("private") ) {
+ privateSlots += functionName;
+ privateSlotTypes += returnType;
+ privateSlotSpecifier += specifier;
+ } else {
+ publicSlots += functionName;
+ publicSlotTypes += returnType;
+ publicSlotSpecifier += specifier;
+ }
+ }
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
+ for ( i = 0; i < (int) nl.length(); i++ ) {
+ n = nl.item(i).toElement();
+ if ( n.parentNode().toElement().tagName() != QLatin1String("functions") )
+ continue;
+ if ( n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++") )
+ continue;
+ QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if ( functionName.endsWith(QLatin1String(";")) )
+ functionName = functionName.left( functionName.length() - 1 );
+ QString specifier = n.attribute(QLatin1String("specifier"));
+ QString access = n.attribute(QLatin1String("access"));
+ if ( access == QLatin1String("protected") ) {
+ protectedFuncts += functionName;
+ protectedFunctRetTyp += returnType;
+ protectedFunctSpec += specifier;
+ } else if ( access == QLatin1String("private") ) {
+ privateFuncts += functionName;
+ privateFunctRetTyp += returnType;
+ privateFunctSpec += specifier;
+ } else {
+ publicFuncts += functionName;
+ publicFunctRetTyp += returnType;
+ publicFunctSpec += specifier;
+ }
+ }
+
+ if ( !publicFuncts.isEmpty() )
+ writeFunctionsSubDecl( publicFuncts, publicFunctRetTyp, publicFunctSpec );
+
+ // create public additional slots
+ if ( !publicSlots.isEmpty() ) {
+ out << "public slots:" << endl;
+ writeFunctionsSubDecl( publicSlots, publicSlotTypes, publicSlotSpecifier );
+ }
+
+ if ( !protectedFuncts.isEmpty() ) {
+ out << "protected:" << endl;
+ writeFunctionsSubDecl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec );
+ }
+
+ // create protected additional slots
+ if ( !protectedSlots.isEmpty() ) {
+ out << "protected slots:" << endl;
+ writeFunctionsSubDecl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier );
+ }
+
+ if ( !privateFuncts.isEmpty() ) {
+ out << "private:" << endl;
+ writeFunctionsSubDecl( privateFuncts, privateFunctRetTyp, privateFunctSpec );
+ }
+
+ // create private additional slots
+ if ( !privateSlots.isEmpty() ) {
+ out << "private slots:" << endl;
+ writeFunctionsSubDecl( privateSlots, privateSlotTypes, privateSlotSpecifier );
+ }
+ out << "};" << endl;
+}
+
+void Ui3Reader::writeFunctionsSubDecl( const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst )
+{
+ QStringList::ConstIterator it, it2, it3;
+ for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin();
+ it != fuLst.end(); ++it, ++it2, ++it3 ) {
+ QString type = fixDeclaration(*it2);
+ if ( type.isEmpty() )
+ type = QLatin1String("void");
+ if ( *it3 == QLatin1String("non virtual") )
+ continue;
+ out << " " << type << " " << fixDeclaration(*it) << ";" << endl;
+ }
+ out << endl;
+}
+
+/*!
+ Creates an implementation for a subclass \a subClass of the form
+ given in \a e
+
+ \sa createSubDecl()
+ */
+void Ui3Reader::createSubImpl( const QDomElement &e, const QString& subClass )
+{
+ QDomElement n;
+ QDomNodeList nl;
+ int i;
+
+ QString objClass = getClassName( e );
+ if ( objClass.isEmpty() )
+ return;
+
+ // constructor
+ if ( objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard") ) {
+ out << "/* " << endl;
+ out << " * Constructs a " << subClass << " which is a child of 'parent', with the " << endl;
+ out << " * name 'name' and widget flags set to 'f' " << endl;
+ out << " *" << endl;
+ out << " * The " << objClass.mid(1).toLower() << " will by default be modeless, unless you set 'modal' to" << endl;
+ out << " * true to construct a modal " << objClass.mid(1).toLower() << "." << endl;
+ out << " */" << endl;
+ out << subClass << "::" << subClass << "( QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl )" << endl;
+ out << " : " << nameOfClass << "( parent, name, modal, fl )" << endl;
+ } else { // standard QWidget
+ out << "/* " << endl;
+ out << " * Constructs a " << subClass << " which is a child of 'parent', with the " << endl;
+ out << " * name 'name' and widget flags set to 'f' " << endl;
+ out << " */" << endl;
+ out << subClass << "::" << subClass << "( QWidget* parent, const char* name, Qt::WindowFlags fl )" << endl;
+ out << " : " << nameOfClass << "( parent, name, fl )" << endl;
+ }
+ out << "{" << endl;
+ out << "}" << endl;
+ out << endl;
+
+ // destructor
+ out << "/* " << endl;
+ out << " * Destroys the object and frees any allocated resources" << endl;
+ out << " */" << endl;
+ out << subClass << "::~" << subClass << "()" << endl;
+ out << "{" << endl;
+ out << " // no need to delete child widgets, Qt does it all for us" << endl;
+ out << "}" << endl;
+ out << endl;
+
+
+ // find additional functions
+ QStringList publicSlots, protectedSlots, privateSlots;
+ QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;
+ QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;
+ QStringList publicFuncts, protectedFuncts, privateFuncts;
+ QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;
+ QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
+ for ( i = 0; i < (int) nl.length(); i++ ) {
+ n = nl.item(i).toElement();
+ if ( n.parentNode().toElement().tagName() != QLatin1String("slots")
+ && n.parentNode().toElement().tagName() != QLatin1String("connections") )
+ continue;
+ if ( n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++") )
+ continue;
+ QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if ( functionName.endsWith(QLatin1String(";")) )
+ functionName = functionName.left( functionName.length() - 1 );
+ QString specifier = n.attribute(QLatin1String("specifier"));
+ QString access = n.attribute(QLatin1String("access"));
+ if ( access == QLatin1String("protected") ) {
+ protectedSlots += functionName;
+ protectedSlotTypes += returnType;
+ protectedSlotSpecifier += specifier;
+ } else if ( access == QLatin1String("private") ) {
+ privateSlots += functionName;
+ privateSlotTypes += returnType;
+ privateSlotSpecifier += specifier;
+ } else {
+ publicSlots += functionName;
+ publicSlotTypes += returnType;
+ publicSlotSpecifier += specifier;
+ }
+ }
+
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
+ for ( i = 0; i < (int) nl.length(); i++ ) {
+ n = nl.item(i).toElement();
+ if ( n.parentNode().toElement().tagName() != QLatin1String("functions") )
+ continue;
+ if ( n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++") )
+ continue;
+ QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
+ QString functionName = n.firstChild().toText().data().trimmed();
+ if ( functionName.endsWith(QLatin1String(";")) )
+ functionName = functionName.left( functionName.length() - 1 );
+ QString specifier = n.attribute(QLatin1String("specifier"));
+ QString access = n.attribute(QLatin1String("access"));
+ if ( access == QLatin1String("protected") ) {
+ protectedFuncts += functionName;
+ protectedFunctRetTyp += returnType;
+ protectedFunctSpec += specifier;
+ } else if ( access == QLatin1String("private") ) {
+ privateFuncts += functionName;
+ privateFunctRetTyp += returnType;
+ privateFunctSpec += specifier;
+ } else {
+ publicFuncts += functionName;
+ publicFunctRetTyp += returnType;
+ publicFunctSpec += specifier;
+ }
+ }
+
+ if ( !publicFuncts.isEmpty() )
+ writeFunctionsSubImpl( publicFuncts, publicFunctRetTyp, publicFunctSpec, subClass, QLatin1String("public function"));
+
+ // create stubs for public additional slots
+ if ( !publicSlots.isEmpty() )
+ writeFunctionsSubImpl( publicSlots, publicSlotTypes, publicSlotSpecifier, subClass, QLatin1String("public slot"));
+
+ if ( !protectedFuncts.isEmpty() )
+ writeFunctionsSubImpl( protectedFuncts, protectedFunctRetTyp, protectedFunctSpec, subClass, QLatin1String("protected function"));
+
+ // create stubs for protected additional slots
+ if ( !protectedSlots.isEmpty() )
+ writeFunctionsSubImpl( protectedSlots, protectedSlotTypes, protectedSlotSpecifier, subClass, QLatin1String("protected slot"));
+
+ if ( !privateFuncts.isEmpty() )
+ writeFunctionsSubImpl( privateFuncts, privateFunctRetTyp, privateFunctSpec, subClass, QLatin1String("private function"));
+
+ // create stubs for private additional slots
+ if ( !privateSlots.isEmpty() )
+ writeFunctionsSubImpl( privateSlots, privateSlotTypes, privateSlotSpecifier, subClass, QLatin1String("private slot"));
+}
+
+void Ui3Reader::writeFunctionsSubImpl( const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst,
+ const QString &subClass, const QString &descr )
+{
+ QStringList::ConstIterator it, it2, it3;
+ for ( it = fuLst.begin(), it2 = typLst.begin(), it3 = specLst.begin();
+ it != fuLst.end(); ++it, ++it2, ++it3 ) {
+ QString type = fixDeclaration(*it2);
+ if ( type.isEmpty() )
+ type = QLatin1String("void");
+ if ( *it3 == QLatin1String("non virtual") )
+ continue;
+ out << "/*" << endl;
+ out << " * " << descr << endl;
+ out << " */" << endl;
+ out << type << " " << subClass << "::" << fixDeclaration(*it) << endl;
+ out << "{" << endl;
+ out << " qWarning( \"" << subClass << "::" << fixDeclaration(*it) << " not yet implemented!\" );" << endl;
+ out << "}" << endl << endl;
+ }
+ out << endl;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/ui3reader.cpp b/src/tools/uic3/ui3reader.cpp
new file mode 100644
index 0000000..1ba4b2f
--- /dev/null
+++ b/src/tools/uic3/ui3reader.cpp
@@ -0,0 +1,639 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui3reader.h"
+#include "parser.h"
+#include "domtool.h"
+#include "ui4.h"
+#include "widgetinfo.h"
+#include "globaldefs.h"
+#include "qt3to4.h"
+
+#include <QFile>
+#include <QDateTime>
+#include <QRegExp>
+#include <QXmlStreamWriter>
+#include <QtDebug>
+#include <stdio.h>
+#include <stdlib.h>
+
+QT_BEGIN_NAMESPACE
+
+bool Ui3Reader::isMainWindow = false;
+
+static QString lineColDebug(int line, int col)
+{
+ if (line >= 0) {
+ const QString ret = QString::fromLatin1("Line: %1%2");
+ return ret.arg(line).arg(col >= 0 ? QString::fromLatin1(" Column: %1").arg(col) : QString());
+ }
+ return QString();
+}
+
+void Ui3Reader::errorInvalidProperty(const QString &propertyName, const QString &widgetName, const QString &widgetClass, int line, int col)
+{
+ fprintf(stderr, "uic3: property `%s' for widget `%s' of type `%s' is not supported. %s\n",
+ propertyName.toLatin1().constData(),
+ widgetName.toLatin1().constData(),
+ widgetClass.toLatin1().constData(),
+ lineColDebug(line, col).toLocal8Bit().constData());
+}
+
+void Ui3Reader::errorInvalidSignal(const QString &signal, const QString &widgetName, const QString &widgetClass, int line, int col)
+{
+ fprintf(stderr, "uic3: signal `%s' for widget `%s' of type `%s' is not supported; connection may fail. %s\n",
+ signal.toLatin1().constData(), widgetName.toLatin1().constData(),
+ widgetClass.toLatin1().constData(),
+ lineColDebug(line, col).toLocal8Bit().constData());
+}
+
+void Ui3Reader::errorInvalidSlot(const QString &slot, const QString &widgetName, const QString &widgetClass, int line, int col)
+{
+ fprintf(stderr, "uic3: slot `%s' for widget `%s' of type `%s' is not supported; connection may fail. %s\n",
+ slot.toLatin1().constData(),
+ widgetName.toLatin1().constData(),
+ widgetClass.toLatin1().constData(),
+ lineColDebug(line, col).toLocal8Bit().constData());
+}
+
+QString Ui3Reader::getComment(const QDomNode& n)
+{
+ QDomNode child = n.firstChild();
+ while (!child.isNull()) {
+ if (child.toElement().tagName() == QLatin1String("comment"))
+ return child.toElement().firstChild().toText().data();
+ child = child.nextSibling();
+ }
+ return QString();
+}
+
+QString Ui3Reader::mkBool(bool b)
+{
+ return b ? QLatin1String("true") : QLatin1String("false");
+}
+
+QString Ui3Reader::mkBool(const QString& s)
+{
+ return mkBool(s == QLatin1String("true") || s == QLatin1String("1"));
+}
+
+bool Ui3Reader::toBool(const QString& s)
+{
+ return s == QLatin1String("true") || s.toInt() != 0;
+}
+
+QString Ui3Reader::fixString(const QString &str, bool encode)
+{
+ QString s;
+ if (!encode) {
+ s = str;
+ s.replace(QLatin1String("\\"), QLatin1String("\\\\"));
+ s.replace(QLatin1String("\""), QLatin1String("\\\""));
+ s.replace(QLatin1String("\r"), QLatin1String(""));
+ s.replace(QLatin1String("\n"), QLatin1String("\\n\"\n\""));
+ } else {
+ QByteArray utf8 = str.utf8();
+ const int l = utf8.length();
+ for (int i = 0; i < l; ++i)
+ s += QLatin1String("\\x") + QString::number((uchar)utf8[i], 16);
+ }
+
+ return QLatin1String("\"") + s + QLatin1String("\"");
+}
+
+QString Ui3Reader::trcall(const QString& sourceText, const QString& comment)
+{
+ if (sourceText.isEmpty() && comment.isEmpty())
+ return QLatin1String("QString()");
+
+ QString t = trmacro;
+ bool encode = false;
+ if (t.isNull()) {
+ t = QLatin1String("tr");
+ for (int i = 0; i < (int) sourceText.length(); i++) {
+ if (sourceText[i].unicode() >= 0x80) {
+ t = QLatin1String("trUtf8");
+ encode = true;
+ break;
+ }
+ }
+ }
+
+ if (comment.isEmpty()) {
+ return t + QLatin1String("(") + fixString(sourceText, encode) + QLatin1String(")");
+ } else {
+ return t + QLatin1String("(")
+ + fixString(sourceText, encode)
+ + QLatin1String(", ")
+ + fixString(comment, encode) + QLatin1String(")");
+ }
+}
+
+QString Ui3Reader::mkStdSet(const QString& prop)
+{
+ return QLatin1String("set") + prop[0].toUpper() + prop.mid(1);
+}
+
+void Ui3Reader::init()
+{
+ outputFileName.clear();
+ trmacro.clear();
+ nofwd = false;
+
+ fileName.clear();
+ writeFunctImpl = true;
+ defMargin = BOXLAYOUT_DEFAULT_MARGIN;
+ defSpacing = BOXLAYOUT_DEFAULT_SPACING;
+ externPixmaps = false;
+ indent = QLatin1String(" "); // default indent
+
+ item_used = cg_used = pal_used = 0;
+
+ layouts.clear();
+ layouts << QLatin1String("hbox") << QLatin1String("vbox") << QLatin1String("grid");
+ tags = layouts;
+ tags << QLatin1String("widget");
+
+ nameOfClass.clear();
+ namespaces.clear();
+ bareNameOfClass.clear();
+}
+
+QDomElement Ui3Reader::parse(const QDomDocument &doc)
+{
+ root = doc.firstChild().toElement();
+ widget = QDomElement();
+
+ pixmapLoaderFunction = getPixmapLoaderFunction(doc.firstChild().toElement());
+ nameOfClass = getFormClassName(doc.firstChild().toElement());
+
+ uiFileVersion = doc.firstChild().toElement().attribute(QLatin1String("version"));
+ stdsetdef = toBool(doc.firstChild().toElement().attribute(QLatin1String("stdsetdef")));
+
+ if (doc.firstChild().isNull() || doc.firstChild().firstChild().isNull())
+ return widget;
+
+ QDomElement e = doc.firstChild().firstChild().toElement();
+ while (!e.isNull()) {
+ if (e.tagName() == QLatin1String("widget")) {
+ widget = e;
+ } else if (e.tagName() == QLatin1String("pixmapinproject")) {
+ externPixmaps = true;
+ } else if (e.tagName() == QLatin1String("layoutdefaults")) {
+ defSpacing = e.attribute(QLatin1String("spacing"), defSpacing.toString());
+ defMargin = e.attribute(QLatin1String("margin"), defMargin.toString());
+ } else if (e.tagName() == QLatin1String("layoutfunctions")) {
+ defSpacing = e.attribute(QLatin1String("spacing"), defSpacing.toString());
+ bool ok;
+ defSpacing.toInt(&ok);
+ if (!ok) {
+ QString buf = defSpacing.toString();
+ defSpacing = buf.append(QLatin1String("()"));
+ }
+ defMargin = e.attribute(QLatin1String("margin"), defMargin.toString());
+ defMargin.toInt(&ok);
+ if (!ok) {
+ QString buf = defMargin.toString();
+ defMargin = buf.append(QLatin1String("()"));
+ }
+ }
+ e = e.nextSibling().toElement();
+ }
+
+ return widget;
+}
+
+Ui3Reader::Ui3Reader(QTextStream &outStream)
+ : out(outStream), trout(&languageChangeBody)
+{
+ m_porting = new Porting();
+ m_extractImages = false;
+}
+
+Ui3Reader::~Ui3Reader()
+{
+ delete m_porting;
+}
+
+void Ui3Reader::generate(const QString &fn, const QString &outputFn,
+ QDomDocument doc, bool decl, bool subcl, const QString &trm,
+ const QString& subClass, bool omitForwardDecls, bool implicitIncludes, const QString &convertedUiFile)
+{
+ init();
+
+ fileName = fn;
+ outputFileName = outputFn;
+ trmacro = trm;
+ nofwd = omitForwardDecls;
+
+ QDomElement e = parse(doc);
+
+ if (nameOfClass.isEmpty())
+ nameOfClass = getObjectName(e);
+ namespaces = nameOfClass.split(QLatin1String("::"));
+ bareNameOfClass = namespaces.last();
+ namespaces.removeLast();
+
+ if (!convertedUiFile.isEmpty()) {
+ createWrapperDecl(e, convertedUiFile);
+ } else if (subcl) {
+ if (decl)
+ createSubDecl(e, subClass);
+ else
+ createSubImpl(e, subClass);
+ } else {
+ if (decl)
+ createFormDecl(e, implicitIncludes);
+ else
+ createFormImpl(e);
+ }
+
+}
+
+void Ui3Reader::generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc, bool implicitIncludes)
+{
+ init();
+
+ fileName = fn;
+ outputFileName = outputFn;
+
+ DomUI *ui = generateUi4(parse(doc), implicitIncludes);
+ if (!ui)
+ return;
+
+ if (pixmapLoaderFunction.size())
+ ui->setElementPixmapFunction(pixmapLoaderFunction);
+
+ QXmlStreamWriter writer(out.device());
+ writer.setAutoFormatting(true);
+ writer.setAutoFormattingIndent(2);
+ writer.writeStartDocument();
+ ui->write(writer);
+ writer.writeEndDocument();
+
+ delete ui;
+}
+
+void Ui3Reader::setTrMacro(const QString &trmacro)
+{
+ this->trmacro = trmacro;
+}
+
+void Ui3Reader::setForwardDeclarationsEnabled(bool b)
+{
+ nofwd = !b;
+}
+
+void Ui3Reader::setOutputFileName(const QString &fileName)
+{
+ outputFileName = fileName;
+}
+
+/*! Extracts a pixmap loader function from \a e
+ */
+QString Ui3Reader::getPixmapLoaderFunction(const QDomElement& e)
+{
+ QDomElement n;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("pixmapfunction"))
+ return n.firstChild().toText().data();
+ }
+ return QString();
+}
+
+
+/*! Extracts the forms class name from \a e
+ */
+QString Ui3Reader::getFormClassName(const QDomElement& e)
+{
+ QDomElement n;
+ QString cn;
+ for (n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement()) {
+ if (n.tagName() == QLatin1String("class")) {
+ QString s = n.firstChild().toText().data();
+ int i;
+ while ((i = s.indexOf(QLatin1Char(' '))) != -1)
+ s[i] = QLatin1Char('_');
+ cn = s;
+ }
+ }
+ return cn;
+}
+
+/*! Extracts a class name from \a e.
+ */
+QString Ui3Reader::getClassName(const QDomElement& e)
+{
+ QString s = e.attribute(QLatin1String("class"));
+ if (s.isEmpty() && e.tagName() == QLatin1String("toolbar"))
+ s = QLatin1String(QLatin1String("QToolBar"));
+ else if (s.isEmpty() && e.tagName() == QLatin1String("menubar"))
+ s = QLatin1String("QMenuBar");
+
+ return fixClassName(s);
+}
+
+/*! Returns true if database framework code is generated, else false.
+*/
+
+bool Ui3Reader::isFrameworkCodeGenerated(const QDomElement& e)
+{
+ QDomElement n = getObjectProperty(e, QLatin1String("frameworkCode"));
+ if (n.attribute(QLatin1String("name")) == QLatin1String("frameworkCode") &&
+ !DomTool::elementToVariant(n.firstChild().toElement(), QVariant(true)).toBool())
+ return false;
+ return true;
+}
+
+/*! Extracts an object name from \a e. It's stored in the 'name'
+ property.
+ */
+QString Ui3Reader::getObjectName(const QDomElement& e)
+{
+ QDomElement n = getObjectProperty(e, QLatin1String("name"));
+ if (n.firstChild().toElement().tagName() == QLatin1String("cstring"))
+ return n.firstChild().toElement().firstChild().toText().data();
+ return QString();
+}
+
+/*! Extracts an layout name from \a e. It's stored in the 'name'
+ property of the preceding sibling (the first child of a QLayoutWidget).
+ */
+QString Ui3Reader::getLayoutName(const QDomElement& e)
+{
+ QDomElement p = e.parentNode().toElement();
+ QString name;
+
+ if (getClassName(p) != QLatin1String("QLayoutWidget"))
+ name = QLatin1String("Layout");
+
+ QDomElement n = getObjectProperty(p, QLatin1String("name"));
+ if (n.firstChild().toElement().tagName() == QLatin1String("cstring")) {
+ name.prepend(n.firstChild().toElement().firstChild().toText().data());
+ return name.split(QLatin1String("::")).last();
+ }
+ return e.tagName();
+}
+
+
+QString Ui3Reader::getDatabaseInfo(const QDomElement& e, const QString& tag)
+{
+ QDomElement n;
+ QDomElement n1;
+ int child = 0;
+ // database info is a stringlist stored in this order
+ if (tag == QLatin1String("connection"))
+ child = 0;
+ else if (tag == QLatin1String("table"))
+ child = 1;
+ else if (tag == QLatin1String("field"))
+ child = 2;
+ else
+ return QString();
+ n = getObjectProperty(e, QLatin1String("database"));
+ if (n.firstChild().toElement().tagName() == QLatin1String("stringlist")) {
+ // find correct stringlist entry
+ QDomElement n1 = n.firstChild().firstChild().toElement();
+ for (int i = 0; i < child && !n1.isNull(); ++i)
+ n1 = n1.nextSibling().toElement();
+ if (n1.isNull())
+ return QString();
+ return n1.firstChild().toText().data();
+ }
+ return QString();
+}
+
+static const char* const ColorRole[] = {
+ "Foreground", "Button", "Light", "Midlight", "Dark", "Mid",
+ "Text", "BrightText", "ButtonText", "Base", "Background", "Shadow",
+ "Highlight", "HighlightedText", "Link", "LinkVisited", 0
+};
+
+
+/*!
+ Creates a colorgroup with name \a name from the color group \a cg
+ */
+void Ui3Reader::createColorGroupImpl(const QString& name, const QDomElement& e)
+{
+ int r = -1;
+ QDomElement n = e.firstChild().toElement();
+ QString color;
+
+ Color white;
+ white.init(255, 255, 255);
+
+ Color black;
+ black.init(0, 0, 0);
+
+ while (!n.isNull()) {
+ if (n.tagName() == QLatin1String("color")) {
+ r++;
+ Color col = DomTool::readColor(n);
+ color = QLatin1String("QColor(%1, %2, %3)");
+ color = color.arg(col.red).arg(col.green).arg(col.blue);
+ if (col == white)
+ color = QLatin1String("white");
+ else if (col == black)
+ color = QLatin1String("black");
+ if (n.nextSibling().toElement().tagName() != QLatin1String("pixmap")) {
+ out << indent << name << ".setColor(QColorGroup::" << ColorRole[r] << ", " << color << ");" << endl;
+ }
+ } else if (n.tagName() == QLatin1String("pixmap")) {
+ QString pixmap = n.firstChild().toText().data();
+ if (!pixmapLoaderFunction.isEmpty()) {
+ pixmap.prepend(pixmapLoaderFunction
+ + QLatin1String("(")
+ + QLatin1String(externPixmaps ? "\"" : ""));
+
+ pixmap.append(QLatin1String(externPixmaps ? "\"" : "") + QLatin1String(")"));
+ }
+ out << indent << name << ".setBrush(QColorGroup::"
+ << ColorRole[r] << ", QBrush(" << color << ", " << pixmap << "));" << endl;
+ }
+ n = n.nextSibling().toElement();
+ }
+}
+
+/*!
+ Auxiliary function to load a color group. The colorgroup must not
+ contain pixmaps.
+ */
+ColorGroup Ui3Reader::loadColorGroup(const QDomElement &e)
+{
+ ColorGroup cg;
+ int r = -1;
+ QDomElement n = e.firstChild().toElement();
+ Color col;
+ while (!n.isNull()) {
+ if (n.tagName() == QLatin1String("color")) {
+ r++;
+ col = DomTool::readColor(n);
+ cg.append(qMakePair(r, col));
+ }
+ n = n.nextSibling().toElement();
+ }
+ return cg;
+}
+
+/*! Returns true if the widget properties specify that it belongs to
+ the database \a connection and \a table.
+*/
+
+bool Ui3Reader::isWidgetInTable(const QDomElement& e, const QString& connection, const QString& table)
+{
+ QString conn = getDatabaseInfo(e, QLatin1String("connection"));
+ QString tab = getDatabaseInfo(e, QLatin1String("table"));
+ if (conn == connection && tab == table)
+ return true;
+ return false;
+}
+
+/*!
+ Registers all database connections, cursors and forms.
+*/
+
+void Ui3Reader::registerDatabases(const QDomElement& e)
+{
+ QDomElement n;
+ QDomNodeList nl;
+ int i;
+ nl = e.parentNode().toElement().elementsByTagName(QLatin1String("widget"));
+ for (i = 0; i < (int) nl.length(); ++i) {
+ n = nl.item(i).toElement();
+ QString conn = getDatabaseInfo(n, QLatin1String("connection"));
+ QString tab = getDatabaseInfo(n, QLatin1String("table"));
+ QString fld = getDatabaseInfo(n, QLatin1String("field"));
+ if (!conn.isNull()) {
+ dbConnections += conn;
+ if (!tab.isNull()) {
+ dbCursors[conn] += tab;
+ if (!fld.isNull())
+ dbForms[conn] += tab;
+ }
+ }
+ }
+}
+
+/*!
+ Registers an object with name \a name.
+
+ The returned name is a valid variable identifier, as similar to \a
+ name as possible and guaranteed to be unique within the form.
+
+ \sa registeredName(), isObjectRegistered()
+ */
+QString Ui3Reader::registerObject(const QString& name)
+{
+ if (objectNames.isEmpty()) {
+ // some temporary variables we need
+ objectNames += QLatin1String("img");
+ objectNames += QLatin1String("item");
+ objectNames += QLatin1String("cg");
+ objectNames += QLatin1String("pal");
+ }
+
+ QString result = name;
+ int i;
+ while ((i = result.indexOf(QLatin1Char(' '))) != -1 ) {
+ result[i] = QLatin1Char('_');
+ }
+
+ if (objectNames.contains(result)) {
+ int i = 2;
+ while (objectNames.contains(result + QLatin1String("_") + QString::number(i)))
+ i++;
+ result += QLatin1String("_");
+ result += QString::number(i);
+ }
+ objectNames += result;
+ objectMapper.insert(name, result);
+ return result;
+}
+
+/*!
+ Returns the registered name for the original name \a name
+ or \a name if \a name wasn't registered.
+
+ \sa registerObject(), isObjectRegistered()
+ */
+QString Ui3Reader::registeredName(const QString& name)
+{
+ if (!objectMapper.contains(name))
+ return name;
+ return objectMapper[name];
+}
+
+/*!
+ Returns whether the object \a name was registered yet or not.
+ */
+bool Ui3Reader::isObjectRegistered(const QString& name)
+{
+ return objectMapper.contains(name);
+}
+
+/*!
+ Unifies the entries in stringlist \a list. Should really be a QStringList feature.
+ */
+QStringList Ui3Reader::unique(const QStringList& list)
+{
+ if (list.isEmpty())
+ return list;
+
+ QStringList result;
+ for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
+ if (!result.contains(*it))
+ result += *it;
+ }
+ return result;
+}
+
+bool Ui3Reader::isLayout(const QString& name) const
+{
+ return layoutObjects.contains(name);
+}
+
+void Ui3Reader::setExtractImages(bool extract, const QString &qrcOutputFile)
+{
+ m_extractImages = extract;
+ m_qrcOutputFile = qrcOutputFile;
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/ui3reader.h b/src/tools/uic3/ui3reader.h
new file mode 100644
index 0000000..60e0cee
--- /dev/null
+++ b/src/tools/uic3/ui3reader.h
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef UI3READER_H
+#define UI3READER_H
+
+#include <QDomDocument>
+#include <QString>
+#include <QStringList>
+#include <QMap>
+#include <QTextStream>
+#include <QVariant>
+#include <QByteArray>
+#include <QPair>
+
+QT_BEGIN_NAMESPACE
+
+class DomUI;
+class DomFont;
+class DomWidget;
+class DomProperty;
+class DomLayout;
+class DomLayoutItem;
+class DomActionGroup;
+class Porting;
+struct Color;
+
+typedef QList<QPair<int, Color> > ColorGroup;
+
+class Ui3Reader
+{
+public:
+ Ui3Reader(QTextStream &stream);
+ ~Ui3Reader();
+
+ void computeDeps(const QDomElement &e, QStringList &globalIncludes, QStringList &localIncludes, bool impl = false);
+ void generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc, bool implicitIncludes);
+
+ void generate(const QString &fn, const QString &outputFn,
+ QDomDocument doc, bool decl, bool subcl, const QString &trm,
+ const QString& subclname, bool omitForwardDecls, bool implicitIncludes, const QString &convertedUiFile);
+
+ void embed(const char *project, const QStringList &images);
+
+ void setTrMacro(const QString &trmacro);
+ void setForwardDeclarationsEnabled(bool b);
+ void setOutputFileName(const QString &fileName);
+
+ void createFormDecl(const QDomElement &e, bool implicitIncludes);
+ void createFormImpl(const QDomElement &e);
+
+ void createWrapperDecl(const QDomElement &e, const QString &convertedUiFile);
+
+ void createSubDecl(const QDomElement &e, const QString& subclname);
+ void createSubImpl(const QDomElement &e, const QString& subclname);
+
+ void createColorGroupImpl(const QString& cg, const QDomElement& e);
+ ColorGroup loadColorGroup(const QDomElement &e);
+
+ QDomElement getObjectProperty(const QDomElement& e, const QString& name);
+ QString getPixmapLoaderFunction(const QDomElement& e);
+ QString getFormClassName(const QDomElement& e);
+ QString getClassName(const QDomElement& e);
+ QString getObjectName(const QDomElement& e);
+ QString getLayoutName(const QDomElement& e);
+
+ QString registerObject(const QString& name);
+ QString registeredName(const QString& name);
+ bool isObjectRegistered(const QString& name);
+ QStringList unique(const QStringList&);
+
+ QString trcall(const QString& sourceText, const QString& comment = QString());
+
+ QDomElement parse(const QDomDocument &doc);
+
+ void setExtractImages(bool extract, const QString &qrcOutputFile);
+
+private:
+ void init();
+
+ void createWrapperDeclContents(const QDomElement &e);
+
+ void errorInvalidProperty(const QString &propertyName, const QString &widgetName, const QString &widgetClass,
+ int line, int col);
+ void errorInvalidSignal(const QString &signal, const QString &widgetName, const QString &widgetClass,
+ int line, int col);
+ void errorInvalidSlot(const QString &slot, const QString &widgetName, const QString &widgetClass,
+ int line, int col);
+
+ DomUI *generateUi4(const QDomElement &e, bool implicitIncludes);
+ DomWidget *createWidget(const QDomElement &w, const QString &widgetClass = QString());
+ void createProperties(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
+ void createAttributes(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
+ DomLayout *createLayout(const QDomElement &e);
+ DomLayoutItem *createLayoutItem(const QDomElement &e);
+ DomProperty *readProperty(const QDomElement &e);
+ void fixActionGroup(DomActionGroup *g);
+ QString fixActionProperties(QList<DomProperty*> &properties, bool isActionGroup = false);
+
+ QString fixHeaderName(const QString &headerName) const;
+ QString fixClassName(const QString &className) const;
+ QString fixDeclaration(const QString &declaration) const;
+ QString fixType(const QString &type) const;
+ QString fixMethod(const QString &method) const;
+
+ QDomElement findDerivedFontProperties(const QDomElement &n) const;
+
+ void fixLayoutMargin(DomLayout *ui_layout);
+
+ QTextStream &out;
+ QTextOStream trout;
+ QString languageChangeBody;
+ QString outputFileName;
+ QStringList objectNames;
+ QMap<QString,QString> objectMapper;
+ QString indent;
+ QStringList tags;
+ QStringList layouts;
+ QString formName;
+ QString lastItem;
+ QString trmacro;
+ bool nofwd;
+
+ struct Buddy
+ {
+ Buddy(const QString& k, const QString& b)
+ : key(k), buddy(b) {}
+ Buddy(){} // for valuelist
+ QString key;
+ QString buddy;
+ bool operator==(const Buddy& other) const
+ { return (key == other.key); }
+ };
+ struct CustomInclude
+ {
+ QString header;
+ QString location;
+ Q_DUMMY_COMPARISON_OPERATOR(CustomInclude)
+ };
+ QList<Buddy> buddies;
+
+ QStringList layoutObjects;
+ bool isLayout(const QString& name) const;
+
+ uint item_used : 1;
+ uint cg_used : 1;
+ uint pal_used : 1;
+ uint stdsetdef : 1;
+ uint externPixmaps : 1;
+
+ QString uiFileVersion;
+ QString nameOfClass;
+ QStringList namespaces;
+ QString bareNameOfClass;
+ QString pixmapLoaderFunction;
+
+ void registerDatabases(const QDomElement& e);
+ bool isWidgetInTable(const QDomElement& e, const QString& connection, const QString& table);
+ bool isFrameworkCodeGenerated(const QDomElement& e);
+ QString getDatabaseInfo(const QDomElement& e, const QString& tag);
+ void createFormImpl(const QDomElement& e, const QString& form, const QString& connection, const QString& table);
+ void writeFunctionsDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst);
+ void writeFunctionsSubDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst);
+ void writeFunctionsSubImpl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst,
+ const QString &subClass, const QString &descr);
+ QStringList dbConnections;
+ QMap<QString, QStringList> dbCursors;
+ QMap<QString, QStringList> dbForms;
+
+ static bool isMainWindow;
+ static QString mkBool(bool b);
+ static QString mkBool(const QString& s);
+ bool toBool(const QString& s);
+ static QString fixString(const QString &str, bool encode = false);
+ static bool onlyAscii;
+ static QString mkStdSet(const QString& prop);
+ static QString getComment(const QDomNode& n);
+ QVariant defSpacing, defMargin;
+ QString fileName;
+ bool writeFunctImpl;
+
+ QDomElement root;
+ QDomElement widget;
+
+ QMap<QString, bool> candidateCustomWidgets;
+ Porting *m_porting;
+
+ bool m_extractImages;
+ QString m_qrcOutputFile;
+ QMap<QString, QString> m_imageMap;
+};
+
+QT_END_NAMESPACE
+
+#endif // UI3READER_H
diff --git a/src/tools/uic3/uic.cpp b/src/tools/uic3/uic.cpp
new file mode 100644
index 0000000..d042abd
--- /dev/null
+++ b/src/tools/uic3/uic.cpp
@@ -0,0 +1,341 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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 <QtXml/QDomDocument>
+#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;
+ }
+
+ QDomDocument doc; // ### generalize. share more code with the other tools!
+ if (!doc.setContent(&f))
+ return false;
+
+ QDomElement root = doc.firstChildElement();
+ DomUI *ui = new DomUI();
+ ui->read(root);
+
+ 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;
+ }
+
+ 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";
+}
+
+bool Uic::write(QIODevice *in)
+{
+ QDomDocument doc;
+ if (!doc.setContent(in))
+ return false;
+
+ if (option().generator == Option::JavaGenerator) {
+ // the Java generator ignores header protection
+ opt.headerProtection = false;
+ }
+
+ QDomElement root = doc.firstChildElement();
+ DomUI *ui = new DomUI();
+ ui->read(root);
+
+ 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::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/uic3/uic.h b/src/tools/uic3/uic.h
new file mode 100644
index 0000000..33b897c
--- /dev/null
+++ b/src/tools/uic3/uic.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@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>
+
+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 isMenuBar(const QString &className) const;
+ bool isMenu(const QString &className) const;
+
+private:
+ // copyright header
+ void writeCopyrightHeader(DomUI *ui);
+
+#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/uic3/uic3.pro b/src/tools/uic3/uic3.pro
new file mode 100644
index 0000000..5ad3c4d
--- /dev/null
+++ b/src/tools/uic3/uic3.pro
@@ -0,0 +1,43 @@
+TEMPLATE = app
+CONFIG += console qt_no_compat_warning
+CONFIG -= app_bundle
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+
+QT += xml qt3support
+
+DESTDIR = ../../../bin
+
+include(../uic/uic.pri)
+include(../uic/cpp/cpp.pri)
+
+INCLUDEPATH += .
+
+HEADERS += ui3reader.h \
+ parser.h \
+ domtool.h \
+ widgetinfo.h \
+ qt3to4.h \
+ uic.h
+
+SOURCES += main.cpp \
+ ui3reader.cpp \
+ parser.cpp \
+ domtool.cpp \
+ object.cpp \
+ subclassing.cpp \
+ form.cpp \
+ converter.cpp \
+ widgetinfo.cpp \
+ embed.cpp \
+ qt3to4.cpp \
+ deps.cpp \
+ uic.cpp
+
+DEFINES -= QT_COMPAT_WARNINGS
+DEFINES += QT_COMPAT QT_UIC3
+
+target.path=$$[QT_INSTALL_BINS]
+INSTALLS += target
diff --git a/src/tools/uic3/widgetinfo.cpp b/src/tools/uic3/widgetinfo.cpp
new file mode 100644
index 0000000..355b3bd
--- /dev/null
+++ b/src/tools/uic3/widgetinfo.cpp
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "widgetinfo.h"
+
+#include <QMetaEnum>
+#include <QTextBrowser>
+#include <QToolBar>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QComboBox>
+#include <QDial>
+#include <QSlider>
+#include <QLCDNumber>
+#include <QProgressBar>
+#include <QLabel>
+#include <QToolBox>
+#include <QMainWindow>
+#include <QToolButton>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QSpinBox>
+#include <QActionGroup>
+#include <QSplitter>
+#include <Q3Frame>
+#include <QTabWidget>
+#include <Q3DateEdit>
+#include <Q3TimeEdit>
+#include <Q3DateTimeEdit>
+#include <Q3ListBox>
+#include <Q3ListView>
+#include <Q3TextEdit>
+#include <Q3WidgetStack>
+#include <Q3Wizard>
+#include <Q3TextView>
+#include <Q3MainWindow>
+#include <Q3GroupBox>
+#include <Q3ButtonGroup>
+#include <Q3IconView>
+#include <Q3ProgressBar>
+
+QT_BEGIN_NAMESPACE
+
+WidgetInfo::WidgetInfo()
+{
+}
+
+const QMetaObject *WidgetInfo::metaObject(const QString &widgetName)
+{
+ if (widgetName == QLatin1String("QObject"))
+ return &QObject::staticMetaObject;
+ else if (widgetName == QLatin1String("QToolBar"))
+ return &QToolBar::staticMetaObject;
+ else if (widgetName == QLatin1String("Q3ToolBar"))
+ return &Q3ToolBar::staticMetaObject;
+ else if (widgetName == QLatin1String("QPushButton"))
+ return &QPushButton::staticMetaObject;
+ else if (widgetName == QLatin1String("QToolButton"))
+ return &QToolButton::staticMetaObject;
+ else if (widgetName == QLatin1String("QCheckBox"))
+ return &QCheckBox::staticMetaObject;
+ else if (widgetName == QLatin1String("QRadioButton"))
+ return &QRadioButton::staticMetaObject;
+ else if (widgetName == QLatin1String("QGroupBox")
+ || widgetName == QLatin1String("Q3GroupBox"))
+ return &Q3GroupBox::staticMetaObject;
+ else if (widgetName == QLatin1String("QButtonGroup")
+ || widgetName == QLatin1String("Q3ButtonGroup"))
+ return &Q3ButtonGroup::staticMetaObject;
+ else if (widgetName == QLatin1String("QDateEdit"))
+ return &Q3DateEdit::staticMetaObject;
+ else if (widgetName == QLatin1String("QTimeEdit"))
+ return &Q3TimeEdit::staticMetaObject;
+ else if (widgetName == QLatin1String("QDateTimeEdit"))
+ return &Q3DateTimeEdit::staticMetaObject;
+ else if (widgetName == QLatin1String("QListBox")
+ || widgetName == QLatin1String("Q3ListBox"))
+ return &Q3ListBox::staticMetaObject;
+ else if (widgetName == QLatin1String("QListView") ||
+ widgetName == QLatin1String("Q3ListView"))
+ return &Q3ListView::staticMetaObject;
+ else if (widgetName == QLatin1String("Q3IconView"))
+ return &Q3IconView::staticMetaObject;
+ else if (widgetName == QLatin1String("QLineEdit"))
+ return &QLineEdit::staticMetaObject;
+ else if (widgetName == QLatin1String("QSpinBox"))
+ return &QSpinBox::staticMetaObject;
+ else if (widgetName == QLatin1String("QSplitter"))
+ return &QSplitter::staticMetaObject;
+ else if (widgetName == QLatin1String("QTextEdit") ||
+ widgetName == QLatin1String("Q3TextEdit"))
+ return &Q3TextEdit::staticMetaObject;
+ else if (widgetName == QLatin1String("QLabel"))
+ return &QLabel::staticMetaObject;
+ else if (widgetName == QLatin1String("QTabWidget"))
+ return &QTabWidget::staticMetaObject;
+ else if (widgetName == QLatin1String("QWidgetStack"))
+ return &Q3WidgetStack::staticMetaObject;
+ else if (widgetName == QLatin1String("QComboBox"))
+ return &QComboBox::staticMetaObject;
+ else if (widgetName == QLatin1String("QWidget"))
+ return &QWidget::staticMetaObject;
+ else if (widgetName == QLatin1String("QDialog"))
+ return &QDialog::staticMetaObject;
+ else if (widgetName == QLatin1String("QWizard") ||
+ widgetName == QLatin1String("Q3Wizard"))
+ return &Q3Wizard::staticMetaObject;
+ else if (widgetName == QLatin1String("QLCDNumber"))
+ return &QLCDNumber::staticMetaObject;
+ else if (widgetName == QLatin1String("QProgressBar"))
+ return &QProgressBar::staticMetaObject;
+ else if (widgetName == QLatin1String("Q3ProgressBar"))
+ return &Q3ProgressBar::staticMetaObject;
+ else if (widgetName == QLatin1String("QTextView")
+ || widgetName == QLatin1String("Q3TextView"))
+ return &Q3TextView::staticMetaObject;
+ else if (widgetName == QLatin1String("QTextBrowser"))
+ return &QTextBrowser::staticMetaObject;
+ else if (widgetName == QLatin1String("QDial"))
+ return &QDial::staticMetaObject;
+ else if (widgetName == QLatin1String("QSlider"))
+ return &QSlider::staticMetaObject;
+ else if (widgetName == QLatin1String("QScrollBar"))
+ return &QScrollBar::staticMetaObject;
+ else if (widgetName == QLatin1String("QFrame"))
+ return &QFrame::staticMetaObject;
+ else if (widgetName == QLatin1String("Q3Frame"))
+ return &Q3Frame::staticMetaObject;
+ else if (widgetName == QLatin1String("QMainWindow"))
+ return &QMainWindow::staticMetaObject;
+ else if (widgetName == QLatin1String("Q3MainWindow"))
+ return &Q3MainWindow::staticMetaObject;
+ else if (widgetName == QLatin1String("QToolBox"))
+ return &QToolBox::staticMetaObject;
+ else if (widgetName == QLatin1String("Line"))
+ return &QFrame::staticMetaObject;
+ else if (widgetName == QLatin1String("TextLabel"))
+ return &QLabel::staticMetaObject;
+ else if (widgetName == QLatin1String("PixmapLabel"))
+ return &QLabel::staticMetaObject;
+ else if (widgetName == QLatin1String("QActionGroup"))
+ return &QActionGroup::staticMetaObject;
+ else if (widgetName == QLatin1String("QAction"))
+ return &QAction::staticMetaObject;
+
+ return 0;
+}
+
+bool WidgetInfo::isValidProperty(const QString &className, const QString &name)
+{
+ const QMetaObject *meta = metaObject(className);
+ if (!meta)
+ return true;
+
+ return meta->indexOfProperty(name.toLatin1()) != -1;
+}
+
+bool WidgetInfo::isValidSignal(const QString &className, const QString &name)
+{
+ const QMetaObject *meta = metaObject(className);
+ if (!meta)
+ return true;
+
+ return meta->indexOfSignal(name.toLatin1()) != -1;
+}
+
+bool WidgetInfo::isValidSlot(const QString &className, const QString &name)
+{
+ const QMetaObject *meta = metaObject(className);
+ if (!meta)
+ return true;
+
+ return meta->indexOfSlot(name.toLatin1()) != -1;
+}
+
+bool WidgetInfo::isValidEnumerator(const QString &className, const QString &name)
+{
+ const QMetaObject *meta = metaObject(className);
+ if (!meta)
+ return true;
+
+ return checkEnumerator(meta, name);
+}
+
+bool WidgetInfo::checkEnumerator(const QMetaObject *meta, const QString &name)
+{
+ for (int i=0; i<meta->enumeratorCount(); ++i)
+ if (checkEnumerator(meta->enumerator(i), name))
+ return true;
+ return false;
+}
+
+bool WidgetInfo::checkEnumerator(const QMetaEnum &metaEnum, const QString &name)
+{
+ return metaEnum.keyToValue(name.toLatin1()) != -1;
+}
+
+
+QString WidgetInfo::resolveEnumerator(const QString &className, const QString &name)
+{
+ const QMetaObject *meta = metaObject(className);
+ if (!meta) {
+ QString e = resolveEnumerator(QLatin1String("QObject"), QLatin1String("Qt::") + name);
+ if (e.size())
+ return e;
+
+ return name;
+ }
+
+ return resolveEnumerator(meta, name);
+}
+
+QString WidgetInfo::resolveEnumerator(const QMetaObject *meta, const QString &name)
+{
+ for (int i=meta->enumeratorCount() - 1; i>=0; --i) {
+ QString e = resolveEnumerator(meta->enumerator(i), name);
+ if (e.size())
+ return e;
+ }
+
+ if (meta != &staticQtMetaObject)
+ return resolveEnumerator(&staticQtMetaObject, name);
+
+ return QString();
+}
+
+QString WidgetInfo::resolveEnumerator(const QMetaEnum &metaEnum, const QString &name)
+{
+ QString scope = QLatin1String(metaEnum.scope());
+
+ QString enumerator = name;
+ int i = enumerator.indexOf(QLatin1String("::"));
+ if (i != -1) {
+ if (scope != enumerator.left(i))
+ return QString();
+ enumerator = enumerator.mid(i + 2);
+ }
+ QByteArray key = enumerator.toLatin1();
+ for (int idx = 0; idx < metaEnum.keyCount(); ++idx) {
+ if (metaEnum.key(idx) == key)
+ return scope + QLatin1String("::") + enumerator;
+ }
+
+ return QString();
+}
+
+QT_END_NAMESPACE
diff --git a/src/tools/uic3/widgetinfo.h b/src/tools/uic3/widgetinfo.h
new file mode 100644
index 0000000..98b01d8
--- /dev/null
+++ b/src/tools/uic3/widgetinfo.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef WIDGETINFO_H
+#define WIDGETINFO_H
+
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+
+class QString;
+struct QMetaObject;
+class QMetaEnum;
+
+class WidgetInfo: public QObject
+{
+protected:
+ WidgetInfo();
+
+public:
+ static bool isValidProperty(const QString &className, const QString &name);
+ static bool isValidEnumerator(const QString &className, const QString &name);
+ static bool isValidSignal(const QString &className, const QString &name);
+ static bool isValidSlot(const QString &className, const QString &name);
+
+ static QString resolveEnumerator(const QString &className, const QString &name);
+
+private:
+ static const QMetaObject *metaObject(const QString &widgetName);
+ static bool checkEnumerator(const QMetaObject *meta, const QString &name);
+ static bool checkEnumerator(const QMetaEnum &metaEnum, const QString &name);
+
+ static QString resolveEnumerator(const QMetaObject *meta, const QString &name);
+ static QString resolveEnumerator(const QMetaEnum &metaEnum, const QString &name);
+};
+
+QT_END_NAMESPACE
+
+#endif // WIDGETINFO_H