summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit38be0d13830efd2d98281c645c3a60afe05ffece (patch)
tree6ea73f3ec77f7d153333779883e8120f82820abe /tools
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'tools')
-rw-r--r--tools/configure/configure.pro132
-rw-r--r--tools/configure/configure_pch.h74
-rw-r--r--tools/configure/configureapp.cpp4200
-rw-r--r--tools/configure/configureapp.h187
-rw-r--r--tools/configure/environment.cpp516
-rw-r--r--tools/configure/environment.h82
-rw-r--r--tools/configure/main.cpp114
-rw-r--r--tools/configure/tools.cpp249
-rw-r--r--tools/configure/tools.h58
-rw-r--r--tools/shared/symbian/epocroot.cpp227
-rw-r--r--tools/shared/symbian/epocroot.pri11
-rw-r--r--tools/shared/symbian/epocroot_p.h83
-rw-r--r--tools/shared/windows/registry.cpp169
-rw-r--r--tools/shared/windows/registry_p.h80
-rw-r--r--tools/uilib/abstractformbuilder.cpp3209
-rw-r--r--tools/uilib/abstractformbuilder.h290
-rw-r--r--tools/uilib/container.h75
-rw-r--r--tools/uilib/container.qdoc172
-rw-r--r--tools/uilib/customwidget.h101
-rw-r--r--tools/uilib/customwidget.qdoc295
-rw-r--r--tools/uilib/formbuilder.cpp570
-rw-r--r--tools/uilib/formbuilder.h115
-rw-r--r--tools/uilib/formbuilderextra.cpp555
-rw-r--r--tools/uilib/formbuilderextra_p.h262
-rw-r--r--tools/uilib/formscriptrunner.cpp208
-rw-r--r--tools/uilib/formscriptrunner_p.h120
-rw-r--r--tools/uilib/properties.cpp681
-rw-r--r--tools/uilib/properties_p.h176
-rw-r--r--tools/uilib/qdesignerexportwidget.h66
-rw-r--r--tools/uilib/resourcebuilder.cpp180
-rw-r--r--tools/uilib/resourcebuilder_p.h104
-rw-r--r--tools/uilib/textbuilder.cpp84
-rw-r--r--tools/uilib/textbuilder_p.h93
-rw-r--r--tools/uilib/ui4.cpp11154
-rw-r--r--tools/uilib/ui4_p.h3807
-rw-r--r--tools/uilib/uilib.pri32
-rw-r--r--tools/uilib/uilib_global.h64
-rw-r--r--tools/uilib/widgets.table148
38 files changed, 28743 insertions, 0 deletions
diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro
new file mode 100644
index 0000000000..124564667c
--- /dev/null
+++ b/tools/configure/configure.pro
@@ -0,0 +1,132 @@
+TARGET = configure
+DESTDIR = $$PWD/../.. # build directly in source dir
+
+CONFIG += console flat
+CONFIG -= moc qt
+DEFINES = UNICODE QT_NODLL QT_NO_CODECS QT_NO_TEXTCODEC QT_NO_UNICODETABLES QT_LITE_COMPONENT QT_NO_STL QT_NO_COMPRESS QT_NO_THREAD QT_NO_QOBJECT _CRT_SECURE_NO_DEPRECATE
+DEFINES += QT_BOOTSTRAPPED
+
+win32 : LIBS += -lole32 -ladvapi32
+win32-msvc.net | win32-msvc2* : QMAKE_CXXFLAGS += /EHsc
+win32-g++* : LIBS += -luuid
+
+win32-msvc* {
+ QMAKE_CFLAGS_RELEASE -= -MD
+ QMAKE_CFLAGS_RELEASE += -MT
+ QMAKE_CFLAGS_DEBUG -= -MDd
+ QMAKE_CFLAGS_DEBUG += -MTd
+ QMAKE_CXXFLAGS_RELEASE -= -MD
+ QMAKE_CXXFLAGS_RELEASE += -MT
+ QMAKE_CXXFLAGS_DEBUG -= -MDd
+ QMAKE_CXXFLAGS_DEBUG += -MTd
+}
+
+PRECOMPILED_HEADER = configure_pch.h
+
+INCLUDEPATH += \
+ $$QT_SOURCE_TREE/src/corelib/arch/generic \
+ $$QT_SOURCE_TREE/src/corelib/global \
+ $$QT_BUILD_TREE/include \
+ $$QT_BUILD_TREE/include/QtCore \
+ $$QT_SOURCE_TREE/tools/shared
+
+HEADERS = configureapp.h environment.h tools.h\
+ $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qchar.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qhash.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qlist.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qlocale.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qvector.h \
+ $$QT_SOURCE_TREE/src/corelib/codecs/qutfcodec_p.h \
+ $$QT_SOURCE_TREE/src/corelib/codecs/qtextcodec.h \
+ $$QT_SOURCE_TREE/src/corelib/global/qglobal.h \
+ $$QT_SOURCE_TREE/src/corelib/global/qnumeric.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qbuffer.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qdatastream.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qdir.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfile.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry_p.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_p.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemmetadata_p.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_p.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_p.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qtextstream.h \
+ $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qbitarray.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qdatetime.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qmap.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qregexp.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qstring.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qstringmatcher.h \
+ $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables_p.h \
+ $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror_p.h \
+ $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.h \
+ $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils_p.h \
+ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot_p.h \
+ $$QT_SOURCE_TREE/tools/shared/windows/registry_p.h
+
+
+SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qbytearray.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qbytearraymatcher.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qchar.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qhash.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qlist.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qlocale.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qvector.cpp \
+ $$QT_SOURCE_TREE/src/corelib/codecs/qutfcodec.cpp \
+ $$QT_SOURCE_TREE/src/corelib/codecs/qtextcodec.cpp \
+ $$QT_SOURCE_TREE/src/corelib/global/qglobal.cpp \
+ $$QT_SOURCE_TREE/src/corelib/global/qnumeric.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qbuffer.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qdatastream.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qdir.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_win.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qtextstream.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \
+ $$QT_SOURCE_TREE/src/corelib/plugin/qsystemlibrary.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qbitarray.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qdatetime.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qmap.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qregexp.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qstring.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qstringmatcher.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qunicodetables.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qvsnprintf.cpp \
+ $$QT_SOURCE_TREE/src/corelib/kernel/qvariant.cpp \
+ $$QT_SOURCE_TREE/src/corelib/kernel/qsystemerror.cpp \
+ $$QT_SOURCE_TREE/src/corelib/io/qurl.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qline.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qsize.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qpoint.cpp \
+ $$QT_SOURCE_TREE/src/corelib/tools/qrect.cpp \
+ $$QT_SOURCE_TREE/src/corelib/kernel/qmetatype.cpp \
+ $$QT_SOURCE_TREE/src/corelib/global/qmalloc.cpp \
+ $$QT_SOURCE_TREE/src/corelib/xml/qxmlstream.cpp \
+ $$QT_SOURCE_TREE/src/corelib/xml/qxmlutils.cpp \
+ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \
+ $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp
+
+DEFINES += COMMERCIAL_VERSION
+
+INCLUDEPATH += $$QT_SOURCE_TREE/src/corelib/arch/generic \
+ $$QT_SOURCE_TREE/include/QtCore \
+ $$QT_SOURCE_TREE/tools/shared
diff --git a/tools/configure/configure_pch.h b/tools/configure/configure_pch.h
new file mode 100644
index 0000000000..3fe15f5952
--- /dev/null
+++ b/tools/configure/configure_pch.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#if (defined(_WIN32) || defined(__NT__))
+# define QT_UNDEF_MACROS_IN_PCH
+# define _WINSCARD_H_
+# define _POSIX_ /* Make sure PATH_MAX et al. are defined */
+# include <limits.h>
+# undef _POSIX_ /* Don't polute */
+
+ /* Make sure IP v6 is defined first of all, before windows.h */
+# ifndef QT_NO_IPV6
+# include <winsock2.h>
+# endif
+# include <stdlib.h>
+#endif
+
+#if defined __cplusplus
+#include <qglobal.h>
+#include <qlist.h>
+#include <qvariant.h> // All moc genereated code has this include
+#include <qplatformdefs.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qtextcodec.h>
+
+#include <limits.h>
+#include <stdlib.h>
+#endif
+
+#if defined(QT_UNDEF_MACROS_IN_PCH)
+# undef max /* These are defined in windef.h, but */
+# undef min /* we don't want them when building Qt */
+# undef _WINSCARD_H_
+#endif
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
new file mode 100644
index 0000000000..494ea52ec5
--- /dev/null
+++ b/tools/configure/configureapp.cpp
@@ -0,0 +1,4200 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "configureapp.h"
+#include "environment.h"
+#ifdef COMMERCIAL_VERSION
+# include "tools.h"
+#endif
+
+#include <QDate>
+#include <qdir.h>
+#include <qtemporaryfile.h>
+#include <qstack.h>
+#include <qdebug.h>
+#include <qfileinfo.h>
+#include <qtextstream.h>
+#include <qregexp.h>
+#include <qhash.h>
+
+#include <iostream>
+#include <windows.h>
+#include <conio.h>
+
+QT_BEGIN_NAMESPACE
+
+std::ostream &operator<<(std::ostream &s, const QString &val) {
+ s << val.toLocal8Bit().data();
+ return s;
+}
+
+
+using namespace std;
+
+// Macros to simplify options marking
+#define MARK_OPTION(x,y) ( dictionary[ #x ] == #y ? "*" : " " )
+
+
+bool writeToFile(const char* text, const QString &filename)
+{
+ QByteArray symFile(text);
+ QFile file(filename);
+ QDir dir(QFileInfo(file).absoluteDir());
+ if (!dir.exists())
+ dir.mkpath(dir.absolutePath());
+ if (!file.open(QFile::WriteOnly)) {
+ cout << "Couldn't write to " << qPrintable(filename) << ": " << qPrintable(file.errorString())
+ << endl;
+ return false;
+ }
+ file.write(symFile);
+ return true;
+}
+
+Configure::Configure(int& argc, char** argv)
+{
+ useUnixSeparators = false;
+ // Default values for indentation
+ optionIndent = 4;
+ descIndent = 25;
+ outputWidth = 0;
+ // Get console buffer output width
+ CONSOLE_SCREEN_BUFFER_INFO info;
+ HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (GetConsoleScreenBufferInfo(hStdout, &info))
+ outputWidth = info.dwSize.X - 1;
+ outputWidth = qMin(outputWidth, 79); // Anything wider gets unreadable
+ if (outputWidth < 35) // Insanely small, just use 79
+ outputWidth = 79;
+ int i;
+
+ /*
+ ** Set up the initial state, the default
+ */
+ dictionary[ "CONFIGCMD" ] = argv[ 0 ];
+
+ for (i = 1; i < argc; i++)
+ configCmdLine += argv[ i ];
+
+
+ // Get the path to the executable
+ wchar_t module_name[MAX_PATH];
+ GetModuleFileName(0, module_name, sizeof(module_name) / sizeof(wchar_t));
+ QFileInfo sourcePathInfo = QString::fromWCharArray(module_name);
+ sourcePath = sourcePathInfo.absolutePath();
+ sourceDir = sourcePathInfo.dir();
+ buildPath = QDir::currentPath();
+#if 0
+ const QString installPath = QString("C:\\Qt\\%1").arg(QT_VERSION_STR);
+#else
+ const QString installPath = buildPath;
+#endif
+ if (sourceDir != buildDir) { //shadow builds!
+ if (!findFile("perl") && !findFile("perl.exe")) {
+ cout << "Error: Creating a shadow build of Qt requires" << endl
+ << "perl to be in the PATH environment";
+ exit(0); // Exit cleanly for Ctrl+C
+ }
+
+ cout << "Preparing build tree..." << endl;
+ QDir(buildPath).mkpath("bin");
+
+ { //duplicate qmake
+ QStack<QString> qmake_dirs;
+ qmake_dirs.push("qmake");
+ while (!qmake_dirs.isEmpty()) {
+ QString dir = qmake_dirs.pop();
+ QString od(buildPath + "/" + dir);
+ QString id(sourcePath + "/" + dir);
+ QFileInfoList entries = QDir(id).entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries);
+ for (int i = 0; i < entries.size(); ++i) {
+ QFileInfo fi(entries.at(i));
+ if (fi.isDir()) {
+ qmake_dirs.push(dir + "/" + fi.fileName());
+ QDir().mkpath(od + "/" + fi.fileName());
+ } else {
+ QDir().mkpath(od);
+ bool justCopy = true;
+ const QString fname = fi.fileName();
+ const QString outFile(od + "/" + fname), inFile(id + "/" + fname);
+ if (fi.fileName() == "Makefile") { //ignore
+ } else if (fi.suffix() == "h" || fi.suffix() == "cpp") {
+ QTemporaryFile tmpFile;
+ if (tmpFile.open()) {
+ QTextStream stream(&tmpFile);
+ stream << "#include \"" << inFile << "\"" << endl;
+ justCopy = false;
+ stream.flush();
+ tmpFile.flush();
+ if (filesDiffer(tmpFile.fileName(), outFile)) {
+ QFile::remove(outFile);
+ tmpFile.copy(outFile);
+ }
+ }
+ }
+ if (justCopy && filesDiffer(inFile, outFile))
+ QFile::copy(inFile, outFile);
+ }
+ }
+ }
+ }
+
+ { //make a syncqt script(s) that can be used in the shadow
+ QFile syncqt(buildPath + "/bin/syncqt");
+ if (syncqt.open(QFile::WriteOnly)) {
+ QTextStream stream(&syncqt);
+ stream << "#!/usr/bin/perl -w" << endl
+ << "require \"" << sourcePath + "/bin/syncqt\";" << endl;
+ }
+ QFile syncqt_bat(buildPath + "/bin/syncqt.bat");
+ if (syncqt_bat.open(QFile::WriteOnly)) {
+ QTextStream stream(&syncqt_bat);
+ stream << "@echo off" << endl
+ << "set QTDIR=" << QDir::toNativeSeparators(sourcePath) << endl
+ << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/syncqt.bat -outdir \"") << fixSeparators(buildPath) << "\"" << endl
+ << "set QTDIR=" << QDir::toNativeSeparators(buildPath) << endl;
+ syncqt_bat.close();
+ }
+ }
+
+ // make patch_capabilities and createpackage scripts for Symbian that can be used from the shadow build
+ QFile patch_capabilities(buildPath + "/bin/patch_capabilities");
+ if (patch_capabilities.open(QFile::WriteOnly)) {
+ QTextStream stream(&patch_capabilities);
+ stream << "#!/usr/bin/perl -w" << endl
+ << "require \"" << sourcePath + "/bin/patch_capabilities\";" << endl;
+ }
+ QFile patch_capabilities_bat(buildPath + "/bin/patch_capabilities.bat");
+ if (patch_capabilities_bat.open(QFile::WriteOnly)) {
+ QTextStream stream(&patch_capabilities_bat);
+ stream << "@echo off" << endl
+ << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/patch_capabilities.bat %*") << endl;
+ patch_capabilities_bat.close();
+ }
+ QFile createpackage(buildPath + "/bin/createpackage");
+ if (createpackage.open(QFile::WriteOnly)) {
+ QTextStream stream(&createpackage);
+ stream << "#!/usr/bin/perl -w" << endl
+ << "require \"" << sourcePath + "/bin/createpackage\";" << endl;
+ }
+ QFile createpackage_bat(buildPath + "/bin/createpackage.bat");
+ if (createpackage_bat.open(QFile::WriteOnly)) {
+ QTextStream stream(&createpackage_bat);
+ stream << "@echo off" << endl
+ << "call " << fixSeparators(sourcePath) << fixSeparators("/bin/createpackage.bat %*") << endl;
+ createpackage_bat.close();
+ }
+
+ // For Windows CE and shadow builds we need to copy these to the
+ // build directory.
+ QFile::copy(sourcePath + "/bin/setcepaths.bat" , buildPath + "/bin/setcepaths.bat");
+ //copy the mkspecs
+ buildDir.mkpath("mkspecs");
+ if (!Environment::cpdir(sourcePath + "/mkspecs", buildPath + "/mkspecs")){
+ cout << "Couldn't copy mkspecs!" << sourcePath << " " << buildPath << endl;
+ dictionary["DONE"] = "error";
+ return;
+ }
+ }
+
+ dictionary[ "QT_SOURCE_TREE" ] = fixSeparators(sourcePath);
+ dictionary[ "QT_BUILD_TREE" ] = fixSeparators(buildPath);
+ dictionary[ "QT_INSTALL_PREFIX" ] = fixSeparators(installPath);
+
+ dictionary[ "QMAKESPEC" ] = getenv("QMAKESPEC");
+ if (dictionary[ "QMAKESPEC" ].size() == 0) {
+ dictionary[ "QMAKESPEC" ] = Environment::detectQMakeSpec();
+ dictionary[ "QMAKESPEC_FROM" ] = "detected";
+ } else {
+ dictionary[ "QMAKESPEC_FROM" ] = "env";
+ }
+
+ dictionary[ "ARCHITECTURE" ] = "windows";
+ dictionary[ "QCONFIG" ] = "full";
+ dictionary[ "EMBEDDED" ] = "no";
+ dictionary[ "BUILD_QMAKE" ] = "yes";
+ dictionary[ "DSPFILES" ] = "yes";
+ dictionary[ "VCPROJFILES" ] = "yes";
+ dictionary[ "QMAKE_INTERNAL" ] = "no";
+ dictionary[ "FAST" ] = "no";
+ dictionary[ "NOPROCESS" ] = "no";
+ dictionary[ "STL" ] = "yes";
+ dictionary[ "EXCEPTIONS" ] = "yes";
+ dictionary[ "RTTI" ] = "yes";
+ dictionary[ "MMX" ] = "auto";
+ dictionary[ "3DNOW" ] = "auto";
+ dictionary[ "SSE" ] = "auto";
+ dictionary[ "SSE2" ] = "auto";
+ dictionary[ "IWMMXT" ] = "auto";
+ dictionary[ "SYNCQT" ] = "auto";
+ dictionary[ "CE_CRT" ] = "no";
+ dictionary[ "CETEST" ] = "auto";
+ dictionary[ "CE_SIGNATURE" ] = "no";
+ dictionary[ "SCRIPT" ] = "auto";
+ dictionary[ "SCRIPTTOOLS" ] = "auto";
+ dictionary[ "XMLPATTERNS" ] = "auto";
+ dictionary[ "PHONON" ] = "auto";
+ dictionary[ "PHONON_BACKEND" ] = "yes";
+ dictionary[ "MULTIMEDIA" ] = "yes";
+ dictionary[ "AUDIO_BACKEND" ] = "auto";
+ dictionary[ "WMSDK" ] = "auto";
+ dictionary[ "DIRECTSHOW" ] = "no";
+ dictionary[ "WEBKIT" ] = "auto";
+ dictionary[ "DECLARATIVE" ] = "auto";
+ dictionary[ "DECLARATIVE_DEBUG" ]= "yes";
+ dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
+ dictionary[ "DIRECTWRITE" ] = "no";
+
+ QString version;
+ QFile qglobal_h(sourcePath + "/src/corelib/global/qglobal.h");
+ if (qglobal_h.open(QFile::ReadOnly)) {
+ QTextStream read(&qglobal_h);
+ QRegExp version_regexp("^# *define *QT_VERSION_STR *\"([^\"]*)\"");
+ QString line;
+ while (!read.atEnd()) {
+ line = read.readLine();
+ if (version_regexp.exactMatch(line)) {
+ version = version_regexp.cap(1).trimmed();
+ if (!version.isEmpty())
+ break;
+ }
+ }
+ qglobal_h.close();
+ }
+
+ if (version.isEmpty())
+ version = QString("%1.%2.%3").arg(QT_VERSION>>16).arg(((QT_VERSION>>8)&0xff)).arg(QT_VERSION&0xff);
+
+ dictionary[ "VERSION" ] = version;
+ {
+ QRegExp version_re("([0-9]*)\\.([0-9]*)\\.([0-9]*)(|-.*)");
+ if (version_re.exactMatch(version)) {
+ dictionary[ "VERSION_MAJOR" ] = version_re.cap(1);
+ dictionary[ "VERSION_MINOR" ] = version_re.cap(2);
+ dictionary[ "VERSION_PATCH" ] = version_re.cap(3);
+ }
+ }
+
+ dictionary[ "REDO" ] = "no";
+ dictionary[ "DEPENDENCIES" ] = "no";
+
+ dictionary[ "BUILD" ] = "debug";
+ dictionary[ "BUILDALL" ] = "auto"; // Means yes, but not explicitly
+
+ dictionary[ "BUILDTYPE" ] = "none";
+
+ dictionary[ "BUILDDEV" ] = "no";
+ dictionary[ "BUILDNOKIA" ] = "no";
+
+ dictionary[ "SHARED" ] = "yes";
+
+ dictionary[ "ZLIB" ] = "auto";
+
+ dictionary[ "GIF" ] = "auto";
+ dictionary[ "TIFF" ] = "auto";
+ dictionary[ "JPEG" ] = "auto";
+ dictionary[ "PNG" ] = "auto";
+ dictionary[ "MNG" ] = "auto";
+ dictionary[ "LIBTIFF" ] = "auto";
+ dictionary[ "LIBJPEG" ] = "auto";
+ dictionary[ "LIBPNG" ] = "auto";
+ dictionary[ "LIBMNG" ] = "auto";
+ dictionary[ "FREETYPE" ] = "no";
+
+ dictionary[ "QT3SUPPORT" ] = "yes";
+ dictionary[ "ACCESSIBILITY" ] = "yes";
+ dictionary[ "OPENGL" ] = "yes";
+ dictionary[ "OPENVG" ] = "no";
+ dictionary[ "IPV6" ] = "yes"; // Always, dynamically loaded
+ dictionary[ "OPENSSL" ] = "auto";
+ dictionary[ "DBUS" ] = "auto";
+ dictionary[ "S60" ] = "yes";
+
+ dictionary[ "STYLE_WINDOWS" ] = "yes";
+ dictionary[ "STYLE_WINDOWSXP" ] = "auto";
+ dictionary[ "STYLE_WINDOWSVISTA" ] = "auto";
+ dictionary[ "STYLE_PLASTIQUE" ] = "yes";
+ dictionary[ "STYLE_CLEANLOOKS" ]= "yes";
+ dictionary[ "STYLE_WINDOWSCE" ] = "no";
+ dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
+ dictionary[ "STYLE_MOTIF" ] = "yes";
+ dictionary[ "STYLE_CDE" ] = "yes";
+ dictionary[ "STYLE_S60" ] = "no";
+ dictionary[ "STYLE_GTK" ] = "no";
+
+ dictionary[ "SQL_MYSQL" ] = "no";
+ dictionary[ "SQL_ODBC" ] = "no";
+ dictionary[ "SQL_OCI" ] = "no";
+ dictionary[ "SQL_PSQL" ] = "no";
+ dictionary[ "SQL_TDS" ] = "no";
+ dictionary[ "SQL_DB2" ] = "no";
+ dictionary[ "SQL_SQLITE" ] = "auto";
+ dictionary[ "SQL_SQLITE_LIB" ] = "qt";
+ dictionary[ "SQL_SQLITE2" ] = "no";
+ dictionary[ "SQL_IBASE" ] = "no";
+ dictionary[ "GRAPHICS_SYSTEM" ] = "raster";
+
+ QString tmp = dictionary[ "QMAKESPEC" ];
+ if (tmp.contains("\\")) {
+ tmp = tmp.mid(tmp.lastIndexOf("\\") + 1);
+ } else {
+ tmp = tmp.mid(tmp.lastIndexOf("/") + 1);
+ }
+ dictionary[ "QMAKESPEC" ] = tmp;
+
+ dictionary[ "INCREDIBUILD_XGE" ] = "auto";
+ dictionary[ "LTCG" ] = "no";
+ dictionary[ "NATIVE_GESTURES" ] = "yes";
+ dictionary[ "MSVC_MP" ] = "no";
+}
+
+Configure::~Configure()
+{
+ for (int i=0; i<3; ++i) {
+ QList<MakeItem*> items = makeList[i];
+ for (int j=0; j<items.size(); ++j)
+ delete items[j];
+ }
+}
+
+QString Configure::fixSeparators(const QString &somePath, bool escape)
+{
+ if (useUnixSeparators)
+ return QDir::fromNativeSeparators(somePath);
+ QString ret = QDir::toNativeSeparators(somePath);
+ return escape ? escapeSeparators(ret) : ret;
+}
+
+QString Configure::escapeSeparators(const QString &somePath)
+{
+ QString out = somePath;
+ out.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
+ return out;
+}
+
+// We could use QDir::homePath() + "/.qt-license", but
+// that will only look in the first of $HOME,$USERPROFILE
+// or $HOMEDRIVE$HOMEPATH. So, here we try'em all to be
+// more forgiving for the end user..
+QString Configure::firstLicensePath()
+{
+ QStringList allPaths;
+ allPaths << "./.qt-license"
+ << QString::fromLocal8Bit(getenv("HOME")) + "/.qt-license"
+ << QString::fromLocal8Bit(getenv("USERPROFILE")) + "/.qt-license"
+ << QString::fromLocal8Bit(getenv("HOMEDRIVE")) + QString::fromLocal8Bit(getenv("HOMEPATH")) + "/.qt-license";
+ for (int i = 0; i< allPaths.count(); ++i)
+ if (QFile::exists(allPaths.at(i)))
+ return allPaths.at(i);
+ return QString();
+}
+
+
+// #### somehow I get a compiler error about vc++ reaching the nesting limit without
+// undefining the ansi for scoping.
+#ifdef for
+#undef for
+#endif
+
+void Configure::parseCmdLine()
+{
+ int argCount = configCmdLine.size();
+ int i = 0;
+ const QStringList imageFormats = QStringList() << "gif" << "png" << "mng" << "jpeg" << "tiff";
+
+#if !defined(EVAL)
+ if (argCount < 1) // skip rest if no arguments
+ ;
+ else if (configCmdLine.at(i) == "-redo") {
+ dictionary[ "REDO" ] = "yes";
+ configCmdLine.clear();
+ reloadCmdLine();
+ }
+ else if (configCmdLine.at(i) == "-loadconfig") {
+ ++i;
+ if (i != argCount) {
+ dictionary[ "REDO" ] = "yes";
+ dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
+ configCmdLine.clear();
+ reloadCmdLine();
+ } else {
+ dictionary[ "HELP" ] = "yes";
+ }
+ i = 0;
+ }
+ argCount = configCmdLine.size();
+#endif
+
+ // Look first for XQMAKESPEC
+ for (int j = 0 ; j < argCount; ++j)
+ {
+ if (configCmdLine.at(j) == "-xplatform") {
+ ++j;
+ if (j == argCount)
+ break;
+ dictionary["XQMAKESPEC"] = configCmdLine.at(j);
+ if (!dictionary[ "XQMAKESPEC" ].isEmpty())
+ applySpecSpecifics();
+ }
+ }
+
+ for (; i<configCmdLine.size(); ++i) {
+ bool continueElse[] = {false, false};
+ if (configCmdLine.at(i) == "-help"
+ || configCmdLine.at(i) == "-h"
+ || configCmdLine.at(i) == "-?")
+ dictionary[ "HELP" ] = "yes";
+
+#if !defined(EVAL)
+ else if (configCmdLine.at(i) == "-qconfig") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QCONFIG" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-buildkey") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "USER_BUILD_KEY" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-release") {
+ dictionary[ "BUILD" ] = "release";
+ if (dictionary[ "BUILDALL" ] == "auto")
+ dictionary[ "BUILDALL" ] = "no";
+ } else if (configCmdLine.at(i) == "-debug") {
+ dictionary[ "BUILD" ] = "debug";
+ if (dictionary[ "BUILDALL" ] == "auto")
+ dictionary[ "BUILDALL" ] = "no";
+ } else if (configCmdLine.at(i) == "-debug-and-release")
+ dictionary[ "BUILDALL" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-shared")
+ dictionary[ "SHARED" ] = "yes";
+ else if (configCmdLine.at(i) == "-static")
+ dictionary[ "SHARED" ] = "no";
+ else if (configCmdLine.at(i) == "-developer-build")
+ dictionary[ "BUILDDEV" ] = "yes";
+ else if (configCmdLine.at(i) == "-nokia-developer") {
+ cout << "Detected -nokia-developer option" << endl;
+ cout << "Nokia employees and agents are allowed to use this software under" << endl;
+ cout << "the authority of Nokia Corporation and/or its subsidiary(-ies)" << endl;
+ dictionary[ "BUILDNOKIA" ] = "yes";
+ dictionary[ "BUILDDEV" ] = "yes";
+ dictionary["LICENSE_CONFIRMED"] = "yes";
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ dictionary[ "SYMBIAN_DEFFILES" ] = "no";
+ }
+ }
+ else if (configCmdLine.at(i) == "-opensource") {
+ dictionary[ "BUILDTYPE" ] = "opensource";
+ }
+ else if (configCmdLine.at(i) == "-commercial") {
+ dictionary[ "BUILDTYPE" ] = "commercial";
+ }
+ else if (configCmdLine.at(i) == "-ltcg") {
+ dictionary[ "LTCG" ] = "yes";
+ }
+ else if (configCmdLine.at(i) == "-no-ltcg") {
+ dictionary[ "LTCG" ] = "no";
+ }
+ else if (configCmdLine.at(i) == "-mp") {
+ dictionary[ "MSVC_MP" ] = "yes";
+ }
+ else if (configCmdLine.at(i) == "-no-mp") {
+ dictionary[ "MSVC_MP" ] = "no";
+ }
+
+#endif
+
+ else if (configCmdLine.at(i) == "-platform") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QMAKESPEC" ] = configCmdLine.at(i);
+ dictionary[ "QMAKESPEC_FROM" ] = "commandline";
+ } else if (configCmdLine.at(i) == "-arch") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "ARCHITECTURE" ] = configCmdLine.at(i);
+ if (configCmdLine.at(i) == "boundschecker") {
+ dictionary[ "ARCHITECTURE" ] = "generic"; // Boundschecker uses the generic arch,
+ qtConfig += "boundschecker"; // but also needs this CONFIG option
+ }
+ } else if (configCmdLine.at(i) == "-embedded") {
+ dictionary[ "EMBEDDED" ] = "yes";
+ } else if (configCmdLine.at(i) == "-xplatform") {
+ ++i;
+ // do nothing
+ }
+
+
+#if !defined(EVAL)
+ else if (configCmdLine.at(i) == "-no-zlib") {
+ // No longer supported since Qt 4.4.0
+ // But save the information for later so that we can print a warning
+ //
+ // If you REALLY really need no zlib support, you can still disable
+ // it by doing the following:
+ // add "no-zlib" to mkspecs/qconfig.pri
+ // #define QT_NO_COMPRESS (probably by adding to src/corelib/global/qconfig.h)
+ //
+ // There's no guarantee that Qt will build under those conditions
+
+ dictionary[ "ZLIB_FORCED" ] = "yes";
+ } else if (configCmdLine.at(i) == "-qt-zlib") {
+ dictionary[ "ZLIB" ] = "qt";
+ } else if (configCmdLine.at(i) == "-system-zlib") {
+ dictionary[ "ZLIB" ] = "system";
+ }
+
+ // Image formats --------------------------------------------
+ else if (configCmdLine.at(i) == "-no-gif")
+ dictionary[ "GIF" ] = "no";
+
+ else if (configCmdLine.at(i) == "-no-libtiff") {
+ dictionary[ "TIFF"] = "no";
+ dictionary[ "LIBTIFF" ] = "no";
+ } else if (configCmdLine.at(i) == "-qt-libtiff") {
+ dictionary[ "LIBTIFF" ] = "qt";
+ } else if (configCmdLine.at(i) == "-system-libtiff") {
+ dictionary[ "LIBTIFF" ] = "system";
+ }
+
+ else if (configCmdLine.at(i) == "-no-libjpeg") {
+ dictionary[ "JPEG" ] = "no";
+ dictionary[ "LIBJPEG" ] = "no";
+ } else if (configCmdLine.at(i) == "-qt-libjpeg") {
+ dictionary[ "LIBJPEG" ] = "qt";
+ } else if (configCmdLine.at(i) == "-system-libjpeg") {
+ dictionary[ "LIBJPEG" ] = "system";
+ }
+
+ else if (configCmdLine.at(i) == "-no-libpng") {
+ dictionary[ "PNG" ] = "no";
+ dictionary[ "LIBPNG" ] = "no";
+ } else if (configCmdLine.at(i) == "-qt-libpng") {
+ dictionary[ "LIBPNG" ] = "qt";
+ } else if (configCmdLine.at(i) == "-system-libpng") {
+ dictionary[ "LIBPNG" ] = "system";
+ }
+
+ else if (configCmdLine.at(i) == "-no-libmng") {
+ dictionary[ "MNG" ] = "no";
+ dictionary[ "LIBMNG" ] = "no";
+ } else if (configCmdLine.at(i) == "-qt-libmng") {
+ dictionary[ "LIBMNG" ] = "qt";
+ } else if (configCmdLine.at(i) == "-system-libmng") {
+ dictionary[ "LIBMNG" ] = "system";
+ }
+
+ // Text Rendering --------------------------------------------
+ else if (configCmdLine.at(i) == "-no-freetype")
+ dictionary[ "FREETYPE" ] = "no";
+ else if (configCmdLine.at(i) == "-qt-freetype")
+ dictionary[ "FREETYPE" ] = "yes";
+
+ // CE- C runtime --------------------------------------------
+ else if (configCmdLine.at(i) == "-crt") {
+ ++i;
+ if (i == argCount)
+ break;
+ QDir cDir(configCmdLine.at(i));
+ if (!cDir.exists())
+ cout << "WARNING: Could not find directory (" << qPrintable(configCmdLine.at(i)) << ")for C runtime deployment" << endl;
+ else
+ dictionary[ "CE_CRT" ] = QDir::toNativeSeparators(cDir.absolutePath());
+ } else if (configCmdLine.at(i) == "-qt-crt") {
+ dictionary[ "CE_CRT" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-crt") {
+ dictionary[ "CE_CRT" ] = "no";
+ }
+ // cetest ---------------------------------------------------
+ else if (configCmdLine.at(i) == "-no-cetest") {
+ dictionary[ "CETEST" ] = "no";
+ dictionary[ "CETEST_REQUESTED" ] = "no";
+ } else if (configCmdLine.at(i) == "-cetest") {
+ // although specified to use it, we stay at "auto" state
+ // this is because checkAvailability() adds variables
+ // we need for crosscompilation; but remember if we asked
+ // for it.
+ dictionary[ "CETEST_REQUESTED" ] = "yes";
+ }
+ // Qt/CE - signing tool -------------------------------------
+ else if (configCmdLine.at(i) == "-signature") {
+ ++i;
+ if (i == argCount)
+ break;
+ QFileInfo info(configCmdLine.at(i));
+ if (!info.exists())
+ cout << "WARNING: Could not find signature file (" << qPrintable(configCmdLine.at(i)) << ")" << endl;
+ else
+ dictionary[ "CE_SIGNATURE" ] = QDir::toNativeSeparators(info.absoluteFilePath());
+ }
+ // Styles ---------------------------------------------------
+ else if (configCmdLine.at(i) == "-qt-style-windows")
+ dictionary[ "STYLE_WINDOWS" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-windows")
+ dictionary[ "STYLE_WINDOWS" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-windowsce")
+ dictionary[ "STYLE_WINDOWSCE" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-windowsce")
+ dictionary[ "STYLE_WINDOWSCE" ] = "no";
+ else if (configCmdLine.at(i) == "-qt-style-windowsmobile")
+ dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-windowsmobile")
+ dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-windowsxp")
+ dictionary[ "STYLE_WINDOWSXP" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-windowsxp")
+ dictionary[ "STYLE_WINDOWSXP" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-windowsvista")
+ dictionary[ "STYLE_WINDOWSVISTA" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-windowsvista")
+ dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-plastique")
+ dictionary[ "STYLE_PLASTIQUE" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-plastique")
+ dictionary[ "STYLE_PLASTIQUE" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-cleanlooks")
+ dictionary[ "STYLE_CLEANLOOKS" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-cleanlooks")
+ dictionary[ "STYLE_CLEANLOOKS" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-motif")
+ dictionary[ "STYLE_MOTIF" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-motif")
+ dictionary[ "STYLE_MOTIF" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-cde")
+ dictionary[ "STYLE_CDE" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-cde")
+ dictionary[ "STYLE_CDE" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-style-s60")
+ dictionary[ "STYLE_S60" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-style-s60")
+ dictionary[ "STYLE_S60" ] = "no";
+
+ // Qt 3 Support ---------------------------------------------
+ else if (configCmdLine.at(i) == "-no-qt3support")
+ dictionary[ "QT3SUPPORT" ] = "no";
+
+ // Work around compiler nesting limitation
+ else
+ continueElse[1] = true;
+ if (!continueElse[1]) {
+ }
+
+ // OpenGL Support -------------------------------------------
+ else if (configCmdLine.at(i) == "-no-opengl") {
+ dictionary[ "OPENGL" ] = "no";
+ } else if (configCmdLine.at(i) == "-opengl-es-cm") {
+ dictionary[ "OPENGL" ] = "yes";
+ dictionary[ "OPENGL_ES_CM" ] = "yes";
+ } else if (configCmdLine.at(i) == "-opengl-es-2") {
+ dictionary[ "OPENGL" ] = "yes";
+ dictionary[ "OPENGL_ES_2" ] = "yes";
+ } else if (configCmdLine.at(i) == "-opengl") {
+ dictionary[ "OPENGL" ] = "yes";
+ i++;
+ if (i == argCount)
+ break;
+
+ if (configCmdLine.at(i) == "es1") {
+ dictionary[ "OPENGL_ES_CM" ] = "yes";
+ } else if ( configCmdLine.at(i) == "es2" ) {
+ dictionary[ "OPENGL_ES_2" ] = "yes";
+ } else if ( configCmdLine.at(i) == "desktop" ) {
+ // OPENGL=yes suffices
+ } else {
+ cout << "Argument passed to -opengl option is not valid." << endl;
+ dictionary[ "DONE" ] = "error";
+ break;
+ }
+ }
+
+ // OpenVG Support -------------------------------------------
+ else if (configCmdLine.at(i) == "-openvg") {
+ dictionary[ "OPENVG" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-openvg") {
+ dictionary[ "OPENVG" ] = "no";
+ }
+
+ // Databases ------------------------------------------------
+ else if (configCmdLine.at(i) == "-qt-sql-mysql")
+ dictionary[ "SQL_MYSQL" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-mysql")
+ dictionary[ "SQL_MYSQL" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-mysql")
+ dictionary[ "SQL_MYSQL" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-odbc")
+ dictionary[ "SQL_ODBC" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-odbc")
+ dictionary[ "SQL_ODBC" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-odbc")
+ dictionary[ "SQL_ODBC" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-oci")
+ dictionary[ "SQL_OCI" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-oci")
+ dictionary[ "SQL_OCI" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-oci")
+ dictionary[ "SQL_OCI" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-psql")
+ dictionary[ "SQL_PSQL" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-psql")
+ dictionary[ "SQL_PSQL" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-psql")
+ dictionary[ "SQL_PSQL" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-tds")
+ dictionary[ "SQL_TDS" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-tds")
+ dictionary[ "SQL_TDS" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-tds")
+ dictionary[ "SQL_TDS" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-db2")
+ dictionary[ "SQL_DB2" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-db2")
+ dictionary[ "SQL_DB2" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-db2")
+ dictionary[ "SQL_DB2" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-sqlite")
+ dictionary[ "SQL_SQLITE" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-sqlite")
+ dictionary[ "SQL_SQLITE" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-sqlite")
+ dictionary[ "SQL_SQLITE" ] = "no";
+ else if (configCmdLine.at(i) == "-system-sqlite")
+ dictionary[ "SQL_SQLITE_LIB" ] = "system";
+ else if (configCmdLine.at(i) == "-qt-sql-sqlite2")
+ dictionary[ "SQL_SQLITE2" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-sqlite2")
+ dictionary[ "SQL_SQLITE2" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-sqlite2")
+ dictionary[ "SQL_SQLITE2" ] = "no";
+
+ else if (configCmdLine.at(i) == "-qt-sql-ibase")
+ dictionary[ "SQL_IBASE" ] = "yes";
+ else if (configCmdLine.at(i) == "-plugin-sql-ibase")
+ dictionary[ "SQL_IBASE" ] = "plugin";
+ else if (configCmdLine.at(i) == "-no-sql-ibase")
+ dictionary[ "SQL_IBASE" ] = "no";
+
+ // Image formats --------------------------------------------
+ else if (configCmdLine.at(i).startsWith("-qt-imageformat-") &&
+ imageFormats.contains(configCmdLine.at(i).section('-', 3)))
+ dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "yes";
+ else if (configCmdLine.at(i).startsWith("-plugin-imageformat-") &&
+ imageFormats.contains(configCmdLine.at(i).section('-', 3)))
+ dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "plugin";
+ else if (configCmdLine.at(i).startsWith("-no-imageformat-") &&
+ imageFormats.contains(configCmdLine.at(i).section('-', 3)))
+ dictionary[ configCmdLine.at(i).section('-', 3).toUpper() ] = "no";
+#endif
+ // IDE project generation -----------------------------------
+ else if (configCmdLine.at(i) == "-no-dsp")
+ dictionary[ "DSPFILES" ] = "no";
+ else if (configCmdLine.at(i) == "-dsp")
+ dictionary[ "DSPFILES" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-no-vcp")
+ dictionary[ "VCPFILES" ] = "no";
+ else if (configCmdLine.at(i) == "-vcp")
+ dictionary[ "VCPFILES" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-no-vcproj")
+ dictionary[ "VCPROJFILES" ] = "no";
+ else if (configCmdLine.at(i) == "-vcproj")
+ dictionary[ "VCPROJFILES" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-no-incredibuild-xge")
+ dictionary[ "INCREDIBUILD_XGE" ] = "no";
+ else if (configCmdLine.at(i) == "-incredibuild-xge")
+ dictionary[ "INCREDIBUILD_XGE" ] = "yes";
+ else if (configCmdLine.at(i) == "-native-gestures")
+ dictionary[ "NATIVE_GESTURES" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-native-gestures")
+ dictionary[ "NATIVE_GESTURES" ] = "no";
+#if !defined(EVAL)
+ // Symbian Support -------------------------------------------
+ else if (configCmdLine.at(i) == "-fpu")
+ {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "ARM_FPU_TYPE" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-s60")
+ dictionary[ "S60" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-s60")
+ dictionary[ "S60" ] = "no";
+
+ else if (configCmdLine.at(i) == "-usedeffiles")
+ dictionary[ "SYMBIAN_DEFFILES" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-usedeffiles")
+ dictionary[ "SYMBIAN_DEFFILES" ] = "no";
+
+ // Others ---------------------------------------------------
+ else if (configCmdLine.at(i) == "-fast")
+ dictionary[ "FAST" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-fast")
+ dictionary[ "FAST" ] = "no";
+
+ else if (configCmdLine.at(i) == "-stl")
+ dictionary[ "STL" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-stl")
+ dictionary[ "STL" ] = "no";
+
+ else if (configCmdLine.at(i) == "-exceptions")
+ dictionary[ "EXCEPTIONS" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-exceptions")
+ dictionary[ "EXCEPTIONS" ] = "no";
+
+ else if (configCmdLine.at(i) == "-rtti")
+ dictionary[ "RTTI" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-rtti")
+ dictionary[ "RTTI" ] = "no";
+
+ else if (configCmdLine.at(i) == "-accessibility")
+ dictionary[ "ACCESSIBILITY" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-accessibility") {
+ dictionary[ "ACCESSIBILITY" ] = "no";
+ cout << "Setting accessibility to NO" << endl;
+ }
+
+ else if (configCmdLine.at(i) == "-no-mmx")
+ dictionary[ "MMX" ] = "no";
+ else if (configCmdLine.at(i) == "-mmx")
+ dictionary[ "MMX" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-3dnow")
+ dictionary[ "3DNOW" ] = "no";
+ else if (configCmdLine.at(i) == "-3dnow")
+ dictionary[ "3DNOW" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-sse")
+ dictionary[ "SSE" ] = "no";
+ else if (configCmdLine.at(i) == "-sse")
+ dictionary[ "SSE" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-sse2")
+ dictionary[ "SSE2" ] = "no";
+ else if (configCmdLine.at(i) == "-sse2")
+ dictionary[ "SSE2" ] = "yes";
+ else if (configCmdLine.at(i) == "-no-iwmmxt")
+ dictionary[ "IWMMXT" ] = "no";
+ else if (configCmdLine.at(i) == "-iwmmxt")
+ dictionary[ "IWMMXT" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-no-openssl") {
+ dictionary[ "OPENSSL"] = "no";
+ } else if (configCmdLine.at(i) == "-openssl") {
+ dictionary[ "OPENSSL" ] = "yes";
+ } else if (configCmdLine.at(i) == "-openssl-linked") {
+ dictionary[ "OPENSSL" ] = "linked";
+ } else if (configCmdLine.at(i) == "-no-qdbus") {
+ dictionary[ "DBUS" ] = "no";
+ } else if (configCmdLine.at(i) == "-qdbus") {
+ dictionary[ "DBUS" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-dbus") {
+ dictionary[ "DBUS" ] = "no";
+ } else if (configCmdLine.at(i) == "-dbus") {
+ dictionary[ "DBUS" ] = "yes";
+ } else if (configCmdLine.at(i) == "-dbus-linked") {
+ dictionary[ "DBUS" ] = "linked";
+ } else if (configCmdLine.at(i) == "-no-script") {
+ dictionary[ "SCRIPT" ] = "no";
+ } else if (configCmdLine.at(i) == "-script") {
+ dictionary[ "SCRIPT" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-scripttools") {
+ dictionary[ "SCRIPTTOOLS" ] = "no";
+ } else if (configCmdLine.at(i) == "-scripttools") {
+ dictionary[ "SCRIPTTOOLS" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-xmlpatterns") {
+ dictionary[ "XMLPATTERNS" ] = "no";
+ } else if (configCmdLine.at(i) == "-xmlpatterns") {
+ dictionary[ "XMLPATTERNS" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-multimedia") {
+ dictionary[ "MULTIMEDIA" ] = "no";
+ } else if (configCmdLine.at(i) == "-multimedia") {
+ dictionary[ "MULTIMEDIA" ] = "yes";
+ } else if (configCmdLine.at(i) == "-audio-backend") {
+ dictionary[ "AUDIO_BACKEND" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-audio-backend") {
+ dictionary[ "AUDIO_BACKEND" ] = "no";
+ } else if (configCmdLine.at(i) == "-no-phonon") {
+ dictionary[ "PHONON" ] = "no";
+ } else if (configCmdLine.at(i) == "-phonon") {
+ dictionary[ "PHONON" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-phonon-backend") {
+ dictionary[ "PHONON_BACKEND" ] = "no";
+ } else if (configCmdLine.at(i) == "-phonon-backend") {
+ dictionary[ "PHONON_BACKEND" ] = "yes";
+ } else if (configCmdLine.at(i) == "-phonon-wince-ds9") {
+ dictionary[ "DIRECTSHOW" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-webkit") {
+ dictionary[ "WEBKIT" ] = "no";
+ } else if (configCmdLine.at(i) == "-webkit") {
+ dictionary[ "WEBKIT" ] = "yes";
+ } else if (configCmdLine.at(i) == "-webkit-debug") {
+ dictionary[ "WEBKIT" ] = "debug";
+ } else if (configCmdLine.at(i) == "-no-declarative") {
+ dictionary[ "DECLARATIVE" ] = "no";
+ } else if (configCmdLine.at(i) == "-declarative") {
+ dictionary[ "DECLARATIVE" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-declarative-debug") {
+ dictionary[ "DECLARATIVE_DEBUG" ] = "no";
+ } else if (configCmdLine.at(i) == "-declarative-debug") {
+ dictionary[ "DECLARATIVE_DEBUG" ] = "yes";
+ } else if (configCmdLine.at(i) == "-no-plugin-manifests") {
+ dictionary[ "PLUGIN_MANIFESTS" ] = "no";
+ } else if (configCmdLine.at(i) == "-plugin-manifests") {
+ dictionary[ "PLUGIN_MANIFESTS" ] = "yes";
+ }
+
+ // Work around compiler nesting limitation
+ else
+ continueElse[0] = true;
+ if (!continueElse[0]) {
+ }
+
+ else if (configCmdLine.at(i) == "-internal")
+ dictionary[ "QMAKE_INTERNAL" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-no-qmake")
+ dictionary[ "BUILD_QMAKE" ] = "no";
+ else if (configCmdLine.at(i) == "-qmake")
+ dictionary[ "BUILD_QMAKE" ] = "yes";
+
+ else if (configCmdLine.at(i) == "-dont-process")
+ dictionary[ "NOPROCESS" ] = "yes";
+ else if (configCmdLine.at(i) == "-process")
+ dictionary[ "NOPROCESS" ] = "no";
+
+ else if (configCmdLine.at(i) == "-no-qmake-deps")
+ dictionary[ "DEPENDENCIES" ] = "no";
+ else if (configCmdLine.at(i) == "-qmake-deps")
+ dictionary[ "DEPENDENCIES" ] = "yes";
+
+
+ else if (configCmdLine.at(i) == "-qtnamespace") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_NAMESPACE" ] = configCmdLine.at(i);
+ } else if (configCmdLine.at(i) == "-qtlibinfix") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_LIBINFIX" ] = configCmdLine.at(i);
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ dictionary[ "QT_INSTALL_PLUGINS" ] =
+ QString("\\resource\\qt%1\\plugins").arg(dictionary[ "QT_LIBINFIX" ]);
+ dictionary[ "QT_INSTALL_IMPORTS" ] =
+ QString("\\resource\\qt%1\\imports").arg(dictionary[ "QT_LIBINFIX" ]);
+ dictionary[ "QT_INSTALL_TRANSLATIONS" ] =
+ QString("\\resource\\qt%1\\translations").arg(dictionary[ "QT_LIBINFIX" ]);
+ }
+ } else if (configCmdLine.at(i) == "-D") {
+ ++i;
+ if (i == argCount)
+ break;
+ qmakeDefines += configCmdLine.at(i);
+ } else if (configCmdLine.at(i) == "-I") {
+ ++i;
+ if (i == argCount)
+ break;
+ qmakeIncludes += configCmdLine.at(i);
+ } else if (configCmdLine.at(i) == "-L") {
+ ++i;
+ if (i == argCount)
+ break;
+ QFileInfo check(configCmdLine.at(i));
+ if (!check.isDir()) {
+ cout << "Argument passed to -L option is not a directory path. Did you mean the -l option?" << endl;
+ dictionary[ "DONE" ] = "error";
+ break;
+ }
+ qmakeLibs += QString("-L" + configCmdLine.at(i));
+ } else if (configCmdLine.at(i) == "-l") {
+ ++i;
+ if (i == argCount)
+ break;
+ qmakeLibs += QString("-l" + configCmdLine.at(i));
+ } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) {
+ opensslLibs = configCmdLine.at(i);
+ } else if (configCmdLine.at(i).startsWith("PSQL_LIBS=")) {
+ psqlLibs = configCmdLine.at(i);
+ } else if (configCmdLine.at(i).startsWith("SYBASE=")) {
+ sybase = configCmdLine.at(i);
+ } else if (configCmdLine.at(i).startsWith("SYBASE_LIBS=")) {
+ sybaseLibs = configCmdLine.at(i);
+ }
+
+ else if ((configCmdLine.at(i) == "-override-version") || (configCmdLine.at(i) == "-version-override")){
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "VERSION" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-saveconfig") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "CUSTOMCONFIG" ] = "_" + configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-confirm-license") {
+ dictionary["LICENSE_CONFIRMED"] = "yes";
+ }
+
+ else if (configCmdLine.at(i) == "-nomake") {
+ ++i;
+ if (i == argCount)
+ break;
+ disabledBuildParts += configCmdLine.at(i);
+ }
+
+ // Directories ----------------------------------------------
+ else if (configCmdLine.at(i) == "-prefix") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_PREFIX" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-bindir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_BINS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-libdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_LIBS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-docdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_DOCS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-headerdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_HEADERS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-plugindir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_PLUGINS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-importdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_IMPORTS" ] = configCmdLine.at(i);
+ }
+ else if (configCmdLine.at(i) == "-datadir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_DATA" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-translationdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_TRANSLATIONS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-examplesdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_EXAMPLES" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-demosdir") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_INSTALL_DEMOS" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-hostprefix") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-make") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary[ "MAKE" ] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-graphicssystem") {
+ ++i;
+ if (i == argCount)
+ break;
+ QString system = configCmdLine.at(i);
+ if (system == QLatin1String("raster")
+ || system == QLatin1String("opengl")
+ || system == QLatin1String("openvg")
+ || system == QLatin1String("runtime"))
+ dictionary["GRAPHICS_SYSTEM"] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i) == "-runtimegraphicssystem") {
+ ++i;
+ if (i == argCount)
+ break;
+ dictionary["RUNTIME_SYSTEM"] = configCmdLine.at(i);
+ }
+
+ else if (configCmdLine.at(i).indexOf(QRegExp("^-(en|dis)able-")) != -1) {
+ // Scan to see if any specific modules and drivers are enabled or disabled
+ for (QStringList::Iterator module = modules.begin(); module != modules.end(); ++module) {
+ if (configCmdLine.at(i) == QString("-enable-") + (*module)) {
+ enabledModules += (*module);
+ break;
+ }
+ else if (configCmdLine.at(i) == QString("-disable-") + (*module)) {
+ disabledModules += (*module);
+ break;
+ }
+ }
+ }
+
+ else if (configCmdLine.at(i) == "-directwrite") {
+ dictionary["DIRECTWRITE"] = "yes";
+ } else if (configCmdLine.at(i) == "-no-directwrite") {
+ dictionary["DIRECTWRITE"] = "no";
+ }
+
+ else {
+ dictionary[ "HELP" ] = "yes";
+ cout << "Unknown option " << configCmdLine.at(i) << endl;
+ break;
+ }
+
+#endif
+ }
+
+ // Ensure that QMAKESPEC exists in the mkspecs folder
+ QDir mkspec_dir = fixSeparators(sourcePath + "/mkspecs");
+ QStringList mkspecs = mkspec_dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
+
+ if (dictionary["QMAKESPEC"].toLower() == "features"
+ || !mkspecs.contains(dictionary["QMAKESPEC"], Qt::CaseInsensitive)) {
+ dictionary[ "HELP" ] = "yes";
+ if (dictionary ["QMAKESPEC_FROM"] == "commandline") {
+ cout << "Invalid option \"" << dictionary["QMAKESPEC"] << "\" for -platform." << endl;
+ } else if (dictionary ["QMAKESPEC_FROM"] == "env") {
+ cout << "QMAKESPEC environment variable is set to \"" << dictionary["QMAKESPEC"]
+ << "\" which is not a supported platform" << endl;
+ } else { // was autodetected from environment
+ cout << "Unable to detect the platform from environment. Use -platform command line"
+ "argument or set the QMAKESPEC environment variable and run configure again" << endl;
+ }
+ cout << "See the README file for a list of supported operating systems and compilers." << endl;
+ } else {
+ if (dictionary[ "QMAKESPEC" ].endsWith("-icc") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc.net") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc2002") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc2003") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc2005") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc2008") ||
+ dictionary[ "QMAKESPEC" ].endsWith("-msvc2010")) {
+ if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "nmake";
+ dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
+ } else if (dictionary[ "QMAKESPEC" ] == QString("win32-g++")) {
+ if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "mingw32-make";
+ if (Environment::detectExecutable("sh.exe")) {
+ dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++-sh";
+ } else {
+ dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32-g++";
+ }
+ } else {
+ if (dictionary[ "MAKE" ].isEmpty()) dictionary[ "MAKE" ] = "make";
+ dictionary[ "QMAKEMAKEFILE" ] = "Makefile.win32";
+ }
+ }
+
+ // Tell the user how to proceed building Qt after configure finished its job
+ dictionary["QTBUILDINSTRUCTION"] = dictionary["MAKE"];
+ if (dictionary.contains("XQMAKESPEC")) {
+ if (dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ dictionary["QTBUILDINSTRUCTION"] = QString("make debug-winscw|debug-armv5|release-armv5");
+ } else if (dictionary["XQMAKESPEC"].startsWith("wince")) {
+ dictionary["QTBUILDINSTRUCTION"] =
+ QString("setcepaths.bat ") + dictionary["XQMAKESPEC"] + QString(" && ") + dictionary["MAKE"];
+ }
+ }
+
+ // Tell the user how to confclean before the next configure
+ dictionary["CONFCLEANINSTRUCTION"] = dictionary["MAKE"] + QString(" confclean");
+
+ // Ensure that -spec (XQMAKESPEC) exists in the mkspecs folder as well
+ if (dictionary.contains("XQMAKESPEC") &&
+ !mkspecs.contains(dictionary["XQMAKESPEC"], Qt::CaseInsensitive)) {
+ dictionary["HELP"] = "yes";
+ cout << "Invalid option \"" << dictionary["XQMAKESPEC"] << "\" for -xplatform." << endl;
+ }
+
+ // Ensure that the crt to be deployed can be found
+ if (dictionary["CE_CRT"] != QLatin1String("yes") && dictionary["CE_CRT"] != QLatin1String("no")) {
+ QDir cDir(dictionary["CE_CRT"]);
+ QStringList entries = cDir.entryList();
+ bool hasDebug = entries.contains("msvcr80.dll");
+ bool hasRelease = entries.contains("msvcr80d.dll");
+ if ((dictionary["BUILDALL"] == "auto") && (!hasDebug || !hasRelease)) {
+ cout << "Could not find debug and release c-runtime." << endl;
+ cout << "You need to have msvcr80.dll and msvcr80d.dll in" << endl;
+ cout << "the path specified. Setting to -no-crt";
+ dictionary[ "CE_CRT" ] = "no";
+ } else if ((dictionary["BUILD"] == "debug") && !hasDebug) {
+ cout << "Could not find debug c-runtime (msvcr80d.dll) in the directory specified." << endl;
+ cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
+ dictionary[ "CE_CRT" ] = "no";
+ } else if ((dictionary["BUILD"] == "release") && !hasRelease) {
+ cout << "Could not find release c-runtime (msvcr80.dll) in the directory specified." << endl;
+ cout << "Setting c-runtime automatic deployment to -no-crt" << endl;
+ dictionary[ "CE_CRT" ] = "no";
+ }
+ }
+
+ useUnixSeparators = (dictionary["QMAKESPEC"] == "win32-g++");
+
+ // Allow tests for private classes to be compiled against internal builds
+ if (dictionary["BUILDDEV"] == "yes")
+ qtConfig += "private_tests";
+
+
+#if !defined(EVAL)
+ for (QStringList::Iterator dis = disabledModules.begin(); dis != disabledModules.end(); ++dis) {
+ modules.removeAll((*dis));
+ }
+ for (QStringList::Iterator ena = enabledModules.begin(); ena != enabledModules.end(); ++ena) {
+ if (modules.indexOf((*ena)) == -1)
+ modules += (*ena);
+ }
+ qtConfig += modules;
+
+ for (QStringList::Iterator it = disabledModules.begin(); it != disabledModules.end(); ++it)
+ qtConfig.removeAll(*it);
+
+ if ((dictionary[ "REDO" ] != "yes") && (dictionary[ "HELP" ] != "yes"))
+ saveCmdLine();
+#endif
+}
+
+#if !defined(EVAL)
+void Configure::validateArgs()
+{
+ // Validate the specified config
+
+ // Get all possible configurations from the file system.
+ QDir dir;
+ QStringList filters;
+ filters << "qconfig-*.h";
+ dir.setNameFilters(filters);
+ dir.setPath(sourcePath + "/src/corelib/global/");
+
+ QStringList stringList = dir.entryList();
+
+ QStringList::Iterator it;
+ for (it = stringList.begin(); it != stringList.end(); ++it)
+ allConfigs << it->remove("qconfig-").remove(".h");
+ allConfigs << "full";
+
+ // Try internal configurations first.
+ QStringList possible_configs = QStringList()
+ << "minimal"
+ << "small"
+ << "medium"
+ << "large"
+ << "full";
+ int index = possible_configs.indexOf(dictionary["QCONFIG"]);
+ if (index >= 0) {
+ for (int c = 0; c <= index; c++) {
+ qmakeConfig += possible_configs[c] + "-config";
+ }
+ return;
+ }
+
+ // If the internal configurations failed, try others.
+ QStringList::Iterator config;
+ for (config = allConfigs.begin(); config != allConfigs.end(); ++config) {
+ if ((*config) == dictionary[ "QCONFIG" ])
+ break;
+ }
+ if (config == allConfigs.end()) {
+ dictionary[ "HELP" ] = "yes";
+ cout << "No such configuration \"" << qPrintable(dictionary[ "QCONFIG" ]) << "\"" << endl ;
+ }
+ else
+ qmakeConfig += (*config) + "-config";
+}
+#endif
+
+
+// Output helper functions --------------------------------[ Start ]-
+/*!
+ Determines the length of a string token.
+*/
+static int tokenLength(const char *str)
+{
+ if (*str == 0)
+ return 0;
+
+ const char *nextToken = strpbrk(str, " _/\n\r");
+ if (nextToken == str || !nextToken)
+ return 1;
+
+ return int(nextToken - str);
+}
+
+/*!
+ Prints out a string which starts at position \a startingAt, and
+ indents each wrapped line with \a wrapIndent characters.
+ The wrap point is set to the console width, unless that width
+ cannot be determined, or is too small.
+*/
+void Configure::desc(const char *description, int startingAt, int wrapIndent)
+{
+ int linePos = startingAt;
+
+ bool firstLine = true;
+ const char *nextToken = description;
+ while (*nextToken) {
+ int nextTokenLen = tokenLength(nextToken);
+ if (*nextToken == '\n' // Wrap on newline, duh
+ || (linePos + nextTokenLen > outputWidth)) // Wrap at outputWidth
+ {
+ printf("\n");
+ linePos = 0;
+ firstLine = false;
+ if (*nextToken == '\n')
+ ++nextToken;
+ continue;
+ }
+ if (!firstLine && linePos < wrapIndent) { // Indent to wrapIndent
+ printf("%*s", wrapIndent , "");
+ linePos = wrapIndent;
+ if (*nextToken == ' ') {
+ ++nextToken;
+ continue;
+ }
+ }
+ printf("%.*s", nextTokenLen, nextToken);
+ linePos += nextTokenLen;
+ nextToken += nextTokenLen;
+ }
+}
+
+/*!
+ Prints out an option with its description wrapped at the
+ description starting point. If \a skipIndent is true, the
+ indentation to the option is not outputted (used by marked option
+ version of desc()). Extra spaces between option and its
+ description is filled with\a fillChar, if there's available
+ space.
+*/
+void Configure::desc(const char *option, const char *description, bool skipIndent, char fillChar)
+{
+ if (!skipIndent)
+ printf("%*s", optionIndent, "");
+
+ int remaining = descIndent - optionIndent - strlen(option);
+ int wrapIndent = descIndent + qMax(0, 1 - remaining);
+ printf("%s", option);
+
+ if (remaining > 2) {
+ printf(" "); // Space in front
+ for (int i = remaining; i > 2; --i)
+ printf("%c", fillChar); // Fill, if available space
+ }
+ printf(" "); // Space between option and description
+
+ desc(description, wrapIndent, wrapIndent);
+ printf("\n");
+}
+
+/*!
+ Same as above, except it also marks an option with an '*', if
+ the option is default action.
+*/
+void Configure::desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar)
+{
+ const QString markedAs = dictionary.value(mark_option);
+ if (markedAs == "auto" && markedAs == mark) // both "auto", always => +
+ printf(" + ");
+ else if (markedAs == "auto") // setting marked as "auto" and option is default => +
+ printf(" %c " , (defaultTo(mark_option) == QLatin1String(mark))? '+' : ' ');
+ else if (QLatin1String(mark) == "auto" && markedAs != "no") // description marked as "auto" and option is available => +
+ printf(" %c " , checkAvailability(mark_option) ? '+' : ' ');
+ else // None are "auto", (markedAs == mark) => *
+ printf(" %c " , markedAs == QLatin1String(mark) ? '*' : ' ');
+
+ desc(option, description, true, fillChar);
+}
+
+/*!
+ Modifies the default configuration based on given -platform option.
+ Eg. switches to different default styles for Windows CE.
+*/
+void Configure::applySpecSpecifics()
+{
+ if (dictionary[ "XQMAKESPEC" ].startsWith("wince")) {
+ dictionary[ "STYLE_WINDOWSXP" ] = "no";
+ dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
+ dictionary[ "STYLE_PLASTIQUE" ] = "no";
+ dictionary[ "STYLE_CLEANLOOKS" ] = "no";
+ dictionary[ "STYLE_WINDOWSCE" ] = "yes";
+ dictionary[ "STYLE_WINDOWSMOBILE" ] = "yes";
+ dictionary[ "STYLE_MOTIF" ] = "no";
+ dictionary[ "STYLE_CDE" ] = "no";
+ dictionary[ "STYLE_S60" ] = "no";
+ dictionary[ "FREETYPE" ] = "no";
+ dictionary[ "QT3SUPPORT" ] = "no";
+ dictionary[ "OPENGL" ] = "no";
+ dictionary[ "OPENSSL" ] = "no";
+ dictionary[ "STL" ] = "no";
+ dictionary[ "EXCEPTIONS" ] = "no";
+ dictionary[ "RTTI" ] = "no";
+ dictionary[ "ARCHITECTURE" ] = "windowsce";
+ dictionary[ "3DNOW" ] = "no";
+ dictionary[ "SSE" ] = "no";
+ dictionary[ "SSE2" ] = "no";
+ dictionary[ "MMX" ] = "no";
+ dictionary[ "IWMMXT" ] = "no";
+ dictionary[ "CE_CRT" ] = "yes";
+ dictionary[ "WEBKIT" ] = "no";
+ dictionary[ "PHONON" ] = "yes";
+ dictionary[ "DIRECTSHOW" ] = "no";
+ // We only apply MMX/IWMMXT for mkspecs we know they work
+ if (dictionary[ "XQMAKESPEC" ].startsWith("wincewm")) {
+ dictionary[ "MMX" ] = "yes";
+ dictionary[ "IWMMXT" ] = "yes";
+ dictionary[ "DIRECTSHOW" ] = "yes";
+ }
+ dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ];
+ dictionary[ "QT_INSTALL_PREFIX" ] = "";
+
+ } else if (dictionary[ "XQMAKESPEC" ].startsWith("symbian")) {
+ dictionary[ "ACCESSIBILITY" ] = "no";
+ dictionary[ "STYLE_WINDOWSXP" ] = "no";
+ dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
+ dictionary[ "STYLE_PLASTIQUE" ] = "no";
+ dictionary[ "STYLE_CLEANLOOKS" ] = "no";
+ dictionary[ "STYLE_WINDOWSCE" ] = "no";
+ dictionary[ "STYLE_WINDOWSMOBILE" ] = "no";
+ dictionary[ "STYLE_MOTIF" ] = "no";
+ dictionary[ "STYLE_CDE" ] = "no";
+ dictionary[ "STYLE_S60" ] = "yes";
+ dictionary[ "FREETYPE" ] = "no";
+ dictionary[ "QT3SUPPORT" ] = "no";
+ dictionary[ "OPENGL" ] = "no";
+ dictionary[ "OPENSSL" ] = "yes";
+ // On Symbian we now always will have IPv6 with no chance to disable it
+ dictionary[ "IPV6" ] = "yes";
+ dictionary[ "STL" ] = "yes";
+ dictionary[ "EXCEPTIONS" ] = "yes";
+ dictionary[ "RTTI" ] = "yes";
+ dictionary[ "ARCHITECTURE" ] = "symbian";
+ dictionary[ "3DNOW" ] = "no";
+ dictionary[ "SSE" ] = "no";
+ dictionary[ "SSE2" ] = "no";
+ dictionary[ "MMX" ] = "no";
+ dictionary[ "IWMMXT" ] = "no";
+ dictionary[ "CE_CRT" ] = "no";
+ dictionary[ "DIRECT3D" ] = "no";
+ dictionary[ "WEBKIT" ] = "yes";
+ dictionary[ "ASSISTANT_WEBKIT" ] = "no";
+ dictionary[ "PHONON" ] = "yes";
+ dictionary[ "XMLPATTERNS" ] = "yes";
+ dictionary[ "QT_GLIB" ] = "no";
+ dictionary[ "S60" ] = "yes";
+ dictionary[ "SYMBIAN_DEFFILES" ] = "yes";
+ // iconv makes makes apps start and run ridiculously slowly in symbian emulator (HW not tested)
+ // iconv_open seems to return -1 always, so something is probably missing from the platform.
+ dictionary[ "QT_ICONV" ] = "no";
+ dictionary[ "SCRIPTTOOLS" ] = "no";
+ dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ];
+ dictionary[ "QT_INSTALL_PREFIX" ] = "";
+ dictionary[ "QT_INSTALL_PLUGINS" ] = "\\resource\\qt\\plugins";
+ dictionary[ "QT_INSTALL_IMPORTS" ] = "\\resource\\qt\\imports";
+ dictionary[ "QT_INSTALL_TRANSLATIONS" ] = "\\resource\\qt\\translations";
+ dictionary[ "ARM_FPU_TYPE" ] = "softvfp";
+ dictionary[ "SQL_SQLITE" ] = "yes";
+ dictionary[ "SQL_SQLITE_LIB" ] = "system";
+
+ // Disable building docs and translations for now
+ disabledBuildParts << "docs" << "translations";
+
+ } else if (dictionary[ "XQMAKESPEC" ].startsWith("linux")) { //TODO actually wrong.
+ //TODO
+ dictionary[ "STYLE_WINDOWSXP" ] = "no";
+ dictionary[ "STYLE_WINDOWSVISTA" ] = "no";
+ dictionary[ "KBD_DRIVERS" ] = "tty";
+ dictionary[ "GFX_DRIVERS" ] = "linuxfb vnc";
+ dictionary[ "MOUSE_DRIVERS" ] = "pc linuxtp";
+ dictionary[ "QT3SUPPORT" ] = "no";
+ dictionary[ "OPENGL" ] = "no";
+ dictionary[ "EXCEPTIONS" ] = "no";
+ dictionary[ "DBUS"] = "no";
+ dictionary[ "QT_QWS_DEPTH" ] = "4 8 16 24 32";
+ dictionary[ "QT_SXE" ] = "no";
+ dictionary[ "QT_INOTIFY" ] = "no";
+ dictionary[ "QT_LPR" ] = "no";
+ dictionary[ "QT_CUPS" ] = "no";
+ dictionary[ "QT_GLIB" ] = "no";
+ dictionary[ "QT_ICONV" ] = "no";
+
+ dictionary["DECORATIONS"] = "default windows styled";
+ }
+}
+
+QString Configure::locateFileInPaths(const QString &fileName, const QStringList &paths)
+{
+ QDir d;
+ for (QStringList::ConstIterator it = paths.begin(); it != paths.end(); ++it) {
+ // Remove any leading or trailing ", this is commonly used in the environment
+ // variables
+ QString path = (*it);
+ if (path.startsWith("\""))
+ path = path.right(path.length() - 1);
+ if (path.endsWith("\""))
+ path = path.left(path.length() - 1);
+ if (d.exists(path + QDir::separator() + fileName)) {
+ return (path);
+ }
+ }
+ return QString();
+}
+
+QString Configure::locateFile(const QString &fileName)
+{
+ QString file = fileName.toLower();
+ QStringList paths;
+#if defined(Q_OS_WIN32)
+ QRegExp splitReg("[;,]");
+#else
+ QRegExp splitReg("[:]");
+#endif
+ if (file.endsWith(".h"))
+ paths = QString::fromLocal8Bit(getenv("INCLUDE")).split(splitReg, QString::SkipEmptyParts);
+ else if (file.endsWith(".lib"))
+ paths = QString::fromLocal8Bit(getenv("LIB")).split(splitReg, QString::SkipEmptyParts);
+ else
+ paths = QString::fromLocal8Bit(getenv("PATH")).split(splitReg, QString::SkipEmptyParts);
+ return locateFileInPaths(file, paths);
+}
+
+// Output helper functions ---------------------------------[ Stop ]-
+
+
+bool Configure::displayHelp()
+{
+ if (dictionary[ "HELP" ] == "yes") {
+ desc("Usage: configure [-buildkey <key>]\n"
+// desc("Usage: configure [-prefix dir] [-bindir <dir>] [-libdir <dir>]\n"
+// "[-docdir <dir>] [-headerdir <dir>] [-plugindir <dir>]\n"
+// "[-importdir <dir>] [-datadir <dir>] [-translationdir <dir>]\n"
+// "[-examplesdir <dir>] [-demosdir <dir>][-buildkey <key>]\n"
+ "[-release] [-debug] [-debug-and-release] [-shared] [-static]\n"
+ "[-no-fast] [-fast] [-no-exceptions] [-exceptions]\n"
+ "[-no-accessibility] [-accessibility] [-no-rtti] [-rtti]\n"
+ "[-no-stl] [-stl] [-no-sql-<driver>] [-qt-sql-<driver>]\n"
+ "[-plugin-sql-<driver>] [-system-sqlite] [-arch <arch>]\n"
+ "[-D <define>] [-I <includepath>] [-L <librarypath>]\n"
+ "[-help] [-no-dsp] [-dsp] [-no-vcproj] [-vcproj]\n"
+ "[-no-qmake] [-qmake] [-dont-process] [-process]\n"
+ "[-no-style-<style>] [-qt-style-<style>] [-redo]\n"
+ "[-saveconfig <config>] [-loadconfig <config>]\n"
+ "[-qt-zlib] [-system-zlib] [-no-gif] [-no-libpng]\n"
+ "[-qt-libpng] [-system-libpng] [-no-libtiff] [-qt-libtiff]\n"
+ "[-system-libtiff] [-no-libjpeg] [-qt-libjpeg] [-system-libjpeg]\n"
+ "[-no-libmng] [-qt-libmng] [-system-libmng] [-no-qt3support] [-mmx]\n"
+ "[-no-mmx] [-3dnow] [-no-3dnow] [-sse] [-no-sse] [-sse2] [-no-sse2]\n"
+ "[-no-iwmmxt] [-iwmmxt] [-openssl] [-openssl-linked]\n"
+ "[-no-openssl] [-no-dbus] [-dbus] [-dbus-linked] [-platform <spec>]\n"
+ "[-qtnamespace <namespace>] [-qtlibinfix <infix>] [-no-phonon]\n"
+ "[-phonon] [-no-phonon-backend] [-phonon-backend]\n"
+ "[-no-multimedia] [-multimedia] [-no-audio-backend] [-audio-backend]\n"
+ "[-no-script] [-script] [-no-scripttools] [-scripttools]\n"
+ "[-no-webkit] [-webkit] [-webkit-debug]\n"
+ "[-graphicssystem raster|opengl|openvg]\n"
+ "[-no-directwrite] [-directwrite]\n\n", 0, 7);
+
+ desc("Installation options:\n\n");
+
+#if !defined(EVAL)
+/*
+ desc(" These are optional, but you may specify install directories.\n\n", 0, 1);
+
+ desc( "-prefix dir", "This will install everything relative to dir\n(default $QT_INSTALL_PREFIX)\n");
+
+ desc(" You may use these to separate different parts of the install:\n\n", 0, 1);
+
+ desc( "-bindir <dir>", "Executables will be installed to dir\n(default PREFIX/bin)");
+ desc( "-libdir <dir>", "Libraries will be installed to dir\n(default PREFIX/lib)");
+ desc( "-docdir <dir>", "Documentation will be installed to dir\n(default PREFIX/doc)");
+ desc( "-headerdir <dir>", "Headers will be installed to dir\n(default PREFIX/include)");
+ desc( "-plugindir <dir>", "Plugins will be installed to dir\n(default PREFIX/plugins)");
+ desc( "-importdir <dir>", "Imports for QML will be installed to dir\n(default PREFIX/imports)");
+ desc( "-datadir <dir>", "Data used by Qt programs will be installed to dir\n(default PREFIX)");
+ desc( "-translationdir <dir>","Translations of Qt programs will be installed to dir\n(default PREFIX/translations)\n");
+ desc( "-examplesdir <dir>", "Examples will be installed to dir\n(default PREFIX/examples)");
+ desc( "-demosdir <dir>", "Demos will be installed to dir\n(default PREFIX/demos)");
+*/
+ desc(" You may use these options to turn on strict plugin loading:\n\n", 0, 1);
+
+ desc( "-buildkey <key>", "Build the Qt library and plugins using the specified <key>. "
+ "When the library loads plugins, it will only load those that have a matching <key>.\n");
+
+ desc("Configure options:\n\n");
+
+ desc(" The defaults (*) are usually acceptable. A plus (+) denotes a default value"
+ " that needs to be evaluated. If the evaluation succeeds, the feature is"
+ " included. Here is a short explanation of each option:\n\n", 0, 1);
+
+ desc("BUILD", "release","-release", "Compile and link Qt with debugging turned off.");
+ desc("BUILD", "debug", "-debug", "Compile and link Qt with debugging turned on.");
+ desc("BUILDALL", "yes", "-debug-and-release", "Compile and link two Qt libraries, with and without debugging turned on.\n");
+
+ desc("OPENSOURCE", "opensource", "-opensource", "Compile and link the Open-Source Edition of Qt.");
+ desc("COMMERCIAL", "commercial", "-commercial", "Compile and link the Commercial Edition of Qt.\n");
+
+ desc("BUILDDEV", "yes", "-developer-build", "Compile and link Qt with Qt developer options (including auto-tests exporting)\n");
+
+ desc("SHARED", "yes", "-shared", "Create and use shared Qt libraries.");
+ desc("SHARED", "no", "-static", "Create and use static Qt libraries.\n");
+
+ desc("LTCG", "yes", "-ltcg", "Use Link Time Code Generation. (Release builds only)");
+ desc("LTCG", "no", "-no-ltcg", "Do not use Link Time Code Generation.\n");
+
+ desc("FAST", "no", "-no-fast", "Configure Qt normally by generating Makefiles for all project files.");
+ desc("FAST", "yes", "-fast", "Configure Qt quickly by generating Makefiles only for library and "
+ "subdirectory targets. All other Makefiles are created as wrappers "
+ "which will in turn run qmake\n");
+
+ desc("EXCEPTIONS", "no", "-no-exceptions", "Disable exceptions on platforms that support it.");
+ desc("EXCEPTIONS", "yes","-exceptions", "Enable exceptions on platforms that support it.\n");
+
+ desc("ACCESSIBILITY", "no", "-no-accessibility", "Do not compile Windows Active Accessibility support.");
+ desc("ACCESSIBILITY", "yes", "-accessibility", "Compile Windows Active Accessibility support.\n");
+
+ desc("STL", "no", "-no-stl", "Do not compile STL support.");
+ desc("STL", "yes", "-stl", "Compile STL support.\n");
+
+ desc( "-no-sql-<driver>", "Disable SQL <driver> entirely, by default none are turned on.");
+ desc( "-qt-sql-<driver>", "Enable a SQL <driver> in the Qt Library.");
+ desc( "-plugin-sql-<driver>", "Enable SQL <driver> as a plugin to be linked to at run time.\n"
+ "Available values for <driver>:");
+ desc("SQL_MYSQL", "auto", "", " mysql", ' ');
+ desc("SQL_PSQL", "auto", "", " psql", ' ');
+ desc("SQL_OCI", "auto", "", " oci", ' ');
+ desc("SQL_ODBC", "auto", "", " odbc", ' ');
+ desc("SQL_TDS", "auto", "", " tds", ' ');
+ desc("SQL_DB2", "auto", "", " db2", ' ');
+ desc("SQL_SQLITE", "auto", "", " sqlite", ' ');
+ desc("SQL_SQLITE2", "auto", "", " sqlite2", ' ');
+ desc("SQL_IBASE", "auto", "", " ibase", ' ');
+ desc( "", "(drivers marked with a '+' have been detected as available on this system)\n", false, ' ');
+
+ desc( "-system-sqlite", "Use sqlite from the operating system.\n");
+
+ desc("QT3SUPPORT", "no","-no-qt3support", "Disables the Qt 3 support functionality.\n");
+ desc("OPENGL", "no","-no-opengl", "Disables OpenGL functionality\n");
+ desc("OPENGL", "no","-opengl <api>", "Enable OpenGL support with specified API version.\n"
+ "Available values for <api>:");
+ desc("", "", "", " desktop - Enable support for Desktop OpenGL", ' ');
+ desc("OPENGL_ES_CM", "no", "", " es1 - Enable support for OpenGL ES Common Profile", ' ');
+ desc("OPENGL_ES_2", "no", "", " es2 - Enable support for OpenGL ES 2.0", ' ');
+
+ desc("OPENVG", "no","-no-openvg", "Disables OpenVG functionality\n");
+ desc("OPENVG", "yes","-openvg", "Enables OpenVG functionality");
+ desc( "", "Requires EGL support, typically supplied by an OpenGL", false, ' ');
+ desc( "", "or other graphics implementation\n", false, ' ');
+
+#endif
+ desc( "-platform <spec>", "The operating system and compiler you are building on.\n(default %QMAKESPEC%)\n");
+ desc( "-xplatform <spec>", "The operating system and compiler you are cross compiling to.\n");
+ desc( "", "See the README file for a list of supported operating systems and compilers.\n", false, ' ');
+
+#if !defined(EVAL)
+ desc( "-qtnamespace <namespace>", "Wraps all Qt library code in 'namespace name {...}");
+ desc( "-qtlibinfix <infix>", "Renames all Qt* libs to Qt*<infix>\n");
+ desc( "-D <define>", "Add an explicit define to the preprocessor.");
+ desc( "-I <includepath>", "Add an explicit include path.");
+ desc( "-L <librarypath>", "Add an explicit library path.");
+ desc( "-l <libraryname>", "Add an explicit library name, residing in a librarypath.\n");
+#endif
+ desc( "-graphicssystem <sys>", "Specify which graphicssystem should be used.\n"
+ "Available values for <sys>:");
+ desc("GRAPHICS_SYSTEM", "raster", "", " raster - Software rasterizer", ' ');
+ desc("GRAPHICS_SYSTEM", "opengl", "", " opengl - Using OpenGL acceleration, experimental!", ' ');
+ desc("GRAPHICS_SYSTEM", "openvg", "", " openvg - Using OpenVG acceleration, experimental!\n", ' ');
+
+ desc( "-help, -h, -?", "Display this information.\n");
+
+#if !defined(EVAL)
+ // 3rd party stuff options go below here --------------------------------------------------------------------------------
+ desc("Third Party Libraries:\n\n");
+
+ desc("ZLIB", "qt", "-qt-zlib", "Use the zlib bundled with Qt.");
+ desc("ZLIB", "system", "-system-zlib", "Use zlib from the operating system.\nSee http://www.gzip.org/zlib\n");
+
+ desc("GIF", "no", "-no-gif", "Do not compile GIF reading support.");
+
+ desc("LIBPNG", "no", "-no-libpng", "Do not compile PNG support.");
+ desc("LIBPNG", "qt", "-qt-libpng", "Use the libpng bundled with Qt.");
+ desc("LIBPNG", "system","-system-libpng", "Use libpng from the operating system.\nSee http://www.libpng.org/pub/png\n");
+
+ desc("LIBMNG", "no", "-no-libmng", "Do not compile MNG support.");
+ desc("LIBMNG", "qt", "-qt-libmng", "Use the libmng bundled with Qt.");
+ desc("LIBMNG", "system","-system-libmng", "Use libmng from the operating system.\nSee See http://www.libmng.com\n");
+
+ desc("LIBTIFF", "no", "-no-libtiff", "Do not compile TIFF support.");
+ desc("LIBTIFF", "qt", "-qt-libtiff", "Use the libtiff bundled with Qt.");
+ desc("LIBTIFF", "system","-system-libtiff", "Use libtiff from the operating system.\nSee http://www.libtiff.org\n");
+
+ desc("LIBJPEG", "no", "-no-libjpeg", "Do not compile JPEG support.");
+ desc("LIBJPEG", "qt", "-qt-libjpeg", "Use the libjpeg bundled with Qt.");
+ desc("LIBJPEG", "system","-system-libjpeg", "Use libjpeg from the operating system.\nSee http://www.ijg.org\n");
+
+#endif
+ // Qt\Windows only options go below here --------------------------------------------------------------------------------
+ desc("Qt for Windows only:\n\n");
+
+ desc("DSPFILES", "no", "-no-dsp", "Do not generate VC++ .dsp files.");
+ desc("DSPFILES", "yes", "-dsp", "Generate VC++ .dsp files, only if spec \"win32-msvc\".\n");
+
+ desc("VCPROJFILES", "no", "-no-vcproj", "Do not generate VC++ .vcproj files.");
+ desc("VCPROJFILES", "yes", "-vcproj", "Generate VC++ .vcproj files, only if platform \"win32-msvc.net\".\n");
+
+ desc("INCREDIBUILD_XGE", "no", "-no-incredibuild-xge", "Do not add IncrediBuild XGE distribution commands to custom build steps.");
+ desc("INCREDIBUILD_XGE", "yes", "-incredibuild-xge", "Add IncrediBuild XGE distribution commands to custom build steps. This will distribute MOC and UIC steps, and other custom buildsteps which are added to the INCREDIBUILD_XGE variable.\n(The IncrediBuild distribution commands are only added to Visual Studio projects)\n");
+
+ desc("PLUGIN_MANIFESTS", "no", "-no-plugin-manifests", "Do not embed manifests in plugins.");
+ desc("PLUGIN_MANIFESTS", "yes", "-plugin-manifests", "Embed manifests in plugins.\n");
+
+#if !defined(EVAL)
+ desc("BUILD_QMAKE", "no", "-no-qmake", "Do not compile qmake.");
+ desc("BUILD_QMAKE", "yes", "-qmake", "Compile qmake.\n");
+
+ desc("NOPROCESS", "yes", "-dont-process", "Do not generate Makefiles/Project files. This will override -no-fast if specified.");
+ desc("NOPROCESS", "no", "-process", "Generate Makefiles/Project files.\n");
+
+ desc("RTTI", "no", "-no-rtti", "Do not compile runtime type information.");
+ desc("RTTI", "yes", "-rtti", "Compile runtime type information.\n");
+ desc("MMX", "no", "-no-mmx", "Do not compile with use of MMX instructions");
+ desc("MMX", "yes", "-mmx", "Compile with use of MMX instructions");
+ desc("3DNOW", "no", "-no-3dnow", "Do not compile with use of 3DNOW instructions");
+ desc("3DNOW", "yes", "-3dnow", "Compile with use of 3DNOW instructions");
+ desc("SSE", "no", "-no-sse", "Do not compile with use of SSE instructions");
+ desc("SSE", "yes", "-sse", "Compile with use of SSE instructions");
+ desc("SSE2", "no", "-no-sse2", "Do not compile with use of SSE2 instructions");
+ desc("SSE2", "yes", "-sse2", "Compile with use of SSE2 instructions");
+ desc("OPENSSL", "no", "-no-openssl", "Do not compile in OpenSSL support");
+ desc("OPENSSL", "yes", "-openssl", "Compile in run-time OpenSSL support");
+ desc("OPENSSL", "linked","-openssl-linked", "Compile in linked OpenSSL support");
+ desc("DBUS", "no", "-no-dbus", "Do not compile in D-Bus support");
+ desc("DBUS", "yes", "-dbus", "Compile in D-Bus support and load libdbus-1 dynamically");
+ desc("DBUS", "linked", "-dbus-linked", "Compile in D-Bus support and link to libdbus-1");
+ desc("PHONON", "no", "-no-phonon", "Do not compile in the Phonon module");
+ desc("PHONON", "yes", "-phonon", "Compile the Phonon module (Phonon is built if a decent C++ compiler is used.)");
+ desc("PHONON_BACKEND","no", "-no-phonon-backend","Do not compile the platform-specific Phonon backend-plugin");
+ desc("PHONON_BACKEND","yes","-phonon-backend", "Compile in the platform-specific Phonon backend-plugin");
+ desc("MULTIMEDIA", "no", "-no-multimedia", "Do not compile the multimedia module");
+ desc("MULTIMEDIA", "yes","-multimedia", "Compile in multimedia module");
+ desc("AUDIO_BACKEND", "no","-no-audio-backend", "Do not compile in the platform audio backend into QtMultimedia");
+ desc("AUDIO_BACKEND", "yes","-audio-backend", "Compile in the platform audio backend into QtMultimedia");
+ desc("WEBKIT", "no", "-no-webkit", "Do not compile in the WebKit module");
+ desc("WEBKIT", "yes", "-webkit", "Compile in the WebKit module (WebKit is built if a decent C++ compiler is used.)");
+ desc("WEBKIT", "debug", "-webkit-debug", "Compile in the WebKit module with debug symbols.");
+ desc("SCRIPT", "no", "-no-script", "Do not build the QtScript module.");
+ desc("SCRIPT", "yes", "-script", "Build the QtScript module.");
+ desc("SCRIPTTOOLS", "no", "-no-scripttools", "Do not build the QtScriptTools module.");
+ desc("SCRIPTTOOLS", "yes", "-scripttools", "Build the QtScriptTools module.");
+ desc("DECLARATIVE", "no", "-no-declarative", "Do not build the declarative module");
+ desc("DECLARATIVE", "yes", "-declarative", "Build the declarative module");
+ desc("DECLARATIVE_DEBUG", "no", "-no-declarative-debug", "Do not build the declarative debugging support");
+ desc("DECLARATIVE_DEBUG", "yes", "-declarative-debug", "Build the declarative debugging support");
+ desc("DIRECTWRITE", "no", "-no-directwrite", "Do not build support for DirectWrite font rendering");
+ desc("DIRECTWRITE", "yes", "-directwrite", "Build support for DirectWrite font rendering (experimental, requires DirectWrite availability on target systems, e.g. Windows Vista with Platform Update, Windows 7, etc.)");
+
+ desc( "-arch <arch>", "Specify an architecture.\n"
+ "Available values for <arch>:");
+ desc("ARCHITECTURE","windows", "", " windows", ' ');
+ desc("ARCHITECTURE","windowsce", "", " windowsce", ' ');
+ desc("ARCHITECTURE","symbian", "", " symbian", ' ');
+ desc("ARCHITECTURE","boundschecker", "", " boundschecker", ' ');
+ desc("ARCHITECTURE","generic", "", " generic\n", ' ');
+
+ desc( "-no-style-<style>", "Disable <style> entirely.");
+ desc( "-qt-style-<style>", "Enable <style> in the Qt Library.\nAvailable styles: ");
+
+ desc("STYLE_WINDOWS", "yes", "", " windows", ' ');
+ desc("STYLE_WINDOWSXP", "auto", "", " windowsxp", ' ');
+ desc("STYLE_WINDOWSVISTA", "auto", "", " windowsvista", ' ');
+ desc("STYLE_PLASTIQUE", "yes", "", " plastique", ' ');
+ desc("STYLE_CLEANLOOKS", "yes", "", " cleanlooks", ' ');
+ desc("STYLE_MOTIF", "yes", "", " motif", ' ');
+ desc("STYLE_CDE", "yes", "", " cde", ' ');
+ desc("STYLE_WINDOWSCE", "yes", "", " windowsce", ' ');
+ desc("STYLE_WINDOWSMOBILE" , "yes", "", " windowsmobile", ' ');
+ desc("STYLE_S60" , "yes", "", " s60\n", ' ');
+ desc("NATIVE_GESTURES", "no", "-no-native-gestures", "Do not use native gestures on Windows 7.");
+ desc("NATIVE_GESTURES", "yes", "-native-gestures", "Use native gestures on Windows 7.");
+ desc("MSVC_MP", "no", "-no-mp", "Do not use multiple processors for compiling with MSVC");
+ desc("MSVC_MP", "yes", "-mp", "Use multiple processors for compiling with MSVC (-MP)");
+
+/* We do not support -qconfig on Windows yet
+
+ desc( "-qconfig <local>", "Use src/tools/qconfig-local.h rather than the default.\nPossible values for local:");
+ for (int i=0; i<allConfigs.size(); ++i)
+ desc( "", qPrintable(QString(" %1").arg(allConfigs.at(i))), false, ' ');
+ printf("\n");
+*/
+#endif
+ desc( "-loadconfig <config>", "Run configure with the parameters from file configure_<config>.cache.");
+ desc( "-saveconfig <config>", "Run configure and save the parameters in file configure_<config>.cache.");
+ desc( "-redo", "Run configure with the same parameters as last time.\n");
+
+ // Qt\Windows CE only options go below here -----------------------------------------------------------------------------
+ desc("Qt for Windows CE only:\n\n");
+ desc("IWMMXT", "no", "-no-iwmmxt", "Do not compile with use of IWMMXT instructions");
+ desc("IWMMXT", "yes", "-iwmmxt", "Do compile with use of IWMMXT instructions (Qt for Windows CE on Arm only)");
+ desc("CE_CRT", "no", "-no-crt" , "Do not add the C runtime to default deployment rules");
+ desc("CE_CRT", "yes", "-qt-crt", "Qt identifies C runtime during project generation");
+ desc( "-crt <path>", "Specify path to C runtime used for project generation.");
+ desc("CETEST", "no", "-no-cetest", "Do not compile Windows CE remote test application");
+ desc("CETEST", "yes", "-cetest", "Compile Windows CE remote test application");
+ desc( "-signature <file>", "Use file for signing the target project");
+
+ desc("DIRECTSHOW", "no", "-phonon-wince-ds9", "Enable Phonon Direct Show 9 backend for Windows CE");
+
+ // Qt\Symbian only options go below here -----------------------------------------------------------------------------
+ desc("Qt for Symbian OS only:\n\n");
+ desc("FREETYPE", "no", "-no-freetype", "Do not compile in Freetype2 support.");
+ desc("FREETYPE", "yes", "-qt-freetype", "Use the libfreetype bundled with Qt.");
+ desc( "-fpu <flags>", "VFP type on ARM, supported options: softvfp(default) | vfpv2 | softvfp+vfpv2");
+ desc("S60", "no", "-no-s60", "Do not compile in S60 support.");
+ desc("S60", "yes", "-s60", "Compile with support for the S60 UI Framework");
+ desc("SYMBIAN_DEFFILES", "no", "-no-usedeffiles", "Disable the usage of DEF files.");
+ desc("SYMBIAN_DEFFILES", "yes", "-usedeffiles", "Enable the usage of DEF files.\n");
+ return true;
+ }
+ return false;
+}
+
+QString Configure::findFileInPaths(const QString &fileName, const QString &paths)
+{
+#if defined(Q_OS_WIN32)
+ QRegExp splitReg("[;,]");
+#else
+ QRegExp splitReg("[:]");
+#endif
+ QStringList pathList = paths.split(splitReg, QString::SkipEmptyParts);
+ QDir d;
+ for (QStringList::ConstIterator it = pathList.begin(); it != pathList.end(); ++it) {
+ // Remove any leading or trailing ", this is commonly used in the environment
+ // variables
+ QString path = (*it);
+ if (path.startsWith('\"'))
+ path = path.right(path.length() - 1);
+ if (path.endsWith('\"'))
+ path = path.left(path.length() - 1);
+ if (d.exists(path + QDir::separator() + fileName))
+ return path;
+ }
+ return QString();
+}
+
+static QString mingwPaths(const QString &mingwPath, const QString &pathName)
+{
+ QString ret;
+ QDir mingwDir = QFileInfo(mingwPath).dir();
+ const QFileInfoList subdirs = mingwDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (int i = 0 ;i < subdirs.length(); ++i) {
+ const QFileInfo &fi = subdirs.at(i);
+ const QString name = fi.fileName();
+ if (name == pathName)
+ ret += fi.absoluteFilePath() + ';';
+ else if (name.contains("mingw"))
+ ret += fi.absoluteFilePath() + QDir::separator() + pathName + ';';
+ }
+ return ret;
+}
+
+bool Configure::findFile(const QString &fileName)
+{
+ const QString file = fileName.toLower();
+ const QString pathEnvVar = QString::fromLocal8Bit(getenv("PATH"));
+ const QString mingwPath = dictionary["QMAKESPEC"].endsWith("-g++") ?
+ findFileInPaths("g++.exe", pathEnvVar) : QString();
+
+ QString paths;
+ if (file.endsWith(".h")) {
+ if (!mingwPath.isNull()) {
+ if (!findFileInPaths(file, mingwPaths(mingwPath, "include")).isNull())
+ return true;
+ //now let's try the additional compiler path
+
+ const QFileInfoList mingwConfigs = QDir(mingwPath + QLatin1String("/../lib/gcc")).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
+ for (int i = 0; i < mingwConfigs.length(); ++i) {
+ const QDir mingwLibDir = mingwConfigs.at(i).absoluteFilePath();
+ foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
+ if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull())
+ return true;
+ }
+ }
+ }
+ paths = QString::fromLocal8Bit(getenv("INCLUDE"));
+ } else if (file.endsWith(".lib") || file.endsWith(".a")) {
+ if (!mingwPath.isNull() && !findFileInPaths(file, mingwPaths(mingwPath, "lib")).isNull())
+ return true;
+ paths = QString::fromLocal8Bit(getenv("LIB"));
+ } else {
+ paths = pathEnvVar;
+ }
+ return !findFileInPaths(file, paths).isNull();
+}
+
+/*!
+ Default value for options marked as "auto" if the test passes.
+ (Used both by the autoDetection() below, and the desc() function
+ to mark (+) the default option of autodetecting options.
+*/
+QString Configure::defaultTo(const QString &option)
+{
+ // We prefer using the system version of the 3rd party libs
+ if (option == "ZLIB"
+ || option == "LIBJPEG"
+ || option == "LIBPNG"
+ || option == "LIBMNG"
+ || option == "LIBTIFF")
+ return "system";
+
+ // PNG is always built-in, never a plugin
+ if (option == "PNG")
+ return "yes";
+
+ // These database drivers and image formats can be built-in or plugins.
+ // Prefer plugins when Qt is shared.
+ if (dictionary[ "SHARED" ] == "yes") {
+ if (option == "SQL_MYSQL"
+ || option == "SQL_MYSQL"
+ || option == "SQL_ODBC"
+ || option == "SQL_OCI"
+ || option == "SQL_PSQL"
+ || option == "SQL_TDS"
+ || option == "SQL_DB2"
+ || option == "SQL_SQLITE"
+ || option == "SQL_SQLITE2"
+ || option == "SQL_IBASE"
+ || option == "JPEG"
+ || option == "MNG"
+ || option == "TIFF"
+ || option == "GIF")
+ return "plugin";
+ }
+
+ // By default we do not want to compile OCI driver when compiling with
+ // MinGW, due to lack of such support from Oracle. It prob. wont work.
+ // (Customer may force the use though)
+ if (dictionary["QMAKESPEC"].endsWith("-g++")
+ && option == "SQL_OCI")
+ return "no";
+
+ if (option == "SYNCQT"
+ && (!QFile::exists(sourcePath + "/bin/syncqt") ||
+ !QFile::exists(sourcePath + "/bin/syncqt.bat")))
+ return "no";
+
+ return "yes";
+}
+
+/*!
+ Checks the system for the availability of a feature.
+ Returns true if the feature is available, else false.
+*/
+bool Configure::checkAvailability(const QString &part)
+{
+ bool available = false;
+ if (part == "STYLE_WINDOWSXP")
+ available = findFile("uxtheme.h");
+
+ else if (part == "ZLIB")
+ available = findFile("zlib.h");
+
+ else if (part == "LIBJPEG")
+ available = findFile("jpeglib.h");
+ else if (part == "LIBPNG")
+ available = findFile("png.h");
+ else if (part == "LIBMNG")
+ available = findFile("libmng.h");
+ else if (part == "LIBTIFF")
+ available = findFile("tiffio.h");
+ else if (part == "SQL_MYSQL")
+ available = findFile("mysql.h") && findFile("libmySQL.lib");
+ else if (part == "SQL_ODBC")
+ available = findFile("sql.h") && findFile("sqlext.h") && findFile("odbc32.lib");
+ else if (part == "SQL_OCI")
+ available = findFile("oci.h") && findFile("oci.lib");
+ else if (part == "SQL_PSQL")
+ available = findFile("libpq-fe.h") && findFile("libpq.lib") && findFile("ws2_32.lib") && findFile("advapi32.lib");
+ else if (part == "SQL_TDS")
+ available = findFile("sybfront.h") && findFile("sybdb.h") && findFile("ntwdblib.lib");
+ else if (part == "SQL_DB2")
+ available = findFile("sqlcli.h") && findFile("sqlcli1.h") && findFile("db2cli.lib");
+ else if (part == "SQL_SQLITE")
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian"))
+ available = false; // In Symbian we only support system sqlite option
+ else
+ available = true; // Built in, we have a fork
+ else if (part == "SQL_SQLITE_LIB") {
+ if (dictionary[ "SQL_SQLITE_LIB" ] == "system") {
+ // Symbian has multiple .lib/.dll files we need to find
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ available = true; // There is sqlite_symbian plugin which exports the necessary stuff
+ dictionary[ "QT_LFLAGS_SQLITE" ] += "-lsqlite3";
+ } else {
+ available = findFile("sqlite3.h") && findFile("sqlite3.lib");
+ if (available)
+ dictionary[ "QT_LFLAGS_SQLITE" ] += "sqlite3.lib";
+ }
+ } else
+ available = true;
+ } else if (part == "SQL_SQLITE2")
+ available = findFile("sqlite.h") && findFile("sqlite.lib");
+ else if (part == "SQL_IBASE")
+ available = findFile("ibase.h") && (findFile("gds32_ms.lib") || findFile("gds32.lib"));
+ else if (part == "IWMMXT")
+ available = (dictionary[ "ARCHITECTURE" ] == "windowsce");
+ else if (part == "OPENGL_ES_CM")
+ available = (dictionary[ "ARCHITECTURE" ] == "windowsce");
+ else if (part == "OPENGL_ES_2")
+ available = (dictionary[ "ARCHITECTURE" ] == "windowsce");
+ else if (part == "DIRECTSHOW")
+ available = (dictionary[ "ARCHITECTURE" ] == "windowsce");
+ else if (part == "SSE2")
+ available = (dictionary.value("QMAKESPEC") != "win32-msvc");
+ else if (part == "3DNOW")
+ available = (dictionary.value("QMAKESPEC") != "win32-msvc") && (dictionary.value("QMAKESPEC") != "win32-icc") && findFile("mm3dnow.h");
+ else if (part == "MMX" || part == "SSE")
+ available = (dictionary.value("QMAKESPEC") != "win32-msvc");
+ else if (part == "OPENSSL")
+ available = findFile("openssl\\ssl.h");
+ else if (part == "DBUS")
+ available = findFile("dbus\\dbus.h");
+ else if (part == "CETEST") {
+ QString rapiHeader = locateFile("rapi.h");
+ QString rapiLib = locateFile("rapi.lib");
+ available = (dictionary[ "ARCHITECTURE" ] == "windowsce") && !rapiHeader.isEmpty() && !rapiLib.isEmpty();
+ if (available) {
+ dictionary[ "QT_CE_RAPI_INC" ] += QLatin1String("\"") + rapiHeader + QLatin1String("\"");
+ dictionary[ "QT_CE_RAPI_LIB" ] += QLatin1String("\"") + rapiLib + QLatin1String("\"");
+ }
+ else if (dictionary[ "CETEST_REQUESTED" ] == "yes") {
+ cout << "cetest could not be enabled: rapi.h and rapi.lib could not be found." << endl;
+ cout << "Make sure the environment is set up for compiling with ActiveSync." << endl;
+ dictionary[ "DONE" ] = "error";
+ }
+ }
+ else if (part == "INCREDIBUILD_XGE")
+ available = findFile("BuildConsole.exe") && findFile("xgConsole.exe");
+ else if (part == "XMLPATTERNS")
+ available = dictionary.value("EXCEPTIONS") == "yes";
+ else if (part == "PHONON") {
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ available = true;
+ } else {
+ available = findFile("vmr9.h") && findFile("dshow.h") && findFile("dmo.h") && findFile("dmodshow.h")
+ && (findFile("strmiids.lib") || findFile("libstrmiids.a"))
+ && (findFile("dmoguids.lib") || findFile("libdmoguids.a"))
+ && (findFile("msdmo.lib") || findFile("libmsdmo.a"))
+ && findFile("d3d9.h");
+
+ if (!available) {
+ cout << "All the required DirectShow/Direct3D files couldn't be found." << endl
+ << "Make sure you have either the platform SDK AND the DirectShow SDK or the Windows SDK installed." << endl
+ << "If you have the DirectShow SDK installed, please make sure that you have run the <path to SDK>\\SetEnv.Cmd script." << endl;
+ if (!findFile("vmr9.h")) cout << "vmr9.h not found" << endl;
+ if (!findFile("dshow.h")) cout << "dshow.h not found" << endl;
+ if (!findFile("strmiids.lib")) cout << "strmiids.lib not found" << endl;
+ if (!findFile("dmoguids.lib")) cout << "dmoguids.lib not found" << endl;
+ if (!findFile("msdmo.lib")) cout << "msdmo.lib not found" << endl;
+ if (!findFile("d3d9.h")) cout << "d3d9.h not found" << endl;
+ }
+ }
+ } else if (part == "WMSDK") {
+ available = findFile("wmsdk.h");
+ } else if (part == "MULTIMEDIA" || part == "SCRIPT" || part == "SCRIPTTOOLS" || part == "DECLARATIVE") {
+ available = true;
+ } else if (part == "WEBKIT") {
+ available = (dictionary.value("QMAKESPEC") == "win32-msvc2005") || (dictionary.value("QMAKESPEC") == "win32-msvc2008") || (dictionary.value("QMAKESPEC") == "win32-msvc2010") || (dictionary.value("QMAKESPEC") == "win32-g++");
+ if (dictionary[ "SHARED" ] == "no") {
+ cout << endl << "WARNING: Using static linking will disable the WebKit module." << endl
+ << endl;
+ available = false;
+ }
+ } else if (part == "AUDIO_BACKEND") {
+ available = true;
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ QString epocRoot = Environment::symbianEpocRoot();
+ const QDir epocRootDir(epocRoot);
+ if (epocRootDir.exists()) {
+ QStringList paths;
+ paths << "epoc32/release/armv5/lib/mmfdevsound.dso"
+ << "epoc32/release/armv5/lib/mmfdevsound.lib"
+ << "epoc32/release/winscw/udeb/mmfdevsound.dll"
+ << "epoc32/release/winscw/udeb/mmfdevsound.lib"
+ << "epoc32/include/mmf/server/sounddevice.h";
+
+ QStringList::iterator i = paths.begin();
+ while (i != paths.end()) {
+ const QString &path = epocRoot + *i;
+ if (QFile::exists(path))
+ i = paths.erase(i);
+ else
+ ++i;
+ }
+
+ available = (paths.size() == 0);
+ if (!available) {
+ if (epocRoot.isEmpty())
+ epocRoot = "<empty string>";
+ cout << endl
+ << "The QtMultimedia audio backend will not be built because required" << endl
+ << "support for CMMFDevSound was not found in the SDK." << endl
+ << "The SDK which was examined was located at the following path:" << endl
+ << " " << epocRoot << endl
+ << "The following required files were missing from the SDK:" << endl;
+ QString path;
+ foreach (path, paths)
+ cout << " " << path << endl;
+ cout << endl;
+ }
+ } else {
+ cout << endl
+ << "The SDK root was determined to be '" << epocRoot << "'." << endl
+ << "This directory was not found, so the SDK could not be checked for" << endl
+ << "CMMFDevSound support. The QtMultimedia audio backend will therefore" << endl
+ << "not be built." << endl << endl;
+ available = false;
+ }
+ }
+ } else if (part == "DIRECTWRITE") {
+ available = findFile("dwrite.h") && findFile("d2d1.h") && findFile("dwrite.lib");
+ }
+
+ return available;
+}
+
+/*
+ Autodetect options marked as "auto".
+*/
+void Configure::autoDetection()
+{
+ // Style detection
+ if (dictionary["STYLE_WINDOWSXP"] == "auto")
+ dictionary["STYLE_WINDOWSXP"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSXP") : "no";
+ if (dictionary["STYLE_WINDOWSVISTA"] == "auto") // Vista style has the same requirements as XP style
+ dictionary["STYLE_WINDOWSVISTA"] = checkAvailability("STYLE_WINDOWSXP") ? defaultTo("STYLE_WINDOWSVISTA") : "no";
+
+ // Compression detection
+ if (dictionary["ZLIB"] == "auto")
+ dictionary["ZLIB"] = checkAvailability("ZLIB") ? defaultTo("ZLIB") : "qt";
+
+ // Image format detection
+ if (dictionary["GIF"] == "auto")
+ dictionary["GIF"] = defaultTo("GIF");
+ if (dictionary["JPEG"] == "auto")
+ dictionary["JPEG"] = defaultTo("JPEG");
+ if (dictionary["PNG"] == "auto")
+ dictionary["PNG"] = defaultTo("PNG");
+ if (dictionary["MNG"] == "auto")
+ dictionary["MNG"] = defaultTo("MNG");
+ if (dictionary["TIFF"] == "auto")
+ dictionary["TIFF"] = dictionary["ZLIB"] == "no" ? "no" : defaultTo("TIFF");
+ if (dictionary["LIBJPEG"] == "auto")
+ dictionary["LIBJPEG"] = checkAvailability("LIBJPEG") ? defaultTo("LIBJPEG") : "qt";
+ if (dictionary["LIBPNG"] == "auto")
+ dictionary["LIBPNG"] = checkAvailability("LIBPNG") ? defaultTo("LIBPNG") : "qt";
+ if (dictionary["LIBMNG"] == "auto")
+ dictionary["LIBMNG"] = checkAvailability("LIBMNG") ? defaultTo("LIBMNG") : "qt";
+ if (dictionary["LIBTIFF"] == "auto")
+ dictionary["LIBTIFF"] = checkAvailability("LIBTIFF") ? defaultTo("LIBTIFF") : "qt";
+
+ // SQL detection (not on by default)
+ if (dictionary["SQL_MYSQL"] == "auto")
+ dictionary["SQL_MYSQL"] = checkAvailability("SQL_MYSQL") ? defaultTo("SQL_MYSQL") : "no";
+ if (dictionary["SQL_ODBC"] == "auto")
+ dictionary["SQL_ODBC"] = checkAvailability("SQL_ODBC") ? defaultTo("SQL_ODBC") : "no";
+ if (dictionary["SQL_OCI"] == "auto")
+ dictionary["SQL_OCI"] = checkAvailability("SQL_OCI") ? defaultTo("SQL_OCI") : "no";
+ if (dictionary["SQL_PSQL"] == "auto")
+ dictionary["SQL_PSQL"] = checkAvailability("SQL_PSQL") ? defaultTo("SQL_PSQL") : "no";
+ if (dictionary["SQL_TDS"] == "auto")
+ dictionary["SQL_TDS"] = checkAvailability("SQL_TDS") ? defaultTo("SQL_TDS") : "no";
+ if (dictionary["SQL_DB2"] == "auto")
+ dictionary["SQL_DB2"] = checkAvailability("SQL_DB2") ? defaultTo("SQL_DB2") : "no";
+ if (dictionary["SQL_SQLITE"] == "auto")
+ dictionary["SQL_SQLITE"] = checkAvailability("SQL_SQLITE") ? defaultTo("SQL_SQLITE") : "no";
+ if (dictionary["SQL_SQLITE_LIB"] == "system")
+ if (!checkAvailability("SQL_SQLITE_LIB"))
+ dictionary["SQL_SQLITE_LIB"] = "no";
+ if (dictionary["SQL_SQLITE2"] == "auto")
+ dictionary["SQL_SQLITE2"] = checkAvailability("SQL_SQLITE2") ? defaultTo("SQL_SQLITE2") : "no";
+ if (dictionary["SQL_IBASE"] == "auto")
+ dictionary["SQL_IBASE"] = checkAvailability("SQL_IBASE") ? defaultTo("SQL_IBASE") : "no";
+ if (dictionary["MMX"] == "auto")
+ dictionary["MMX"] = checkAvailability("MMX") ? "yes" : "no";
+ if (dictionary["3DNOW"] == "auto")
+ dictionary["3DNOW"] = checkAvailability("3DNOW") ? "yes" : "no";
+ if (dictionary["SSE"] == "auto")
+ dictionary["SSE"] = checkAvailability("SSE") ? "yes" : "no";
+ if (dictionary["SSE2"] == "auto")
+ dictionary["SSE2"] = checkAvailability("SSE2") ? "yes" : "no";
+ if (dictionary["IWMMXT"] == "auto")
+ dictionary["IWMMXT"] = checkAvailability("IWMMXT") ? "yes" : "no";
+ if (dictionary["OPENSSL"] == "auto")
+ dictionary["OPENSSL"] = checkAvailability("OPENSSL") ? "yes" : "no";
+ if (dictionary["DBUS"] == "auto")
+ dictionary["DBUS"] = checkAvailability("DBUS") ? "yes" : "no";
+ if (dictionary["SCRIPT"] == "auto")
+ dictionary["SCRIPT"] = checkAvailability("SCRIPT") ? "yes" : "no";
+ if (dictionary["SCRIPTTOOLS"] == "auto")
+ dictionary["SCRIPTTOOLS"] = dictionary["SCRIPT"] == "yes" ? "yes" : "no";
+ if (dictionary["XMLPATTERNS"] == "auto")
+ dictionary["XMLPATTERNS"] = checkAvailability("XMLPATTERNS") ? "yes" : "no";
+ if (dictionary["PHONON"] == "auto")
+ dictionary["PHONON"] = checkAvailability("PHONON") ? "yes" : "no";
+ if (dictionary["WEBKIT"] == "auto")
+ dictionary["WEBKIT"] = checkAvailability("WEBKIT") ? "yes" : "no";
+ if (dictionary["DECLARATIVE"] == "auto")
+ dictionary["DECLARATIVE"] = dictionary["SCRIPT"] == "yes" ? "yes" : "no";
+ if (dictionary["DECLARATIVE_DEBUG"] == "auto")
+ dictionary["DECLARATIVE_DEBUG"] = dictionary["DECLARATIVE"] == "yes" ? "yes" : "no";
+ if (dictionary["AUDIO_BACKEND"] == "auto")
+ dictionary["AUDIO_BACKEND"] = checkAvailability("AUDIO_BACKEND") ? "yes" : "no";
+ if (dictionary["WMSDK"] == "auto")
+ dictionary["WMSDK"] = checkAvailability("WMSDK") ? "yes" : "no";
+
+ // Qt/WinCE remote test application
+ if (dictionary["CETEST"] == "auto")
+ dictionary["CETEST"] = checkAvailability("CETEST") ? "yes" : "no";
+
+ // Detection of IncrediBuild buildconsole
+ if (dictionary["INCREDIBUILD_XGE"] == "auto")
+ dictionary["INCREDIBUILD_XGE"] = checkAvailability("INCREDIBUILD_XGE") ? "yes" : "no";
+
+ // Mark all unknown "auto" to the default value..
+ for (QMap<QString,QString>::iterator i = dictionary.begin(); i != dictionary.end(); ++i) {
+ if (i.value() == "auto")
+ i.value() = defaultTo(i.key());
+ }
+}
+
+bool Configure::verifyConfiguration()
+{
+ if (dictionary["SQL_SQLITE_LIB"] == "no" && dictionary["SQL_SQLITE"] != "no") {
+ cout << "WARNING: Configure could not detect the presence of a system SQLite3 lib." << endl
+ << "Configure will therefore continue with the SQLite3 lib bundled with Qt." << endl
+ << "(Press any key to continue..)";
+ if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
+ exit(0); // Exit cleanly for Ctrl+C
+
+ dictionary["SQL_SQLITE_LIB"] = "qt"; // Set to Qt's bundled lib an continue
+ }
+ if (dictionary["QMAKESPEC"].endsWith("-g++")
+ && dictionary["SQL_OCI"] != "no") {
+ cout << "WARNING: Qt does not support compiling the Oracle database driver with" << endl
+ << "MinGW, due to lack of such support from Oracle. Consider disabling the" << endl
+ << "Oracle driver, as the current build will most likely fail." << endl;
+ cout << "(Press any key to continue..)";
+ if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
+ exit(0); // Exit cleanly for Ctrl+C
+ }
+ if (dictionary["QMAKESPEC"].endsWith("win32-msvc.net")) {
+ cout << "WARNING: The makespec win32-msvc.net is deprecated. Consider using" << endl
+ << "win32-msvc2002 or win32-msvc2003 instead." << endl;
+ cout << "(Press any key to continue..)";
+ if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
+ exit(0); // Exit cleanly for Ctrl+C
+ }
+ if (0 != dictionary["ARM_FPU_TYPE"].size()) {
+ QStringList l= QStringList()
+ << "softvfp"
+ << "softvfp+vfpv2"
+ << "vfpv2";
+ if (!(l.contains(dictionary["ARM_FPU_TYPE"])))
+ cout << QString("WARNING: Using unsupported fpu flag: %1").arg(dictionary["ARM_FPU_TYPE"]) << endl;
+ }
+ if (dictionary["DECLARATIVE"] == "yes" && dictionary["SCRIPT"] == "no") {
+ cout << "WARNING: To be able to compile QtDeclarative we need to also compile the" << endl
+ << "QtScript module. If you continue, we will turn on the QtScript module." << endl
+ << "(Press any key to continue..)";
+ if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
+ exit(0); // Exit cleanly for Ctrl+C
+
+ dictionary["SCRIPT"] = "yes";
+ }
+
+ if (dictionary["DIRECTWRITE"] == "yes" && !checkAvailability("DIRECTWRITE")) {
+ cout << "WARNING: To be able to compile the DirectWrite font engine you will" << endl
+ << "need the Microsoft DirectWrite and Microsoft Direct2D development" << endl
+ << "files such as headers and libraries." << endl
+ << "(Press any key to continue..)";
+ if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
+ exit(0); // Exit cleanly for Ctrl+C
+ }
+
+ return true;
+}
+
+/*
+ Things that affect the Qt API/ABI:
+ Options:
+ minimal-config small-config medium-config large-config full-config
+
+ Options:
+ debug release
+ stl
+
+ Things that do not affect the Qt API/ABI:
+ system-jpeg no-jpeg jpeg
+ system-mng no-mng mng
+ system-png no-png png
+ system-zlib no-zlib zlib
+ system-tiff no-tiff tiff
+ no-gif gif
+ dll staticlib
+
+ nocrosscompiler
+ GNUmake
+ largefile
+ nis
+ nas
+ tablet
+ ipv6
+
+ X11 : x11sm xinerama xcursor xfixes xrandr xrender fontconfig xkb
+ Embedded: embedded freetype
+*/
+void Configure::generateBuildKey()
+{
+ QString spec = dictionary["QMAKESPEC"];
+
+ QString compiler = "msvc"; // ICC is compatible
+ if (spec.endsWith("-g++"))
+ compiler = "mingw";
+ else if (spec.endsWith("-borland"))
+ compiler = "borland";
+
+ // Build options which changes the Qt API/ABI
+ QStringList build_options;
+ if (!dictionary["QCONFIG"].isEmpty())
+ build_options += dictionary["QCONFIG"] + "-config ";
+ build_options.sort();
+
+ // Sorted defines that start with QT_NO_
+ QStringList build_defines = qmakeDefines.filter(QRegExp("^QT_NO_"));
+ build_defines.sort();
+
+ // Build up the QT_BUILD_KEY ifdef
+ QString buildKey = "QT_BUILD_KEY \"";
+ if (!dictionary["USER_BUILD_KEY"].isEmpty())
+ buildKey += dictionary["USER_BUILD_KEY"] + " ";
+
+ QString build32Key = buildKey + "Windows " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" ");
+ QString build64Key = buildKey + "Windows x64 " + compiler + " %1 " + build_options.join(" ") + " " + build_defines.join(" ");
+ QString buildSymbianKey = buildKey + "Symbian " + build_options.join(" ") + " " + build_defines.join(" ");
+ build32Key = build32Key.simplified();
+ build64Key = build64Key.simplified();
+ buildSymbianKey = buildSymbianKey.simplified();
+ build32Key.prepend("# define ");
+ build64Key.prepend("# define ");
+ buildSymbianKey.prepend("# define ");
+
+ QString buildkey = "#if defined(__SYMBIAN32__)\n"
+ + buildSymbianKey + "\"\n"
+ "#else\n"
+ // Debug builds
+ "# if !defined(QT_NO_DEBUG)\n"
+ "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n"
+ + build64Key.arg("debug") + "\"\n"
+ "# else\n"
+ + build32Key.arg("debug") + "\"\n"
+ "# endif\n"
+ "# else\n"
+ // Release builds
+ "# if (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))\n"
+ + build64Key.arg("release") + "\"\n"
+ "# else\n"
+ + build32Key.arg("release") + "\"\n"
+ "# endif\n"
+ "# endif\n"
+ "#endif\n";
+
+ dictionary["BUILD_KEY"] = buildkey;
+}
+
+void Configure::generateOutputVars()
+{
+ // Generate variables for output
+ // Build key ----------------------------------------------------
+ if (dictionary.contains("BUILD_KEY")) {
+ qmakeVars += dictionary.value("BUILD_KEY");
+ }
+
+ QString build = dictionary[ "BUILD" ];
+ bool buildAll = (dictionary[ "BUILDALL" ] == "yes");
+ if (build == "debug") {
+ if (buildAll)
+ qtConfig += "release";
+ qtConfig += "debug";
+ } else if (build == "release") {
+ if (buildAll)
+ qtConfig += "debug";
+ qtConfig += "release";
+ }
+
+ // Compression --------------------------------------------------
+ if (dictionary[ "ZLIB" ] == "qt")
+ qtConfig += "zlib";
+ else if (dictionary[ "ZLIB" ] == "system")
+ qtConfig += "system-zlib";
+
+ // Image formates -----------------------------------------------
+ if (dictionary[ "GIF" ] == "no")
+ qtConfig += "no-gif";
+ else if (dictionary[ "GIF" ] == "yes")
+ qtConfig += "gif";
+
+ if (dictionary[ "TIFF" ] == "no")
+ qtConfig += "no-tiff";
+ else if (dictionary[ "TIFF" ] == "yes")
+ qtConfig += "tiff";
+ if (dictionary[ "LIBTIFF" ] == "system")
+ qtConfig += "system-tiff";
+
+ if (dictionary[ "JPEG" ] == "no")
+ qtConfig += "no-jpeg";
+ else if (dictionary[ "JPEG" ] == "yes")
+ qtConfig += "jpeg";
+ if (dictionary[ "LIBJPEG" ] == "system")
+ qtConfig += "system-jpeg";
+
+ if (dictionary[ "PNG" ] == "no")
+ qtConfig += "no-png";
+ else if (dictionary[ "PNG" ] == "yes")
+ qtConfig += "png";
+ if (dictionary[ "LIBPNG" ] == "system")
+ qtConfig += "system-png";
+
+ if (dictionary[ "MNG" ] == "no")
+ qtConfig += "no-mng";
+ else if (dictionary[ "MNG" ] == "yes")
+ qtConfig += "mng";
+ if (dictionary[ "LIBMNG" ] == "system")
+ qtConfig += "system-mng";
+
+ // Text rendering --------------------------------------------------
+ if (dictionary[ "FREETYPE" ] == "yes")
+ qtConfig += "freetype";
+
+ // Styles -------------------------------------------------------
+ if (dictionary[ "STYLE_WINDOWS" ] == "yes")
+ qmakeStyles += "windows";
+
+ if (dictionary[ "STYLE_PLASTIQUE" ] == "yes")
+ qmakeStyles += "plastique";
+
+ if (dictionary[ "STYLE_CLEANLOOKS" ] == "yes")
+ qmakeStyles += "cleanlooks";
+
+ if (dictionary[ "STYLE_WINDOWSXP" ] == "yes")
+ qmakeStyles += "windowsxp";
+
+ if (dictionary[ "STYLE_WINDOWSVISTA" ] == "yes")
+ qmakeStyles += "windowsvista";
+
+ if (dictionary[ "STYLE_MOTIF" ] == "yes")
+ qmakeStyles += "motif";
+
+ if (dictionary[ "STYLE_SGI" ] == "yes")
+ qmakeStyles += "sgi";
+
+ if (dictionary[ "STYLE_WINDOWSCE" ] == "yes")
+ qmakeStyles += "windowsce";
+
+ if (dictionary[ "STYLE_WINDOWSMOBILE" ] == "yes")
+ qmakeStyles += "windowsmobile";
+
+ if (dictionary[ "STYLE_CDE" ] == "yes")
+ qmakeStyles += "cde";
+
+ if (dictionary[ "STYLE_S60" ] == "yes")
+ qmakeStyles += "s60";
+
+ // Databases ----------------------------------------------------
+ if (dictionary[ "SQL_MYSQL" ] == "yes")
+ qmakeSql += "mysql";
+ else if (dictionary[ "SQL_MYSQL" ] == "plugin")
+ qmakeSqlPlugins += "mysql";
+
+ if (dictionary[ "SQL_ODBC" ] == "yes")
+ qmakeSql += "odbc";
+ else if (dictionary[ "SQL_ODBC" ] == "plugin")
+ qmakeSqlPlugins += "odbc";
+
+ if (dictionary[ "SQL_OCI" ] == "yes")
+ qmakeSql += "oci";
+ else if (dictionary[ "SQL_OCI" ] == "plugin")
+ qmakeSqlPlugins += "oci";
+
+ if (dictionary[ "SQL_PSQL" ] == "yes")
+ qmakeSql += "psql";
+ else if (dictionary[ "SQL_PSQL" ] == "plugin")
+ qmakeSqlPlugins += "psql";
+
+ if (dictionary[ "SQL_TDS" ] == "yes")
+ qmakeSql += "tds";
+ else if (dictionary[ "SQL_TDS" ] == "plugin")
+ qmakeSqlPlugins += "tds";
+
+ if (dictionary[ "SQL_DB2" ] == "yes")
+ qmakeSql += "db2";
+ else if (dictionary[ "SQL_DB2" ] == "plugin")
+ qmakeSqlPlugins += "db2";
+
+ if (dictionary[ "SQL_SQLITE" ] == "yes")
+ qmakeSql += "sqlite";
+ else if (dictionary[ "SQL_SQLITE" ] == "plugin")
+ qmakeSqlPlugins += "sqlite";
+
+ if (dictionary[ "SQL_SQLITE_LIB" ] == "system")
+ qmakeConfig += "system-sqlite";
+
+ if (dictionary[ "SQL_SQLITE2" ] == "yes")
+ qmakeSql += "sqlite2";
+ else if (dictionary[ "SQL_SQLITE2" ] == "plugin")
+ qmakeSqlPlugins += "sqlite2";
+
+ if (dictionary[ "SQL_IBASE" ] == "yes")
+ qmakeSql += "ibase";
+ else if (dictionary[ "SQL_IBASE" ] == "plugin")
+ qmakeSqlPlugins += "ibase";
+
+ // Other options ------------------------------------------------
+ if (dictionary[ "BUILDALL" ] == "yes") {
+ qmakeConfig += "build_all";
+ }
+ qmakeConfig += dictionary[ "BUILD" ];
+ dictionary[ "QMAKE_OUTDIR" ] = dictionary[ "BUILD" ];
+
+ if (dictionary[ "SHARED" ] == "yes") {
+ QString version = dictionary[ "VERSION" ];
+ if (!version.isEmpty()) {
+ qmakeVars += "QMAKE_QT_VERSION_OVERRIDE = " + version.left(version.indexOf("."));
+ version.remove(QLatin1Char('.'));
+ }
+ dictionary[ "QMAKE_OUTDIR" ] += "_shared";
+ } else {
+ dictionary[ "QMAKE_OUTDIR" ] += "_static";
+ }
+
+ if (dictionary[ "ACCESSIBILITY" ] == "yes")
+ qtConfig += "accessibility";
+
+ if (!qmakeLibs.isEmpty())
+ qmakeVars += "LIBS += " + escapeSeparators(qmakeLibs.join(" "));
+
+ if (!dictionary["QT_LFLAGS_SQLITE"].isEmpty())
+ qmakeVars += "QT_LFLAGS_SQLITE += " + escapeSeparators(dictionary["QT_LFLAGS_SQLITE"]);
+
+ if (dictionary[ "QT3SUPPORT" ] == "yes")
+ qtConfig += "qt3support";
+
+ if (dictionary[ "OPENGL" ] == "yes")
+ qtConfig += "opengl";
+
+ if (dictionary["OPENGL_ES_CM"] == "yes") {
+ qtConfig += "opengles1";
+ qtConfig += "egl";
+ }
+
+ if (dictionary["OPENGL_ES_2"] == "yes") {
+ qtConfig += "opengles2";
+ qtConfig += "egl";
+ }
+
+ if (dictionary["OPENVG"] == "yes") {
+ qtConfig += "openvg";
+ qtConfig += "egl";
+ }
+
+ if (dictionary["S60"] == "yes") {
+ qtConfig += "s60";
+ }
+
+ if (dictionary["DIRECTSHOW"] == "yes")
+ qtConfig += "directshow";
+
+ if (dictionary[ "OPENSSL" ] == "yes")
+ qtConfig += "openssl";
+ else if (dictionary[ "OPENSSL" ] == "linked")
+ qtConfig += "openssl-linked";
+
+ if (dictionary[ "DBUS" ] == "yes")
+ qtConfig += "dbus";
+ else if (dictionary[ "DBUS" ] == "linked")
+ qtConfig += "dbus dbus-linked";
+
+ if (dictionary["IPV6"] == "yes")
+ qtConfig += "ipv6";
+ else if (dictionary["IPV6"] == "no")
+ qtConfig += "no-ipv6";
+
+ if (dictionary[ "CETEST" ] == "yes")
+ qtConfig += "cetest";
+
+ if (dictionary[ "SCRIPT" ] == "yes")
+ qtConfig += "script";
+
+ if (dictionary[ "SCRIPTTOOLS" ] == "yes") {
+ if (dictionary[ "SCRIPT" ] == "no") {
+ cout << "QtScriptTools was requested, but it can't be built due to QtScript being "
+ "disabled." << endl;
+ dictionary[ "DONE" ] = "error";
+ }
+ qtConfig += "scripttools";
+ }
+
+ if (dictionary[ "XMLPATTERNS" ] == "yes")
+ qtConfig += "xmlpatterns";
+
+ if (dictionary["PHONON"] == "yes") {
+ qtConfig += "phonon";
+ if (dictionary["PHONON_BACKEND"] == "yes")
+ qtConfig += "phonon-backend";
+ }
+
+ if (dictionary["MULTIMEDIA"] == "yes") {
+ qtConfig += "multimedia";
+ if (dictionary["AUDIO_BACKEND"] == "yes")
+ qtConfig += "audio-backend";
+ }
+
+ QString dst = buildPath + "/mkspecs/modules/qt_webkit_version.pri";
+ QFile::remove(dst);
+ if (dictionary["WEBKIT"] != "no") {
+ // This include takes care of adding "webkit" to QT_CONFIG.
+ QString src = sourcePath + "/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri";
+ QFile::copy(src, dst);
+ if (dictionary["WEBKIT"] == "debug")
+ qtConfig += "webkit-debug";
+ }
+
+ if (dictionary["DECLARATIVE"] == "yes") {
+ if (dictionary[ "SCRIPT" ] == "no") {
+ cout << "QtDeclarative was requested, but it can't be built due to QtScript being "
+ "disabled." << endl;
+ dictionary[ "DONE" ] = "error";
+ }
+ qtConfig += "declarative";
+ }
+
+ if (dictionary["DIRECTWRITE"] == "yes")
+ qtConfig += "directwrite";
+
+ if (dictionary[ "NATIVE_GESTURES" ] == "yes")
+ qtConfig += "native-gestures";
+
+ // We currently have no switch for QtSvg, so add it unconditionally.
+ qtConfig += "svg";
+
+ // Add config levels --------------------------------------------
+ QStringList possible_configs = QStringList()
+ << "minimal"
+ << "small"
+ << "medium"
+ << "large"
+ << "full";
+
+ QString set_config = dictionary["QCONFIG"];
+ if (possible_configs.contains(set_config)) {
+ foreach (const QString &cfg, possible_configs) {
+ qtConfig += (cfg + "-config");
+ if (cfg == set_config)
+ break;
+ }
+ }
+
+ if (dictionary.contains("XQMAKESPEC") && (dictionary["QMAKESPEC"] != dictionary["XQMAKESPEC"]))
+ qmakeConfig += "cross_compile";
+
+ // Directories and settings for .qmake.cache --------------------
+
+ // if QT_INSTALL_* have not been specified on commandline, define them now from QT_INSTALL_PREFIX
+ // if prefix is empty (WINCE), make all of them empty, if they aren't set
+ bool qipempty = false;
+ if (dictionary[ "QT_INSTALL_PREFIX" ].isEmpty())
+ qipempty = true;
+
+ if (!dictionary[ "QT_INSTALL_DOCS" ].size())
+ dictionary[ "QT_INSTALL_DOCS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/doc");
+ if (!dictionary[ "QT_INSTALL_HEADERS" ].size())
+ dictionary[ "QT_INSTALL_HEADERS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/include");
+ if (!dictionary[ "QT_INSTALL_LIBS" ].size())
+ dictionary[ "QT_INSTALL_LIBS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/lib");
+ if (!dictionary[ "QT_INSTALL_BINS" ].size())
+ dictionary[ "QT_INSTALL_BINS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/bin");
+ if (!dictionary[ "QT_INSTALL_PLUGINS" ].size())
+ dictionary[ "QT_INSTALL_PLUGINS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/plugins");
+ if (!dictionary[ "QT_INSTALL_IMPORTS" ].size())
+ dictionary[ "QT_INSTALL_IMPORTS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/imports");
+ if (!dictionary[ "QT_INSTALL_DATA" ].size())
+ dictionary[ "QT_INSTALL_DATA" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ]);
+ if (!dictionary[ "QT_INSTALL_TRANSLATIONS" ].size())
+ dictionary[ "QT_INSTALL_TRANSLATIONS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/translations");
+ if (!dictionary[ "QT_INSTALL_EXAMPLES" ].size())
+ dictionary[ "QT_INSTALL_EXAMPLES" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/examples");
+ if (!dictionary[ "QT_INSTALL_DEMOS" ].size())
+ dictionary[ "QT_INSTALL_DEMOS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/demos");
+
+ if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux"))
+ dictionary[ "QMAKE_RPATHDIR" ] = dictionary[ "QT_INSTALL_LIBS" ];
+
+ qmakeVars += QString("OBJECTS_DIR = ") + fixSeparators("tmp/obj/" + dictionary[ "QMAKE_OUTDIR" ], true);
+ qmakeVars += QString("MOC_DIR = ") + fixSeparators("tmp/moc/" + dictionary[ "QMAKE_OUTDIR" ], true);
+ qmakeVars += QString("RCC_DIR = ") + fixSeparators("tmp/rcc/" + dictionary["QMAKE_OUTDIR"], true);
+
+ if (!qmakeDefines.isEmpty())
+ qmakeVars += QString("DEFINES += ") + qmakeDefines.join(" ");
+ if (!qmakeIncludes.isEmpty())
+ qmakeVars += QString("INCLUDEPATH += ") + escapeSeparators(qmakeIncludes.join(" "));
+ if (!opensslLibs.isEmpty())
+ qmakeVars += opensslLibs;
+ else if (dictionary[ "OPENSSL" ] == "linked") {
+ if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("symbian"))
+ qmakeVars += QString("OPENSSL_LIBS = -llibssl -llibcrypto");
+ else
+ qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32");
+ }
+ if (!psqlLibs.isEmpty())
+ qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1);
+
+ {
+ QStringList lflagsTDS;
+ if (!sybase.isEmpty())
+ lflagsTDS += QString("-L") + fixSeparators(sybase.section("=", 1) + "/lib");
+ if (!sybaseLibs.isEmpty())
+ lflagsTDS += sybaseLibs.section("=", 1);
+ if (!lflagsTDS.isEmpty())
+ qmakeVars += QString("QT_LFLAGS_TDS=") + lflagsTDS.join(" ");
+ }
+
+ if (!qmakeSql.isEmpty())
+ qmakeVars += QString("sql-drivers += ") + qmakeSql.join(" ");
+ if (!qmakeSqlPlugins.isEmpty())
+ qmakeVars += QString("sql-plugins += ") + qmakeSqlPlugins.join(" ");
+ if (!qmakeStyles.isEmpty())
+ qmakeVars += QString("styles += ") + qmakeStyles.join(" ");
+ if (!qmakeStylePlugins.isEmpty())
+ qmakeVars += QString("style-plugins += ") + qmakeStylePlugins.join(" ");
+
+ if (dictionary["QMAKESPEC"].endsWith("-g++")) {
+ QString includepath = qgetenv("INCLUDE");
+ bool hasSh = Environment::detectExecutable("sh.exe");
+ QChar separator = (!includepath.contains(":\\") && hasSh ? QChar(':') : QChar(';'));
+ qmakeVars += QString("TMPPATH = $$quote($$(INCLUDE))");
+ qmakeVars += QString("QMAKE_INCDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
+ qmakeVars += QString("TMPPATH = $$quote($$(LIB))");
+ qmakeVars += QString("QMAKE_LIBDIR_POST += $$split(TMPPATH,\"%1\")").arg(separator);
+ }
+
+ if (!dictionary[ "QMAKESPEC" ].length()) {
+ cout << "Configure could not detect your compiler. QMAKESPEC must either" << endl
+ << "be defined as an environment variable, or specified as an" << endl
+ << "argument with -platform" << endl;
+ dictionary[ "HELP" ] = "yes";
+
+ QStringList winPlatforms;
+ QDir mkspecsDir(sourcePath + "/mkspecs");
+ const QFileInfoList &specsList = mkspecsDir.entryInfoList();
+ for (int i = 0; i < specsList.size(); ++i) {
+ const QFileInfo &fi = specsList.at(i);
+ if (fi.fileName().left(5) == "win32") {
+ winPlatforms += fi.fileName();
+ }
+ }
+ cout << "Available platforms are: " << qPrintable(winPlatforms.join(", ")) << endl;
+ dictionary[ "DONE" ] = "error";
+ }
+}
+
+#if !defined(EVAL)
+void Configure::generateCachefile()
+{
+ // Generate .qmake.cache
+ QFile cacheFile(buildPath + "/.qmake.cache");
+ if (cacheFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
+ QTextStream cacheStream(&cacheFile);
+ for (QStringList::Iterator var = qmakeVars.begin(); var != qmakeVars.end(); ++var) {
+ cacheStream << (*var) << endl;
+ }
+ cacheStream << "CONFIG += " << qmakeConfig.join(" ") << " incremental msvc_mp create_prl link_prl depend_includepath QTDIR_build" << endl;
+
+ QStringList buildParts;
+ buildParts << "libs" << "tools" << "examples" << "demos" << "docs" << "translations";
+ foreach (const QString &item, disabledBuildParts) {
+ buildParts.removeAll(item);
+ }
+ cacheStream << "QT_BUILD_PARTS = " << buildParts.join(" ") << endl;
+
+ QString targetSpec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
+ QString mkspec_path = fixSeparators(sourcePath + "/mkspecs/" + targetSpec);
+ if (QFile::exists(mkspec_path))
+ cacheStream << "QMAKESPEC = " << escapeSeparators(mkspec_path) << endl;
+ else
+ cacheStream << "QMAKESPEC = " << fixSeparators(targetSpec, true) << endl;
+ cacheStream << "ARCH = " << dictionary[ "ARCHITECTURE" ] << endl;
+ cacheStream << "QT_BUILD_TREE = " << fixSeparators(dictionary[ "QT_BUILD_TREE" ], true) << endl;
+ cacheStream << "QT_SOURCE_TREE = " << fixSeparators(dictionary[ "QT_SOURCE_TREE" ], true) << endl;
+
+ if (dictionary["QT_EDITION"] != "QT_EDITION_OPENSOURCE")
+ cacheStream << "DEFINES *= QT_EDITION=QT_EDITION_DESKTOP" << endl;
+
+ //so that we can build without an install first (which would be impossible)
+ cacheStream << "QMAKE_MOC = $$QT_BUILD_TREE" << fixSeparators("/bin/moc.exe", true) << endl;
+ cacheStream << "QMAKE_UIC = $$QT_BUILD_TREE" << fixSeparators("/bin/uic.exe", true) << endl;
+ cacheStream << "QMAKE_UIC3 = $$QT_BUILD_TREE" << fixSeparators("/bin/uic3.exe", true) << endl;
+ cacheStream << "QMAKE_RCC = $$QT_BUILD_TREE" << fixSeparators("/bin/rcc.exe", true) << endl;
+ cacheStream << "QMAKE_DUMPCPP = $$QT_BUILD_TREE" << fixSeparators("/bin/dumpcpp.exe", true) << endl;
+ cacheStream << "QMAKE_INCDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/include", true) << endl;
+ cacheStream << "QMAKE_LIBDIR_QT = $$QT_BUILD_TREE" << fixSeparators("/lib", true) << endl;
+ if (dictionary["CETEST"] == "yes") {
+ cacheStream << "QT_CE_RAPI_INC = " << fixSeparators(dictionary[ "QT_CE_RAPI_INC" ], true) << endl;
+ cacheStream << "QT_CE_RAPI_LIB = " << fixSeparators(dictionary[ "QT_CE_RAPI_LIB" ], true) << endl;
+ }
+
+ // embedded
+ if (!dictionary["KBD_DRIVERS"].isEmpty())
+ cacheStream << "kbd-drivers += "<< dictionary["KBD_DRIVERS"]<<endl;
+ if (!dictionary["GFX_DRIVERS"].isEmpty())
+ cacheStream << "gfx-drivers += "<< dictionary["GFX_DRIVERS"]<<endl;
+ if (!dictionary["MOUSE_DRIVERS"].isEmpty())
+ cacheStream << "mouse-drivers += "<< dictionary["MOUSE_DRIVERS"]<<endl;
+ if (!dictionary["DECORATIONS"].isEmpty())
+ cacheStream << "decorations += "<<dictionary["DECORATIONS"]<<endl;
+
+ if (!dictionary["QMAKE_RPATHDIR"].isEmpty())
+ cacheStream << "QMAKE_RPATHDIR += "<<dictionary["QMAKE_RPATHDIR"];
+
+ cacheStream.flush();
+ cacheFile.close();
+ }
+ QFile configFile(dictionary[ "QT_BUILD_TREE" ] + "/mkspecs/qconfig.pri");
+ if (configFile.open(QFile::WriteOnly | QFile::Text)) { // Truncates any existing file.
+ QTextStream configStream(&configFile);
+ configStream << "CONFIG+= ";
+ configStream << dictionary[ "BUILD" ];
+ if (dictionary[ "SHARED" ] == "yes")
+ configStream << " shared";
+ else
+ configStream << " static";
+
+ if (dictionary[ "LTCG" ] == "yes")
+ configStream << " ltcg";
+ if (dictionary[ "MSVC_MP" ] == "yes")
+ configStream << " msvc_mp";
+ if (dictionary[ "STL" ] == "yes")
+ configStream << " stl";
+ if (dictionary[ "EXCEPTIONS" ] == "yes")
+ configStream << " exceptions";
+ if (dictionary[ "EXCEPTIONS" ] == "no")
+ configStream << " exceptions_off";
+ if (dictionary[ "RTTI" ] == "yes")
+ configStream << " rtti";
+ if (dictionary[ "MMX" ] == "yes")
+ configStream << " mmx";
+ if (dictionary[ "3DNOW" ] == "yes")
+ configStream << " 3dnow";
+ if (dictionary[ "SSE" ] == "yes")
+ configStream << " sse";
+ if (dictionary[ "SSE2" ] == "yes")
+ configStream << " sse2";
+ if (dictionary[ "IWMMXT" ] == "yes")
+ configStream << " iwmmxt";
+ if (dictionary["INCREDIBUILD_XGE"] == "yes")
+ configStream << " incredibuild_xge";
+ if (dictionary["PLUGIN_MANIFESTS"] == "no")
+ configStream << " no_plugin_manifest";
+
+ if (dictionary.contains("SYMBIAN_DEFFILES")) {
+ if (dictionary["SYMBIAN_DEFFILES"] == "yes") {
+ configStream << " def_files";
+ } else if (dictionary["SYMBIAN_DEFFILES"] == "no") {
+ configStream << " def_files_disabled";
+ }
+ }
+
+ if (dictionary["DIRECTWRITE"] == "yes")
+ configStream << "directwrite";
+
+ configStream << endl;
+ configStream << "QT_ARCH = " << dictionary[ "ARCHITECTURE" ] << endl;
+ if (dictionary["QT_EDITION"].contains("OPENSOURCE"))
+ configStream << "QT_EDITION = " << QLatin1String("OpenSource") << endl;
+ else
+ configStream << "QT_EDITION = " << dictionary["EDITION"] << endl;
+ configStream << "QT_CONFIG += " << qtConfig.join(" ") << endl;
+
+ configStream << "#versioning " << endl
+ << "QT_VERSION = " << dictionary["VERSION"] << endl
+ << "QT_MAJOR_VERSION = " << dictionary["VERSION_MAJOR"] << endl
+ << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl
+ << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl;
+
+ configStream << "#Qt for Windows CE c-runtime deployment" << endl
+ << "QT_CE_C_RUNTIME = " << fixSeparators(dictionary[ "CE_CRT" ], true) << endl;
+
+ if (dictionary["CE_SIGNATURE"] != QLatin1String("no"))
+ configStream << "DEFAULT_SIGNATURE=" << dictionary["CE_SIGNATURE"] << endl;
+
+ if (!dictionary["QMAKE_RPATHDIR"].isEmpty())
+ configStream << "QMAKE_RPATHDIR += " << dictionary["QMAKE_RPATHDIR"] << endl;
+
+ if (!dictionary["QT_LIBINFIX"].isEmpty())
+ configStream << "QT_LIBINFIX = " << dictionary["QT_LIBINFIX"] << endl;
+
+ configStream << "#Qt for Symbian FPU settings" << endl;
+ if (!dictionary["ARM_FPU_TYPE"].isEmpty()) {
+ configStream<<"MMP_RULES += \"ARMFPU "<< dictionary["ARM_FPU_TYPE"]<< "\"";
+ }
+ if (!dictionary["QT_NAMESPACE"].isEmpty()) {
+ configStream << "#namespaces" << endl << "QT_NAMESPACE = " << dictionary["QT_NAMESPACE"] << endl;
+ }
+
+ configStream.flush();
+ configFile.close();
+ }
+}
+#endif
+
+QString Configure::addDefine(QString def)
+{
+ QString result, defNeg, defD = def;
+
+ defD.replace(QRegExp("=.*"), "");
+ def.replace(QRegExp("="), " ");
+
+ if (def.startsWith("QT_NO_")) {
+ defNeg = defD;
+ defNeg.replace("QT_NO_", "QT_");
+ } else if (def.startsWith("QT_")) {
+ defNeg = defD;
+ defNeg.replace("QT_", "QT_NO_");
+ }
+
+ if (defNeg.isEmpty()) {
+ result = "#ifndef $DEFD\n"
+ "# define $DEF\n"
+ "#endif\n\n";
+ } else {
+ result = "#if defined($DEFD) && defined($DEFNEG)\n"
+ "# undef $DEFD\n"
+ "#elif !defined($DEFD)\n"
+ "# define $DEF\n"
+ "#endif\n\n";
+ }
+ result.replace("$DEFNEG", defNeg);
+ result.replace("$DEFD", defD);
+ result.replace("$DEF", def);
+ return result;
+}
+
+#if !defined(EVAL)
+void Configure::generateConfigfiles()
+{
+ QDir(buildPath).mkpath("src/corelib/global");
+ QString outName(buildPath + "/src/corelib/global/qconfig.h");
+ QTemporaryFile tmpFile;
+ QTextStream tmpStream;
+
+ if (tmpFile.open()) {
+ tmpStream.setDevice(&tmpFile);
+
+ if (dictionary[ "QCONFIG" ] == "full") {
+ tmpStream << "/* Everything */" << endl;
+ } else {
+ QString configName("qconfig-" + dictionary[ "QCONFIG" ] + ".h");
+ tmpStream << "/* Copied from " << configName << "*/" << endl;
+ tmpStream << "#ifndef QT_BOOTSTRAPPED" << endl;
+ QFile inFile(sourcePath + "/src/corelib/global/" + configName);
+ if (inFile.open(QFile::ReadOnly)) {
+ QByteArray buffer = inFile.readAll();
+ tmpFile.write(buffer.constData(), buffer.size());
+ inFile.close();
+ }
+ tmpStream << "#endif // QT_BOOTSTRAPPED" << endl;
+ }
+ tmpStream << endl;
+
+ if (dictionary[ "SHARED" ] == "yes") {
+ tmpStream << "#ifndef QT_DLL" << endl;
+ tmpStream << "#define QT_DLL" << endl;
+ tmpStream << "#endif" << endl;
+ }
+ tmpStream << endl;
+ tmpStream << "/* License information */" << endl;
+ tmpStream << "#define QT_PRODUCT_LICENSEE \"" << licenseInfo[ "LICENSEE" ] << "\"" << endl;
+ tmpStream << "#define QT_PRODUCT_LICENSE \"" << dictionary[ "EDITION" ] << "\"" << endl;
+ tmpStream << endl;
+ tmpStream << "// Qt Edition" << endl;
+ tmpStream << "#ifndef QT_EDITION" << endl;
+ tmpStream << "# define QT_EDITION " << dictionary["QT_EDITION"] << endl;
+ tmpStream << "#endif" << endl;
+ tmpStream << endl;
+ tmpStream << dictionary["BUILD_KEY"];
+ tmpStream << endl;
+ if (dictionary["BUILDDEV"] == "yes") {
+ dictionary["QMAKE_INTERNAL"] = "yes";
+ tmpStream << "/* Used for example to export symbols for the certain autotests*/" << endl;
+ tmpStream << "#define QT_BUILD_INTERNAL" << endl;
+ tmpStream << endl;
+ }
+ tmpStream << "/* Machine byte-order */" << endl;
+ tmpStream << "#define Q_BIG_ENDIAN 4321" << endl;
+ tmpStream << "#define Q_LITTLE_ENDIAN 1234" << endl;
+ tmpStream << "#define Q_BYTE_ORDER Q_LITTLE_ENDIAN" << endl;
+
+ tmpStream << endl << "// Compile time features" << endl;
+ tmpStream << "#define QT_ARCH_" << dictionary["ARCHITECTURE"].toUpper() << endl;
+ if (dictionary["GRAPHICS_SYSTEM"] == "runtime" && dictionary["RUNTIME_SYSTEM"] != "runtime")
+ tmpStream << "#define QT_DEFAULT_RUNTIME_SYSTEM \"" << dictionary["RUNTIME_SYSTEM"] << "\"" << endl;
+
+ QStringList qconfigList;
+ if (dictionary["STL"] == "no") qconfigList += "QT_NO_STL";
+ if (dictionary["STYLE_WINDOWS"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWS";
+ if (dictionary["STYLE_PLASTIQUE"] != "yes") qconfigList += "QT_NO_STYLE_PLASTIQUE";
+ if (dictionary["STYLE_CLEANLOOKS"] != "yes") qconfigList += "QT_NO_STYLE_CLEANLOOKS";
+ if (dictionary["STYLE_WINDOWSXP"] != "yes" && dictionary["STYLE_WINDOWSVISTA"] != "yes")
+ qconfigList += "QT_NO_STYLE_WINDOWSXP";
+ if (dictionary["STYLE_WINDOWSVISTA"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSVISTA";
+ if (dictionary["STYLE_MOTIF"] != "yes") qconfigList += "QT_NO_STYLE_MOTIF";
+ if (dictionary["STYLE_CDE"] != "yes") qconfigList += "QT_NO_STYLE_CDE";
+ if (dictionary["STYLE_S60"] != "yes") qconfigList += "QT_NO_STYLE_S60";
+ if (dictionary["STYLE_WINDOWSCE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSCE";
+ if (dictionary["STYLE_WINDOWSMOBILE"] != "yes") qconfigList += "QT_NO_STYLE_WINDOWSMOBILE";
+ if (dictionary["STYLE_GTK"] != "yes") qconfigList += "QT_NO_STYLE_GTK";
+
+ if (dictionary["GIF"] == "yes") qconfigList += "QT_BUILTIN_GIF_READER=1";
+ if (dictionary["PNG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_PNG";
+ if (dictionary["MNG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_MNG";
+ if (dictionary["JPEG"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_JPEG";
+ if (dictionary["TIFF"] != "yes") qconfigList += "QT_NO_IMAGEFORMAT_TIFF";
+ if (dictionary["ZLIB"] == "no") {
+ qconfigList += "QT_NO_ZLIB";
+ qconfigList += "QT_NO_COMPRESS";
+ }
+
+ if (dictionary["ACCESSIBILITY"] == "no") qconfigList += "QT_NO_ACCESSIBILITY";
+ if (dictionary["EXCEPTIONS"] == "no") qconfigList += "QT_NO_EXCEPTIONS";
+ if (dictionary["OPENGL"] == "no") qconfigList += "QT_NO_OPENGL";
+ if (dictionary["OPENVG"] == "no") qconfigList += "QT_NO_OPENVG";
+ if (dictionary["OPENSSL"] == "no") qconfigList += "QT_NO_OPENSSL";
+ if (dictionary["OPENSSL"] == "linked") qconfigList += "QT_LINKED_OPENSSL";
+ if (dictionary["DBUS"] == "no") qconfigList += "QT_NO_DBUS";
+ if (dictionary["IPV6"] == "no") qconfigList += "QT_NO_IPV6";
+ if (dictionary["WEBKIT"] == "no") qconfigList += "QT_NO_WEBKIT";
+ if (dictionary["DECLARATIVE"] == "no") qconfigList += "QT_NO_DECLARATIVE";
+ if (dictionary["DECLARATIVE_DEBUG"] == "no") qconfigList += "QDECLARATIVE_NO_DEBUG_PROTOCOL";
+ if (dictionary["PHONON"] == "no") qconfigList += "QT_NO_PHONON";
+ if (dictionary["MULTIMEDIA"] == "no") qconfigList += "QT_NO_MULTIMEDIA";
+ if (dictionary["XMLPATTERNS"] == "no") qconfigList += "QT_NO_XMLPATTERNS";
+ if (dictionary["SCRIPT"] == "no") qconfigList += "QT_NO_SCRIPT";
+ if (dictionary["SCRIPTTOOLS"] == "no") qconfigList += "QT_NO_SCRIPTTOOLS";
+ if (dictionary["FREETYPE"] == "no") qconfigList += "QT_NO_FREETYPE";
+ if (dictionary["S60"] == "no") qconfigList += "QT_NO_S60";
+ if (dictionary["NATIVE_GESTURES"] == "no") qconfigList += "QT_NO_NATIVE_GESTURES";
+
+ if (dictionary["OPENGL_ES_CM"] == "no" &&
+ dictionary["OPENGL_ES_2"] == "no" &&
+ dictionary["OPENVG"] == "no") qconfigList += "QT_NO_EGL";
+
+ if (dictionary["OPENGL_ES_CM"] == "yes" ||
+ dictionary["OPENGL_ES_2"] == "yes") qconfigList += "QT_OPENGL_ES";
+
+ if (dictionary["OPENGL_ES_CM"] == "yes") qconfigList += "QT_OPENGL_ES_1";
+ if (dictionary["OPENGL_ES_2"] == "yes") qconfigList += "QT_OPENGL_ES_2";
+ if (dictionary["SQL_MYSQL"] == "yes") qconfigList += "QT_SQL_MYSQL";
+ if (dictionary["SQL_ODBC"] == "yes") qconfigList += "QT_SQL_ODBC";
+ if (dictionary["SQL_OCI"] == "yes") qconfigList += "QT_SQL_OCI";
+ if (dictionary["SQL_PSQL"] == "yes") qconfigList += "QT_SQL_PSQL";
+ if (dictionary["SQL_TDS"] == "yes") qconfigList += "QT_SQL_TDS";
+ if (dictionary["SQL_DB2"] == "yes") qconfigList += "QT_SQL_DB2";
+ if (dictionary["SQL_SQLITE"] == "yes") qconfigList += "QT_SQL_SQLITE";
+ if (dictionary["SQL_SQLITE2"] == "yes") qconfigList += "QT_SQL_SQLITE2";
+ if (dictionary["SQL_IBASE"] == "yes") qconfigList += "QT_SQL_IBASE";
+
+ if (dictionary["GRAPHICS_SYSTEM"] == "openvg") qconfigList += "QT_GRAPHICSSYSTEM_OPENVG";
+ if (dictionary["GRAPHICS_SYSTEM"] == "opengl") qconfigList += "QT_GRAPHICSSYSTEM_OPENGL";
+ if (dictionary["GRAPHICS_SYSTEM"] == "raster") qconfigList += "QT_GRAPHICSSYSTEM_RASTER";
+ if (dictionary["GRAPHICS_SYSTEM"] == "runtime") qconfigList += "QT_GRAPHICSSYSTEM_RUNTIME";
+
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) {
+ // These features are not ported to Symbian (yet)
+ qconfigList += "QT_NO_CONCURRENT";
+ qconfigList += "QT_NO_QFUTURE";
+ qconfigList += "QT_NO_CRASHHANDLER";
+ qconfigList += "QT_NO_PRINTER";
+ qconfigList += "QT_NO_SYSTEMTRAYICON";
+ if (dictionary.contains("QT_LIBINFIX"))
+ tmpStream << QString("#define QT_LIBINFIX \"%1\"").arg(dictionary["QT_LIBINFIX"]) << endl;
+ }
+
+ qconfigList.sort();
+ for (int i = 0; i < qconfigList.count(); ++i)
+ tmpStream << addDefine(qconfigList.at(i));
+
+ if (dictionary["EMBEDDED"] == "yes")
+ {
+ // Check for keyboard, mouse, gfx.
+ QStringList kbdDrivers = dictionary["KBD_DRIVERS"].split(" ");;
+ QStringList allKbdDrivers;
+ allKbdDrivers<<"tty"<<"usb"<<"sl5000"<<"yopy"<<"vr41xx"<<"qvfb"<<"um";
+ foreach (const QString &kbd, allKbdDrivers) {
+ if (!kbdDrivers.contains(kbd))
+ tmpStream<<"#define QT_NO_QWS_KBD_"<<kbd.toUpper()<<endl;
+ }
+
+ QStringList mouseDrivers = dictionary["MOUSE_DRIVERS"].split(" ");
+ QStringList allMouseDrivers;
+ allMouseDrivers << "pc"<<"bus"<<"linuxtp"<<"yopy"<<"vr41xx"<<"tslib"<<"qvfb";
+ foreach (const QString &mouse, allMouseDrivers) {
+ if (!mouseDrivers.contains(mouse))
+ tmpStream<<"#define QT_NO_QWS_MOUSE_"<<mouse.toUpper()<<endl;
+ }
+
+ QStringList gfxDrivers = dictionary["GFX_DRIVERS"].split(" ");
+ QStringList allGfxDrivers;
+ allGfxDrivers<<"linuxfb"<<"transformed"<<"qvfb"<<"vnc"<<"multiscreen"<<"ahi";
+ foreach (const QString &gfx, allGfxDrivers) {
+ if (!gfxDrivers.contains(gfx))
+ tmpStream<<"#define QT_NO_QWS_"<<gfx.toUpper()<<endl;
+ }
+
+ tmpStream<<"#define Q_WS_QWS"<<endl;
+
+ QStringList depths = dictionary[ "QT_QWS_DEPTH" ].split(" ");
+ foreach (const QString &depth, depths)
+ tmpStream<<"#define QT_QWS_DEPTH_"+depth<<endl;
+ }
+
+ if (dictionary[ "QT_CUPS" ] == "no")
+ tmpStream<<"#define QT_NO_CUPS"<<endl;
+
+ if (dictionary[ "QT_ICONV" ] == "no")
+ tmpStream<<"#define QT_NO_ICONV"<<endl;
+
+ if (dictionary[ "QT_GLIB" ] == "no")
+ tmpStream<<"#define QT_NO_GLIB"<<endl;
+
+ if (dictionary[ "QT_LPR" ] == "no")
+ tmpStream<<"#define QT_NO_LPR"<<endl;
+
+ if (dictionary[ "QT_INOTIFY" ] == "no")
+ tmpStream<<"#define QT_NO_INOTIFY"<<endl;
+
+ if (dictionary[ "QT_SXE" ] == "no")
+ tmpStream<<"#define QT_NO_SXE"<<endl;
+
+ tmpStream.flush();
+ tmpFile.flush();
+
+ // Replace old qconfig.h with new one
+ ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
+ QFile::remove(outName);
+ tmpFile.copy(outName);
+ tmpFile.close();
+ }
+
+ // Copy configured mkspec to default directory, but remove the old one first, if there is any
+ QString defSpec = buildPath + "/mkspecs/default";
+ QFileInfo defSpecInfo(defSpec);
+ if (defSpecInfo.exists()) {
+ if (!Environment::rmdir(defSpec)) {
+ cout << "Couldn't update default mkspec! Are files in " << qPrintable(defSpec) << " read-only?" << endl;
+ dictionary["DONE"] = "error";
+ return;
+ }
+ }
+
+ QString spec = dictionary.contains("XQMAKESPEC") ? dictionary["XQMAKESPEC"] : dictionary["QMAKESPEC"];
+ QString pltSpec = sourcePath + "/mkspecs/" + spec;
+ QString includeSpec = buildPath + "/mkspecs/" + spec;
+ if (!Environment::cpdir(pltSpec, defSpec, includeSpec)) {
+ cout << "Couldn't update default mkspec! Does " << qPrintable(pltSpec) << " exist?" << endl;
+ dictionary["DONE"] = "error";
+ return;
+ }
+
+ // Generate the new qconfig.cpp file
+ QDir(buildPath).mkpath("src/corelib/global");
+ outName = buildPath + "/src/corelib/global/qconfig.cpp";
+
+ QTemporaryFile tmpFile2;
+ if (tmpFile2.open()) {
+ tmpStream.setDevice(&tmpFile2);
+ tmpStream << "/* Licensed */" << endl
+ << "static const char qt_configure_licensee_str [512 + 12] = \"qt_lcnsuser=" << licenseInfo["LICENSEE"] << "\";" << endl
+ << "static const char qt_configure_licensed_products_str [512 + 12] = \"qt_lcnsprod=" << dictionary["EDITION"] << "\";" << endl
+ << endl
+ << "/* Build date */" << endl
+ << "static const char qt_configure_installation [11 + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl
+ << endl;
+ if (!dictionary[ "QT_HOST_PREFIX" ].isNull())
+ tmpStream << "#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)" << endl;
+ tmpStream << "static const char qt_configure_prefix_path_str [512 + 12] = \"qt_prfxpath=" << escapeSeparators(dictionary["QT_INSTALL_PREFIX"]) << "\";" << endl
+ << "static const char qt_configure_documentation_path_str[512 + 12] = \"qt_docspath=" << escapeSeparators(dictionary["QT_INSTALL_DOCS"]) << "\";" << endl
+ << "static const char qt_configure_headers_path_str [512 + 12] = \"qt_hdrspath=" << escapeSeparators(dictionary["QT_INSTALL_HEADERS"]) << "\";" << endl
+ << "static const char qt_configure_libraries_path_str [512 + 12] = \"qt_libspath=" << escapeSeparators(dictionary["QT_INSTALL_LIBS"]) << "\";" << endl
+ << "static const char qt_configure_binaries_path_str [512 + 12] = \"qt_binspath=" << escapeSeparators(dictionary["QT_INSTALL_BINS"]) << "\";" << endl
+ << "static const char qt_configure_plugins_path_str [512 + 12] = \"qt_plugpath=" << escapeSeparators(dictionary["QT_INSTALL_PLUGINS"]) << "\";" << endl
+ << "static const char qt_configure_imports_path_str [512 + 12] = \"qt_impspath=" << escapeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << "\";" << endl
+ << "static const char qt_configure_data_path_str [512 + 12] = \"qt_datapath=" << escapeSeparators(dictionary["QT_INSTALL_DATA"]) << "\";" << endl
+ << "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << escapeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\";" << endl
+ << "static const char qt_configure_examples_path_str [512 + 12] = \"qt_xmplpath=" << escapeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << "\";" << endl
+ << "static const char qt_configure_demos_path_str [512 + 12] = \"qt_demopath=" << escapeSeparators(dictionary["QT_INSTALL_DEMOS"]) << "\";" << endl
+ //<< "static const char qt_configure_settings_path_str [256] = \"qt_stngpath=" << escapeSeparators(dictionary["QT_INSTALL_SETTINGS"]) << "\";" << endl
+ ;
+ if (!dictionary[ "QT_HOST_PREFIX" ].isNull()) {
+ tmpStream << "#else" << endl
+ << "static const char qt_configure_prefix_path_str [512 + 12] = \"qt_prfxpath=" << escapeSeparators(dictionary[ "QT_HOST_PREFIX" ]) << "\";" << endl
+ << "static const char qt_configure_documentation_path_str[512 + 12] = \"qt_docspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/doc", true) <<"\";" << endl
+ << "static const char qt_configure_headers_path_str [512 + 12] = \"qt_hdrspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/include", true) <<"\";" << endl
+ << "static const char qt_configure_libraries_path_str [512 + 12] = \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib", true) <<"\";" << endl
+ << "static const char qt_configure_binaries_path_str [512 + 12] = \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin", true) <<"\";" << endl
+ << "static const char qt_configure_plugins_path_str [512 + 12] = \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins", true) <<"\";" << endl
+ << "static const char qt_configure_imports_path_str [512 + 12] = \"qt_impspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/imports", true) <<"\";" << endl
+ << "static const char qt_configure_data_path_str [512 + 12] = \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ], true) <<"\";" << endl
+ << "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations", true) <<"\";" << endl
+ << "static const char qt_configure_examples_path_str [512 + 12] = \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example", true) <<"\";" << endl
+ << "static const char qt_configure_demos_path_str [512 + 12] = \"qt_demopath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/demos", true) <<"\";" << endl
+ << "#endif //QT_BOOTSTRAPPED" << endl;
+ }
+ tmpStream << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl
+ << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl
+ << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl
+ << "#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12;" << endl
+ << "#define QT_CONFIGURE_DEMOS_PATH qt_configure_demos_path_str + 12;" << endl
+ //<< "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl
+ << endl;
+
+ tmpStream.flush();
+ tmpFile2.flush();
+
+ // Replace old qconfig.cpp with new one
+ ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
+ QFile::remove(outName);
+ tmpFile2.copy(outName);
+ tmpFile2.close();
+ }
+
+ QTemporaryFile tmpFile3;
+ if (tmpFile3.open()) {
+ tmpStream.setDevice(&tmpFile3);
+ tmpStream << "/* Evaluation license key */" << endl
+ << "static const volatile char qt_eval_key_data [512 + 12] = \"qt_qevalkey=" << licenseInfo["LICENSEKEYEXT"] << "\";" << endl;
+
+ tmpStream.flush();
+ tmpFile3.flush();
+
+ outName = buildPath + "/src/corelib/global/qconfig_eval.cpp";
+ ::SetFileAttributes((wchar_t*)outName.utf16(), FILE_ATTRIBUTE_NORMAL);
+ QFile::remove(outName);
+
+ if (dictionary["EDITION"] == "Evaluation" || qmakeDefines.contains("QT_EVAL"))
+ tmpFile3.copy(outName);
+ tmpFile3.close();
+ }
+}
+#endif
+
+#if !defined(EVAL)
+void Configure::displayConfig()
+{
+ // Give some feedback
+ cout << "Environment:" << endl;
+ QString env = QString::fromLocal8Bit(getenv("INCLUDE")).replace(QRegExp("[;,]"), "\r\n ");
+ if (env.isEmpty())
+ env = "Unset";
+ cout << " INCLUDE=\r\n " << env << endl;
+ env = QString::fromLocal8Bit(getenv("LIB")).replace(QRegExp("[;,]"), "\r\n ");
+ if (env.isEmpty())
+ env = "Unset";
+ cout << " LIB=\r\n " << env << endl;
+ env = QString::fromLocal8Bit(getenv("PATH")).replace(QRegExp("[;,]"), "\r\n ");
+ if (env.isEmpty())
+ env = "Unset";
+ cout << " PATH=\r\n " << env << endl;
+
+ if (dictionary["EDITION"] == "OpenSource") {
+ cout << "You are licensed to use this software under the terms of the GNU GPL version 3.";
+ cout << "You are licensed to use this software under the terms of the Lesser GNU LGPL version 2.1." << endl;
+ cout << "See " << dictionary["LICENSE FILE"] << "3" << endl << endl
+ << " or " << dictionary["LICENSE FILE"] << "L" << endl << endl;
+ } else {
+ QString l1 = licenseInfo[ "LICENSEE" ];
+ QString l2 = licenseInfo[ "LICENSEID" ];
+ QString l3 = dictionary["EDITION"] + ' ' + "Edition";
+ QString l4 = licenseInfo[ "EXPIRYDATE" ];
+ cout << "Licensee...................." << (l1.isNull() ? "" : l1) << endl;
+ cout << "License ID.................." << (l2.isNull() ? "" : l2) << endl;
+ cout << "Product license............." << (l3.isNull() ? "" : l3) << endl;
+ cout << "Expiry Date................." << (l4.isNull() ? "" : l4) << endl << endl;
+ }
+
+ cout << "Configuration:" << endl;
+ cout << " " << qmakeConfig.join("\r\n ") << endl;
+ cout << "Qt Configuration:" << endl;
+ cout << " " << qtConfig.join("\r\n ") << endl;
+ cout << endl;
+
+ if (dictionary.contains("XQMAKESPEC"))
+ cout << "QMAKESPEC..................." << dictionary[ "XQMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
+ else
+ cout << "QMAKESPEC..................." << dictionary[ "QMAKESPEC" ] << " (" << dictionary["QMAKESPEC_FROM"] << ")" << endl;
+ cout << "Architecture................" << dictionary[ "ARCHITECTURE" ] << endl;
+ cout << "Maketool...................." << dictionary[ "MAKE" ] << endl;
+ cout << "Debug symbols..............." << (dictionary[ "BUILD" ] == "debug" ? "yes" : "no") << endl;
+ cout << "Link Time Code Generation..." << dictionary[ "LTCG" ] << endl;
+ cout << "Accessibility support......." << dictionary[ "ACCESSIBILITY" ] << endl;
+ cout << "STL support................." << dictionary[ "STL" ] << endl;
+ cout << "Exception support..........." << dictionary[ "EXCEPTIONS" ] << endl;
+ cout << "RTTI support................" << dictionary[ "RTTI" ] << endl;
+ cout << "MMX support................." << dictionary[ "MMX" ] << endl;
+ cout << "3DNOW support..............." << dictionary[ "3DNOW" ] << endl;
+ cout << "SSE support................." << dictionary[ "SSE" ] << endl;
+ cout << "SSE2 support................" << dictionary[ "SSE2" ] << endl;
+ cout << "IWMMXT support.............." << dictionary[ "IWMMXT" ] << endl;
+ cout << "OpenGL support.............." << dictionary[ "OPENGL" ] << endl;
+ cout << "OpenVG support.............." << dictionary[ "OPENVG" ] << endl;
+ cout << "OpenSSL support............." << dictionary[ "OPENSSL" ] << endl;
+ cout << "QtDBus support.............." << dictionary[ "DBUS" ] << endl;
+ cout << "QtXmlPatterns support......." << dictionary[ "XMLPATTERNS" ] << endl;
+ cout << "Phonon support.............." << dictionary[ "PHONON" ] << endl;
+ cout << "QtMultimedia support........" << dictionary[ "MULTIMEDIA" ] << endl;
+ {
+ QString webkit = dictionary[ "WEBKIT" ];
+ if (webkit == "debug")
+ webkit = "yes (debug)";
+ cout << "WebKit support.............." << webkit << endl;
+ }
+ {
+ QString declarative = dictionary[ "DECLARATIVE" ];
+ cout << "Declarative support........." << declarative << endl;
+ if (declarative == "yes")
+ cout << "Declarative debugging......." << dictionary[ "DECLARATIVE_DEBUG" ] << endl;
+ }
+ cout << "QtScript support............" << dictionary[ "SCRIPT" ] << endl;
+ cout << "QtScriptTools support......." << dictionary[ "SCRIPTTOOLS" ] << endl;
+ cout << "Graphics System............." << dictionary[ "GRAPHICS_SYSTEM" ] << endl;
+ cout << "Qt3 compatibility..........." << dictionary[ "QT3SUPPORT" ] << endl;
+ cout << "DirectWrite support........." << dictionary[ "DIRECTWRITE" ] << endl << endl;
+
+ cout << "Third Party Libraries:" << endl;
+ cout << " ZLIB support............" << dictionary[ "ZLIB" ] << endl;
+ cout << " GIF support............." << dictionary[ "GIF" ] << endl;
+ cout << " TIFF support............" << dictionary[ "TIFF" ] << endl;
+ cout << " JPEG support............" << dictionary[ "JPEG" ] << endl;
+ cout << " PNG support............." << dictionary[ "PNG" ] << endl;
+ cout << " MNG support............." << dictionary[ "MNG" ] << endl;
+ cout << " FreeType support........" << dictionary[ "FREETYPE" ] << endl << endl;
+
+ cout << "Styles:" << endl;
+ cout << " Windows................." << dictionary[ "STYLE_WINDOWS" ] << endl;
+ cout << " Windows XP.............." << dictionary[ "STYLE_WINDOWSXP" ] << endl;
+ cout << " Windows Vista..........." << dictionary[ "STYLE_WINDOWSVISTA" ] << endl;
+ cout << " Plastique..............." << dictionary[ "STYLE_PLASTIQUE" ] << endl;
+ cout << " Cleanlooks.............." << dictionary[ "STYLE_CLEANLOOKS" ] << endl;
+ cout << " Motif..................." << dictionary[ "STYLE_MOTIF" ] << endl;
+ cout << " CDE....................." << dictionary[ "STYLE_CDE" ] << endl;
+ cout << " Windows CE.............." << dictionary[ "STYLE_WINDOWSCE" ] << endl;
+ cout << " Windows Mobile.........." << dictionary[ "STYLE_WINDOWSMOBILE" ] << endl;
+ cout << " S60....................." << dictionary[ "STYLE_S60" ] << endl << endl;
+
+ cout << "Sql Drivers:" << endl;
+ cout << " ODBC...................." << dictionary[ "SQL_ODBC" ] << endl;
+ cout << " MySQL..................." << dictionary[ "SQL_MYSQL" ] << endl;
+ cout << " OCI....................." << dictionary[ "SQL_OCI" ] << endl;
+ cout << " PostgreSQL.............." << dictionary[ "SQL_PSQL" ] << endl;
+ cout << " TDS....................." << dictionary[ "SQL_TDS" ] << endl;
+ cout << " DB2....................." << dictionary[ "SQL_DB2" ] << endl;
+ cout << " SQLite.................." << dictionary[ "SQL_SQLITE" ] << " (" << dictionary[ "SQL_SQLITE_LIB" ] << ")" << endl;
+ cout << " SQLite2................." << dictionary[ "SQL_SQLITE2" ] << endl;
+ cout << " InterBase..............." << dictionary[ "SQL_IBASE" ] << endl << endl;
+
+ cout << "Sources are in.............." << dictionary[ "QT_SOURCE_TREE" ] << endl;
+ cout << "Build is done in............" << dictionary[ "QT_BUILD_TREE" ] << endl;
+ cout << "Install prefix.............." << dictionary[ "QT_INSTALL_PREFIX" ] << endl;
+ cout << "Headers installed to........" << dictionary[ "QT_INSTALL_HEADERS" ] << endl;
+ cout << "Libraries installed to......" << dictionary[ "QT_INSTALL_LIBS" ] << endl;
+ cout << "Plugins installed to........" << dictionary[ "QT_INSTALL_PLUGINS" ] << endl;
+ cout << "Imports installed to........" << dictionary[ "QT_INSTALL_IMPORTS" ] << endl;
+ cout << "Binaries installed to......." << dictionary[ "QT_INSTALL_BINS" ] << endl;
+ cout << "Docs installed to..........." << dictionary[ "QT_INSTALL_DOCS" ] << endl;
+ cout << "Data installed to..........." << dictionary[ "QT_INSTALL_DATA" ] << endl;
+ cout << "Translations installed to..." << dictionary[ "QT_INSTALL_TRANSLATIONS" ] << endl;
+ cout << "Examples installed to......." << dictionary[ "QT_INSTALL_EXAMPLES" ] << endl;
+ cout << "Demos installed to.........." << dictionary[ "QT_INSTALL_DEMOS" ] << endl << endl;
+
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith(QLatin1String("wince"))) {
+ cout << "Using c runtime detection..." << dictionary[ "CE_CRT" ] << endl;
+ cout << "Cetest support.............." << dictionary[ "CETEST" ] << endl;
+ cout << "Signature..................." << dictionary[ "CE_SIGNATURE"] << endl << endl;
+ }
+
+ if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith(QLatin1String("symbian"))) {
+ cout << "Support for S60............." << dictionary[ "S60" ] << endl;
+ }
+
+ if (dictionary.contains("SYMBIAN_DEFFILES")) {
+ cout << "Symbian DEF files enabled..." << dictionary[ "SYMBIAN_DEFFILES" ] << endl;
+ if (dictionary["SYMBIAN_DEFFILES"] == "no") {
+ cout << "WARNING: Disabling DEF files will mean that Qt is NOT binary compatible with previous versions." << endl;
+ cout << " This feature is only intended for use during development, NEVER for release builds." << endl;
+ }
+ }
+
+ if (dictionary["ASSISTANT_WEBKIT"] == "yes")
+ cout << "Using WebKit as html rendering engine in Qt Assistant." << endl;
+
+ if (checkAvailability("INCREDIBUILD_XGE"))
+ cout << "Using IncrediBuild XGE......" << dictionary["INCREDIBUILD_XGE"] << endl;
+ if (!qmakeDefines.isEmpty()) {
+ cout << "Defines.....................";
+ for (QStringList::Iterator defs = qmakeDefines.begin(); defs != qmakeDefines.end(); ++defs)
+ cout << (*defs) << " ";
+ cout << endl;
+ }
+ if (!qmakeIncludes.isEmpty()) {
+ cout << "Include paths...............";
+ for (QStringList::Iterator incs = qmakeIncludes.begin(); incs != qmakeIncludes.end(); ++incs)
+ cout << (*incs) << " ";
+ cout << endl;
+ }
+ if (!qmakeLibs.isEmpty()) {
+ cout << "Additional libraries........";
+ for (QStringList::Iterator libs = qmakeLibs.begin(); libs != qmakeLibs.end(); ++libs)
+ cout << (*libs) << " ";
+ cout << endl;
+ }
+ if (dictionary[ "QMAKE_INTERNAL" ] == "yes") {
+ cout << "Using internal configuration." << endl;
+ }
+ if (dictionary[ "SHARED" ] == "no") {
+ cout << "WARNING: Using static linking will disable the use of plugins." << endl;
+ cout << " Make sure you compile ALL needed modules into the library." << endl;
+ }
+ if (dictionary[ "OPENSSL" ] == "linked" && opensslLibs.isEmpty()) {
+ cout << "NOTE: When linking against OpenSSL, you can override the default" << endl;
+ cout << "library names through OPENSSL_LIBS." << endl;
+ cout << "For example:" << endl;
+ cout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl;
+ }
+ if (dictionary[ "ZLIB_FORCED" ] == "yes") {
+ QString which_zlib = "supplied";
+ if (dictionary[ "ZLIB" ] == "system")
+ which_zlib = "system";
+
+ cout << "NOTE: The -no-zlib option was supplied but is no longer supported." << endl
+ << endl
+ << "Qt now requires zlib support in all builds, so the -no-zlib" << endl
+ << "option was ignored. Qt will be built using the " << which_zlib
+ << "zlib" << endl;
+ }
+}
+#endif
+
+#if !defined(EVAL)
+void Configure::generateHeaders()
+{
+ if (dictionary["SYNCQT"] == "yes"
+ && findFile("perl.exe")) {
+ cout << "Running syncqt..." << endl;
+ QStringList args;
+ args += buildPath + "/bin/syncqt.bat";
+ QStringList env;
+ env += QString("QTDIR=" + sourcePath);
+ env += QString("PATH=" + buildPath + "/bin/;" + qgetenv("PATH"));
+ int retc = Environment::execute(args, env, QStringList());
+ if (retc) {
+ cout << "syncqt failed, return code " << retc << endl << endl;
+ dictionary["DONE"] = "error";
+ }
+ }
+}
+
+void Configure::buildQmake()
+{
+ if (dictionary[ "BUILD_QMAKE" ] == "yes") {
+ QStringList args;
+
+ // Build qmake
+ QString pwd = QDir::currentPath();
+ QDir::setCurrent(buildPath + "/qmake");
+
+ QString makefile = "Makefile";
+ {
+ QFile out(makefile);
+ if (out.open(QFile::WriteOnly | QFile::Text)) {
+ QTextStream stream(&out);
+ stream << "#AutoGenerated by configure.exe" << endl
+ << "BUILD_PATH = " << QDir::convertSeparators(buildPath) << endl
+ << "SOURCE_PATH = " << QDir::convertSeparators(sourcePath) << endl;
+ stream << "QMAKESPEC = " << dictionary["QMAKESPEC"] << endl;
+
+ if (dictionary["EDITION"] == "OpenSource" ||
+ dictionary["QT_EDITION"].contains("OPENSOURCE"))
+ stream << "QMAKE_OPENSOURCE_EDITION = yes" << endl;
+ stream << "\n\n";
+
+ QFile in(sourcePath + "/qmake/" + dictionary["QMAKEMAKEFILE"]);
+ if (in.open(QFile::ReadOnly | QFile::Text)) {
+ QString d = in.readAll();
+ //### need replaces (like configure.sh)? --Sam
+ stream << d << endl;
+ }
+ stream.flush();
+ out.close();
+ }
+ }
+
+ args += dictionary[ "MAKE" ];
+ args += "-f";
+ args += makefile;
+
+ cout << "Creating qmake..." << endl;
+ int exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ args.clear();
+ args += dictionary[ "MAKE" ];
+ args += "-f";
+ args += makefile;
+ args += "clean";
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ cout << "Cleaning qmake failed, return code " << exitCode << endl << endl;
+ dictionary[ "DONE" ] = "error";
+ } else {
+ args.clear();
+ args += dictionary[ "MAKE" ];
+ args += "-f";
+ args += makefile;
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ cout << "Building qmake failed, return code " << exitCode << endl << endl;
+ dictionary[ "DONE" ] = "error";
+ }
+ }
+ }
+ QDir::setCurrent(pwd);
+ }
+}
+#endif
+
+void Configure::buildHostTools()
+{
+ if (dictionary[ "NOPROCESS" ] == "yes")
+ dictionary[ "DONE" ] = "yes";
+
+ if (!dictionary.contains("XQMAKESPEC"))
+ return;
+
+ QString pwd = QDir::currentPath();
+ QStringList hostToolsDirs;
+ hostToolsDirs
+ << "src/tools"
+ << "tools/linguist/lrelease";
+
+ if (dictionary["XQMAKESPEC"].startsWith("wince"))
+ hostToolsDirs << "tools/checksdk";
+
+ if (dictionary[ "CETEST" ] == "yes")
+ hostToolsDirs << "tools/qtestlib/wince/cetest";
+
+ for (int i = 0; i < hostToolsDirs.count(); ++i) {
+ cout << "Creating " << hostToolsDirs.at(i) << " ..." << endl;
+ QString toolBuildPath = buildPath + "/" + hostToolsDirs.at(i);
+ QString toolSourcePath = sourcePath + "/" + hostToolsDirs.at(i);
+
+ // generate Makefile
+ QStringList args;
+ args << QDir::toNativeSeparators(buildPath + "/bin/qmake");
+ // override .qmake.cache because we are not cross-building these.
+ // we need a full path so that a build with -prefix will still find it.
+ args << "-spec" << QDir::toNativeSeparators(buildPath + "/mkspecs/" + dictionary["QMAKESPEC"]);
+ args << "-r";
+ args << "-o" << QDir::toNativeSeparators(toolBuildPath + "/Makefile");
+
+ QDir().mkpath(toolBuildPath);
+ QDir::setCurrent(toolSourcePath);
+ int exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ cout << "qmake failed, return code " << exitCode << endl << endl;
+ dictionary["DONE"] = "error";
+ break;
+ }
+
+ // build app
+ args.clear();
+ args += dictionary["MAKE"];
+ QDir::setCurrent(toolBuildPath);
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ args.clear();
+ args += dictionary["MAKE"];
+ args += "clean";
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ cout << "Cleaning " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
+ dictionary["DONE"] = "error";
+ break;
+ } else {
+ args.clear();
+ args += dictionary["MAKE"];
+ exitCode = Environment::execute(args, QStringList(), QStringList());
+ if (exitCode) {
+ cout << "Building " << hostToolsDirs.at(i) << " failed, return code " << exitCode << endl << endl;
+ dictionary["DONE"] = "error";
+ break;
+ }
+ }
+ }
+ }
+ QDir::setCurrent(pwd);
+}
+
+void Configure::findProjects(const QString& dirName)
+{
+ if (dictionary[ "NOPROCESS" ] == "no") {
+ QDir dir(dirName);
+ QString entryName;
+ int makeListNumber;
+ ProjectType qmakeTemplate;
+ const QFileInfoList &list = dir.entryInfoList(QStringList(QLatin1String("*.pro")),
+ QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
+ for (int i = 0; i < list.size(); ++i) {
+ const QFileInfo &fi = list.at(i);
+ if (fi.fileName() != "qmake.pro") {
+ entryName = dirName + "/" + fi.fileName();
+ if (fi.isDir()) {
+ findProjects(entryName);
+ } else {
+ qmakeTemplate = projectType(fi.absoluteFilePath());
+ switch (qmakeTemplate) {
+ case Lib:
+ case Subdirs:
+ makeListNumber = 1;
+ break;
+ default:
+ makeListNumber = 2;
+ break;
+ }
+ makeList[makeListNumber].append(new MakeItem(sourceDir.relativeFilePath(fi.absolutePath()),
+ fi.fileName(),
+ "Makefile",
+ qmakeTemplate));
+ }
+ }
+
+ }
+ }
+}
+
+void Configure::appendMakeItem(int inList, const QString &item)
+{
+ QString dir;
+ if (item != "src")
+ dir = "/" + item;
+ dir.prepend("/src");
+ makeList[inList].append(new MakeItem(sourcePath + dir,
+ item + ".pro", buildPath + dir + "/Makefile", Lib));
+ if (dictionary[ "DSPFILES" ] == "yes") {
+ makeList[inList].append(new MakeItem(sourcePath + dir,
+ item + ".pro", buildPath + dir + "/" + item + ".dsp", Lib));
+ }
+ if (dictionary[ "VCPFILES" ] == "yes") {
+ makeList[inList].append(new MakeItem(sourcePath + dir,
+ item + ".pro", buildPath + dir + "/" + item + ".vcp", Lib));
+ }
+ if (dictionary[ "VCPROJFILES" ] == "yes") {
+ makeList[inList].append(new MakeItem(sourcePath + dir,
+ item + ".pro", buildPath + dir + "/" + item + ".vcproj", Lib));
+ }
+}
+
+void Configure::generateMakefiles()
+{
+ if (dictionary[ "NOPROCESS" ] == "no") {
+#if !defined(EVAL)
+ cout << "Creating makefiles in src..." << endl;
+#endif
+
+ QString spec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ];
+ if (spec != "win32-msvc")
+ dictionary[ "DSPFILES" ] = "no";
+
+ if (spec != "win32-msvc.net" && !spec.startsWith("win32-msvc2") && !spec.startsWith(QLatin1String("wince")))
+ dictionary[ "VCPROJFILES" ] = "no";
+
+ int i = 0;
+ QString pwd = QDir::currentPath();
+ if (dictionary["FAST"] != "yes") {
+ QString dirName;
+ bool generate = true;
+ bool doDsp = (dictionary["DSPFILES"] == "yes" || dictionary["VCPFILES"] == "yes"
+ || dictionary["VCPROJFILES"] == "yes");
+ while (generate) {
+ QString pwd = QDir::currentPath();
+ QString dirPath = fixSeparators(buildPath + dirName);
+ QStringList args;
+
+ args << fixSeparators(buildPath + "/bin/qmake");
+
+ if (doDsp) {
+ if (dictionary[ "DEPENDENCIES" ] == "no")
+ args << "-nodepend";
+ args << "-tp" << "vc";
+ doDsp = false; // DSP files will be done
+ printf("Generating Visual Studio project files...\n");
+ } else {
+ printf("Generating Makefiles...\n");
+ generate = false; // Now Makefiles will be done
+ }
+ // don't pass -spec - .qmake.cache has it already
+ args << "-r";
+ args << (sourcePath + "/projects.pro");
+ args << "-o";
+ args << buildPath;
+ if (!dictionary[ "QMAKEADDITIONALARGS" ].isEmpty())
+ args << dictionary[ "QMAKEADDITIONALARGS" ];
+
+ QDir::setCurrent(fixSeparators(dirPath));
+ if (int exitCode = Environment::execute(args, QStringList(), QStringList())) {
+ cout << "Qmake failed, return code " << exitCode << endl << endl;
+ dictionary[ "DONE" ] = "error";
+ }
+ }
+ } else {
+ findProjects(sourcePath);
+ for (i=0; i<3; i++) {
+ for (int j=0; j<makeList[i].size(); ++j) {
+ MakeItem *it=makeList[i][j];
+ QString dirPath = fixSeparators(it->directory + "/");
+ QString projectName = it->proFile;
+ QString makefileName = buildPath + "/" + dirPath + it->target;
+
+ // For shadowbuilds, we need to create the path first
+ QDir buildPathDir(buildPath);
+ if (sourcePath != buildPath && !buildPathDir.exists(dirPath))
+ buildPathDir.mkpath(dirPath);
+
+ QStringList args;
+
+ args << fixSeparators(buildPath + "/bin/qmake");
+ args << sourcePath + "/" + dirPath + projectName;
+ args << dictionary[ "QMAKE_ALL_ARGS" ];
+
+ cout << "For " << qPrintable(dirPath + projectName) << endl;
+ args << "-o";
+ args << it->target;
+ args << "-spec";
+ args << spec;
+ if (!dictionary[ "QMAKEADDITIONALARGS" ].isEmpty())
+ args << dictionary[ "QMAKEADDITIONALARGS" ];
+
+ QDir::setCurrent(fixSeparators(dirPath));
+
+ QFile file(makefileName);
+ if (!file.open(QFile::WriteOnly)) {
+ printf("failed on dirPath=%s, makefile=%s\n",
+ qPrintable(dirPath), qPrintable(makefileName));
+ continue;
+ }
+ QTextStream txt(&file);
+ txt << "all:\n";
+ txt << "\t" << args.join(" ") << "\n";
+ txt << "\t\"$(MAKE)\" -$(MAKEFLAGS) -f " << it->target << "\n";
+ txt << "first: all\n";
+ txt << "qmake:\n";
+ txt << "\t" << args.join(" ") << "\n";
+ }
+ }
+ }
+ QDir::setCurrent(pwd);
+ } else {
+ cout << "Processing of project files have been disabled." << endl;
+ cout << "Only use this option if you really know what you're doing." << endl << endl;
+ return;
+ }
+}
+
+void Configure::showSummary()
+{
+ QString make = dictionary[ "MAKE" ];
+ if (!dictionary.contains("XQMAKESPEC")) {
+ cout << endl << endl << "Qt is now configured for building. Just run " << qPrintable(make) << "." << endl;
+ cout << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
+ } else if (dictionary.value("QMAKESPEC").startsWith("wince")) {
+ // we are cross compiling for Windows CE
+ cout << endl << endl << "Qt is now configured for building. To start the build run:" << endl
+ << "\tsetcepaths " << dictionary.value("XQMAKESPEC") << endl
+ << "\t" << qPrintable(make) << endl
+ << "To reconfigure, run " << qPrintable(make) << " confclean and configure." << endl << endl;
+ } else { // Compiling for Symbian OS
+ cout << endl << endl << "Qt is now configured for building. To start the build run:" << qPrintable(dictionary["QTBUILDINSTRUCTION"]) << "." << endl
+ << "To reconfigure, run '" << qPrintable(dictionary["CONFCLEANINSTRUCTION"]) << "' and configure." << endl;
+ }
+}
+
+Configure::ProjectType Configure::projectType(const QString& proFileName)
+{
+ QFile proFile(proFileName);
+ if (proFile.open(QFile::ReadOnly)) {
+ QString buffer = proFile.readLine(1024);
+ while (!buffer.isEmpty()) {
+ QStringList segments = buffer.split(QRegExp("\\s"));
+ QStringList::Iterator it = segments.begin();
+
+ if (segments.size() >= 3) {
+ QString keyword = (*it++);
+ QString operation = (*it++);
+ QString value = (*it++);
+
+ if (keyword == "TEMPLATE") {
+ if (value == "lib")
+ return Lib;
+ else if (value == "subdirs")
+ return Subdirs;
+ }
+ }
+ // read next line
+ buffer = proFile.readLine(1024);
+ }
+ proFile.close();
+ }
+ // Default to app handling
+ return App;
+}
+
+#if !defined(EVAL)
+
+bool Configure::showLicense(QString orgLicenseFile)
+{
+ if (dictionary["LICENSE_CONFIRMED"] == "yes") {
+ cout << "You have already accepted the terms of the license." << endl << endl;
+ return true;
+ }
+
+ bool haveGpl3 = false;
+ QString licenseFile = orgLicenseFile;
+ QString theLicense;
+ if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
+ haveGpl3 = QFile::exists(orgLicenseFile + "/LICENSE.GPL3");
+ theLicense = "GNU Lesser General Public License (LGPL) version 2.1";
+ if (haveGpl3)
+ theLicense += "\nor the GNU General Public License (GPL) version 3";
+ } else {
+ // the first line of the license file tells us which license it is
+ QFile file(licenseFile);
+ if (!file.open(QFile::ReadOnly)) {
+ cout << "Failed to load LICENSE file" << endl;
+ return false;
+ }
+ theLicense = file.readLine().trimmed();
+ }
+
+ forever {
+ char accept = '?';
+ cout << "You are licensed to use this software under the terms of" << endl
+ << "the " << theLicense << "." << endl
+ << endl;
+ if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
+ if (haveGpl3)
+ cout << "Type '3' to view the GNU General Public License version 3 (GPLv3)." << endl;
+ cout << "Type 'L' to view the Lesser GNU General Public License version 2.1 (LGPLv2.1)." << endl;
+ } else {
+ cout << "Type '?' to view the " << theLicense << "." << endl;
+ }
+ cout << "Type 'y' to accept this license offer." << endl
+ << "Type 'n' to decline this license offer." << endl
+ << endl
+ << "Do you accept the terms of the license?" << endl;
+ cin >> accept;
+ accept = tolower(accept);
+
+ if (accept == 'y') {
+ return true;
+ } else if (accept == 'n') {
+ return false;
+ } else {
+ if (dictionary["EDITION"] == "OpenSource" || dictionary["EDITION"] == "Snapshot") {
+ if (accept == '3')
+ licenseFile = orgLicenseFile + "/LICENSE.GPL3";
+ else
+ licenseFile = orgLicenseFile + "/LICENSE.LGPL";
+ }
+ // Get console line height, to fill the screen properly
+ int i = 0, screenHeight = 25; // default
+ CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
+ HANDLE stdOut = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (GetConsoleScreenBufferInfo(stdOut, &consoleInfo))
+ screenHeight = consoleInfo.srWindow.Bottom
+ - consoleInfo.srWindow.Top
+ - 1; // Some overlap for context
+
+ // Prompt the license content to the user
+ QFile file(licenseFile);
+ if (!file.open(QFile::ReadOnly)) {
+ cout << "Failed to load LICENSE file" << licenseFile << endl;
+ return false;
+ }
+ QStringList licenseContent = QString(file.readAll()).split('\n');
+ while (i < licenseContent.size()) {
+ cout << licenseContent.at(i) << endl;
+ if (++i % screenHeight == 0) {
+ cout << "(Press any key for more..)";
+ if (_getch() == 3) // _Any_ keypress w/no echo(eat <Enter> for stdout)
+ exit(0); // Exit cleanly for Ctrl+C
+ cout << "\r"; // Overwrite text above
+ }
+ }
+ }
+ }
+}
+
+void Configure::readLicense()
+{
+ if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/src/corelib/kernel/qfunctions_wince.h") &&
+ (dictionary.value("QMAKESPEC").startsWith("wince") || dictionary.value("XQMAKESPEC").startsWith("wince")))
+ dictionary["PLATFORM NAME"] = "Qt for Windows CE";
+ else if (dictionary.value("XQMAKESPEC").startsWith("symbian"))
+ dictionary["PLATFORM NAME"] = "Qt for Symbian";
+ else
+ dictionary["PLATFORM NAME"] = "Qt for Windows";
+ dictionary["LICENSE FILE"] = sourcePath;
+
+ bool openSource = false;
+ bool hasOpenSource = QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.GPL3") || QFile::exists(dictionary["LICENSE FILE"] + "/LICENSE.LGPL");
+ if (dictionary["BUILDNOKIA"] == "yes" || dictionary["BUILDTYPE"] == "commercial") {
+ openSource = false;
+ } else if (dictionary["BUILDTYPE"] == "opensource") {
+ openSource = true;
+ } else if (hasOpenSource) { // No Open Source? Just display the commercial license right away
+ forever {
+ char accept = '?';
+ cout << "Which edition of Qt do you want to use ?" << endl;
+ cout << "Type 'c' if you want to use the Commercial Edition." << endl;
+ cout << "Type 'o' if you want to use the Open Source Edition." << endl;
+ cin >> accept;
+ accept = tolower(accept);
+
+ if (accept == 'c') {
+ openSource = false;
+ break;
+ } else if (accept == 'o') {
+ openSource = true;
+ break;
+ }
+ }
+ }
+ if (hasOpenSource && openSource) {
+ cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " Open Source Edition." << endl;
+ licenseInfo["LICENSEE"] = "Open Source";
+ dictionary["EDITION"] = "OpenSource";
+ dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE";
+ cout << endl;
+ if (!showLicense(dictionary["LICENSE FILE"])) {
+ cout << "Configuration aborted since license was not accepted";
+ dictionary["DONE"] = "error";
+ return;
+ }
+ } else if (openSource) {
+ cout << endl << "Cannot find the GPL license files! Please download the Open Source version of the library." << endl;
+ dictionary["DONE"] = "error";
+ }
+#ifdef COMMERCIAL_VERSION
+ else {
+ Tools::checkLicense(dictionary, licenseInfo, firstLicensePath());
+ if (dictionary["DONE"] != "error" && dictionary["BUILDNOKIA"] != "yes") {
+ // give the user some feedback, and prompt for license acceptance
+ cout << endl << "This is the " << dictionary["PLATFORM NAME"] << " " << dictionary["EDITION"] << " Edition."<< endl << endl;
+ if (!showLicense(dictionary["LICENSE FILE"])) {
+ cout << "Configuration aborted since license was not accepted";
+ dictionary["DONE"] = "error";
+ return;
+ }
+ }
+ }
+#else // !COMMERCIAL_VERSION
+ else {
+ cout << endl << "Cannot build commercial edition from the open source version of the library." << endl;
+ dictionary["DONE"] = "error";
+ }
+#endif
+}
+
+void Configure::reloadCmdLine()
+{
+ if (dictionary[ "REDO" ] == "yes") {
+ QFile inFile(buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache");
+ if (inFile.open(QFile::ReadOnly)) {
+ QTextStream inStream(&inFile);
+ QString buffer;
+ inStream >> buffer;
+ while (buffer.length()) {
+ configCmdLine += buffer;
+ inStream >> buffer;
+ }
+ inFile.close();
+ }
+ }
+}
+
+void Configure::saveCmdLine()
+{
+ if (dictionary[ "REDO" ] != "yes") {
+ QFile outFile(buildPath + "/configure" + dictionary[ "CUSTOMCONFIG" ] + ".cache");
+ if (outFile.open(QFile::WriteOnly | QFile::Text)) {
+ QTextStream outStream(&outFile);
+ for (QStringList::Iterator it = configCmdLine.begin(); it != configCmdLine.end(); ++it) {
+ outStream << (*it) << " " << endl;
+ }
+ outStream.flush();
+ outFile.close();
+ }
+ }
+}
+#endif // !EVAL
+
+bool Configure::isDone()
+{
+ return !dictionary["DONE"].isEmpty();
+}
+
+bool Configure::isOk()
+{
+ return (dictionary[ "DONE" ] != "error");
+}
+
+bool
+Configure::filesDiffer(const QString &fn1, const QString &fn2)
+{
+ QFile file1(fn1), file2(fn2);
+ if (!file1.open(QFile::ReadOnly) || !file2.open(QFile::ReadOnly))
+ return true;
+ const int chunk = 2048;
+ int used1 = 0, used2 = 0;
+ char b1[chunk], b2[chunk];
+ while (!file1.atEnd() && !file2.atEnd()) {
+ if (!used1)
+ used1 = file1.read(b1, chunk);
+ if (!used2)
+ used2 = file2.read(b2, chunk);
+ if (used1 > 0 && used2 > 0) {
+ const int cmp = qMin(used1, used2);
+ if (memcmp(b1, b2, cmp))
+ return true;
+ if ((used1 -= cmp))
+ memcpy(b1, b1+cmp, used1);
+ if ((used2 -= cmp))
+ memcpy(b2, b2+cmp, used2);
+ }
+ }
+ return !file1.atEnd() || !file2.atEnd();
+}
+
+QT_END_NAMESPACE
diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h
new file mode 100644
index 0000000000..fa14f98b14
--- /dev/null
+++ b/tools/configure/configureapp.h
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qmap.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qlist.h>
+#include <qtextstream.h>
+#include <qdir.h>
+
+QT_BEGIN_NAMESPACE
+
+class MakeItem;
+
+class Configure
+{
+public:
+ Configure( int& argc, char** argv );
+ ~Configure();
+
+ void parseCmdLine();
+#if !defined(EVAL)
+ void validateArgs();
+#endif
+ bool displayHelp();
+
+ QString defaultTo(const QString &option);
+ bool checkAvailability(const QString &part);
+ void autoDetection();
+ bool verifyConfiguration();
+
+ void generateOutputVars();
+#if !defined(EVAL)
+ void generateHeaders();
+ void generateBuildKey();
+ void generateCachefile();
+ void displayConfig();
+ void buildQmake();
+ void buildHostTools();
+#endif
+ void generateMakefiles();
+ void appendMakeItem(int inList, const QString &item);
+#if !defined(EVAL)
+ void generateConfigfiles();
+#endif
+ void showSummary();
+ void findProjects( const QString& dirName );
+ QString firstLicensePath();
+
+#if !defined(EVAL)
+ bool showLicense(QString licenseFile);
+ void readLicense();
+#endif
+
+ QString addDefine(QString def);
+
+ enum ProjectType {
+ App,
+ Lib,
+ Subdirs
+ };
+
+ ProjectType projectType( const QString& proFileName );
+ bool isDone();
+ bool isOk();
+private:
+ // Our variable dictionaries
+ QMap<QString,QString> dictionary;
+ QStringList licensedModules;
+ QStringList allSqlDrivers;
+ QStringList allConfigs;
+ QStringList disabledModules;
+ QStringList enabledModules;
+ QStringList modules;
+ QStringList disabledBuildParts;
+// QStringList sqlDrivers;
+ QStringList configCmdLine;
+ QStringList qmakeConfig;
+ QStringList qtConfig;
+
+ QStringList qmakeSql;
+ QStringList qmakeSqlPlugins;
+
+ QStringList qmakeStyles;
+ QStringList qmakeStylePlugins;
+
+ QStringList qmakeVars;
+ QStringList qmakeDefines;
+ // makeList[0] for qt and qtmain
+ // makeList[1] for subdirs and libs
+ // makeList[2] for the rest
+ QList<MakeItem*> makeList[3];
+ QStringList qmakeIncludes;
+ QStringList qmakeLibs;
+ QString opensslLibs;
+ QString psqlLibs;
+ QString sybase;
+ QString sybaseLibs;
+
+ QMap<QString,QString> licenseInfo;
+ QString outputLine;
+
+ QTextStream outStream;
+ QString sourcePath, buildPath;
+ QDir sourceDir, buildDir;
+
+ // Variables for usage output
+ int optionIndent;
+ int descIndent;
+ int outputWidth;
+
+ bool useUnixSeparators;
+ QString fixSeparators(const QString &somePath, bool escape = false);
+ QString escapeSeparators(const QString &somePath);
+ bool filesDiffer(const QString &file1, const QString &file2);
+
+ bool findFile(const QString &fileName);
+ static QString findFileInPaths(const QString &fileName, const QString &paths);
+#if !defined(EVAL)
+ void reloadCmdLine();
+ void saveCmdLine();
+#endif
+
+ void desc(const char *description, int startingAt = 0, int wrapIndent = 0);
+ void desc(const char *option, const char *description, bool skipIndent = false, char fillChar = '.');
+ void desc(const char *mark_option, const char *mark, const char *option, const char *description, char fillChar = '.');
+ void applySpecSpecifics();
+ static QString locateFile(const QString &fileName);
+ static QString locateFileInPaths(const QString &fileName, const QStringList &paths);
+};
+
+class MakeItem
+{
+public:
+ MakeItem( const QString &d, const QString &p, const QString &t, Configure::ProjectType qt )
+ : directory( d ),
+ proFile( p ),
+ target( t ),
+ qmakeTemplate( qt )
+ { }
+
+ QString directory;
+ QString proFile;
+ QString target;
+ Configure::ProjectType qmakeTemplate;
+};
+
+
+QT_END_NAMESPACE
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
new file mode 100644
index 0000000000..188595523a
--- /dev/null
+++ b/tools/configure/environment.cpp
@@ -0,0 +1,516 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "environment.h"
+
+#include <process.h>
+#include <iostream>
+#include <qdebug.h>
+#include <QDir>
+#include <QStringList>
+#include <QMap>
+#include <QDir>
+#include <QFile>
+#include <QFileInfo>
+
+//#define CONFIGURE_DEBUG_EXECUTE
+//#define CONFIGURE_DEBUG_CP_DIR
+
+using namespace std;
+
+#ifdef Q_OS_WIN32
+#include <qt_windows.h>
+#endif
+
+#include <symbian/epocroot_p.h> // from tools/shared
+#include <windows/registry_p.h> // from tools/shared
+
+QT_BEGIN_NAMESPACE
+
+struct CompilerInfo{
+ Compiler compiler;
+ const char *compilerStr;
+ const char *regKey;
+ const char *executable;
+} compiler_info[] = {
+ // The compilers here are sorted in a reversed-preferred order
+ {CC_BORLAND, "Borland C++", 0, "bcc32.exe"},
+ {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "g++.exe"},
+ {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", 0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe
+ {CC_NET2003, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe
+ {CC_NET2005, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\8.0", "cl.exe"}, // link.exe, lib.exe
+ {CC_NET2008, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\9.0", "cl.exe"}, // link.exe, lib.exe
+ {CC_NET2010, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2010 (10.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\10.0", "cl.exe"}, // link.exe, lib.exe
+ {CC_UNKNOWN, "Unknown", 0, 0},
+};
+
+
+// Initialize static variables
+Compiler Environment::detectedCompiler = CC_UNKNOWN;
+
+/*!
+ Returns the pointer to the CompilerInfo for a \a compiler.
+*/
+CompilerInfo *Environment::compilerInfo(Compiler compiler)
+{
+ int i = 0;
+ while(compiler_info[i].compiler != compiler && compiler_info[i].compiler != CC_UNKNOWN)
+ ++i;
+ return &(compiler_info[i]);
+}
+
+/*!
+ Returns the qmakespec for the compiler detected on the system.
+*/
+QString Environment::detectQMakeSpec()
+{
+ QString spec;
+ switch (detectCompiler()) {
+ case CC_NET2010:
+ spec = "win32-msvc2010";
+ break;
+ case CC_NET2008:
+ spec = "win32-msvc2008";
+ break;
+ case CC_NET2005:
+ spec = "win32-msvc2005";
+ break;
+ case CC_NET2003:
+ spec = "win32-msvc2003";
+ break;
+ case CC_INTEL:
+ spec = "win32-icc";
+ break;
+ case CC_MINGW:
+ spec = "win32-g++";
+ break;
+ case CC_BORLAND:
+ spec = "win32-borland";
+ break;
+ default:
+ break;
+ }
+
+ return spec;
+}
+
+/*!
+ Returns the enum of the compiler which was detected on the system.
+ The compilers are detected in the order as entered into the
+ compiler_info list.
+
+ If more than one compiler is found, CC_UNKNOWN is returned.
+*/
+Compiler Environment::detectCompiler()
+{
+#ifndef Q_OS_WIN32
+ return CC_UNKNOWN; // Always generate CC_UNKNOWN on other platforms
+#else
+ if(detectedCompiler != CC_UNKNOWN)
+ return detectedCompiler;
+
+ int installed = 0;
+
+ // Check for compilers in registry first, to see which version is in PATH
+ QString paths = qgetenv("PATH");
+ QStringList pathlist = paths.toLower().split(";");
+ for(int i = 0; compiler_info[i].compiler; ++i) {
+ QString productPath = qt_readRegistryKey(HKEY_LOCAL_MACHINE, compiler_info[i].regKey).toLower();
+ if (productPath.length()) {
+ QStringList::iterator it;
+ for(it = pathlist.begin(); it != pathlist.end(); ++it) {
+ if((*it).contains(productPath)) {
+ ++installed;
+ detectedCompiler = compiler_info[i].compiler;
+ break;
+ }
+ }
+ }
+ }
+
+ // Now just go looking for the executables, and accept any executable as the lowest version
+ if (!installed) {
+ for(int i = 0; compiler_info[i].compiler; ++i) {
+ QString executable = QString(compiler_info[i].executable).toLower();
+ if (executable.length() && Environment::detectExecutable(executable)) {
+ ++installed;
+ detectedCompiler = compiler_info[i].compiler;
+ break;
+ }
+ }
+ }
+
+ if (installed > 1) {
+ cout << "Found more than one known compiler! Using \"" << compilerInfo(detectedCompiler)->compilerStr << "\"" << endl;
+ detectedCompiler = CC_UNKNOWN;
+ }
+ return detectedCompiler;
+#endif
+};
+
+/*!
+ Returns true if the \a executable could be loaded, else false.
+ This means that the executable either is in the current directory
+ or in the PATH.
+*/
+bool Environment::detectExecutable(const QString &executable)
+{
+ PROCESS_INFORMATION procInfo;
+ memset(&procInfo, 0, sizeof(procInfo));
+
+ STARTUPINFO startInfo;
+ memset(&startInfo, 0, sizeof(startInfo));
+ startInfo.cb = sizeof(startInfo);
+
+ bool couldExecute = CreateProcess(0, (wchar_t*)executable.utf16(),
+ 0, 0, false,
+ CREATE_NO_WINDOW | CREATE_SUSPENDED,
+ 0, 0, &startInfo, &procInfo);
+
+ if (couldExecute) {
+ CloseHandle(procInfo.hThread);
+ TerminateProcess(procInfo.hProcess, 0);
+ CloseHandle(procInfo.hProcess);
+ }
+ return couldExecute;
+}
+
+/*!
+ Creates a commandling from \a program and it \a arguments,
+ escaping characters that needs it.
+*/
+static QString qt_create_commandline(const QString &program, const QStringList &arguments)
+{
+ QString programName = program;
+ if (!programName.startsWith("\"") && !programName.endsWith("\"") && programName.contains(" "))
+ programName = "\"" + programName + "\"";
+ programName.replace("/", "\\");
+
+ QString args;
+ // add the prgram as the first arrg ... it works better
+ args = programName + " ";
+ for (int i=0; i<arguments.size(); ++i) {
+ QString tmp = arguments.at(i);
+ // in the case of \" already being in the string the \ must also be escaped
+ tmp.replace( "\\\"", "\\\\\"" );
+ // escape a single " because the arguments will be parsed
+ tmp.replace( "\"", "\\\"" );
+ if (tmp.isEmpty() || tmp.contains(' ') || tmp.contains('\t')) {
+ // The argument must not end with a \ since this would be interpreted
+ // as escaping the quote -- rather put the \ behind the quote: e.g.
+ // rather use "foo"\ than "foo\"
+ QString endQuote("\"");
+ int i = tmp.length();
+ while (i>0 && tmp.at(i-1) == '\\') {
+ --i;
+ endQuote += "\\";
+ }
+ args += QString(" \"") + tmp.left(i) + endQuote;
+ } else {
+ args += ' ' + tmp;
+ }
+ }
+ return args;
+}
+
+/*!
+ Creates a QByteArray of the \a environment.
+*/
+static QByteArray qt_create_environment(const QStringList &environment)
+{
+ QByteArray envlist;
+ if (environment.isEmpty())
+ return envlist;
+
+ int pos = 0;
+ // add PATH if necessary (for DLL loading)
+ QByteArray path = qgetenv("PATH");
+ if (environment.filter(QRegExp("^PATH=",Qt::CaseInsensitive)).isEmpty() && !path.isNull()) {
+ QString tmp = QString(QLatin1String("PATH=%1")).arg(QString::fromLocal8Bit(path));
+ uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
+ envlist.resize(envlist.size() + tmpSize);
+ memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
+ pos += tmpSize;
+ }
+ // add the user environment
+ foreach (const QString &tmp, environment) {
+ uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
+ envlist.resize(envlist.size() + tmpSize);
+ memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
+ pos += tmpSize;
+ }
+ // add the 2 terminating 0 (actually 4, just to be on the safe side)
+ envlist.resize(envlist.size() + 4);
+ envlist[pos++] = 0;
+ envlist[pos++] = 0;
+ envlist[pos++] = 0;
+ envlist[pos++] = 0;
+
+ return envlist;
+}
+
+/*!
+ Executes the command described in \a arguments, in the
+ environment inherited from the parent process, with the
+ \a additionalEnv settings applied.
+ \a removeEnv removes the specified environment variables from
+ the environment of the executed process.
+
+ Returns the exit value of the process, or -1 if the command could
+ not be executed.
+
+ This function uses _(w)spawnvpe to spawn a process by searching
+ through the PATH environment variable.
+*/
+int Environment::execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv)
+{
+#ifdef CONFIGURE_DEBUG_EXECUTE
+ qDebug() << "About to Execute: " << arguments;
+ qDebug() << " " << QDir::currentPath();
+ qDebug() << " " << additionalEnv;
+ qDebug() << " " << removeEnv;
+#endif
+ // Create the full environment from the current environment and
+ // the additionalEnv strings, then remove all variables defined
+ // in removeEnv
+ QMap<QString, QString> fullEnvMap;
+ LPWSTR envStrings = GetEnvironmentStrings();
+ if (envStrings) {
+ int strLen = 0;
+ for (LPWSTR envString = envStrings; *(envString); envString += strLen + 1) {
+ strLen = wcslen(envString);
+ QString str = QString((const QChar*)envString, strLen);
+ if (!str.startsWith("=")) { // These are added by the system
+ int sepIndex = str.indexOf('=');
+ fullEnvMap.insert(str.left(sepIndex).toUpper(), str.mid(sepIndex +1));
+ }
+ }
+ }
+ FreeEnvironmentStrings(envStrings);
+
+ // Add additionalEnv variables
+ for (int i = 0; i < additionalEnv.count(); ++i) {
+ const QString &str = additionalEnv.at(i);
+ int sepIndex = str.indexOf('=');
+ fullEnvMap.insert(str.left(sepIndex).toUpper(), str.mid(sepIndex +1));
+ }
+
+ // Remove removeEnv variables
+ for (int j = 0; j < removeEnv.count(); ++j)
+ fullEnvMap.remove(removeEnv.at(j).toUpper());
+
+ // Add all variables to a QStringList
+ QStringList fullEnv;
+ QMapIterator<QString, QString> it(fullEnvMap);
+ while (it.hasNext()) {
+ it.next();
+ fullEnv += QString(it.key() + "=" + it.value());
+ }
+
+ // ----------------------------
+ QString program = arguments.takeAt(0);
+ QString args = qt_create_commandline(program, arguments);
+ QByteArray envlist = qt_create_environment(fullEnv);
+
+ DWORD exitCode = DWORD(-1);
+ PROCESS_INFORMATION procInfo;
+ memset(&procInfo, 0, sizeof(procInfo));
+
+ STARTUPINFO startInfo;
+ memset(&startInfo, 0, sizeof(startInfo));
+ startInfo.cb = sizeof(startInfo);
+
+ bool couldExecute = CreateProcess(0, (wchar_t*)args.utf16(),
+ 0, 0, true, CREATE_UNICODE_ENVIRONMENT,
+ envlist.isEmpty() ? 0 : envlist.data(),
+ 0, &startInfo, &procInfo);
+
+ if (couldExecute) {
+ WaitForSingleObject(procInfo.hProcess, INFINITE);
+ GetExitCodeProcess(procInfo.hProcess, &exitCode);
+ CloseHandle(procInfo.hThread);
+ CloseHandle(procInfo.hProcess);
+ }
+
+
+ if (exitCode == DWORD(-1)) {
+ switch(GetLastError()) {
+ case E2BIG:
+ cerr << "execute: Argument list exceeds 1024 bytes" << endl;
+ foreach (const QString &arg, arguments)
+ cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl;
+ break;
+ case ENOENT:
+ cerr << "execute: File or path is not found (" << program.toLocal8Bit().constData() << ")" << endl;
+ break;
+ case ENOEXEC:
+ cerr << "execute: Specified file is not executable or has invalid executable-file format (" << program.toLocal8Bit().constData() << ")" << endl;
+ break;
+ case ENOMEM:
+ cerr << "execute: Not enough memory is available to execute new process." << endl;
+ break;
+ default:
+ cerr << "execute: Unknown error" << endl;
+ foreach (const QString &arg, arguments)
+ cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl;
+ break;
+ }
+ }
+ return exitCode;
+}
+
+/*!
+ Copies the \a srcDir contents into \a destDir.
+
+ If \a includeSrcDir is not empty, any files with 'h', 'prf', or 'conf' suffixes
+ will not be copied over from \a srcDir. Instead a new file will be created
+ in \a destDir with the same name and that file will include a file with the
+ same name from the \a includeSrcDir using relative path and appropriate
+ syntax for the file type.
+
+ Returns true if copying was successful.
+*/
+bool Environment::cpdir(const QString &srcDir,
+ const QString &destDir,
+ const QString &includeSrcDir)
+{
+ QString cleanSrcName = QDir::cleanPath(srcDir);
+ QString cleanDstName = QDir::cleanPath(destDir);
+ QString cleanIncludeName = QDir::cleanPath(includeSrcDir);
+
+#ifdef CONFIGURE_DEBUG_CP_DIR
+ qDebug() << "Attempt to cpdir " << cleanSrcName << "->" << cleanDstName;
+#endif
+ if(!QFile::exists(cleanDstName) && !QDir().mkpath(cleanDstName)) {
+ qDebug() << "cpdir: Failure to create " << cleanDstName;
+ return false;
+ }
+
+ bool result = true;
+ QDir dir = QDir(cleanSrcName);
+ QDir destinationDir = QDir(cleanDstName);
+ QFileInfoList allEntries = dir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
+ for (int i = 0; result && (i < allEntries.count()); ++i) {
+ QFileInfo entry = allEntries.at(i);
+ bool intermediate = true;
+ if (entry.isDir()) {
+ QString newIncSrcDir;
+ if (!includeSrcDir.isEmpty())
+ newIncSrcDir = QString("%1/%2").arg(cleanIncludeName).arg(entry.fileName());
+
+ intermediate = cpdir(QString("%1/%2").arg(cleanSrcName).arg(entry.fileName()),
+ QString("%1/%2").arg(cleanDstName).arg(entry.fileName()),
+ newIncSrcDir);
+ } else {
+ QString destFile = QString("%1/%2").arg(cleanDstName).arg(entry.fileName());
+#ifdef CONFIGURE_DEBUG_CP_DIR
+ qDebug() << "About to cp (file)" << entry.absoluteFilePath() << "->" << destFile;
+#endif
+ QFile::remove(destFile);
+ QString suffix = entry.suffix();
+ if (!includeSrcDir.isEmpty() && (suffix == "prf" || suffix == "conf" || suffix == "h")) {
+ QString relativeIncludeFilePath = QString("%1/%2").arg(cleanIncludeName).arg(entry.fileName());
+ relativeIncludeFilePath = destinationDir.relativeFilePath(relativeIncludeFilePath);
+#ifdef CONFIGURE_DEBUG_CP_DIR
+ qDebug() << "...instead generate relative include to" << relativeIncludeFilePath;
+#endif
+ QFile currentFile(destFile);
+ if (currentFile.open(QFile::WriteOnly | QFile::Text)) {
+ QTextStream fileStream;
+ fileStream.setDevice(&currentFile);
+
+ if (suffix == "prf" || suffix == "conf") {
+ if (entry.fileName() == "qmake.conf") {
+ // While QMAKESPEC_ORIGINAL being relative or absolute doesn't matter for the
+ // primary use of this variable by qmake to identify the original mkspec, the
+ // variable is also used for few special cases where the absolute path is required.
+ // Conversely, the include of the original qmake.conf must be done using relative path,
+ // as some Qt binary deployments are done in a manner that doesn't allow for patching
+ // the paths at the installation time.
+ fileStream << "QMAKESPEC_ORIGINAL=" << cleanSrcName << endl << endl;
+ }
+ fileStream << "include(" << relativeIncludeFilePath << ")" << endl << endl;
+ } else if (suffix == "h") {
+ fileStream << "#include \"" << relativeIncludeFilePath << "\"" << endl << endl;
+ }
+
+ fileStream.flush();
+ currentFile.close();
+ }
+ } else {
+ intermediate = QFile::copy(entry.absoluteFilePath(), destFile);
+ SetFileAttributes((wchar_t*)destFile.utf16(), FILE_ATTRIBUTE_NORMAL);
+ }
+ }
+ if(!intermediate) {
+ qDebug() << "cpdir: Failure for " << entry.fileName() << entry.isDir();
+ result = false;
+ }
+ }
+ return result;
+}
+
+bool Environment::rmdir(const QString &name)
+{
+ bool result = true;
+ QString cleanName = QDir::cleanPath(name);
+
+ QDir dir = QDir(cleanName);
+ QFileInfoList allEntries = dir.entryInfoList(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
+ for (int i = 0; result && (i < allEntries.count()); ++i) {
+ QFileInfo entry = allEntries.at(i);
+ if (entry.isDir()) {
+ result &= rmdir(entry.absoluteFilePath());
+ } else {
+ result &= QFile::remove(entry.absoluteFilePath());
+ }
+ }
+ result &= dir.rmdir(cleanName);
+ return result;
+}
+
+QString Environment::symbianEpocRoot()
+{
+ // Call function defined in tools/shared/symbian/epocroot_p.h
+ return ::qt_epocRoot();
+}
+
+QT_END_NAMESPACE
diff --git a/tools/configure/environment.h b/tools/configure/environment.h
new file mode 100644
index 0000000000..faee63f435
--- /dev/null
+++ b/tools/configure/environment.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qstring.h>
+#include <qt_windows.h>
+
+QT_BEGIN_NAMESPACE
+
+
+enum Compiler {
+ CC_UNKNOWN = 0,
+ CC_BORLAND = 0x01,
+ CC_MINGW = 0x02,
+ CC_INTEL = 0x03,
+ CC_NET2003 = 0x71,
+ CC_NET2005 = 0x80,
+ CC_NET2008 = 0x90,
+ CC_NET2010 = 0x91
+};
+
+struct CompilerInfo;
+class Environment
+{
+public:
+ static Compiler detectCompiler();
+ static QString detectQMakeSpec();
+ static bool detectExecutable(const QString &executable);
+
+ static int execute(QStringList arguments, const QStringList &additionalEnv, const QStringList &removeEnv);
+ static bool cpdir(const QString &srcDir,
+ const QString &destDir,
+ const QString &includeSrcDir = QString());
+ static bool rmdir(const QString &name);
+
+ static QString symbianEpocRoot();
+
+private:
+ static Compiler detectedCompiler;
+
+ static CompilerInfo *compilerInfo(Compiler compiler);
+};
+
+
+QT_END_NAMESPACE
diff --git a/tools/configure/main.cpp b/tools/configure/main.cpp
new file mode 100644
index 0000000000..a2b7eb7881
--- /dev/null
+++ b/tools/configure/main.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+** Configure tool
+**
+*/
+
+#include "configureapp.h"
+
+QT_BEGIN_NAMESPACE
+
+int runConfigure( int argc, char** argv )
+{
+ Configure app( argc, argv );
+ if (!app.isOk())
+ return 3;
+
+ app.parseCmdLine();
+#if !defined(EVAL)
+ app.validateArgs();
+#endif
+ if( app.displayHelp() )
+ return 1;
+
+ // Read license now, and exit if it doesn't pass.
+ // This lets the user see the command-line options of configure
+ // without having to load and parse the license file.
+ app.readLicense();
+ if (!app.isOk())
+ return 3;
+
+ // Auto-detect modules and settings.
+ app.autoDetection();
+
+ // After reading all command-line arguments, and doing all the
+ // auto-detection, it's time to do some last minute validation.
+ // If the validation fails, we cannot continue.
+ if (!app.verifyConfiguration())
+ return 3;
+
+ app.generateOutputVars();
+
+#if !defined(EVAL)
+ if( !app.isDone() )
+ app.generateCachefile();
+ if( !app.isDone() )
+ app.generateBuildKey();
+ if( !app.isDone() )
+ app.generateConfigfiles();
+ if( !app.isDone() )
+ app.displayConfig();
+ if( !app.isDone() )
+ app.generateHeaders();
+ if( !app.isDone() )
+ app.buildQmake();
+#endif
+ if( !app.isDone() )
+ app.generateMakefiles();
+ if( !app.isDone() )
+ app.buildHostTools();
+ if( !app.isDone() )
+ app.showSummary();
+ if( !app.isOk() )
+ return 2;
+
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+int main( int argc, char** argv )
+{
+ QT_USE_NAMESPACE
+ return runConfigure(argc, argv);
+}
diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp
new file mode 100644
index 0000000000..ab724f9888
--- /dev/null
+++ b/tools/configure/tools.cpp
@@ -0,0 +1,249 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tools.h"
+
+#include <QDir>
+#include <QFile>
+#include <QByteArray>
+
+
+// std stuff ------------------------------------
+#include <iostream>
+#include <windows.h>
+#include <conio.h>
+#define NUMBER_OF_PARTS 7
+
+std::ostream &operator<<(std::ostream &s, const QString &val); // defined in configureapp.cpp
+using namespace std;
+
+void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString> &licenseInfo,
+ const QString &path)
+{
+ if (dictionary[ "BUILDNOKIA" ] == "yes") {
+ dictionary["EDITION"] = "NokiaInternalBuild";
+ dictionary["LICENSE_FILE"] = ""; // No License for nokia developers
+ dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE";
+ return; // No license key checking in internal builds
+ }
+
+ QString tpLicense = dictionary["QT_SOURCE_TREE"] + "/LICENSE.PREVIEW.OPENSOURCE";
+ if (QFile::exists(tpLicense)) {
+ dictionary["EDITION"] = "Preview";
+ dictionary["LICENSE FILE"] = tpLicense;
+ dictionary["QT_EDITION"] = "QT_EDITION_OPENSOURCE";
+ return; // No license key checking in Tech Preview
+ }
+ tpLicense = dictionary["QT_SOURCE_TREE"] + "/LICENSE.PREVIEW.COMMERCIAL";
+ if (QFile::exists(tpLicense)) {
+ dictionary["EDITION"] = "Preview";
+ dictionary["LICENSE FILE"] = tpLicense;
+ dictionary["QT_EDITION"] = "QT_EDITION_DESKTOP";
+ return; // No license key checking in Tech Preview
+ }
+
+ // Read in the license file
+ QFile licenseFile(path);
+ if( !path.isEmpty() && licenseFile.open( QFile::ReadOnly ) ) {
+ cout << "Reading license file in....." << qPrintable(path) << endl;
+
+ QString buffer = licenseFile.readLine(1024);
+ while (!buffer.isEmpty()) {
+ if( buffer[ 0 ] != '#' ) {
+ QStringList components = buffer.split( '=' );
+ if ( components.size() >= 2 ) {
+ QStringList::Iterator it = components.begin();
+ QString key = (*it++).trimmed().remove('"').toUpper();
+ QString value = (*it++).trimmed().remove('"');
+ licenseInfo[ key ] = value;
+ }
+ }
+ // read next line
+ buffer = licenseFile.readLine(1024);
+ }
+ licenseFile.close();
+ } else {
+ cout << "License file not found in " << QDir::homePath() << endl;
+ cout << "Please put the Qt license file, '.qt-license' in your home "
+ << "directory and run configure again.";
+ dictionary["DONE"] = "error";
+ return;
+ }
+
+ // Verify license info...
+ QString licenseKey = licenseInfo["LICENSEKEYEXT"];
+ QByteArray clicenseKey = licenseKey.toLatin1();
+ //We check the license
+ static const char * const SEP = "-";
+ char *licenseParts[NUMBER_OF_PARTS];
+ int partNumber = 0;
+ for (char *part = strtok(clicenseKey.data(), SEP); part != 0; part = strtok(0, SEP))
+ licenseParts[partNumber++] = part;
+ if (partNumber < (NUMBER_OF_PARTS-1)) {
+ dictionary["DONE"] = "error";
+ cout << "License file does not contain proper license key." <<partNumber<< endl;
+ return;
+ }
+
+ char products = licenseParts[0][0];
+ char* platforms = licenseParts[1];
+ char* licenseSchema = licenseParts[2];
+ char licenseFeatures = licenseParts[3][0];
+
+ // Determine edition ---------------------------------------------------------------------------
+ QString licenseType;
+ if (strcmp(licenseSchema,"F4M") == 0) {
+ licenseType = "Commercial";
+ if (products == 'F') {
+ dictionary["EDITION"] = "Universal";
+ dictionary["QT_EDITION"] = "QT_EDITION_UNIVERSAL";
+ } else if (products == 'B') {
+ dictionary["EDITION"] = "FullFramework";
+ dictionary["QT_EDITION"] = "QT_EDITION_DESKTOP";
+ } else {
+ dictionary["EDITION"] = "GUIFramework";
+ dictionary["QT_EDITION"] = "QT_EDITION_DESKTOPLIGHT";
+ }
+ } else if (strcmp(licenseSchema,"Z4M") == 0 || strcmp(licenseSchema,"R4M") == 0 || strcmp(licenseSchema,"Q4M") == 0) {
+ if (products == 'B') {
+ dictionary["EDITION"] = "Evaluation";
+ dictionary["QT_EDITION"] = "QT_EDITION_EVALUATION";
+ licenseType = "Evaluation";
+ }
+ }
+
+ if (platforms[2] == 'L') {
+ static const char src[] = "8NPQRTZ";
+ static const char dst[] = "UCWX9M7";
+ const char *p = strchr(src, platforms[1]);
+ platforms[1] = dst[p - src];
+ }
+
+#define PL(a,b) (int(a)+int(b)*256)
+ int platformCode = PL(platforms[0],platforms[1]);
+ switch (platformCode) {
+ case PL('X','9'):
+ case PL('X','C'):
+ case PL('X','U'):
+ case PL('X','W'):
+ case PL('X','M'): // old license key
+ dictionary["LICENSE_EXTENSION"] = "-ALLOS";
+ break;
+
+ case PL('6', 'M'):
+ case PL('8', 'M'):
+ case PL('K', 'M'): // old license key
+ case PL('N', '7'):
+ case PL('N', '9'):
+ case PL('N', 'X'):
+ case PL('S', '9'):
+ case PL('S', 'C'):
+ case PL('S', 'U'):
+ case PL('S', 'W'):
+ dictionary["LICENSE_EXTENSION"] = "-EMBEDDED";
+ if (dictionary["PLATFORM NAME"].contains("Windows CE")
+ && platformCode != PL('6', 'M') && platformCode != PL('S', '9')
+ && platformCode != PL('S', 'C') && platformCode != PL('S', 'U')
+ && platformCode != PL('S', 'W') && platformCode != PL('K', 'M')) {
+ dictionary["DONE"] = "error";
+ } else if (dictionary["PLATFORM NAME"].contains("Symbian")
+ && platformCode != PL('N', '9') && platformCode != PL('S', '9')
+ && platformCode != PL('S', 'C') && platformCode != PL('S', 'U')
+ && platformCode != PL('S', 'W')) {
+ dictionary["DONE"] = "error";
+ }
+ break;
+ case PL('R', 'M'):
+ case PL('F', 'M'):
+ dictionary["LICENSE_EXTENSION"] = "-DESKTOP";
+ if (!dictionary["PLATFORM NAME"].endsWith("Windows")) {
+ dictionary["DONE"] = "error";
+ }
+ break;
+ default:
+ dictionary["DONE"] = "error";
+ break;
+ }
+#undef PL
+
+ if (dictionary.value("DONE") == "error") {
+ cout << "You are not licensed for the " << dictionary["PLATFORM NAME"] << " platform." << endl << endl;
+ cout << "Please contact qt-info@nokia.com to upgrade your license" << endl;
+ cout << "to include the " << dictionary["PLATFORM NAME"] << " platform, or install the" << endl;
+ cout << "Qt Open Source Edition if you intend to develop free software." << endl;
+ return;
+ }
+
+ // Override for evaluation licenses
+ if (dictionary["EDITION"] == "Evaluation")
+ dictionary["LICENSE_EXTENSION"] = "-EVALUATION";
+
+ if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/.LICENSE")) {
+ // Generic, no-suffix license
+ dictionary["LICENSE_EXTENSION"].clear();
+ } else if (dictionary["LICENSE_EXTENSION"].isEmpty()) {
+ cout << "License file does not contain proper license key." << endl;
+ dictionary["DONE"] = "error";
+ }
+ if (licenseType.isEmpty()
+ || dictionary["EDITION"].isEmpty()
+ || dictionary["QT_EDITION"].isEmpty()) {
+ cout << "License file does not contain proper license key." << endl;
+ dictionary["DONE"] = "error";
+ return;
+ }
+
+ // copy one of .LICENSE-*(-US) to LICENSE
+ QString toLicenseFile = dictionary["QT_SOURCE_TREE"] + "/LICENSE";
+ QString fromLicenseFile = dictionary["QT_SOURCE_TREE"] + "/.LICENSE" + dictionary["LICENSE_EXTENSION"];
+ if (licenseFeatures == 'B' || licenseFeatures == 'G'
+ || licenseFeatures == 'L' || licenseFeatures == 'Y')
+ fromLicenseFile += "-US";
+
+ if (!CopyFile((wchar_t*)QDir::toNativeSeparators(fromLicenseFile).utf16(),
+ (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), false)) {
+ cout << "Failed to copy license file (" << fromLicenseFile << ")";
+ dictionary["DONE"] = "error";
+ return;
+ }
+ dictionary["LICENSE FILE"] = toLicenseFile;
+}
+
diff --git a/tools/configure/tools.h b/tools/configure/tools.h
new file mode 100644
index 0000000000..5ea25642ef
--- /dev/null
+++ b/tools/configure/tools.h
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef _TOOLS_H_
+#define _TOOLS_H_
+
+#include <QString>
+#include <QStringList>
+#include <QMap>
+
+
+class Tools
+{
+public:
+ static void checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString> &licenseInfo,
+ const QString &path);
+};
+
+#endif // _TOOLS_H_
+
diff --git a/tools/shared/symbian/epocroot.cpp b/tools/shared/symbian/epocroot.cpp
new file mode 100644
index 0000000000..5e6bc120cf
--- /dev/null
+++ b/tools/shared/symbian/epocroot.cpp
@@ -0,0 +1,227 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake application of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qdir.h>
+#include <QtCore/qxmlstream.h>
+
+#include "epocroot_p.h"
+#include "../windows/registry_p.h"
+
+QT_BEGIN_NAMESPACE
+
+// Registry key under which the location of the Symbian devices.xml file is
+// stored.
+// Note that, on 64-bit machines, this key is located under the 32-bit
+// compatibility key:
+// HKEY_LOCAL_MACHINE\Software\Wow6432Node
+#define SYMBIAN_SDKS_REG_SUBKEY "Software\\Symbian\\EPOC SDKs\\CommonPath"
+
+#ifdef Q_OS_WIN32
+# define SYMBIAN_SDKS_REG_HANDLE HKEY_LOCAL_MACHINE
+#else
+# define SYMBIAN_SDKS_REG_HANDLE 0
+#endif
+
+// Value which is populated and returned by the epocRoot() function.
+// Stored as a static value in order to avoid unnecessary re-evaluation.
+static QString epocRootValue;
+
+static QString getDevicesXmlPath()
+ {
+ // Note that the following call will return a null string on platforms other
+ // than Windows. If support is required on other platforms for devices.xml,
+ // an alternative mechanism for retrieving the location of this file will
+ // be required.
+ return qt_readRegistryKey(SYMBIAN_SDKS_REG_HANDLE, QLatin1String(SYMBIAN_SDKS_REG_SUBKEY));
+ }
+
+/**
+ * Checks whether epocRootValue points to an existent directory.
+ * If not, epocRootValue is set to an empty string and an error message is printed.
+ */
+static void checkEpocRootExists(const QString &source)
+{
+ if (!epocRootValue.isEmpty()) {
+ QDir dir(epocRootValue);
+ if (!dir.exists()) {
+ qWarning("Warning: %s is set to an invalid path: '%s'", qPrintable(source),
+ qPrintable(epocRootValue));
+ epocRootValue = QString();
+ }
+ }
+}
+
+/**
+ * Translate path from Windows to Qt format.
+ */
+static void fixEpocRoot(QString &path)
+{
+ path.replace(QLatin1Char('\\'), QLatin1Char('/'));
+
+ if (!path.size() || path[path.size()-1] != QLatin1Char('/')) {
+ path += QLatin1Char('/');
+ }
+#ifdef Q_OS_WIN32
+ // Make sure we have drive letter in epocroot
+ if (path.startsWith(QLatin1Char('/')))
+ path.prepend(QDir::currentPath().left(2));
+#endif
+}
+
+/**
+ * Determine the epoc root for the currently active SDK.
+ */
+QString qt_epocRoot()
+{
+ if (epocRootValue.isEmpty()) {
+ // 1. If environment variable EPOCROOT is set and points to an existent
+ // directory, this is returned.
+ epocRootValue = QString::fromLocal8Bit(qgetenv("EPOCROOT").constData());
+ checkEpocRootExists(QLatin1String("EPOCROOT environment variable"));
+
+ if (epocRootValue.isEmpty()) {
+ // 2. The location of devices.xml is specified by a registry key. If this
+ // file exists, it is parsed.
+ QString devicesXmlPath = getDevicesXmlPath();
+ if (!devicesXmlPath.isEmpty()) {
+ devicesXmlPath += QLatin1String("/devices.xml");
+ QFile devicesFile(devicesXmlPath);
+ if (devicesFile.open(QIODevice::ReadOnly)) {
+
+ // 3. If the EPOCDEVICE environment variable is set and a corresponding
+ // entry is found in devices.xml, and its epocroot value points to an
+ // existent directory, it is returned.
+ // 4. If a device element marked as default is found in devices.xml and its
+ // epocroot value points to an existent directory, this is returned.
+
+ const QString epocDeviceValue = QString::fromLocal8Bit(qgetenv("EPOCDEVICE").constData());
+ bool epocDeviceFound = false;
+
+ QXmlStreamReader xml(&devicesFile);
+ while (!xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement() && xml.name() == QLatin1String("devices")) {
+ if (xml.attributes().value(QLatin1String("version")) == QLatin1String("1.0")) {
+ while (!(xml.isEndElement() && xml.name() == QLatin1String("devices")) && !xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement() && xml.name() == QLatin1String("device")) {
+ const bool isDefault = xml.attributes().value(QLatin1String("default")) == QLatin1String("yes");
+ const QString id = xml.attributes().value(QLatin1String("id")).toString();
+ const QString name = xml.attributes().value(QLatin1String("name")).toString();
+ const QString alias = xml.attributes().value(QLatin1String("alias")).toString();
+ bool epocDeviceMatch = QString(id + QLatin1String(":") + name) == epocDeviceValue;
+ if (!alias.isEmpty())
+ epocDeviceMatch |= alias == epocDeviceValue;
+ epocDeviceFound |= epocDeviceMatch;
+
+ if((epocDeviceValue.isEmpty() && isDefault) || epocDeviceMatch) {
+ // Found a matching device
+ while (!(xml.isEndElement() && xml.name() == QLatin1String("device")) && !xml.atEnd()) {
+ xml.readNext();
+ if (xml.isStartElement() && xml.name() == QLatin1String("epocroot")) {
+ epocRootValue = xml.readElementText();
+ const QString deviceSource = epocDeviceValue.isEmpty()
+ ? QLatin1String("default device")
+ : QString(QLatin1String("EPOCDEVICE (") + epocDeviceValue + QLatin1String(")"));
+ checkEpocRootExists(deviceSource);
+ }
+ }
+
+ if (epocRootValue.isEmpty())
+ xml.raiseError(QLatin1String("No epocroot element found"));
+ }
+ }
+ }
+ } else {
+ xml.raiseError(QLatin1String("Invalid 'devices' element version"));
+ }
+ }
+ }
+ if (xml.hasError()) {
+ qWarning("Warning: Error \"%s\" when parsing devices.xml",
+ qPrintable(xml.errorString()));
+ } else {
+ if (epocRootValue.isEmpty()) {
+ if (!epocDeviceValue.isEmpty()) {
+ if (epocDeviceFound) {
+ qWarning("Warning: Missing or invalid epocroot attribute in device '%s' in devices.xml.",
+ qPrintable(epocDeviceValue));
+ } else {
+ qWarning("Warning: No device matching EPOCDEVICE (%s) in devices.xml.",
+ qPrintable(epocDeviceValue));
+ }
+ } else {
+ if (epocDeviceFound) {
+ qWarning("Warning: Missing or invalid epocroot attribute in default device in devices.xml.");
+ } else {
+ qWarning("Warning: No default device set in devices.xml.");
+ }
+ }
+ }
+ }
+ } else {
+ qWarning("Warning: Could not open file: '%s'.", qPrintable(devicesXmlPath));
+ }
+ }
+ }
+
+ if (epocRootValue.isEmpty()) {
+ // 5. An empty string is returned.
+ qWarning("Warning: failed to resolve epocroot."
+#ifdef Q_OS_WIN32
+ "\nEither\n"
+ " 1. Set EPOCROOT environment variable to a valid value.\n"
+ " or 2. Ensure that the HKEY_LOCAL_MACHINE\\" SYMBIAN_SDKS_REG_SUBKEY
+ " registry key is set, and then\n"
+ " a. Set EPOCDEVICE environment variable to a valid device\n"
+ " or b. Specify a default device in the devices.xml file.");
+#else
+ " Set EPOCROOT environment variable to a valid value.");
+#endif
+ } else {
+ fixEpocRoot(epocRootValue);
+ }
+ }
+
+ return epocRootValue;
+}
+
+QT_END_NAMESPACE
diff --git a/tools/shared/symbian/epocroot.pri b/tools/shared/symbian/epocroot.pri
new file mode 100644
index 0000000000..f0f0dab535
--- /dev/null
+++ b/tools/shared/symbian/epocroot.pri
@@ -0,0 +1,11 @@
+# Epocroot resolving is only required for tools, so omit it from all mobile/embedded builds
+!symbian:!wince*:!embedded {
+HEADERS += \
+ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot_p.h \
+ $$QT_SOURCE_TREE/tools/shared/windows/registry_p.h
+SOURCES += \
+ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \
+ $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp
+INCLUDEPATH += $$QT_SOURCE_TREE/tools/shared
+DEFINES += QLIBRARYINFO_EPOCROOT
+}
diff --git a/tools/shared/symbian/epocroot_p.h b/tools/shared/symbian/epocroot_p.h
new file mode 100644
index 0000000000..61197dc653
--- /dev/null
+++ b/tools/shared/symbian/epocroot_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake application of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_SYMBIAN_EPOCROOT_H
+#define QT_SYMBIAN_EPOCROOT_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qstring.h>
+
+QT_BEGIN_NAMESPACE
+
+/**
+ * Determine the epoc root for the currently active SDK.
+ *
+ * The algorithm used is as follows:
+ * 1. If environment variable EPOCROOT is set and points to an existent
+ * directory, this is returned.
+ * 2. The location of devices.xml is specified by a registry key. If this
+ * file exists, it is parsed.
+ * 3. If the EPOCDEVICE environment variable is set and a corresponding
+ * entry is found in devices.xml, and its epocroot value points to an
+ * existent directory, it is returned.
+ * 4. If a device element marked as default is found in devices.xml and its
+ * epocroot value points to an existent directory, this is returned.
+ * 5. An empty string is returned.
+ *
+ * Any return value other than the empty string therefore is guaranteed to
+ * point to an existent directory.
+ */
+QString qt_epocRoot();
+
+QT_END_NAMESPACE
+
+#endif // QT_SYMBIAN_EPOCROOT_H
+
diff --git a/tools/shared/windows/registry.cpp b/tools/shared/windows/registry.cpp
new file mode 100644
index 0000000000..87808c4060
--- /dev/null
+++ b/tools/shared/windows/registry.cpp
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake application of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qstringlist.h>
+#include "registry_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_OS_WIN32
+/*!
+ Returns the path part of a registry key.
+ e.g.
+ For a key
+ "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"
+ it returns
+ "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\"
+*/
+static QString keyPath(const QString &rKey)
+{
+ int idx = rKey.lastIndexOf(QLatin1Char('\\'));
+ if (idx == -1)
+ return QString();
+ return rKey.left(idx + 1);
+}
+
+/*!
+ Returns the name part of a registry key.
+ e.g.
+ For a key
+ "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"
+ it returns
+ "ProductDir"
+*/
+static QString keyName(const QString &rKey)
+{
+ int idx = rKey.lastIndexOf(QLatin1Char('\\'));
+ if (idx == -1)
+ return rKey;
+
+ QString res(rKey.mid(idx + 1));
+ if (res == QLatin1String("Default") || res == QLatin1String("."))
+ res = QString();
+ return res;
+}
+#endif
+
+QString qt_readRegistryKey(HKEY parentHandle, const QString &rSubkey)
+{
+ QString result;
+
+#ifdef Q_OS_WIN32
+ QString rSubkeyName = keyName(rSubkey);
+ QString rSubkeyPath = keyPath(rSubkey);
+
+ HKEY handle = 0;
+ LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, KEY_READ, &handle);
+
+ if (res != ERROR_SUCCESS)
+ return QString();
+
+ // get the size and type of the value
+ DWORD dataType;
+ DWORD dataSize;
+ res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, &dataType, 0, &dataSize);
+ if (res != ERROR_SUCCESS) {
+ RegCloseKey(handle);
+ return QString();
+ }
+
+ // get the value
+ QByteArray data(dataSize, 0);
+ res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), 0, 0,
+ reinterpret_cast<unsigned char*>(data.data()), &dataSize);
+ if (res != ERROR_SUCCESS) {
+ RegCloseKey(handle);
+ return QString();
+ }
+
+ switch (dataType) {
+ case REG_EXPAND_SZ:
+ case REG_SZ: {
+ result = QString::fromWCharArray(((const wchar_t *)data.constData()));
+ break;
+ }
+
+ case REG_MULTI_SZ: {
+ QStringList l;
+ int i = 0;
+ for (;;) {
+ QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i);
+ i += s.length() + 1;
+
+ if (s.isEmpty())
+ break;
+ l.append(s);
+ }
+ result = l.join(QLatin1String(", "));
+ break;
+ }
+
+ case REG_NONE:
+ case REG_BINARY: {
+ result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2);
+ break;
+ }
+
+ case REG_DWORD_BIG_ENDIAN:
+ case REG_DWORD: {
+ Q_ASSERT(data.size() == sizeof(int));
+ int i;
+ memcpy((char*)&i, data.constData(), sizeof(int));
+ result = QString::number(i);
+ break;
+ }
+
+ default:
+ qWarning("QSettings: unknown data %u type in windows registry", quint32(dataType));
+ break;
+ }
+
+ RegCloseKey(handle);
+#else
+ Q_UNUSED(parentHandle);
+ Q_UNUSED(rSubkey)
+#endif
+
+ return result;
+}
+
+QT_END_NAMESPACE
+
diff --git a/tools/shared/windows/registry_p.h b/tools/shared/windows/registry_p.h
new file mode 100644
index 0000000000..226cedc49e
--- /dev/null
+++ b/tools/shared/windows/registry_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the qmake application of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_WINDOWS_REGISTRY_H
+#define QT_WINDOWS_REGISTRY_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QT_BEGIN_NAMESPACE
+
+#include <QtCore/qglobal.h>
+
+#ifdef Q_OS_WIN32
+ #include <QtCore/qt_windows.h>
+#else
+ typedef void* HKEY;
+#endif
+
+#include <QtCore/qstring.h>
+
+/**
+ * Read a value from the Windows registry.
+ *
+ * If the key is not found, or the registry cannot be accessed (for example
+ * if this code is compiled for a platform other than Windows), a null
+ * string is returned.
+ */
+QString qt_readRegistryKey(HKEY parentHandle, const QString &rSubkey);
+
+QT_END_NAMESPACE
+
+#endif // QT_WINDOWS_REGISTRY_H
+
diff --git a/tools/uilib/abstractformbuilder.cpp b/tools/uilib/abstractformbuilder.cpp
new file mode 100644
index 0000000000..ecb43db89f
--- /dev/null
+++ b/tools/uilib/abstractformbuilder.cpp
@@ -0,0 +1,3209 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**sw
+****************************************************************************/
+
+#include "abstractformbuilder.h"
+#include "formbuilderextra_p.h"
+#include "resourcebuilder_p.h"
+#include "textbuilder_p.h"
+#include "ui4_p.h"
+#include "properties_p.h"
+
+#include <QtCore/QVariant>
+#include <QtCore/QMetaProperty>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QQueue>
+#include <QtCore/QHash>
+#include <QtCore/qdebug.h>
+#include <QtCore/QCoreApplication>
+
+#include <QtGui/QAction>
+#include <QtGui/QActionGroup>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QComboBox>
+#include <QtGui/QFontComboBox>
+#include <QtGui/QGridLayout>
+#ifndef QT_NO_FORMLAYOUT
+# include <QtGui/QFormLayout>
+#endif
+#include <QtGui/QIcon>
+#include <QtGui/QListWidget>
+#include <QtGui/QMainWindow>
+#include <QtGui/QPixmap>
+#include <QtGui/QStatusBar>
+#include <QtGui/QTreeWidget>
+#include <QtGui/QTableWidget>
+#include <QtGui/QWidget>
+#include <QtGui/QSplitter>
+#include <QtGui/QScrollArea>
+#include <QtGui/QAbstractButton>
+#include <QtGui/QAbstractItemView>
+#include <QtGui/QHeaderView>
+#ifndef QFORMINTERNAL_NAMESPACE
+# include <private/qlayout_p.h> // Compiling within Designer
+#endif
+
+#include <QtXml/QXmlStreamReader>
+
+#include <QtGui/QDialog>
+
+// containers
+#include <QtGui/QToolBox>
+#include <QtGui/QStackedWidget>
+#include <QtGui/QTabWidget>
+#include <QtGui/QToolBar>
+#include <QtGui/QMenuBar>
+#include <QtGui/QDockWidget>
+#include <QtGui/QMdiArea>
+#include <QtGui/QWorkspace>
+#include <QtGui/QWizard>
+#include <QtGui/QWizardPage>
+
+#include <QtCore/qdebug.h>
+
+#include <limits.h>
+
+Q_DECLARE_METATYPE(QWidgetList)
+
+static const char *buttonGroupPropertyC = "buttonGroup";
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+using namespace QFormInternal;
+#endif
+
+class QFriendlyLayout: public QLayout
+{
+public:
+ inline QFriendlyLayout() { Q_ASSERT(0); }
+
+#ifdef QFORMINTERNAL_NAMESPACE
+ friend class QFormInternal::QAbstractFormBuilder;
+#else
+ friend class QAbstractFormBuilder;
+#endif
+};
+
+/*!
+ \class QAbstractFormBuilder
+
+ \brief The QAbstractFormBuilder class provides a default
+ implementation for classes that create user interfaces at
+ run-time.
+
+ \inmodule QtDesigner
+
+ QAbstractFormBuilder provides a standard interface and a default
+ implementation for constructing forms from user interface
+ files. It is not intended to be instantiated directly. Use the
+ QFormBuilder class to create user interfaces from UI files at
+ run-time. For example:
+
+ \snippet doc/src/snippets/code/tools_designer_src_lib_uilib_abstractformbuilder.cpp 0
+
+ To override certain aspects of the form builder's behavior,
+ subclass QAbstractFormBuilder and reimplement the relevant virtual
+ functions:
+
+ \list
+ \o load() handles reading of UI format files from arbitrary
+ QIODevices, and construction of widgets from the XML data
+ that they contain.
+ \o save() handles saving of widget details in UI format to
+ arbitrary QIODevices.
+ \o workingDirectory() and setWorkingDirectory() control the
+ directory in which forms are held. The form builder looks for
+ other resources on paths relative to this directory.
+ \endlist
+
+ The QFormBuilder class is typically used by custom components and
+ applications that embed \QD. Standalone applications that need to
+ dynamically generate user interfaces at run-time use the
+ QUiLoader, found in the QtUiTools module.
+
+ \sa {QtUiTools Module}
+*/
+
+/*!
+ Constructs a new form builder.*/
+QAbstractFormBuilder::QAbstractFormBuilder() :
+ m_defaultMargin(INT_MIN),
+ m_defaultSpacing(INT_MIN)
+{
+ setResourceBuilder(new QResourceBuilder());
+ setTextBuilder(new QTextBuilder());
+}
+
+/*!
+ Destroys the form builder.*/
+QAbstractFormBuilder::~QAbstractFormBuilder()
+{
+ QFormBuilderExtra::removeInstance(this);
+}
+
+
+/*!
+ \fn QWidget *QAbstractFormBuilder::load(QIODevice *device, QWidget *parent)
+
+ Loads an XML representation of a widget from the given \a device,
+ and constructs a new widget with the specified \a parent.
+
+ \sa save()
+*/
+QWidget *QAbstractFormBuilder::load(QIODevice *dev, QWidget *parentWidget)
+{
+ QXmlStreamReader reader;
+ reader.setDevice(dev);
+ DomUI ui;
+ bool initialized = false;
+
+ const QString uiElement = QLatin1String("ui");
+ while (!reader.atEnd()) {
+ if (reader.readNext() == QXmlStreamReader::StartElement) {
+ if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0) {
+ ui.read(reader);
+ initialized = true;
+ } else {
+ reader.raiseError(QCoreApplication::translate("QAbstractFormBuilder", "Unexpected element <%1>").arg(reader.name().toString()));
+ }
+ }
+ }
+ if (reader.hasError()) {
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "An error has occurred while reading the UI file at line %1, column %2: %3")
+ .arg(reader.lineNumber()).arg(reader.columnNumber())
+ .arg(reader.errorString()));
+ return 0;
+ }
+ if (!initialized) {
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "Invalid UI file: The root element <ui> is missing."));
+ return 0;
+ }
+
+ QWidget *widget = create(&ui, parentWidget);
+ return widget;
+}
+
+/*!
+ \internal
+*/
+QWidget *QAbstractFormBuilder::create(DomUI *ui, QWidget *parentWidget)
+{
+ typedef QFormBuilderExtra::ButtonGroupHash ButtonGroupHash;
+
+ QFormBuilderExtra *formBuilderPrivate = QFormBuilderExtra::instance(this);
+ formBuilderPrivate->clear();
+ if (const DomLayoutDefault *def = ui->elementLayoutDefault()) {
+ m_defaultMargin = def->hasAttributeMargin() ? def->attributeMargin() : INT_MIN;
+ m_defaultSpacing = def->hasAttributeSpacing() ? def->attributeSpacing() : INT_MIN;
+ }
+
+ DomWidget *ui_widget = ui->elementWidget();
+ if (!ui_widget)
+ return 0;
+
+ initialize(ui);
+
+ if (const DomButtonGroups *domButtonGroups = ui->elementButtonGroups())
+ formBuilderPrivate->registerButtonGroups(domButtonGroups);
+
+ if (QWidget *widget = create(ui_widget, parentWidget)) {
+ // Reparent button groups that were actually created to main container for them to be found in the signal/slot part
+ const ButtonGroupHash &buttonGroups = formBuilderPrivate->buttonGroups();
+ if (!buttonGroups.empty()) {
+ const ButtonGroupHash::const_iterator cend = buttonGroups.constEnd();
+ for (ButtonGroupHash::const_iterator it = buttonGroups.constBegin(); it != cend; ++it)
+ if (it.value().second)
+ it.value().second->setParent(widget);
+ }
+ createConnections(ui->elementConnections(), widget);
+ createResources(ui->elementResources()); // maybe this should go first, before create()...
+ applyTabStops(widget, ui->elementTabStops());
+ formBuilderPrivate->applyInternalProperties();
+ reset();
+ formBuilderPrivate->clear();
+ return widget;
+ }
+ formBuilderPrivate->clear();
+ return 0;
+}
+
+/*!
+ \internal
+ Retrieve relevant information from the custom widgets section.
+ Called by create(DomUI *, QWidget *); call manually if you
+ just use create(DomWidget *, QWidget *) on some child widget of DomUI.
+ */
+
+void QAbstractFormBuilder::initialize(const DomUI *ui)
+{
+ typedef QList<DomCustomWidget*> DomCustomWidgetList;
+
+ DomCustomWidgets *domCustomWidgets = ui->elementCustomWidgets();
+ createCustomWidgets(domCustomWidgets);
+
+ if (domCustomWidgets) {
+ const DomCustomWidgetList customWidgets = domCustomWidgets->elementCustomWidget();
+ if (!customWidgets.empty()) {
+ QFormBuilderExtra *formBuilderPrivate = QFormBuilderExtra::instance(this);
+ const DomCustomWidgetList::const_iterator cend = customWidgets.constEnd();
+ for (DomCustomWidgetList::const_iterator it = customWidgets.constBegin(); it != cend; ++it)
+ formBuilderPrivate->storeCustomWidgetData((*it)->elementClass(), *it);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget)
+{
+ QWidget *w = createWidget(ui_widget->attributeClass(), parentWidget, ui_widget->attributeName());
+ if (!w)
+ return 0;
+
+ applyProperties(w, ui_widget->elementProperty());
+
+ foreach (DomAction *ui_action, ui_widget->elementAction()) {
+ QAction *child_action = create(ui_action, w);
+ Q_UNUSED( child_action );
+ }
+
+ foreach (DomActionGroup *ui_action_group, ui_widget->elementActionGroup()) {
+ QActionGroup *child_action_group = create(ui_action_group, w);
+ Q_UNUSED( child_action_group );
+ }
+
+ QWidgetList children;
+ foreach (DomWidget *ui_child, ui_widget->elementWidget()) {
+ if (QWidget *child = create(ui_child, w)) {
+ children += child;
+ } else {
+ const QString className = ui_child->elementClass().empty() ? QString() : ui_child->elementClass().front();
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "The creation of a widget of the class '%1' failed.").arg(className));
+ }
+ }
+
+ foreach (DomLayout *ui_lay, ui_widget->elementLayout()) {
+ QLayout *child_lay = create(ui_lay, 0, w);
+ Q_UNUSED( child_lay );
+ }
+
+ const QList<DomActionRef *> addActions = ui_widget->elementAddAction();
+ if (!addActions.empty()) {
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ foreach (DomActionRef *ui_action_ref, addActions) {
+ const QString name = ui_action_ref->attributeName();
+ if (name == strings.separator) {
+ QAction *sep = new QAction(w);
+ sep->setSeparator(true);
+ w->addAction(sep);
+ addMenuAction(sep);
+ } else if (QAction *a = m_actions.value(name)) {
+ w->addAction(a);
+ } else if (QActionGroup *g = m_actionGroups.value(name)) {
+ w->addActions(g->actions());
+ } else if (QMenu *menu = w->findChild<QMenu*>(name)) {
+ w->addAction(menu->menuAction());
+ addMenuAction(menu->menuAction());
+ }
+ }
+ }
+
+ loadExtraInfo(ui_widget, w, parentWidget);
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+ QString scriptErrorMessage;
+ QFormBuilderExtra *extra = QFormBuilderExtra::instance(this);
+ extra->formScriptRunner().run(ui_widget,
+ extra->customWidgetScript(ui_widget->attributeClass()),
+ w, children, &scriptErrorMessage);
+#endif
+ addItem(ui_widget, w, parentWidget);
+
+ if (qobject_cast<QDialog *>(w) && parentWidget)
+ w->setAttribute(Qt::WA_Moved, false); // So that QDialog::setVisible(true) will center it
+
+ const QStringList zOrderNames = ui_widget->elementZOrder();
+ if (!zOrderNames.isEmpty()) {
+ QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(w->property("_q_zOrder"));
+ foreach (const QString &widgetName, zOrderNames) {
+ if (QWidget *child = w->findChild<QWidget*>(widgetName)) {
+ if (child->parentWidget() == w) {
+ zOrder.removeAll(child);
+ zOrder.append(child);
+ child->raise();
+ }
+ }
+ }
+ w->setProperty("_q_zOrder", QVariant::fromValue(zOrder));
+ }
+
+ return w;
+}
+
+/*!
+ \internal
+*/
+QAction *QAbstractFormBuilder::create(DomAction *ui_action, QObject *parent)
+{
+ QAction *a = createAction(parent, ui_action->attributeName());
+ if (!a)
+ return 0;
+
+ m_actions.insert(ui_action->attributeName(), a);
+ applyProperties(a, ui_action->elementProperty());
+ return a;
+}
+
+/*!
+ \internal
+*/
+QActionGroup *QAbstractFormBuilder::create(DomActionGroup *ui_action_group, QObject *parent)
+{
+ QActionGroup *a = createActionGroup(parent, ui_action_group->attributeName());
+ if (!a)
+ return 0;
+ m_actionGroups.insert(ui_action_group->attributeName(), a);
+ applyProperties(a, ui_action_group->elementProperty());
+
+ foreach (DomAction *ui_action, ui_action_group->elementAction()) {
+ QAction *child_action = create(ui_action, a);
+ Q_UNUSED( child_action );
+ }
+
+ foreach (DomActionGroup *g, ui_action_group->elementActionGroup()) {
+ QActionGroup *child_action_group = create(g, parent);
+ Q_UNUSED( child_action_group );
+ }
+
+ return a;
+}
+
+// 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.
+Qt::ToolBarArea QAbstractFormBuilder::toolbarAreaFromDOMAttributes(const DomPropertyHash &attributes) {
+ const DomProperty *attr = attributes.value(QFormBuilderStrings::instance().toolBarAreaAttribute);
+ if (!attr)
+ return Qt::TopToolBarArea;
+ switch(attr->kind()) {
+ case DomProperty::Number:
+ return static_cast<Qt::ToolBarArea>(attr->elementNumber());
+ case DomProperty::Enum:
+ return enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::ToolBarArea>("toolBarArea", attr->elementEnum().toLatin1());
+ default:
+ break;
+ }
+ return Qt::TopToolBarArea;
+}
+
+/*!
+ \internal
+*/
+bool QAbstractFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget)
+{
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ const DomPropertyHash attributes = propertyMap(ui_widget->elementAttribute());
+
+ if (parentWidget == 0)
+ return true;
+ // Check special cases. First: Custom container
+ const QString className = QLatin1String(parentWidget->metaObject()->className());
+ const QString addPageMethod = QFormBuilderExtra::instance(this)->customWidgetAddPageMethod(className);
+ if (!addPageMethod.isEmpty()) {
+ // If this fails ( non-existent or non-slot), use ContainerExtension in Designer, else it can't be helped
+ return QMetaObject::invokeMethod(parentWidget, addPageMethod.toUtf8().constData(), Qt::DirectConnection, Q_ARG(QWidget*, widget));
+ }
+
+ if (QMainWindow *mw = qobject_cast<QMainWindow*>(parentWidget)) {
+
+#ifndef QT_NO_MENUBAR
+ // the menubar
+ if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(widget)) {
+ mw->setMenuBar(menuBar);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_TOOLBAR
+ // apply the toolbar's attributes
+ else if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
+ mw->addToolBar(toolbarAreaFromDOMAttributes(attributes), toolBar);
+ // check break
+ if (const DomProperty *attr = attributes.value(strings.toolBarBreakAttribute))
+ if (attr->elementBool() == strings.trueValue)
+ mw->insertToolBarBreak (toolBar);
+
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_STATUSBAR
+ // statusBar
+ else if (QStatusBar *statusBar = qobject_cast<QStatusBar*>(widget)) {
+ mw->setStatusBar(statusBar);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_DOCKWIDGET
+ // apply the dockwidget's attributes
+ else if (QDockWidget *dockWidget = qobject_cast<QDockWidget*>(widget)) {
+ if (const DomProperty *attr = attributes.value(strings.dockWidgetAreaAttribute)) {
+ Qt::DockWidgetArea area = static_cast<Qt::DockWidgetArea>(attr->elementNumber());
+ if (!dockWidget->isAreaAllowed(area)) {
+ if (dockWidget->isAreaAllowed(Qt::LeftDockWidgetArea))
+ area = Qt::LeftDockWidgetArea;
+ else if (dockWidget->isAreaAllowed(Qt::RightDockWidgetArea))
+ area = Qt::RightDockWidgetArea;
+ else if (dockWidget->isAreaAllowed(Qt::TopDockWidgetArea))
+ area = Qt::TopDockWidgetArea;
+ else if (dockWidget->isAreaAllowed(Qt::BottomDockWidgetArea))
+ area = Qt::BottomDockWidgetArea;
+ }
+ mw->addDockWidget(area, dockWidget);
+ } else {
+ mw->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
+ }
+ return true;
+ }
+#endif
+
+ else if (! mw->centralWidget()) {
+ mw->setCentralWidget(widget);
+ return true;
+ }
+ }
+
+#ifndef QT_NO_TABWIDGET
+ else if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(parentWidget)) {
+ widget->setParent(0);
+
+ const int tabIndex = tabWidget->count();
+ if (const DomProperty *titleP = attributes.value(strings.titleAttribute, 0))
+ tabWidget->addTab(widget, toString(titleP->elementString()));
+ else
+ tabWidget->addTab(widget, strings.defaultTitle);
+
+ if (DomProperty *picon = attributes.value(strings.iconAttribute)) {
+ QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon);
+ QVariant nativeValue = resourceBuilder()->toNativeValue(v);
+ tabWidget->setTabIcon(tabIndex, qvariant_cast<QIcon>(nativeValue));
+ }
+
+#ifndef QT_NO_TOOLTIP
+ if (const DomProperty *ptoolTip = attributes.value(strings.toolTipAttribute)) {
+ tabWidget->setTabToolTip(tabIndex, toString(ptoolTip->elementString()));
+ }
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ if (const DomProperty *pwhatsThis = attributes.value(strings.whatsThisAttribute)) {
+ tabWidget->setTabWhatsThis(tabIndex, toString(pwhatsThis->elementString()));
+ }
+#endif
+
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_TOOLBOX
+ else if (QToolBox *toolBox = qobject_cast<QToolBox*>(parentWidget)) {
+ const int tabIndex = toolBox->count();
+ if (const DomProperty *labelP = attributes.value(strings.labelAttribute, 0))
+ toolBox->addItem(widget, toString(labelP->elementString()));
+ else
+ toolBox->addItem(widget, strings.defaultTitle);
+
+ if (DomProperty *picon = attributes.value(strings.iconAttribute)) {
+ QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon);
+ QVariant nativeValue = resourceBuilder()->toNativeValue(v);
+ toolBox->setItemIcon(tabIndex, qvariant_cast<QIcon>(nativeValue));
+ }
+
+#ifndef QT_NO_TOOLTIP
+ if (const DomProperty *ptoolTip = attributes.value(strings.toolTipAttribute)) {
+ toolBox->setItemToolTip(tabIndex, toString(ptoolTip->elementString()));
+ }
+#endif
+
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_STACKEDWIDGET
+ else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(parentWidget)) {
+ stackedWidget->addWidget(widget);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_SPLITTER
+ else if (QSplitter *splitter = qobject_cast<QSplitter*>(parentWidget)) {
+ splitter->addWidget(widget);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_MDIAREA
+ else if (QMdiArea *mdiArea = qobject_cast<QMdiArea*>(parentWidget)) {
+ mdiArea->addSubWindow(widget);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_WORKSPACE
+ else if (QWorkspace *ws = qobject_cast<QWorkspace*>(parentWidget)) {
+ ws->addWindow(widget);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_DOCKWIDGET
+ else if (QDockWidget *dockWidget = qobject_cast<QDockWidget*>(parentWidget)) {
+ dockWidget->setWidget(widget);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_SCROLLAREA
+ else if (QScrollArea *scrollArea = qobject_cast<QScrollArea*>(parentWidget)) {
+ scrollArea->setWidget(widget);
+ return true;
+ }
+#endif
+
+#ifndef QT_NO_WIZARD
+ else if (QWizard *wizard = qobject_cast<QWizard *>(parentWidget)) {
+ QWizardPage *page = qobject_cast<QWizardPage*>(widget);
+ if (!page) {
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "Attempt to add child that is not of class QWizardPage to QWizard."));
+ return false;
+ }
+ wizard->addPage(page);
+ return true;
+ }
+#endif
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::layoutInfo(DomLayout *ui_layout, QObject *parent, int *margin, int *spacing)
+{
+ Q_UNUSED(parent)
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());
+
+ int mar = INT_MIN;
+ int spac = INT_MIN;
+ if (const DomProperty *p = properties.value(strings.marginProperty, 0))
+ mar = p->elementNumber();
+
+ if (const DomProperty *p = properties.value(strings.spacingProperty, 0))
+ spac = p->elementNumber();
+
+#ifdef Q_OS_MAC
+ // here we recognize UI file < 4.3 (no we don't store margin property)
+ if (mar != INT_MIN) {
+ const int defaultMargin = parent->inherits("QLayoutWidget") ? 0 : 9;
+ if (mar == defaultMargin)
+ mar = INT_MIN;
+ if (spac == 6)
+ spac = INT_MIN;
+
+ if (mar == INT_MIN || spac == INT_MIN) {
+ QList<DomProperty *> properties = ui_layout->elementProperty();
+ QMutableListIterator<DomProperty *> it(properties);
+ while (it.hasNext()) {
+ DomProperty *prop = it.next();
+ if ((mar == INT_MIN && prop->attributeName() == strings.marginProperty) ||
+ (spac == INT_MIN && prop->attributeName() == strings.spacingProperty)) {
+ it.remove();
+ delete prop;
+ }
+ }
+ ui_layout->setElementProperty(properties);
+ }
+ }
+#endif
+ if (margin)
+ *margin = mar;
+ if (spacing)
+ *spacing = spac;
+}
+
+/*!
+ \internal
+*/
+QLayout *QAbstractFormBuilder::create(DomLayout *ui_layout, QLayout *parentLayout, QWidget *parentWidget)
+{
+ QObject *p = parentLayout;
+
+ if (p == 0)
+ p = parentWidget;
+
+ Q_ASSERT(p != 0);
+
+ bool tracking = false;
+
+ if (p == parentWidget && parentWidget->layout()) {
+ tracking = true;
+ p = parentWidget->layout();
+ }
+
+ QLayout *layout = createLayout(ui_layout->attributeClass(), p, ui_layout->hasAttributeName() ? ui_layout->attributeName() : QString());
+
+ if (layout == 0)
+ return 0;
+
+ if (tracking && layout->parent() == 0) {
+ QBoxLayout *box = qobject_cast<QBoxLayout*>(parentWidget->layout());
+ if (!box) { // only QBoxLayout is supported
+ const QString widgetClass = QString::fromUtf8(parentWidget->metaObject()->className());
+ const QString layoutClass = QString::fromUtf8(parentWidget->layout()->metaObject()->className());
+ const QString msg = QCoreApplication::translate("QAbstractFormBuilder", "Attempt to add a layout to a widget '%1' (%2) which already has a layout of non-box type %3.\n"
+ "This indicates an inconsistency in the ui-file.").
+ arg(parentWidget->objectName(), widgetClass, layoutClass);
+ uiLibWarning(msg);
+ return 0;
+ }
+ box->addLayout(layout);
+ }
+
+ int margin = INT_MIN, spacing = INT_MIN;
+ layoutInfo(ui_layout, p, &margin, &spacing);
+
+ if (margin != INT_MIN) {
+ layout->setMargin(margin);
+ } else {
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ int left, top, right, bottom;
+ left = top = right = bottom = -1;
+ layout->getContentsMargins(&left, &top, &right, &bottom);
+
+ const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());
+
+ if (const DomProperty *p = properties.value(strings.leftMarginProperty, 0))
+ left = p->elementNumber();
+
+ if (const DomProperty *p = properties.value(strings.topMarginProperty, 0))
+ top = p->elementNumber();
+
+ if (const DomProperty *p = properties.value(strings.rightMarginProperty, 0))
+ right = p->elementNumber();
+
+ if (const DomProperty *p = properties.value(strings.bottomMarginProperty, 0))
+ bottom = p->elementNumber();
+
+ layout->setContentsMargins(left, top, right, bottom);
+ }
+
+ if (spacing != INT_MIN) {
+ layout->setSpacing(spacing);
+ } else {
+ QGridLayout *grid = qobject_cast<QGridLayout *>(layout);
+ if (grid) {
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());
+
+ if (const DomProperty *p = properties.value(strings.horizontalSpacingProperty, 0))
+ grid->setHorizontalSpacing(p->elementNumber());
+ if (const DomProperty *p = properties.value(strings.verticalSpacingProperty, 0))
+ grid->setVerticalSpacing(p->elementNumber());
+ }
+ }
+
+ applyProperties(layout, ui_layout->elementProperty());
+
+ foreach (DomLayoutItem *ui_item, ui_layout->elementItem()) {
+ if (QLayoutItem *item = create(ui_item, layout, parentWidget)) {
+ addItem(ui_item, item, layout);
+ }
+ }
+ // Check the box stretch attributes
+ if (QBoxLayout *box = qobject_cast<QBoxLayout*>(layout)) {
+ const QString boxStretch = ui_layout->attributeStretch();
+ if (!boxStretch.isEmpty())
+ QFormBuilderExtra::setBoxLayoutStretch(boxStretch, box);
+ }
+ // Check the grid stretch/minimum size attributes
+ if (QGridLayout *grid = qobject_cast<QGridLayout*>(layout)) {
+ // Stretch
+ const QString gridRowStretch = ui_layout->attributeRowStretch();
+ if (!gridRowStretch.isEmpty())
+ QFormBuilderExtra::setGridLayoutRowStretch(gridRowStretch, grid);
+ const QString gridColumnStretch = ui_layout->attributeColumnStretch();
+ if (!gridColumnStretch.isEmpty())
+ QFormBuilderExtra::setGridLayoutColumnStretch(gridColumnStretch, grid);
+ // Minimum size
+ const QString gridColumnMinimumWidth = ui_layout->attributeColumnMinimumWidth();
+ if (!gridColumnMinimumWidth.isEmpty())
+ QFormBuilderExtra::setGridLayoutColumnMinimumWidth(gridColumnMinimumWidth, grid);
+ const QString gridRowMinimumHeight = ui_layout->attributeRowMinimumHeight();
+ if (!gridRowMinimumHeight.isEmpty())
+ QFormBuilderExtra::setGridLayoutRowMinimumHeight(gridRowMinimumHeight, grid);
+ }
+ return layout;
+}
+
+#ifndef QT_NO_FORMLAYOUT
+static inline QFormLayout::ItemRole formLayoutRole(int column, int colspan)
+{
+ if (colspan > 1)
+ return QFormLayout::SpanningRole;
+ return column == 0 ? QFormLayout::LabelRole : QFormLayout::FieldRole;
+}
+#endif
+
+static inline QString alignmentValue(Qt::Alignment a)
+{
+ QString h,v;
+ switch (a & Qt::AlignHorizontal_Mask) {
+ case Qt::AlignLeft:
+ h = QLatin1String("Qt::AlignLeft");
+ break;
+ case Qt::AlignRight:
+ h = QLatin1String("Qt::AlignRight");
+ break;
+ case Qt::AlignHCenter:
+ h = QLatin1String("Qt::AlignHCenter");
+ break;
+ case Qt::AlignJustify:
+ h = QLatin1String("Qt::AlignJustify");
+ break;
+ }
+ switch (a & Qt::AlignVertical_Mask) {
+ case Qt::AlignTop:
+ v = QLatin1String("Qt::AlignTop");
+ break;
+ case Qt::AlignBottom:
+ v = QLatin1String("Qt::AlignBottom");
+ break;
+ case Qt::AlignVCenter:
+ v = QLatin1String("Qt::AlignVCenter");
+ break;
+ }
+ if (h.isEmpty() && v.isEmpty())
+ return QString();
+ if (!v.isEmpty()) {
+ if (!h.isEmpty())
+ h += QLatin1Char('|');
+ h += v;
+ }
+ return h;
+}
+
+static inline Qt::Alignment alignmentFromDom(const QString &in)
+{
+ Qt::Alignment rc = 0;
+ if (!in.isEmpty()) {
+ foreach (const QString &f, in.split(QLatin1Char('|'))) {
+ if (f == QLatin1String("Qt::AlignLeft")) {
+ rc |= Qt::AlignLeft;
+ } else if (f == QLatin1String("Qt::AlignRight")) {
+ rc |= Qt::AlignRight;
+ } else if (f == QLatin1String("Qt::AlignHCenter")) {
+ rc |= Qt::AlignHCenter;
+ } else if (f == QLatin1String("Qt::AlignJustify")) {
+ rc |= Qt::AlignJustify;
+ } else if (f == QLatin1String("Qt::AlignTop")) {
+ rc |= Qt::AlignTop;
+ } else if (f == QLatin1String("Qt::AlignBottom")) {
+ rc |= Qt::AlignBottom;
+ } else if (f == QLatin1String("Qt::AlignVCenter")) {
+ rc |= Qt::AlignVCenter;
+ }
+ }
+ }
+ return rc;
+}
+
+/*!
+ \internal
+*/
+bool QAbstractFormBuilder::addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout)
+{
+ // Calling addChildWidget(), etc. is required to maintain consistency of the layouts,
+ // see documentation of addItem(), which should ideally not be used.
+ if (item->widget()) {
+ static_cast<QFriendlyLayout*>(layout)->addChildWidget(item->widget());
+ } else if (item->layout()) {
+ static_cast<QFriendlyLayout*>(layout)->addChildLayout(item->layout());
+ } else if (item->spacerItem()) {
+ // nothing to do
+ } else {
+ return false;
+ }
+
+ if (QGridLayout *grid = qobject_cast<QGridLayout*>(layout)) {
+ const int rowSpan = ui_item->hasAttributeRowSpan() ? ui_item->attributeRowSpan() : 1;
+ const int colSpan = ui_item->hasAttributeColSpan() ? ui_item->attributeColSpan() : 1;
+ grid->addItem(item, ui_item->attributeRow(), ui_item->attributeColumn(),
+ rowSpan, colSpan, item->alignment());
+ return true;
+ }
+#ifndef QT_NO_FORMLAYOUT
+ if (QFormLayout *form = qobject_cast<QFormLayout *>(layout)) {
+ const int row = ui_item->attributeRow();
+ const int colSpan = ui_item->hasAttributeColSpan() ? ui_item->attributeColSpan() : 1;
+ form->setItem(row, formLayoutRole(ui_item->attributeColumn(), colSpan), item);
+ return true;
+ }
+
+#endif
+ layout->addItem(item);
+ return true;
+}
+
+/*!
+ \internal
+*/
+QLayoutItem *QAbstractFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget)
+{
+ switch (ui_layoutItem->kind()) {
+ case DomLayoutItem::Widget: {
+ if (QWidget *w = create(ui_layoutItem->elementWidget(), parentWidget)) {
+#ifdef QFORMINTERNAL_NAMESPACE // uilib
+ QWidgetItem *item = new QWidgetItemV2(w);
+#else // Within Designer: Use factory method that returns special items that refuse to shrink to 0,0
+ QWidgetItem *item = QLayoutPrivate::createWidgetItem(layout, w);
+#endif
+ item->setAlignment(alignmentFromDom(ui_layoutItem->attributeAlignment()));
+ return item;
+ }
+ qWarning() << QCoreApplication::translate("QAbstractFormBuilder", "Empty widget item in %1 '%2'.").arg(QString::fromUtf8(layout->metaObject()->className()), layout->objectName());
+ return 0;
+ }
+ case DomLayoutItem::Spacer: {
+ QSize size(0, 0);
+ QSizePolicy::Policy sizeType = QSizePolicy::Expanding;
+ bool isVspacer = false;
+
+ const DomSpacer *ui_spacer = ui_layoutItem->elementSpacer();
+
+ const QMetaEnum sizePolicy_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
+ const QMetaEnum orientation_enum = metaEnum<QAbstractFormBuilderGadget>("orientation");
+
+ const QList<DomProperty *> spacerProperties = ui_spacer->elementProperty();
+ if (!spacerProperties.empty()) {
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ foreach (DomProperty *p, spacerProperties) {
+ const QVariant v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p); // ### remove me
+ if (v.isNull())
+ continue;
+ if (p->attributeName() == strings.sizeHintProperty && p->kind() == DomProperty::Size) {
+ size = v.toSize(); // ### remove me
+ } else if (p->attributeName() == strings.sizeTypeProperty && p->kind() == DomProperty::Enum) {
+ sizeType = static_cast<QSizePolicy::Policy>(v.toInt());
+ } else if (p->attributeName() == strings.orientationProperty && p->kind() == DomProperty::Enum) {
+ const Qt::Orientation o = static_cast<Qt::Orientation>(v.toInt());
+ isVspacer = (o == Qt::Vertical);
+ }
+ }
+ }
+
+ QSpacerItem *spacer = 0;
+ if (isVspacer)
+ spacer = new QSpacerItem(size.width(), size.height(), QSizePolicy::Minimum, sizeType);
+ else
+ spacer = new QSpacerItem(size.width(), size.height(), sizeType, QSizePolicy::Minimum);
+ return spacer; }
+
+ case DomLayoutItem::Layout:
+ return create(ui_layoutItem->elementLayout(), layout, parentWidget);
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties)
+{
+ typedef QList<DomProperty*> DomPropertyList;
+
+ if (properties.empty())
+ return;
+
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
+
+ const DomPropertyList::const_iterator cend = properties.constEnd();
+ for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) {
+ const QVariant v = toVariant(o->metaObject(), *it);
+ if (!v.isNull()) {
+ const QString attributeName = (*it)->attributeName();
+ if (!fb->applyPropertyInternally(o, attributeName, v))
+ o->setProperty(attributeName.toUtf8(), v);
+ }
+ }
+}
+
+
+/*!
+ \internal
+ Check whether a property is applied internally by QAbstractFormBuilder. Call this
+ from overwritten applyProperties().
+*/
+
+bool QAbstractFormBuilder::applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value)
+{
+ return QFormBuilderExtra::instance(this)->applyPropertyInternally(o,propertyName, value);
+}
+
+/*!
+ \internal
+*/
+
+QVariant QAbstractFormBuilder::toVariant(const QMetaObject *meta, DomProperty *p)
+{
+ return domPropertyToVariant(this, meta, p);
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::setupColorGroup(QPalette &palette, QPalette::ColorGroup colorGroup,
+ DomColorGroup *group)
+{
+ // old format
+ const QList<DomColor*> colors = group->elementColor();
+ for (int role = 0; role < colors.size(); ++role) {
+ const DomColor *color = colors.at(role);
+ const QColor c(color->elementRed(), color->elementGreen(), color->elementBlue());
+ palette.setColor(colorGroup, QPalette::ColorRole(role), c);
+ }
+
+ // new format
+ const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole");
+
+ const QList<DomColorRole*> colorRoles = group->elementColorRole();
+ for (int role = 0; role < colorRoles.size(); ++role) {
+ const DomColorRole *colorRole = colorRoles.at(role);
+
+ if (colorRole->hasAttributeRole()) {
+ const int r = colorRole_enum.keyToValue(colorRole->attributeRole().toLatin1());
+ if (r != -1) {
+ const QBrush br = setupBrush(colorRole->elementBrush());
+ palette.setBrush(colorGroup, static_cast<QPalette::ColorRole>(r), br);
+ }
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+DomColorGroup *QAbstractFormBuilder::saveColorGroup(const QPalette &palette)
+{
+
+ const QMetaEnum colorRole_enum = metaEnum<QAbstractFormBuilderGadget>("colorRole");
+
+ DomColorGroup *group = new DomColorGroup();
+ QList<DomColorRole*> colorRoles;
+
+ const uint mask = palette.resolve();
+ for (int role = QPalette::WindowText; role < QPalette::NColorRoles; ++role) {
+ if (mask & (1 << role)) {
+ QBrush br = palette.brush(QPalette::ColorRole(role));
+
+ DomColorRole *colorRole = new DomColorRole();
+ colorRole->setElementBrush(saveBrush(br));
+ colorRole->setAttributeRole(QLatin1String(colorRole_enum.valueToKey(role)));
+ colorRoles.append(colorRole);
+ }
+ }
+
+ group->setElementColorRole(colorRoles);
+ return group;
+}
+
+/*!
+ \internal
+*/
+QBrush QAbstractFormBuilder::setupBrush(DomBrush *brush)
+{
+ QBrush br;
+ if (!brush->hasAttributeBrushStyle())
+ return br;
+
+ const Qt::BrushStyle style = enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::BrushStyle>("brushStyle", brush->attributeBrushStyle().toLatin1());
+
+ if (style == Qt::LinearGradientPattern ||
+ style == Qt::RadialGradientPattern ||
+ style == Qt::ConicalGradientPattern) {
+ const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType");
+ const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread");
+ const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate");
+
+ const DomGradient *gradient = brush->elementGradient();
+ const QGradient::Type type = enumKeyToValue<QGradient::Type>(gradientType_enum, gradient->attributeType().toLatin1());
+
+
+ QGradient *gr = 0;
+
+ if (type == QGradient::LinearGradient) {
+ gr = new QLinearGradient(QPointF(gradient->attributeStartX(), gradient->attributeStartY()),
+ QPointF(gradient->attributeEndX(), gradient->attributeEndY()));
+ } else if (type == QGradient::RadialGradient) {
+ gr = new QRadialGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()),
+ gradient->attributeRadius(),
+ QPointF(gradient->attributeFocalX(), gradient->attributeFocalY()));
+ } else if (type == QGradient::ConicalGradient) {
+ gr = new QConicalGradient(QPointF(gradient->attributeCentralX(), gradient->attributeCentralY()),
+ gradient->attributeAngle());
+ }
+ if (!gr)
+ return br;
+
+ const QGradient::Spread spread = enumKeyToValue<QGradient::Spread>(gradientSpread_enum, gradient->attributeSpread().toLatin1());
+ gr->setSpread(spread);
+
+ const QGradient::CoordinateMode coord = enumKeyToValue<QGradient::CoordinateMode>(gradientCoordinate_enum, gradient->attributeCoordinateMode().toLatin1());
+ gr->setCoordinateMode(coord);
+
+ const QList<DomGradientStop *> stops = gradient->elementGradientStop();
+ QListIterator<DomGradientStop *> it(stops);
+ while (it.hasNext()) {
+ const DomGradientStop *stop = it.next();
+ const DomColor *color = stop->elementColor();
+ gr->setColorAt(stop->attributePosition(), QColor::fromRgb(color->elementRed(),
+ color->elementGreen(), color->elementBlue(), color->attributeAlpha()));
+ }
+ br = QBrush(*gr);
+ delete gr;
+ } else if (style == Qt::TexturePattern) {
+ const DomProperty *texture = brush->elementTexture();
+ if (texture && texture->kind() == DomProperty::Pixmap) {
+ br.setTexture(domPropertyToPixmap(texture));
+ }
+ } else {
+ const DomColor *color = brush->elementColor();
+ br.setColor(QColor::fromRgb(color->elementRed(),
+ color->elementGreen(), color->elementBlue(), color->attributeAlpha()));
+ br.setStyle((Qt::BrushStyle)style);
+ }
+ return br;
+}
+
+/*!
+ \internal
+*/
+DomBrush *QAbstractFormBuilder::saveBrush(const QBrush &br)
+{
+ const QMetaEnum brushStyle_enum = metaEnum<QAbstractFormBuilderGadget>("brushStyle");
+
+ DomBrush *brush = new DomBrush();
+ const Qt::BrushStyle style = br.style();
+ brush->setAttributeBrushStyle(QLatin1String(brushStyle_enum.valueToKey(style)));
+ if (style == Qt::LinearGradientPattern ||
+ style == Qt::RadialGradientPattern ||
+ style == Qt::ConicalGradientPattern) {
+ const QMetaEnum gradientType_enum = metaEnum<QAbstractFormBuilderGadget>("gradientType");
+ const QMetaEnum gradientSpread_enum = metaEnum<QAbstractFormBuilderGadget>("gradientSpread");
+ const QMetaEnum gradientCoordinate_enum = metaEnum<QAbstractFormBuilderGadget>("gradientCoordinate");
+
+ DomGradient *gradient = new DomGradient();
+ const QGradient *gr = br.gradient();
+ const QGradient::Type type = gr->type();
+ gradient->setAttributeType(QLatin1String(gradientType_enum.valueToKey(type)));
+ gradient->setAttributeSpread(QLatin1String(gradientSpread_enum.valueToKey(gr->spread())));
+ gradient->setAttributeCoordinateMode(QLatin1String(gradientCoordinate_enum.valueToKey(gr->coordinateMode())));
+ QList<DomGradientStop *> stops;
+ QGradientStops st = gr->stops();
+ QVectorIterator<QPair<qreal, QColor> > it(st);
+ while (it.hasNext()) {
+ const QPair<qreal, QColor> pair = it.next();
+ DomGradientStop *stop = new DomGradientStop();
+ stop->setAttributePosition(pair.first);
+ DomColor *color = new DomColor();
+ color->setElementRed(pair.second.red());
+ color->setElementGreen(pair.second.green());
+ color->setElementBlue(pair.second.blue());
+ color->setAttributeAlpha(pair.second.alpha());
+ stop->setElementColor(color);
+ stops.append(stop);
+ }
+ gradient->setElementGradientStop(stops);
+ if (type == QGradient::LinearGradient) {
+ QLinearGradient *lgr = (QLinearGradient *)(gr);
+ gradient->setAttributeStartX(lgr->start().x());
+ gradient->setAttributeStartY(lgr->start().y());
+ gradient->setAttributeEndX(lgr->finalStop().x());
+ gradient->setAttributeEndY(lgr->finalStop().y());
+ } else if (type == QGradient::RadialGradient) {
+ QRadialGradient *rgr = (QRadialGradient *)(gr);
+ gradient->setAttributeCentralX(rgr->center().x());
+ gradient->setAttributeCentralY(rgr->center().y());
+ gradient->setAttributeFocalX(rgr->focalPoint().x());
+ gradient->setAttributeFocalY(rgr->focalPoint().y());
+ gradient->setAttributeRadius(rgr->radius());
+ } else if (type == QGradient::ConicalGradient) {
+ QConicalGradient *cgr = (QConicalGradient *)(gr);
+ gradient->setAttributeCentralX(cgr->center().x());
+ gradient->setAttributeCentralY(cgr->center().y());
+ gradient->setAttributeAngle(cgr->angle());
+ }
+
+ brush->setElementGradient(gradient);
+ } else if (style == Qt::TexturePattern) {
+ const QPixmap pixmap = br.texture();
+ if (!pixmap.isNull()) {
+ DomProperty *p = new DomProperty;
+ setPixmapProperty(*p, pixmapPaths(pixmap));
+ brush->setElementTexture(p);
+ }
+ } else {
+ QColor c = br.color();
+ DomColor *color = new DomColor();
+ color->setElementRed(c.red());
+ color->setElementGreen(c.green());
+ color->setElementBlue(c.blue());
+ color->setAttributeAlpha(c.alpha());
+ brush->setElementColor(color);
+ }
+ return brush;
+}
+
+/*!
+ \internal
+*/
+QWidget *QAbstractFormBuilder::createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name)
+{
+ Q_UNUSED(widgetName);
+ Q_UNUSED(parentWidget);
+ Q_UNUSED(name);
+ return 0;
+}
+
+/*!
+ \internal
+*/
+QLayout *QAbstractFormBuilder::createLayout(const QString &layoutName, QObject *parent, const QString &name)
+{
+ Q_UNUSED(layoutName);
+ Q_UNUSED(parent);
+ Q_UNUSED(name);
+ return 0;
+}
+
+/*!
+ \internal
+*/
+QAction *QAbstractFormBuilder::createAction(QObject *parent, const QString &name)
+{
+ QAction *action = new QAction(parent);
+ action->setObjectName(name);
+ return action;
+}
+
+/*!
+ \internal
+*/
+QActionGroup *QAbstractFormBuilder::createActionGroup(QObject *parent, const QString &name)
+{
+ QActionGroup *g = new QActionGroup(parent);
+ g->setObjectName(name);
+ return g;
+}
+
+/*!
+ \fn void QAbstractFormBuilder::save(QIODevice *device, QWidget *widget)
+
+ Saves an XML representation of the given \a widget to the
+ specified \a device in the standard UI file format.
+
+ \sa load()*/
+void QAbstractFormBuilder::save(QIODevice *dev, QWidget *widget)
+{
+ DomWidget *ui_widget = createDom(widget, 0);
+ Q_ASSERT( ui_widget != 0 );
+
+ DomUI *ui = new DomUI();
+ ui->setAttributeVersion(QLatin1String("4.0"));
+ ui->setElementWidget(ui_widget);
+
+ saveDom(ui, widget);
+
+ QXmlStreamWriter writer(dev);
+ writer.setAutoFormatting(true);
+ writer.setAutoFormattingIndent(1);
+ writer.writeStartDocument();
+ ui->write(writer);
+ writer.writeEndDocument();
+
+ m_laidout.clear();
+
+ delete ui;
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::saveDom(DomUI *ui, QWidget *widget)
+{
+ ui->setElementClass(widget->objectName());
+
+ if (DomConnections *ui_connections = saveConnections()) {
+ ui->setElementConnections(ui_connections);
+ }
+
+ if (DomCustomWidgets *ui_customWidgets = saveCustomWidgets()) {
+ ui->setElementCustomWidgets(ui_customWidgets);
+ }
+
+ if (DomTabStops *ui_tabStops = saveTabStops()) {
+ ui->setElementTabStops(ui_tabStops);
+ }
+
+ if (DomResources *ui_resources = saveResources()) {
+ ui->setElementResources(ui_resources);
+ }
+ if (DomButtonGroups *ui_buttonGroups = saveButtonGroups(widget))
+ ui->setElementButtonGroups(ui_buttonGroups);
+}
+
+/*!
+ \internal
+*/
+DomConnections *QAbstractFormBuilder::saveConnections()
+{
+ return new DomConnections;
+}
+
+/*!
+ \internal
+*/
+
+DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive)
+{
+ DomWidget *ui_widget = new DomWidget();
+ ui_widget->setAttributeClass(QLatin1String(widget->metaObject()->className()));
+ ui_widget->setElementProperty(computeProperties(widget));
+
+ if (recursive) {
+ if (QLayout *layout = widget->layout()) {
+ if (DomLayout *ui_layout = createDom(layout, 0, ui_parentWidget)) {
+ QList<DomLayout*> ui_layouts;
+ ui_layouts.append(ui_layout);
+
+ ui_widget->setElementLayout(ui_layouts);
+ }
+ }
+ }
+
+ // widgets, actions and action groups
+ QList<DomWidget*> ui_widgets;
+ QList<DomAction*> ui_actions;
+ QList<DomActionGroup*> ui_action_groups;
+
+ QList<QObject*> children;
+
+ // splitters need to store their children in the order specified by child indexes,
+ // not the order of the child list.
+#ifndef QT_NO_SPLITTER
+ if (const QSplitter *splitter = qobject_cast<const QSplitter*>(widget)) {
+ const int count = splitter->count();
+ for (int i = 0; i < count; ++i)
+ children.append(splitter->widget(i));
+ } else
+#endif
+ {
+ QList<QObject *> childObjects = widget->children();
+
+ const QList<QWidget *> list = qvariant_cast<QWidgetList>(widget->property("_q_widgetOrder"));
+ foreach (QWidget *w, list) {
+ if (childObjects.contains(w)) {
+ children.append(w);
+ childObjects.removeAll(w);
+ }
+ }
+ children += childObjects;
+
+ const QList<QWidget *> zOrder = qvariant_cast<QWidgetList>(widget->property("_q_zOrder"));
+ if (list != zOrder) {
+ QStringList zOrderList;
+ QListIterator<QWidget* > itZOrder(zOrder);
+ while (itZOrder.hasNext())
+ zOrderList.append(itZOrder.next()->objectName());
+ ui_widget->setElementZOrder(zOrderList);
+ }
+ }
+
+ foreach (QObject *obj, children) {
+ if (QWidget *childWidget = qobject_cast<QWidget*>(obj)) {
+ if (m_laidout.contains(childWidget) || recursive == false)
+ continue;
+
+ if (QMenu *menu = qobject_cast<QMenu *>(childWidget)) {
+ QList<QAction *> actions = menu->parentWidget()->actions();
+ QListIterator<QAction *> it(actions);
+ bool found = false;
+ while (it.hasNext()) {
+ if (it.next()->menu() == menu)
+ found = true;
+ }
+ if (!found)
+ continue;
+ }
+
+ if (DomWidget *ui_child = createDom(childWidget, ui_widget)) {
+ ui_widgets.append(ui_child);
+ }
+ } else if (QAction *childAction = qobject_cast<QAction*>(obj)) {
+ if (childAction->actionGroup() != 0) {
+ // it will be added later.
+ continue;
+ }
+
+ if (DomAction *ui_action = createDom(childAction)) {
+ ui_actions.append(ui_action);
+ }
+ } else if (QActionGroup *childActionGroup = qobject_cast<QActionGroup*>(obj)) {
+ if (DomActionGroup *ui_action_group = createDom(childActionGroup)) {
+ ui_action_groups.append(ui_action_group);
+ }
+ }
+ }
+
+ // add-action
+ QList<DomActionRef*> ui_action_refs;
+ foreach (QAction *action, widget->actions()) {
+ if (DomActionRef *ui_action_ref = createActionRefDom(action)) {
+ ui_action_refs.append(ui_action_ref);
+ }
+ }
+
+ if (recursive)
+ ui_widget->setElementWidget(ui_widgets);
+
+ ui_widget->setElementAction(ui_actions);
+ ui_widget->setElementActionGroup(ui_action_groups);
+ ui_widget->setElementAddAction(ui_action_refs);
+
+ saveExtraInfo(widget, ui_widget, ui_parentWidget);
+
+ return ui_widget;
+}
+
+/*!
+ \internal
+*/
+DomActionRef *QAbstractFormBuilder::createActionRefDom(QAction *action)
+{
+ QString name = action->objectName();
+
+ if (action->menu() != 0)
+ name = action->menu()->objectName();
+
+ DomActionRef *ui_action_ref = new DomActionRef();
+ if (action->isSeparator())
+ ui_action_ref->setAttributeName(QFormBuilderStrings::instance().separator);
+ else
+ ui_action_ref->setAttributeName(name);
+
+ return ui_action_ref;
+}
+
+// Struct to store layout item parameters for saving layout items
+struct FormBuilderSaveLayoutEntry {
+ explicit FormBuilderSaveLayoutEntry(QLayoutItem *li = 0) :
+ item(li), row(-1), column(-1), rowSpan(0), columnSpan(0), alignment(0) {}
+
+ QLayoutItem *item;
+ int row;
+ int column;
+ int rowSpan;
+ int columnSpan;
+ Qt::Alignment alignment;
+};
+
+// Create list from standard box layout
+static QList<FormBuilderSaveLayoutEntry> saveLayoutEntries(const QLayout *layout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = layout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = layout->itemAt(idx);
+ FormBuilderSaveLayoutEntry entry(item);
+ entry.alignment = item->alignment();
+ rc.append(entry);
+ }
+ }
+ return rc;
+}
+
+// Create list from grid layout
+static QList<FormBuilderSaveLayoutEntry> saveGridLayoutEntries(QGridLayout *gridLayout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = gridLayout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = gridLayout->itemAt(idx);
+ FormBuilderSaveLayoutEntry entry(item);
+ gridLayout->getItemPosition(idx, &entry.row, &entry.column, &entry.rowSpan,&entry.columnSpan);
+ entry.alignment = item->alignment();
+ rc.append(entry);
+ }
+ }
+ return rc;
+}
+
+#ifndef QT_NO_FORMLAYOUT
+// Create list from form layout
+static QList<FormBuilderSaveLayoutEntry> saveFormLayoutEntries(const QFormLayout *formLayout)
+{
+ QList<FormBuilderSaveLayoutEntry> rc;
+ if (const int count = formLayout->count()) {
+ rc.reserve(count);
+ for (int idx = 0; idx < count; ++idx) {
+ QLayoutItem *item = formLayout->itemAt(idx);
+ QFormLayout::ItemRole role = QFormLayout::LabelRole;
+ FormBuilderSaveLayoutEntry entry(item);
+ formLayout->getItemPosition(idx, &entry.row, &role);
+ switch (role ) {
+ case QFormLayout::LabelRole:
+ entry.column = 0;
+ break;
+ case QFormLayout::FieldRole:
+ entry.column = 1;
+ break;
+ case QFormLayout::SpanningRole:
+ entry.column = 0;
+ entry.columnSpan = 2;
+ break;
+ }
+ rc.push_back(entry);
+ }
+ }
+ return rc;
+}
+#endif
+
+/*!
+ \internal
+*/
+
+DomLayout *QAbstractFormBuilder::createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget)
+{
+ Q_UNUSED(ui_layout)
+ DomLayout *lay = new DomLayout();
+ lay->setAttributeClass(QLatin1String(layout->metaObject()->className()));
+ const QString objectName = layout->objectName();
+ if (!objectName.isEmpty())
+ lay->setAttributeName(objectName);
+ lay->setElementProperty(computeProperties(layout));
+
+ QList<FormBuilderSaveLayoutEntry> newList;
+ if (QGridLayout *gridLayout = qobject_cast<QGridLayout *>(layout)) {
+ newList = saveGridLayoutEntries(gridLayout);
+#ifndef QT_NO_FORMLAYOUT
+ } else if (const QFormLayout *formLayout = qobject_cast<const QFormLayout *>(layout)) {
+ newList = saveFormLayoutEntries(formLayout);
+#endif
+ } else {
+ newList = saveLayoutEntries(layout);
+ }
+
+ QList<DomLayoutItem*> ui_items;
+ foreach (const FormBuilderSaveLayoutEntry &item, newList) {
+ if (DomLayoutItem *ui_item = createDom(item.item, lay, ui_parentWidget)) {
+ if (item.row >= 0)
+ ui_item->setAttributeRow(item.row);
+ if (item.column >= 0)
+ ui_item->setAttributeColumn(item.column);
+ if (item.rowSpan > 1)
+ ui_item->setAttributeRowSpan(item.rowSpan);
+ if (item.columnSpan > 1)
+ ui_item->setAttributeColSpan(item.columnSpan);
+ if (item.alignment)
+ ui_item->setAttributeAlignment(alignmentValue(item.alignment));
+ ui_items.append(ui_item);
+ }
+ }
+
+ lay->setElementItem(ui_items);
+
+ return lay;
+}
+
+/*!
+ \internal
+*/
+DomLayoutItem *QAbstractFormBuilder::createDom(QLayoutItem *item, DomLayout *ui_layout, DomWidget *ui_parentWidget)
+{
+ DomLayoutItem *ui_item = new DomLayoutItem();
+
+ if (item->widget()) {
+ ui_item->setElementWidget(createDom(item->widget(), ui_parentWidget));
+ m_laidout.insert(item->widget(), true);
+ } else if (item->layout()) {
+ ui_item->setElementLayout(createDom(item->layout(), ui_layout, ui_parentWidget));
+ } else if (item->spacerItem()) {
+ ui_item->setElementSpacer(createDom(item->spacerItem(), ui_layout, ui_parentWidget));
+ }
+
+ return ui_item;
+}
+
+/*!
+ \internal
+*/
+DomSpacer *QAbstractFormBuilder::createDom(QSpacerItem *spacer, DomLayout *ui_layout, DomWidget *ui_parentWidget)
+{
+ Q_UNUSED(ui_layout);
+ Q_UNUSED(ui_parentWidget);
+
+ DomSpacer *ui_spacer = new DomSpacer();
+ QList<DomProperty*> properties;
+
+ DomProperty *prop = 0;
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ // sizeHint property
+ prop = new DomProperty();
+ prop->setAttributeName(strings.sizeHintProperty);
+ prop->setElementSize(new DomSize());
+ prop->elementSize()->setElementWidth(spacer->sizeHint().width());
+ prop->elementSize()->setElementHeight(spacer->sizeHint().height());
+ properties.append(prop);
+
+ // orientation property
+ prop = new DomProperty(); // ### we don't implemented the case where expandingDirections() is both Vertical and Horizontal
+ prop->setAttributeName(strings.orientationProperty);
+ prop->setElementEnum((spacer->expandingDirections() & Qt::Horizontal) ? strings.qtHorizontal : strings.qtVertical);
+ properties.append(prop);
+
+ ui_spacer->setElementProperty(properties);
+ return ui_spacer;
+}
+
+/*!
+ \internal
+*/
+DomProperty *QAbstractFormBuilder::createProperty(QObject *obj, const QString &pname, const QVariant &v)
+{
+ if (!checkProperty(obj, pname)) {
+ return 0;
+ }
+ return variantToDomProperty(this, obj->metaObject(), pname, v);
+}
+
+/*!
+ \internal
+*/
+QList<DomProperty*> QAbstractFormBuilder::computeProperties(QObject *obj)
+{
+ QList<DomProperty*> lst;
+
+ const QMetaObject *meta = obj->metaObject();
+
+ QHash<QByteArray, bool> properties;
+ const int propertyCount = meta->propertyCount();
+ for(int i=0; i < propertyCount; ++i)
+ properties.insert(meta->property(i).name(), true);
+
+ const QList<QByteArray> propertyNames = properties.keys();
+
+ const int propertyNamesCount = propertyNames.size();
+ for(int i=0; i<propertyNamesCount ; ++i) {
+ const QString pname = QString::fromUtf8(propertyNames.at(i));
+ const QMetaProperty prop = meta->property(meta->indexOfProperty(pname.toUtf8()));
+
+ if (!prop.isWritable() || !checkProperty(obj, QLatin1String(prop.name())))
+ continue;
+
+ const QVariant v = prop.read(obj);
+
+ DomProperty *dom_prop = 0;
+ if (v.type() == QVariant::Int) {
+ dom_prop = new DomProperty();
+
+ if (prop.isFlagType())
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "Flags property are not supported yet."));
+
+ if (prop.isEnumType()) {
+ QString scope = QString::fromUtf8(prop.enumerator().scope());
+ if (scope.size())
+ scope += QString::fromUtf8("::");
+ const QString e = QString::fromUtf8(prop.enumerator().valueToKey(v.toInt()));
+ if (e.size())
+ dom_prop->setElementEnum(scope + e);
+ } else
+ dom_prop->setElementNumber(v.toInt());
+ dom_prop->setAttributeName(pname);
+ } else {
+ dom_prop = createProperty(obj, pname, v);
+ }
+
+ if (!dom_prop || dom_prop->kind() == DomProperty::Unknown)
+ delete dom_prop;
+ else
+ lst.append(dom_prop);
+ }
+
+ return lst;
+}
+
+
+/*!
+ \internal
+ \typedef QAbstractFormBuilder::DomPropertyHash
+ \typedef QAbstractFormBuilder::IconPaths
+*/
+
+
+/*!
+ \internal
+*/
+QAbstractFormBuilder::DomPropertyHash QAbstractFormBuilder::propertyMap(const QList<DomProperty*> &properties)
+{
+ DomPropertyHash map;
+
+ foreach (DomProperty *p, properties)
+ map.insert(p->attributeName(), p);
+
+ return map;
+}
+
+/*!
+ \internal
+*/
+bool QAbstractFormBuilder::checkProperty(QObject *obj, const QString &prop) const
+{
+ Q_UNUSED(obj);
+ Q_UNUSED(prop);
+
+ return true;
+}
+
+/*!
+ \internal
+*/
+QString QAbstractFormBuilder::toString(const DomString *str)
+{
+ return str ? str->text() : QString();
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::applyTabStops(QWidget *widget, DomTabStops *tabStops)
+{
+ if (!tabStops)
+ return;
+
+ QWidget *lastWidget = 0;
+
+ const QStringList l = tabStops->elementTabStop();
+ for (int i=0; i<l.size(); ++i) {
+ const QString name = l.at(i);
+
+ QWidget *child = widget->findChild<QWidget*>(name);
+ if (!child) {
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "While applying tab stops: The widget '%1' could not be found.").arg(name));
+ continue;
+ }
+
+ if (i == 0) {
+ lastWidget = widget->findChild<QWidget*>(name);
+ continue;
+ } else if (!child || !lastWidget) {
+ continue;
+ }
+
+ QWidget::setTabOrder(lastWidget, child);
+
+ lastWidget = widget->findChild<QWidget*>(name);
+ }
+}
+
+/*!
+ \internal
+*/
+DomCustomWidgets *QAbstractFormBuilder::saveCustomWidgets()
+{
+ return 0;
+}
+
+/*!
+ \internal
+*/
+DomTabStops *QAbstractFormBuilder::saveTabStops()
+{
+ return 0;
+}
+
+/*!
+ \internal
+*/
+DomResources *QAbstractFormBuilder::saveResources()
+{
+ return 0;
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+DomButtonGroups *QAbstractFormBuilder::saveButtonGroups(const QWidget *mainContainer)
+{
+ // Save fst order buttongroup children of maincontainer
+ typedef QList<QButtonGroup*> ButtonGroupList;
+ const QObjectList mchildren = mainContainer->children();
+ if (mchildren.empty())
+ return 0;
+ QList<DomButtonGroup*> domGroups;
+ const QObjectList::const_iterator cend = mchildren.constEnd();
+ for (QObjectList::const_iterator it = mchildren.constBegin(); it != cend; ++it)
+ if (QButtonGroup *bg = qobject_cast<QButtonGroup *>(*it))
+ if (DomButtonGroup* dg = createDom(bg))
+ domGroups.push_back(dg);
+
+ if (domGroups.empty())
+ return 0;
+ DomButtonGroups *rc = new DomButtonGroups;
+ rc->setElementButtonGroup(domGroups);
+ return rc;
+}
+
+// VC6 would not find templated members, so we use statics and this utter hack.
+class FriendlyFB : public QAbstractFormBuilder {
+public:
+ using QAbstractFormBuilder::saveResource;
+ using QAbstractFormBuilder::saveText;
+ using QAbstractFormBuilder::resourceBuilder;
+ using QAbstractFormBuilder::textBuilder;
+ using QAbstractFormBuilder::toVariant;
+};
+
+template<class T>
+static void storeItemFlags(const T *item, QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const Qt::ItemFlags defaultFlags = T().flags();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ if (item->flags() != defaultFlags) {
+ DomProperty *p = new DomProperty;
+ p->setAttributeName(strings.flagsAttribute);
+ p->setElementSet(QString::fromAscii(itemFlags_enum.valueToKeys(item->flags())));
+ properties->append(p);
+ }
+}
+
+#ifndef Q_CC_RVCT
+// RVCT does not accept static inline functions if one argument is templated type
+// For this reason all necessary function variants are explicityly written for it.
+template<class T>
+static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const T *item,
+ QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = formBuilder->saveText(it.second, item->data(it.first.second))))
+ properties->append(p);
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = item->data(it.first)).isValid() &&
+ (p = variantToDomProperty(abstractFormBuilder,
+ static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject),
+ it.second, v)))
+ properties->append(p);
+
+ if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole))))
+ properties->append(p);
+}
+
+template<class T>
+static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const T *item,
+ QList<DomProperty*> *properties)
+{
+ storeItemProps<T>(abstractFormBuilder, item, properties);
+ storeItemFlags<T>(item, properties);
+}
+
+template<class T>
+static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, T *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = properties.value(it.second))) {
+ v = formBuilder->textBuilder()->loadText(p);
+ QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v);
+ item->setData(it.first.first, qvariant_cast<QString>(nativeValue));
+ item->setData(it.first.second, v);
+ }
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((p = properties.value(it.second)) &&
+ (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid())
+ item->setData(it.first, v);
+
+ if ((p = properties.value(strings.iconAttribute))) {
+ v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p);
+ QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v);
+ item->setIcon(qvariant_cast<QIcon>(nativeValue));
+ item->setData(Qt::DecorationPropertyRole, v);
+ }
+}
+
+template<class T>
+static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, T *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ loadItemProps<T>(abstractFormBuilder, item, properties);
+
+ DomProperty *p;
+ if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set)
+ item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii()));
+}
+
+#else
+
+static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const QTableWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = formBuilder->saveText(it.second, item->data(it.first.second))))
+ properties->append(p);
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = item->data(it.first)).isValid() &&
+ (p = variantToDomProperty(abstractFormBuilder,
+ static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject),
+ it.second, v)))
+ properties->append(p);
+
+ if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole))))
+ properties->append(p);
+}
+
+static void storeItemProps(QAbstractFormBuilder *abstractFormBuilder, const QListWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = formBuilder->saveText(it.second, item->data(it.first.second))))
+ properties->append(p);
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = item->data(it.first)).isValid() &&
+ (p = variantToDomProperty(abstractFormBuilder,
+ static_cast<const QMetaObject *>(&QAbstractFormBuilderGadget::staticMetaObject),
+ it.second, v)))
+ properties->append(p);
+
+ if ((p = formBuilder->saveResource(item->data(Qt::DecorationPropertyRole))))
+ properties->append(p);
+}
+
+static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const QTableWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ storeItemProps(abstractFormBuilder, item, properties);
+ storeItemFlags(item, properties);
+}
+
+static void storeItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, const QListWidgetItem *item,
+ QList<DomProperty*> *properties)
+{
+ storeItemProps(abstractFormBuilder, item, properties);
+ storeItemFlags(item, properties);
+}
+
+static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = properties.value(it.second))) {
+ v = formBuilder->textBuilder()->loadText(p);
+ QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v);
+ item->setData(it.first.first, qvariant_cast<QString>(nativeValue));
+ item->setData(it.first.second, v);
+ }
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((p = properties.value(it.second)) &&
+ (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid())
+ item->setData(it.first, v);
+
+ if ((p = properties.value(strings.iconAttribute))) {
+ v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p);
+ QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v);
+ item->setIcon(qvariant_cast<QIcon>(nativeValue));
+ item->setData(Qt::DecorationPropertyRole, v);
+ }
+}
+
+static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ FriendlyFB * const formBuilder = static_cast<FriendlyFB *>(abstractFormBuilder);
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = properties.value(it.second))) {
+ v = formBuilder->textBuilder()->loadText(p);
+ QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v);
+ item->setData(it.first.first, qvariant_cast<QString>(nativeValue));
+ item->setData(it.first.second, v);
+ }
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((p = properties.value(it.second)) &&
+ (v = formBuilder->toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid())
+ item->setData(it.first, v);
+
+ if ((p = properties.value(strings.iconAttribute))) {
+ v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p);
+ QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v);
+ item->setIcon(qvariant_cast<QIcon>(nativeValue));
+ item->setData(Qt::DecorationPropertyRole, v);
+ }
+}
+
+static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, QTableWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ loadItemProps(abstractFormBuilder, item, properties);
+
+ DomProperty *p;
+ if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set)
+ item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii()));
+}
+
+static void loadItemPropsNFlags(QAbstractFormBuilder *abstractFormBuilder, QListWidgetItem *item,
+ const QHash<QString, DomProperty*> &properties)
+{
+ static const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ static const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ loadItemProps(abstractFormBuilder, item, properties);
+
+ DomProperty *p;
+ if ((p = properties.value(strings.flagsAttribute)) && p->kind() == DomProperty::Set)
+ item->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, p->elementSet().toAscii()));
+}
+
+#endif
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget)
+{
+ Q_UNUSED(ui_parentWidget);
+
+ QList<DomColumn*> columns;
+ DomProperty *p;
+ QVariant v;
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ // save the header
+ for (int c = 0; c<treeWidget->columnCount(); ++c) {
+ DomColumn *column = new DomColumn;
+
+ QList<DomProperty*> properties;
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles) {
+ p = saveText(it.second, treeWidget->headerItem()->data(c, it.first.second));
+ // Prevent uic 4.4.X from crashing if it cannot find a column text
+ if (!p && it.first.first == Qt::EditRole && it.second == QLatin1String("text")) {
+ DomString *defaultHeader = new DomString;
+ defaultHeader->setText(QString::number(c + 1));
+ defaultHeader->setAttributeNotr(QLatin1String("true"));
+ p = new DomProperty;
+ p->setAttributeName(it.second);
+ p->setElementString(defaultHeader);
+ }
+ if (p)
+ properties.append(p);
+ }
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = treeWidget->headerItem()->data(c, it.first)).isValid() &&
+ (p = variantToDomProperty(this, &QAbstractFormBuilderGadget::staticMetaObject, it.second, v)))
+ properties.append(p);
+
+ if ((p = saveResource(treeWidget->headerItem()->data(c, Qt::DecorationPropertyRole))))
+ properties.append(p);
+
+ column->setElementProperty(properties);
+ columns.append(column);
+ }
+
+ ui_widget->setElementColumn(columns);
+
+ QList<DomItem *> items = ui_widget->elementItem();
+
+ QQueue<QPair<QTreeWidgetItem *, DomItem *> > pendingQueue;
+ for (int i = 0; i < treeWidget->topLevelItemCount(); i++)
+ pendingQueue.enqueue(qMakePair(treeWidget->topLevelItem(i), (DomItem *)0));
+
+ while (!pendingQueue.isEmpty()) {
+ const QPair<QTreeWidgetItem *, DomItem *> pair = pendingQueue.dequeue();
+ QTreeWidgetItem *item = pair.first;
+ DomItem *parentDomItem = pair.second;
+
+ DomItem *currentDomItem = new DomItem;
+
+ QList<DomProperty*> properties;
+ for (int c = 0; c < treeWidget->columnCount(); c++) {
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = saveText(it.second, item->data(c, it.first.second))))
+ properties.append(p);
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((v = item->data(c, it.first)).isValid() &&
+ (p = variantToDomProperty(this, &QAbstractFormBuilderGadget::staticMetaObject, it.second, v)))
+ properties.append(p);
+
+ if ((p = saveResource(item->data(c, Qt::DecorationPropertyRole))))
+ properties.append(p);
+ }
+ storeItemFlags(item, &properties);
+ currentDomItem->setElementProperty(properties);
+
+ if (parentDomItem) {
+ QList<DomItem *> childrenItems = parentDomItem->elementItem();
+ childrenItems.append(currentDomItem);
+ parentDomItem->setElementItem(childrenItems);
+ } else
+ items.append(currentDomItem);
+
+ for (int i = 0; i < item->childCount(); i++)
+ pendingQueue.enqueue(qMakePair(item->child(i), currentDomItem));
+ }
+
+ ui_widget->setElementItem(items);
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::saveTableWidgetExtraInfo(QTableWidget *tableWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget)
+{
+ Q_UNUSED(ui_parentWidget);
+
+ // save the horizontal header
+ QList<DomColumn*> columns;
+ for (int c = 0; c < tableWidget->columnCount(); c++) {
+ QList<DomProperty*> properties;
+ QTableWidgetItem *item = tableWidget->horizontalHeaderItem(c);
+ if (item)
+ storeItemProps(this, item, &properties);
+
+ DomColumn *column = new DomColumn;
+ column->setElementProperty(properties);
+ columns.append(column);
+ }
+ ui_widget->setElementColumn(columns);
+
+ // save the vertical header
+ QList<DomRow*> rows;
+ for (int r = 0; r < tableWidget->rowCount(); r++) {
+ QList<DomProperty*> properties;
+ QTableWidgetItem *item = tableWidget->verticalHeaderItem(r);
+ if (item)
+ storeItemProps(this, item, &properties);
+
+ DomRow *row = new DomRow;
+ row->setElementProperty(properties);
+ rows.append(row);
+ }
+ ui_widget->setElementRow(rows);
+
+ QList<DomItem *> items = ui_widget->elementItem();
+ for (int r = 0; r < tableWidget->rowCount(); r++)
+ for (int c = 0; c < tableWidget->columnCount(); c++) {
+ QTableWidgetItem *item = tableWidget->item(r, c);
+ if (item) {
+ QList<DomProperty*> properties;
+ storeItemPropsNFlags(this, item, &properties);
+
+ DomItem *domItem = new DomItem;
+ domItem->setAttributeRow(r);
+ domItem->setAttributeColumn(c);
+ domItem->setElementProperty(properties);
+ items.append(domItem);
+ }
+ }
+
+ ui_widget->setElementItem(items);
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::saveListWidgetExtraInfo(QListWidget *listWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget)
+{
+ Q_UNUSED(ui_parentWidget);
+
+ QList<DomItem*> ui_items = ui_widget->elementItem();
+ for (int i=0; i<listWidget->count(); ++i) {
+ QList<DomProperty*> properties;
+ storeItemPropsNFlags(this, listWidget->item(i), &properties);
+
+ DomItem *ui_item = new DomItem();
+ ui_item->setElementProperty(properties);
+ ui_items.append(ui_item);
+ }
+
+ ui_widget->setElementItem(ui_items);
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::saveComboBoxExtraInfo(QComboBox *comboBox, DomWidget *ui_widget, DomWidget *ui_parentWidget)
+{
+ Q_UNUSED(ui_parentWidget);
+ QList<DomItem*> ui_items = ui_widget->elementItem();
+
+ const int count = comboBox->count();
+ for (int i=0; i < count; ++i) {
+ // We might encounter items for which both builders return 0 in Designer
+ // (indicating a custom combo adding items in the constructor). Ignore those.
+ DomProperty *textProperty = saveText(QFormBuilderStrings::instance().textAttribute,
+ comboBox->itemData(i, Qt::DisplayPropertyRole));
+ DomProperty *iconProperty = saveResource(comboBox->itemData(i, Qt::DecorationPropertyRole));
+ if (textProperty || iconProperty) {
+ QList<DomProperty*> properties;
+ if (textProperty)
+ properties.push_back(textProperty);
+ if (iconProperty)
+ properties.push_back(iconProperty);
+
+ DomItem *ui_item = new DomItem();
+ ui_item->setElementProperty(properties);
+ ui_items.push_back(ui_item);
+ }
+ }
+
+ ui_widget->setElementItem(ui_items);
+}
+
+// Return the buttongroups assigned to a button except the internal one
+// (with empty object name) used by Q3ButtonGroup.
+static inline const QButtonGroup *formButtonGroup(const QAbstractButton *widget)
+{
+ const QButtonGroup *buttonGroup = widget->group();
+ if (!buttonGroup)
+ return 0;
+ if (buttonGroup->objectName().isEmpty()) {
+ if (const QWidget *parent = widget->parentWidget())
+ if (!qstrcmp(parent->metaObject()->className(), "Q3ButtonGroup"))
+ return 0;
+ }
+ return buttonGroup;
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+void QAbstractFormBuilder::saveButtonExtraInfo(const QAbstractButton *widget, DomWidget *ui_widget, DomWidget *)
+{
+ typedef QList<DomProperty*> DomPropertyList;
+ if (const QButtonGroup *buttonGroup = formButtonGroup(widget)) {
+ DomPropertyList attributes = ui_widget->elementAttribute();
+ DomString *domString = new DomString();
+ domString->setText(buttonGroup->objectName());
+ domString->setAttributeNotr(QLatin1String("true"));
+ DomProperty *domProperty = new DomProperty();
+ domProperty->setAttributeName(QLatin1String(buttonGroupPropertyC));
+ domProperty->setElementString(domString);
+ attributes += domProperty;
+ ui_widget->setElementAttribute(attributes);
+ }
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemView,
+ DomWidget *ui_widget, DomWidget *)
+{
+ //
+ // 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 (const QTreeView *treeView = qobject_cast<const QTreeView*>(itemView)) {
+ QList<DomProperty*> viewProperties = ui_widget->elementAttribute();
+ QList<DomProperty*> headerProperties = computeProperties(treeView->header());
+ foreach (const QString &realPropertyName, realPropertyNames) {
+ const QString upperPropertyName = realPropertyName.at(0).toUpper()
+ + realPropertyName.mid(1);
+ const QString fakePropertyName = QLatin1String("header") + upperPropertyName;
+ foreach (DomProperty *property, headerProperties) {
+ if (property->attributeName() == realPropertyName) {
+ property->setAttributeName(fakePropertyName);
+ viewProperties << property;
+ }
+ }
+ }
+ ui_widget->setElementAttribute(viewProperties);
+ } else if (const QTableView *tableView = qobject_cast<const QTableView*>(itemView)) {
+ static QStringList headerPrefixes =
+ (QStringList() << QLatin1String("horizontalHeader")
+ << QLatin1String("verticalHeader"));
+
+ QList<DomProperty*> viewProperties = ui_widget->elementAttribute();
+ foreach (const QString &headerPrefix, headerPrefixes) {
+ QList<DomProperty*> headerProperties;
+ if (headerPrefix == QLatin1String("horizontalHeader"))
+ headerProperties = computeProperties(tableView->horizontalHeader());
+ else
+ headerProperties = computeProperties(tableView->verticalHeader());
+ foreach (const QString &realPropertyName, realPropertyNames) {
+ const QString upperPropertyName = realPropertyName.at(0).toUpper()
+ + realPropertyName.mid(1);
+ const QString fakePropertyName = headerPrefix + upperPropertyName;
+ foreach (DomProperty *property, headerProperties) {
+ if (property->attributeName() == realPropertyName) {
+ property->setAttributeName(fakePropertyName);
+ viewProperties << property;
+ }
+ }
+ }
+ }
+ ui_widget->setElementAttribute(viewProperties);
+ }
+}
+
+/*!
+ \internal
+ \since 4.4
+*/
+
+void QAbstractFormBuilder::setResourceBuilder(QResourceBuilder *builder)
+{
+ QFormBuilderExtra::instance(this)->setResourceBuilder(builder);
+}
+
+/*!
+ \internal
+ \since 4.4
+*/
+
+QResourceBuilder *QAbstractFormBuilder::resourceBuilder() const
+{
+ return QFormBuilderExtra::instance(this)->resourceBuilder();
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+void QAbstractFormBuilder::setTextBuilder(QTextBuilder *builder)
+{
+ QFormBuilderExtra::instance(this)->setTextBuilder(builder);
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+QTextBuilder *QAbstractFormBuilder::textBuilder() const
+{
+ return QFormBuilderExtra::instance(this)->textBuilder();
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::saveExtraInfo(QWidget *widget, DomWidget *ui_widget,
+ DomWidget *ui_parentWidget)
+{
+ if (QListWidget *listWidget = qobject_cast<QListWidget*>(widget)) {
+ saveListWidgetExtraInfo(listWidget, ui_widget, ui_parentWidget);
+ } else if (QTreeWidget *treeWidget = qobject_cast<QTreeWidget*>(widget)) {
+ saveTreeWidgetExtraInfo(treeWidget, ui_widget, ui_parentWidget);
+ } else if (QTableWidget *tableWidget = qobject_cast<QTableWidget*>(widget)) {
+ saveTableWidgetExtraInfo(tableWidget, ui_widget, ui_parentWidget);
+ } else if (QComboBox *comboBox = qobject_cast<QComboBox*>(widget)) {
+ if (!qobject_cast<QFontComboBox*>(widget))
+ saveComboBoxExtraInfo(comboBox, ui_widget, ui_parentWidget);
+ } else if(QAbstractButton *ab = qobject_cast<QAbstractButton *>(widget)) {
+ saveButtonExtraInfo(ab, ui_widget, ui_parentWidget);
+ }
+ if (QAbstractItemView *itemView = qobject_cast<QAbstractItemView *>(widget)) {
+ saveItemViewExtraInfo(itemView, ui_widget, ui_parentWidget);
+ }
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::loadListWidgetExtraInfo(DomWidget *ui_widget, QListWidget *listWidget, QWidget *parentWidget)
+{
+ Q_UNUSED(parentWidget);
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+
+ foreach (DomItem *ui_item, ui_widget->elementItem()) {
+ const DomPropertyHash properties = propertyMap(ui_item->elementProperty());
+ QListWidgetItem *item = new QListWidgetItem(listWidget);
+#ifndef Q_CC_RVCT
+ loadItemPropsNFlags<QListWidgetItem>(this, item, properties);
+#else
+ loadItemPropsNFlags(this, item, properties);
+#endif
+ }
+
+ DomProperty *currentRow = propertyMap(ui_widget->elementProperty()).value(strings.currentRowProperty);
+ if (currentRow)
+ listWidget->setCurrentRow(currentRow->elementNumber());
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWidget *treeWidget, QWidget *parentWidget)
+{
+ Q_UNUSED(parentWidget);
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ const QMetaEnum itemFlags_enum = metaEnum<QAbstractFormBuilderGadget>("itemFlags");
+ const QList<DomColumn*> columns = ui_widget->elementColumn();
+ if (columns.count() > 0)
+ treeWidget->setColumnCount(columns.count());
+
+ for (int i = 0; i<columns.count(); ++i) {
+ const DomColumn *c = columns.at(i);
+ const DomPropertyHash properties = propertyMap(c->elementProperty());
+
+ DomProperty *p;
+ QVariant v;
+
+ foreach (const QFormBuilderStrings::RoleNName &it, strings.itemRoles)
+ if ((p = properties.value(it.second)) &&
+ (v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, p)).isValid())
+ treeWidget->headerItem()->setData(i, it.first, v);
+
+ foreach (const QFormBuilderStrings::TextRoleNName &it, strings.itemTextRoles)
+ if ((p = properties.value(it.second))) {
+ v = textBuilder()->loadText(p);
+ QVariant nativeValue = textBuilder()->toNativeValue(v);
+ treeWidget->headerItem()->setData(i, it.first.first, qvariant_cast<QString>(nativeValue));
+ treeWidget->headerItem()->setData(i, it.first.second, v);
+ }
+
+ if ((p = properties.value(strings.iconAttribute))) {
+ v = resourceBuilder()->loadResource(workingDirectory(), p);
+ QVariant nativeValue = resourceBuilder()->toNativeValue(v);
+ treeWidget->headerItem()->setIcon(i, qvariant_cast<QIcon>(nativeValue));
+ treeWidget->headerItem()->setData(i, Qt::DecorationPropertyRole, v);
+ }
+ }
+
+ QQueue<QPair<DomItem *, QTreeWidgetItem *> > pendingQueue;
+ foreach (DomItem *ui_item, ui_widget->elementItem())
+ pendingQueue.enqueue(qMakePair(ui_item, (QTreeWidgetItem *)0));
+
+ while (!pendingQueue.isEmpty()) {
+ const QPair<DomItem *, QTreeWidgetItem *> pair = pendingQueue.dequeue();
+ const DomItem *domItem = pair.first;
+ QTreeWidgetItem *parentItem = pair.second;
+
+ QTreeWidgetItem *currentItem = 0;
+
+ if (parentItem)
+ currentItem = new QTreeWidgetItem(parentItem);
+ else
+ currentItem = new QTreeWidgetItem(treeWidget);
+
+ const QList<DomProperty *> properties = domItem->elementProperty();
+ int col = -1;
+ foreach (DomProperty *property, properties) {
+ if (property->attributeName() == strings.flagsAttribute && !property->elementSet().isEmpty()) {
+ currentItem->setFlags(enumKeysToValue<Qt::ItemFlags>(itemFlags_enum, property->elementSet().toAscii()));
+ } else if (property->attributeName() == strings.textAttribute && property->elementString()) {
+ col++;
+ QVariant textV = textBuilder()->loadText(property);
+ QVariant nativeValue = textBuilder()->toNativeValue(textV);
+ currentItem->setText(col, qvariant_cast<QString>(nativeValue));
+ currentItem->setData(col, Qt::DisplayPropertyRole, textV);
+ } else if (col >= 0) {
+ if (property->attributeName() == strings.iconAttribute) {
+ QVariant v = resourceBuilder()->loadResource(workingDirectory(), property);
+ if (v.isValid()) {
+ QVariant nativeValue = resourceBuilder()->toNativeValue(v);
+ currentItem->setIcon(col, qvariant_cast<QIcon>(nativeValue));
+ currentItem->setData(col, Qt::DecorationPropertyRole, v);
+ }
+ } else {
+ QVariant v;
+ int role = strings.treeItemRoleHash.value(property->attributeName(), (Qt::ItemDataRole)-1);
+ if (role >= 0) {
+ if ((v = toVariant(&QAbstractFormBuilderGadget::staticMetaObject, property)).isValid())
+ currentItem->setData(col, role, v);
+ } else {
+ QPair<Qt::ItemDataRole, Qt::ItemDataRole> rolePair =
+ strings.treeItemTextRoleHash.value(property->attributeName(),
+ qMakePair((Qt::ItemDataRole)-1, (Qt::ItemDataRole)-1));
+ if (rolePair.first >= 0) {
+ QVariant textV = textBuilder()->loadText(property);
+ QVariant nativeValue = textBuilder()->toNativeValue(textV);
+ currentItem->setData(col, rolePair.first, qvariant_cast<QString>(nativeValue));
+ currentItem->setData(col, rolePair.second, textV);
+ }
+ }
+ }
+ }
+ }
+
+ foreach (DomItem *childItem, domItem->elementItem())
+ pendingQueue.enqueue(qMakePair(childItem, currentItem));
+
+ }
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::loadTableWidgetExtraInfo(DomWidget *ui_widget, QTableWidget *tableWidget, QWidget *parentWidget)
+{
+ Q_UNUSED(parentWidget);
+
+ const QList<DomColumn*> columns = ui_widget->elementColumn();
+ if (columns.count() > 0)
+ tableWidget->setColumnCount(columns.count());
+ for (int i = 0; i< columns.count(); i++) {
+ DomColumn *c = columns.at(i);
+ const DomPropertyHash properties = propertyMap(c->elementProperty());
+
+ if (!properties.isEmpty()) {
+ QTableWidgetItem *item = new QTableWidgetItem;
+ loadItemProps(this, item, properties);
+ tableWidget->setHorizontalHeaderItem(i, item);
+ }
+ }
+
+ const QList<DomRow*> rows = ui_widget->elementRow();
+ if (rows.count() > 0)
+ tableWidget->setRowCount(rows.count());
+ for (int i = 0; i< rows.count(); i++) {
+ const DomRow *r = rows.at(i);
+ const DomPropertyHash properties = propertyMap(r->elementProperty());
+
+ if (!properties.isEmpty()) {
+ QTableWidgetItem *item = new QTableWidgetItem;
+ loadItemProps(this, item, properties);
+ tableWidget->setVerticalHeaderItem(i, item);
+ }
+ }
+
+ foreach (DomItem *ui_item, ui_widget->elementItem()) {
+ if (ui_item->hasAttributeRow() && ui_item->hasAttributeColumn()) {
+ const DomPropertyHash properties = propertyMap(ui_item->elementProperty());
+ QTableWidgetItem *item = new QTableWidgetItem;
+ loadItemPropsNFlags(this, item, properties);
+ tableWidget->setItem(ui_item->attributeRow(), ui_item->attributeColumn(), item);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox *comboBox, QWidget *parentWidget)
+{
+ Q_UNUSED(parentWidget);
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ foreach (DomItem *ui_item, ui_widget->elementItem()) {
+ const DomPropertyHash properties = propertyMap(ui_item->elementProperty());
+ QString text;
+ QIcon icon;
+ QVariant textData;
+ QVariant iconData;
+
+ DomProperty *p = 0;
+
+ p = properties.value(strings.textAttribute);
+ if (p && p->elementString()) {
+ textData = textBuilder()->loadText(p);
+ text = qvariant_cast<QString>(textBuilder()->toNativeValue(textData));
+ }
+
+ p = properties.value(strings.iconAttribute);
+ if (p) {
+ iconData = resourceBuilder()->loadResource(workingDirectory(), p);
+ icon = qvariant_cast<QIcon>(resourceBuilder()->toNativeValue(iconData));
+ }
+
+ comboBox->addItem(icon, text);
+ comboBox->setItemData((comboBox->count()-1), iconData, Qt::DecorationPropertyRole);
+ comboBox->setItemData((comboBox->count()-1), textData, Qt::DisplayPropertyRole);
+ }
+
+ DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty);
+ if (currentIndex)
+ comboBox->setCurrentIndex(currentIndex->elementNumber());
+}
+
+// Get the button group name out of a widget's attribute list
+static QString buttonGroupName(const DomWidget *ui_widget)
+{
+ typedef QList<DomProperty*> DomPropertyList;
+ const DomPropertyList attributes = ui_widget->elementAttribute();
+ if (attributes.empty())
+ return QString();
+ const QString buttonGroupProperty = QLatin1String(buttonGroupPropertyC);
+ const DomPropertyList::const_iterator cend = attributes.constEnd();
+ for (DomPropertyList::const_iterator it = attributes.constBegin(); it != cend; ++it)
+ if ( (*it)->attributeName() == buttonGroupProperty)
+ return (*it)->elementString()->text();
+ return QString();
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+void QAbstractFormBuilder::loadButtonExtraInfo(const DomWidget *ui_widget, QAbstractButton *button, QWidget *)
+{
+ typedef QFormBuilderExtra::ButtonGroupEntry ButtonGroupEntry;
+ typedef QFormBuilderExtra::ButtonGroupHash ButtonGroupHash;
+
+ const QString groupName = buttonGroupName(ui_widget);
+ if (groupName.isEmpty())
+ return;
+ // Find entry
+ QFormBuilderExtra *extra = QFormBuilderExtra::instance(this);
+ ButtonGroupHash &buttonGroups = extra->buttonGroups();
+ ButtonGroupHash::iterator it = buttonGroups.find(groupName);
+ if (it == buttonGroups.end()) {
+#ifdef QFORMINTERNAL_NAMESPACE // Suppress the warning when copying in Designer
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "Invalid QButtonGroup reference '%1' referenced by '%2'.").arg(groupName, button->objectName()));
+#endif
+ return;
+ }
+ // Create button group on demand?
+ QButtonGroup *&group = it.value().second;
+ if (group == 0) {
+ group = new QButtonGroup;
+ group->setObjectName(groupName);
+ applyProperties(group, it.value().first->elementProperty());
+ }
+ group->addButton(button);
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstractItemView *itemView,
+ QWidget *)
+{
+ //
+ // 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 (QTreeView *treeView = qobject_cast<QTreeView*>(itemView)) {
+ QList<DomProperty*> allAttributes = ui_widget->elementAttribute();
+ QList<DomProperty*> headerProperties;
+ foreach (const QString &realPropertyName, realPropertyNames) {
+ const QString upperPropertyName = realPropertyName.at(0).toUpper()
+ + realPropertyName.mid(1);
+ const QString fakePropertyName = QLatin1String("header") + upperPropertyName;
+ foreach (DomProperty *attr, allAttributes) {
+ if (attr->attributeName() == fakePropertyName) {
+ attr->setAttributeName(realPropertyName);
+ headerProperties << attr;
+ }
+ }
+ }
+ applyProperties(treeView->header(), headerProperties);
+ } else if (QTableView *tableView = qobject_cast<QTableView*>(itemView)) {
+ static QStringList headerPrefixes =
+ (QStringList() << QLatin1String("horizontalHeader")
+ << QLatin1String("verticalHeader"));
+
+ QList<DomProperty*> allAttributes = ui_widget->elementAttribute();
+ foreach (const QString &headerPrefix, headerPrefixes) {
+ QList<DomProperty*> headerProperties;
+ foreach (const QString &realPropertyName, realPropertyNames) {
+ const QString upperPropertyName = realPropertyName.at(0).toUpper()
+ + realPropertyName.mid(1);
+ const QString fakePropertyName = headerPrefix + upperPropertyName;
+ foreach (DomProperty *attr, allAttributes) {
+ if (attr->attributeName() == fakePropertyName) {
+ attr->setAttributeName(realPropertyName);
+ headerProperties << attr;
+ }
+ }
+ }
+ if (headerPrefix == QLatin1String("horizontalHeader"))
+ applyProperties(tableView->horizontalHeader(), headerProperties);
+ else
+ applyProperties(tableView->verticalHeader(), headerProperties);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget)
+{
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ if (0) {
+#ifndef QT_NO_LISTWIDGET
+ } else if (QListWidget *listWidget = qobject_cast<QListWidget*>(widget)) {
+ loadListWidgetExtraInfo(ui_widget, listWidget, parentWidget);
+#endif
+#ifndef QT_NO_TREEWIDGET
+ } else if (QTreeWidget *treeWidget = qobject_cast<QTreeWidget*>(widget)) {
+ loadTreeWidgetExtraInfo(ui_widget, treeWidget, parentWidget);
+#endif
+#ifndef QT_NO_TABLEWIDGET
+ } else if (QTableWidget *tableWidget = qobject_cast<QTableWidget*>(widget)) {
+ loadTableWidgetExtraInfo(ui_widget, tableWidget, parentWidget);
+#endif
+#ifndef QT_NO_COMBOBOX
+ } else if (QComboBox *comboBox = qobject_cast<QComboBox*>(widget)) {
+ if (!qobject_cast<QFontComboBox *>(widget))
+ loadComboBoxExtraInfo(ui_widget, comboBox, parentWidget);
+#endif
+#ifndef QT_NO_TABWIDGET
+ } else if (QTabWidget *tabWidget = qobject_cast<QTabWidget*>(widget)) {
+ const DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty);
+ if (currentIndex)
+ tabWidget->setCurrentIndex(currentIndex->elementNumber());
+#endif
+#ifndef QT_NO_STACKEDWIDGET
+ } else if (QStackedWidget *stackedWidget = qobject_cast<QStackedWidget*>(widget)) {
+ const DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty);
+ if (currentIndex)
+ stackedWidget->setCurrentIndex(currentIndex->elementNumber());
+#endif
+#ifndef QT_NO_TOOLBOX
+ } else if (QToolBox *toolBox = qobject_cast<QToolBox*>(widget)) {
+ const DomProperty *currentIndex = propertyMap(ui_widget->elementProperty()).value(strings.currentIndexProperty);
+ if (currentIndex)
+ toolBox->setCurrentIndex(currentIndex->elementNumber());
+ const DomProperty *tabSpacing = propertyMap(ui_widget->elementProperty()).value(strings.tabSpacingProperty);
+ if (tabSpacing)
+ toolBox->layout()->setSpacing(tabSpacing->elementNumber());
+#endif
+ } else if (QAbstractButton *ab = qobject_cast<QAbstractButton *>(widget)) {
+ loadButtonExtraInfo(ui_widget, ab, parentWidget);
+ }
+ if (QAbstractItemView *itemView = qobject_cast<QAbstractItemView *>(widget)) {
+ loadItemViewExtraInfo(ui_widget, itemView, parentWidget);
+ }
+}
+
+/*!
+ \internal
+*/
+QIcon QAbstractFormBuilder::nameToIcon(const QString &filePath, const QString &qrcPath)
+{
+ Q_UNUSED(filePath)
+ Q_UNUSED(qrcPath)
+ qWarning() << "QAbstractFormBuilder::nameToIcon() is obsoleted";
+ return QIcon();
+}
+
+/*!
+ \internal
+*/
+QString QAbstractFormBuilder::iconToFilePath(const QIcon &pm) const
+{
+ Q_UNUSED(pm)
+ qWarning() << "QAbstractFormBuilder::iconToFilePath() is obsoleted";
+ return QString();
+}
+
+/*!
+ \internal
+*/
+QString QAbstractFormBuilder::iconToQrcPath(const QIcon &pm) const
+{
+ Q_UNUSED(pm)
+ qWarning() << "QAbstractFormBuilder::iconToQrcPath() is obsoleted";
+ return QString();
+}
+
+/*!
+ \internal
+*/
+QPixmap QAbstractFormBuilder::nameToPixmap(const QString &filePath, const QString &qrcPath)
+{
+ Q_UNUSED(filePath)
+ Q_UNUSED(qrcPath)
+ qWarning() << "QAbstractFormBuilder::nameToPixmap() is obsoleted";
+ return QPixmap();
+}
+
+/*!
+ \internal
+*/
+QString QAbstractFormBuilder::pixmapToFilePath(const QPixmap &pm) const
+{
+ Q_UNUSED(pm)
+ qWarning() << "QAbstractFormBuilder::pixmapToFilePath() is obsoleted";
+ return QString();
+}
+
+/*!
+ \internal
+*/
+QString QAbstractFormBuilder::pixmapToQrcPath(const QPixmap &pm) const
+{
+ Q_UNUSED(pm)
+ qWarning() << "QAbstractFormBuilder::pixmapToQrcPath() is obsoleted";
+ return QString();
+}
+
+/*!
+ Returns the current working directory of the form builder.
+
+ \sa setWorkingDirectory() */
+QDir QAbstractFormBuilder::workingDirectory() const
+{
+ return m_workingDirectory;
+}
+
+/*!
+ Sets the current working directory of the form builder to the
+ specified \a directory.
+
+ \sa workingDirectory()*/
+void QAbstractFormBuilder::setWorkingDirectory(const QDir &directory)
+{
+ m_workingDirectory = directory;
+}
+
+/*!
+ \internal
+*/
+DomAction *QAbstractFormBuilder::createDom(QAction *action)
+{
+ if (action->parentWidget() == action->menu() || action->isSeparator())
+ return 0;
+
+ DomAction *ui_action = new DomAction;
+ ui_action->setAttributeName(action->objectName());
+
+ const QList<DomProperty*> properties = computeProperties(action);
+ ui_action->setElementProperty(properties);
+
+ return ui_action;
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+DomButtonGroup *QAbstractFormBuilder::createDom(QButtonGroup *buttonGroup)
+{
+ if (buttonGroup->buttons().count() == 0) // Empty group left over on form?
+ return 0;
+ DomButtonGroup *domButtonGroup = new DomButtonGroup;
+ domButtonGroup->setAttributeName(buttonGroup->objectName());
+
+ QList<DomProperty*> properties = computeProperties(buttonGroup);
+ domButtonGroup->setElementProperty(properties);
+ return domButtonGroup;
+}
+
+/*!
+ \internal
+*/
+DomActionGroup *QAbstractFormBuilder::createDom(QActionGroup *actionGroup)
+{
+ DomActionGroup *ui_action_group = new DomActionGroup;
+ ui_action_group->setAttributeName(actionGroup->objectName());
+
+ QList<DomProperty*> properties = computeProperties(actionGroup);
+ ui_action_group->setElementProperty(properties);
+
+ QList<DomAction*> ui_actions;
+
+ foreach (QAction *action, actionGroup->actions()) {
+ if (DomAction *ui_action = createDom(action)) {
+ ui_actions.append(ui_action);
+ }
+ }
+
+ ui_action_group->setElementAction(ui_actions);
+
+ return ui_action_group;
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::addMenuAction(QAction *action)
+{
+ Q_UNUSED(action);
+}
+
+/*!
+ \internal
+*/
+void QAbstractFormBuilder::reset()
+{
+ m_laidout.clear();
+ m_actions.clear();
+ m_actionGroups.clear();
+ m_defaultMargin = INT_MIN;
+ m_defaultSpacing = INT_MIN;
+}
+
+/*!
+ \internal
+ Access meta enumeration for Qt::ToolBarArea
+*/
+
+QMetaEnum QAbstractFormBuilder::toolBarAreaMetaEnum()
+{
+ return metaEnum<QAbstractFormBuilderGadget>("toolBarArea");
+}
+
+/*!
+ \internal
+ Return paths of an icon.
+*/
+
+QAbstractFormBuilder::IconPaths QAbstractFormBuilder::iconPaths(const QIcon &icon) const
+{
+ Q_UNUSED(icon);
+ qWarning() << "QAbstractFormBuilder::iconPaths() is obsoleted";
+ return IconPaths();
+}
+
+/*!
+ \internal
+ Return paths of a pixmap.
+*/
+
+QAbstractFormBuilder::IconPaths QAbstractFormBuilder::pixmapPaths(const QPixmap &pixmap) const
+{
+ Q_UNUSED(pixmap);
+ qWarning() << "QAbstractFormBuilder::pixmapPaths() is obsoleted";
+ return IconPaths();
+}
+
+/*!
+ \internal
+ Set up a DOM property with icon.
+*/
+
+void QAbstractFormBuilder::setIconProperty(DomProperty &p, const IconPaths &ip) const
+{
+ DomResourceIcon *dpi = new DomResourceIcon;
+
+ /* TODO
+ if (!ip.second.isEmpty())
+ pix->setAttributeResource(ip.second);
+*/
+ dpi->setText(ip.first);
+
+ p.setAttributeName(QFormBuilderStrings::instance().iconAttribute);
+ p.setElementIconSet(dpi);
+}
+
+/*!
+ \internal
+ Set up a DOM property with pixmap.
+*/
+
+void QAbstractFormBuilder::setPixmapProperty(DomProperty &p, const IconPaths &ip) const
+{
+ DomResourcePixmap *pix = new DomResourcePixmap;
+ if (!ip.second.isEmpty())
+ pix->setAttributeResource(ip.second);
+
+ pix->setText(ip.first);
+
+ p.setAttributeName(QFormBuilderStrings::instance().pixmapAttribute);
+ p.setElementPixmap(pix);
+}
+
+/*!
+ \internal
+ Convenience. Return DOM property for icon; 0 if icon.isNull().
+*/
+
+DomProperty* QAbstractFormBuilder::iconToDomProperty(const QIcon &icon) const
+{
+ Q_UNUSED(icon);
+ qWarning() << "QAbstractFormBuilder::iconToDomProperty() is obsoleted";
+ return 0;
+}
+
+/*!
+ \internal
+ \since 4.4
+*/
+
+DomProperty *QAbstractFormBuilder::saveResource(const QVariant &v) const
+{
+ if (v.isNull())
+ return 0;
+
+ DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), v);
+ if (p)
+ p->setAttributeName(QFormBuilderStrings::instance().iconAttribute);
+ return p;
+}
+
+/*!
+ \internal
+ \since 4.5
+*/
+
+DomProperty *QAbstractFormBuilder::saveText(const QString &attributeName, const QVariant &v) const
+{
+ if (v.isNull())
+ return 0;
+
+ DomProperty *p = textBuilder()->saveText(v);
+ if (p)
+ p->setAttributeName(attributeName);
+ return p;
+}
+
+/*!
+ \internal
+ Return the appropriate DOM pixmap for an image dom property.
+ From 4.4 - unused
+*/
+
+const DomResourcePixmap *QAbstractFormBuilder::domPixmap(const DomProperty* p) {
+ switch (p->kind()) {
+ case DomProperty::IconSet:
+ qDebug() << "** WARNING QAbstractFormBuilder::domPixmap() called for icon set!";
+ break;
+ case DomProperty::Pixmap:
+ return p->elementPixmap();
+ default:
+ break;
+ }
+ return 0;
+}
+
+/*!
+ \internal
+ Create icon from DOM.
+ From 4.4 - unused
+*/
+
+QIcon QAbstractFormBuilder::domPropertyToIcon(const DomResourcePixmap *icon)
+{
+ Q_UNUSED(icon);
+ qWarning() << "QAbstractFormBuilder::domPropertyToIcon() is obsoleted";
+ return QIcon();
+}
+
+/*!
+ \internal
+ Create icon from DOM. Assert if !domPixmap
+ From 4.4 - unused
+*/
+
+QIcon QAbstractFormBuilder::domPropertyToIcon(const DomProperty* p)
+{
+ Q_UNUSED(p);
+ qWarning() << "QAbstractFormBuilder::domPropertyToIcon() is obsoleted";
+ return QIcon();
+}
+
+
+/*!
+ \internal
+ Create pixmap from DOM.
+ From 4.4 - unused
+*/
+
+QPixmap QAbstractFormBuilder::domPropertyToPixmap(const DomResourcePixmap* pixmap)
+{
+ Q_UNUSED(pixmap);
+ qWarning() << "QAbstractFormBuilder::domPropertyToPixmap() is obsoleted";
+ return QPixmap();
+}
+
+
+/*!
+ \internal
+ Create pixmap from DOM. Assert if !domPixmap
+ From 4.4 - unused
+*/
+
+QPixmap QAbstractFormBuilder::domPropertyToPixmap(const DomProperty* p)
+{
+ Q_UNUSED(p);
+ qWarning() << "QAbstractFormBuilder::domPropertyToPixmap() is obsoleted";
+ return QPixmap();
+}
+
+/*!
+ \fn void QAbstractFormBuilder::createConnections ( DomConnections *, QWidget * )
+ \internal
+*/
+
+/*!
+ \fn void QAbstractFormBuilder::createCustomWidgets ( DomCustomWidgets * )
+ \internal
+*/
+
+/*!
+ \fn void QAbstractFormBuilder::createResources ( DomResources * )
+ \internal
+*/
+
+/*!
+ \fn QFormScriptRunner *QAbstractFormBuilder::formScriptRunner() const
+ \internal
+ \since 4.3
+*/
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+QFormScriptRunner *QAbstractFormBuilder::formScriptRunner() const
+{
+ return &(QFormBuilderExtra::instance(this)->formScriptRunner());
+}
+#endif
+
+/*!
+ Sets whether the execution of scripts is enabled to \a enabled.
+ \since 4.3
+ \internal
+*/
+
+void QAbstractFormBuilder::setScriptingEnabled(bool enabled)
+{
+#ifdef QT_FORMBUILDER_NO_SCRIPT
+ if (enabled)
+ uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "This version of the uitools library is linked without script support."));
+#else
+ QFormScriptRunner::Options options = formScriptRunner()->options();
+ if (enabled)
+ options &= ~QFormScriptRunner::DisableScripts;
+ else
+ options |= QFormScriptRunner::DisableScripts;
+ formScriptRunner()->setOptions(options);
+#endif
+}
+
+/*!
+ Returns whether the execution of scripts is enabled.
+ \sa setScriptingEnabled()
+ \since 4.3
+ \internal
+*/
+
+bool QAbstractFormBuilder::isScriptingEnabled() const
+{
+#ifdef QT_FORMBUILDER_NO_SCRIPT
+ return false;
+#else
+ return !(formScriptRunner()->options() & QFormScriptRunner::DisableScripts);
+#endif
+}
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/abstractformbuilder.h b/tools/uilib/abstractformbuilder.h
new file mode 100644
index 0000000000..b76f0e42b2
--- /dev/null
+++ b/tools/uilib/abstractformbuilder.h
@@ -0,0 +1,290 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTFORMBUILDER_H
+#define ABSTRACTFORMBUILDER_H
+
+#include <QtDesigner/uilib_global.h>
+
+#include <QtCore/QList>
+#include <QtCore/QHash>
+#include <QtCore/QDir>
+
+#include <QtGui/QSizePolicy>
+#include <QtGui/QPalette>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+#if 0
+// pragma for syncqt, don't remove.
+
+#pragma qt_class(QAbstractFormBuilder)
+#endif
+
+class QAction;
+class QButtonGroup;
+class QActionGroup;
+class QComboBox;
+class QIODevice;
+class QIcon;
+class QLayout;
+class QLayoutItem;
+class QListWidget;
+class QObject;
+class QSpacerItem;
+class QTreeWidget;
+class QTableWidget;
+class QVariant;
+class QWidget;
+class QAbstractButton;
+class QAbstractItemView;
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class DomAction;
+class DomActionGroup;
+class DomButtonGroup;
+class DomButtonGroups;
+class DomActionRef;
+class DomBrush;
+class DomColorGroup;
+class DomConnections;
+class DomCustomWidgets;
+class DomLayout;
+class DomLayoutItem;
+class DomProperty;
+class DomResources;
+class DomSpacer;
+class DomString;
+class DomTabStops;
+class DomUI;
+class DomWidget;
+class DomResourcePixmap;
+
+class QResourceBuilder;
+class QTextBuilder;
+
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+class QFormScriptRunner;
+#endif
+
+class QDESIGNER_UILIB_EXPORT QAbstractFormBuilder
+{
+public:
+ QAbstractFormBuilder();
+ virtual ~QAbstractFormBuilder();
+
+ QDir workingDirectory() const;
+ void setWorkingDirectory(const QDir &directory);
+
+ virtual QWidget *load(QIODevice *dev, QWidget *parentWidget=0);
+ virtual void save(QIODevice *dev, QWidget *widget);
+
+ void setScriptingEnabled(bool enabled);
+ bool isScriptingEnabled() const;
+
+protected:
+//
+// load
+//
+ virtual void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget);
+
+ virtual QWidget *create(DomUI *ui, QWidget *parentWidget);
+ virtual QWidget *create(DomWidget *ui_widget, QWidget *parentWidget);
+ virtual QLayout *create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget);
+ virtual QLayoutItem *create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget);
+
+ virtual QAction *create(DomAction *ui_action, QObject *parent);
+ virtual QActionGroup *create(DomActionGroup *ui_action_group, QObject *parent);
+ virtual void addMenuAction(QAction *action);
+
+ virtual void applyProperties(QObject *o, const QList<DomProperty*> &properties);
+ bool applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value);
+
+ virtual void applyTabStops(QWidget *widget, DomTabStops *tabStops);
+
+ virtual QWidget *createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name);
+ virtual QLayout *createLayout(const QString &layoutName, QObject *parent, const QString &name);
+ virtual QAction *createAction(QObject *parent, const QString &name);
+ virtual QActionGroup *createActionGroup(QObject *parent, const QString &name);
+
+ virtual void createCustomWidgets(DomCustomWidgets *) {}
+ virtual void createConnections(DomConnections *, QWidget *) {}
+ virtual void createResources(DomResources*) {}
+
+ virtual bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout);
+ virtual bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget);
+
+//
+// save
+//
+ virtual void saveExtraInfo(QWidget *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+
+ virtual void saveDom(DomUI *ui, QWidget *widget);
+
+ virtual DomActionRef *createActionRefDom(QAction *action);
+
+ virtual DomWidget *createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive = true);
+ virtual DomLayout *createDom(QLayout *layout, DomLayout *ui_layout, DomWidget *ui_parentWidget);
+ virtual DomLayoutItem *createDom(QLayoutItem *item, DomLayout *ui_parentLayout, DomWidget *ui_parentWidget);
+ virtual DomSpacer *createDom(QSpacerItem *spacer, DomLayout *ui_parentLayout, DomWidget *ui_parentWidget);
+
+ virtual DomAction *createDom(QAction *action);
+ virtual DomActionGroup *createDom(QActionGroup *actionGroup);
+ DomButtonGroup *createDom(QButtonGroup *buttonGroup);
+
+ virtual DomConnections *saveConnections();
+ virtual DomCustomWidgets *saveCustomWidgets();
+ virtual DomTabStops *saveTabStops();
+ virtual DomResources *saveResources();
+ DomButtonGroups *saveButtonGroups(const QWidget *mainContainer);
+ virtual QList<DomProperty*> computeProperties(QObject *obj);
+ virtual bool checkProperty(QObject *obj, const QString &prop) const;
+ virtual DomProperty *createProperty(QObject *object, const QString &propertyName, const QVariant &value);
+
+ virtual void layoutInfo(DomLayout *layout, QObject *parent, int *margin, int *spacing);
+
+ virtual QIcon nameToIcon(const QString &filePath, const QString &qrcPath);
+ virtual QString iconToFilePath(const QIcon &pm) const;
+ virtual QString iconToQrcPath(const QIcon &pm) const;
+ virtual QPixmap nameToPixmap(const QString &filePath, const QString &qrcPath);
+ virtual QString pixmapToFilePath(const QPixmap &pm) const;
+ virtual QString pixmapToQrcPath(const QPixmap &pm) const;
+
+ void loadListWidgetExtraInfo(DomWidget *ui_widget, QListWidget *listWidget, QWidget *parentWidget);
+ void loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWidget *treeWidget, QWidget *parentWidget);
+ void loadTableWidgetExtraInfo(DomWidget *ui_widget, QTableWidget *tableWidget, QWidget *parentWidget);
+ void loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox *comboBox, QWidget *parentWidget);
+ void loadButtonExtraInfo(const DomWidget *ui_widget, QAbstractButton *button, QWidget *parentWidget);
+ void loadItemViewExtraInfo(DomWidget *ui_widget, QAbstractItemView *itemView, QWidget *parentWidget);
+
+ void saveListWidgetExtraInfo(QListWidget *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+ void saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+ void saveTableWidgetExtraInfo(QTableWidget *tablWidget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+ void saveComboBoxExtraInfo(QComboBox *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+ void saveButtonExtraInfo(const QAbstractButton *widget, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+ void saveItemViewExtraInfo(const QAbstractItemView *itemView, DomWidget *ui_widget, DomWidget *ui_parentWidget);
+
+ void setResourceBuilder(QResourceBuilder *builder);
+ QResourceBuilder *resourceBuilder() const;
+ DomProperty *saveResource(const QVariant &v) const;
+
+ void setTextBuilder(QTextBuilder *builder);
+ QTextBuilder *textBuilder() const;
+ DomProperty *saveText(const QString &attributeName, const QVariant &v) const;
+//
+// utils
+//
+
+ QVariant toVariant(const QMetaObject *meta, DomProperty *property);
+ static QString toString(const DomString *str);
+
+ typedef QHash<QString, DomProperty*> DomPropertyHash;
+ static DomPropertyHash propertyMap(const QList<DomProperty*> &properties);
+
+ void setupColorGroup(QPalette &palette, QPalette::ColorGroup colorGroup, DomColorGroup *group);
+ DomColorGroup *saveColorGroup(const QPalette &palette);
+ QBrush setupBrush(DomBrush *brush);
+ DomBrush *saveBrush(const QBrush &brush);
+
+ void reset();
+ void initialize(const DomUI *ui);
+
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+ QFormScriptRunner *formScriptRunner() const;
+#endif
+//
+// utils
+//
+
+ static QMetaEnum toolBarAreaMetaEnum();
+
+//
+// Icon/pixmap stuff
+//
+ // A Pair of icon path/qrc path.
+ typedef QPair<QString, QString> IconPaths;
+
+ IconPaths iconPaths(const QIcon &) const;
+ IconPaths pixmapPaths(const QPixmap &) const;
+ void setIconProperty(DomProperty &, const IconPaths &) const;
+ void setPixmapProperty(DomProperty &, const IconPaths &) const;
+ DomProperty* iconToDomProperty(const QIcon &) const;
+
+ static const DomResourcePixmap *domPixmap(const DomProperty* p);
+ QIcon domPropertyToIcon(const DomResourcePixmap *);
+ QIcon domPropertyToIcon(const DomProperty* p);
+ QPixmap domPropertyToPixmap(const DomResourcePixmap* p);
+ QPixmap domPropertyToPixmap(const DomProperty* p);
+
+ QHash<QObject*, bool> m_laidout;
+ QHash<QString, QAction*> m_actions;
+ QHash<QString, QActionGroup*> m_actionGroups;
+ int m_defaultMargin;
+ int m_defaultSpacing;
+ QDir m_workingDirectory;
+
+private:
+//
+// utils
+//
+ static Qt::ToolBarArea toolbarAreaFromDOMAttributes(const DomPropertyHash &attributeMap);
+
+ QAbstractFormBuilder(const QAbstractFormBuilder &other);
+ void operator = (const QAbstractFormBuilder &other);
+
+ friend QDESIGNER_UILIB_EXPORT DomProperty *variantToDomProperty(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const QString &propertyName, const QVariant &value);
+ friend QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(QAbstractFormBuilder *abstractFormBuilder,const QMetaObject *meta, const DomProperty *property);
+};
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // ABSTRACTFORMBUILDER_H
diff --git a/tools/uilib/container.h b/tools/uilib/container.h
new file mode 100644
index 0000000000..89df461e02
--- /dev/null
+++ b/tools/uilib/container.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONTAINER_H
+#define CONTAINER_H
+
+#include <QtDesigner/extension.h>
+#include <QtCore/QObject>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QWidget;
+
+class QDesignerContainerExtension
+{
+public:
+ virtual ~QDesignerContainerExtension() {}
+
+ virtual int count() const = 0;
+ virtual QWidget *widget(int index) const = 0;
+
+ virtual int currentIndex() const = 0;
+ virtual void setCurrentIndex(int index) = 0;
+
+ virtual void addWidget(QWidget *widget) = 0;
+ virtual void insertWidget(int index, QWidget *widget) = 0;
+ virtual void remove(int index) = 0;
+};
+Q_DECLARE_EXTENSION_INTERFACE(QDesignerContainerExtension, "com.trolltech.Qt.Designer.Container")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // CONTAINER_H
diff --git a/tools/uilib/container.qdoc b/tools/uilib/container.qdoc
new file mode 100644
index 0000000000..d9310515d3
--- /dev/null
+++ b/tools/uilib/container.qdoc
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QDesignerContainerExtension
+ \brief The QDesignerContainerExtension class allows you to add pages to
+ a custom multi-page container in Qt Designer's workspace.
+ \inmodule QtDesigner
+
+ QDesignerContainerExtension provide an interface for creating
+ custom container extensions. A container extension consists of a
+ collection of functions that \QD needs to manage a multi-page
+ container plugin, and a list of the container's pages.
+
+ \image containerextension-example.png
+
+ \warning This is \e not an extension for container plugins in
+ general, only custom \e multi-page containers.
+
+ To create a container extension, your extension class must inherit
+ from both QObject and QDesignerContainerExtension. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 6
+
+ Since we are implementing an interface, we must ensure that it's
+ made known to the meta object system using the Q_INTERFACES()
+ macro. This enables \QD to use the qobject_cast() function to
+ query for supported interfaces using nothing but a QObject
+ pointer.
+
+ You must reimplement several functions to enable \QD to manage a
+ custom multi-page container widget: \QD uses count() to keep track
+ of the number pages in your container, widget() to return the page
+ at a given index in the list of the container's pages, and
+ currentIndex() to return the list index of the selected page. \QD
+ uses the addWidget() function to add a given page to the
+ container, expecting it to be appended to the list of pages, while
+ it expects the insertWidget() function to add a given page to the
+ container by inserting it at a given index.
+
+ In \QD the extensions are not created until they are
+ required. For that reason you must also create a
+ QExtensionFactory, i.e a class that is able to make an instance of
+ your extension, and register it using \QD's \l
+ {QExtensionManager}{extension manager}.
+
+ When a container extension is required, \QD's \l
+ {QExtensionManager}{extension manager} will run through all its
+ registered factories calling QExtensionFactory::createExtension()
+ for each until the first one that is able to create a container
+ extension, is found. This factory will then create the extension
+ for the plugin.
+
+ There are four available types of extensions in \QD:
+ QDesignerContainerExtension , QDesignerMemberSheetExtension,
+ QDesignerPropertySheetExtension and QDesignerTaskMenuExtension.
+ \QD's behavior is the same whether the requested extension is
+ associated with a multi page container, a member sheet, a property
+ sheet or a task menu.
+
+ The QExtensionFactory class provides a standard extension factory,
+ and can also be used as an interface for custom extension
+ factories. You can either create a new QExtensionFactory and
+ reimplement the QExtensionFactory::createExtension() function. For
+ example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 7
+
+ Or you can use an existing factory, expanding the
+ QExtensionFactory::createExtension() function to make the factory
+ able to create a container extension as well. For example:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 8
+
+ For a complete example using the QDesignerContainerExtension
+ class, see the \l {designer/containerextension}{Container
+ Extension example}. The example shows how to create a custom
+ multi-page plugin for \QD.
+
+ \sa QExtensionFactory, QExtensionManager, {Creating Custom Widget
+ Extensions}
+*/
+
+/*!
+ \fn QDesignerContainerExtension::~QDesignerContainerExtension()
+
+ Destroys the extension.
+*/
+
+/*!
+ \fn int QDesignerContainerExtension::count() const
+
+ Returns the number of pages in the container.
+*/
+
+/*!
+ \fn QWidget *QDesignerContainerExtension::widget(int index) const
+
+ Returns the page at the given \a index in the extension's list of
+ pages.
+
+ \sa addWidget(), insertWidget()
+*/
+
+/*!
+ \fn int QDesignerContainerExtension::currentIndex() const
+
+ Returns the index of the currently selected page in the
+ container.
+
+ \sa setCurrentIndex()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::setCurrentIndex(int index)
+
+ Sets the currently selected page in the container to be the
+ page at the given \a index in the extension's list of pages.
+
+ \sa currentIndex()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::addWidget(QWidget *page)
+
+ Adds the given \a page to the container by appending it to the
+ extension's list of pages.
+
+ \sa insertWidget(), remove(), widget()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page)
+
+ Adds the given \a page to the container by inserting it at the
+ given \a index in the extension's list of pages.
+
+ \sa addWidget(), remove(), widget()
+*/
+
+/*!
+ \fn void QDesignerContainerExtension::remove(int index)
+
+ Removes the page at the given \a index from the extension's list
+ of pages.
+
+ \sa addWidget(), insertWidget()
+*/
diff --git a/tools/uilib/customwidget.h b/tools/uilib/customwidget.h
new file mode 100644
index 0000000000..52c234207c
--- /dev/null
+++ b/tools/uilib/customwidget.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CUSTOMWIDGET_H
+#define CUSTOMWIDGET_H
+
+#include <QtDesigner/extension.h>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtGui/QIcon>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QWidget;
+class QDesignerFormEditorInterface;
+
+class QDesignerCustomWidgetInterface
+{
+public:
+ virtual ~QDesignerCustomWidgetInterface() {}
+
+ virtual QString name() const = 0;
+ virtual QString group() const = 0;
+ virtual QString toolTip() const = 0;
+ virtual QString whatsThis() const = 0;
+ virtual QString includeFile() const = 0;
+ virtual QIcon icon() const = 0;
+
+ virtual bool isContainer() const = 0;
+
+ virtual QWidget *createWidget(QWidget *parent) = 0;
+
+ virtual bool isInitialized() const { return false; }
+ virtual void initialize(QDesignerFormEditorInterface *core) { Q_UNUSED(core); }
+
+ virtual QString domXml() const
+ {
+ return QString::fromUtf8("<widget class=\"%1\" name=\"%2\"/>")
+ .arg(name()).arg(name().toLower());
+ }
+
+ virtual QString codeTemplate() const { return QString(); }
+};
+Q_DECLARE_INTERFACE(QDesignerCustomWidgetInterface, "com.trolltech.Qt.Designer.CustomWidget")
+
+
+class QDesignerCustomWidgetCollectionInterface
+{
+public:
+ virtual ~QDesignerCustomWidgetCollectionInterface() {}
+
+ virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const = 0;
+};
+Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface,
+ "com.trolltech.Qt.Designer.CustomWidgetCollection")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // CUSTOMWIDGET_H
diff --git a/tools/uilib/customwidget.qdoc b/tools/uilib/customwidget.qdoc
new file mode 100644
index 0000000000..d5ddaa7d30
--- /dev/null
+++ b/tools/uilib/customwidget.qdoc
@@ -0,0 +1,295 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QDesignerCustomWidgetInterface
+
+ \brief The QDesignerCustomWidgetInterface class enables Qt Designer
+ to access and construct custom widgets.
+
+ \inmodule QtDesigner
+
+ QDesignerCustomWidgetInterface provides a custom widget with an
+ interface. The class contains a set of functions that must be subclassed
+ to return basic information about the widget, such as its class name and
+ the name of its header file. Other functions must be implemented to
+ initialize the plugin when it is loaded, and to construct instances of
+ the custom widget for \QD to use.
+
+ When implementing a custom widget you must subclass
+ QDesignerCustomWidgetInterface to expose your widget to \QD. For
+ example, this is the declaration for the plugin used in the
+ \l{Custom Widget Plugin Example}{Custom Widget Plugin example} that
+ enables an analog clock custom widget to be used by \QD:
+
+ \snippet examples/designer/customwidgetplugin/customwidgetplugin.h 0
+
+ Note that the only part of the class definition that is specific
+ to this particular custom widget is the class name. In addition,
+ since we are implementing an interface, we must ensure that it's
+ made known to the meta object system using the Q_INTERFACES()
+ macro. This enables \QD to use the qobject_cast() function to
+ query for supported interfaces using nothing but a QObject
+ pointer.
+
+ After \QD loads a custom widget plugin, it calls the interface's
+ initialize() function to enable it to set up any resources that it
+ may need. This function is called with a QDesignerFormEditorInterface
+ parameter that provides the plugin with a gateway to all of \QD's API.
+
+ \QD constructs instances of the custom widget by calling the plugin's
+ createWidget() function with a suitable parent widget. Plugins must
+ construct and return an instance of a custom widget with the specified
+ parent widget.
+
+ In the implementation of the class you must remember to export
+ your custom widget plugin to \QD using the Q_EXPORT_PLUGIN2()
+ macro. For example, if a library called \c libcustomwidgetplugin.so
+ (on Unix) or \c libcustomwidget.dll (on Windows) contains a widget
+ class called \c MyCustomWidget, we can export it by adding the
+ following line to the file containing the plugin implementation:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 14
+
+ This macro ensures that \QD can access and construct the custom widget.
+ Without this macro, there is no way for \QD to use it.
+
+ When implementing a custom widget plugin, you build it as a
+ separate library. If you want to include several custom widget
+ plugins in the same library, you must in addition subclass
+ QDesignerCustomWidgetCollectionInterface.
+
+ \warning If your custom widget plugin contains QVariant
+ properties, be aware that only the following \l
+ {QVariant::Type}{types} are supported:
+
+ \list
+ \o QVariant::ByteArray
+ \o QVariant::Bool
+ \o QVariant::Color
+ \o QVariant::Cursor
+ \o QVariant::Date
+ \o QVariant::DateTime
+ \o QVariant::Double
+ \o QVariant::Int
+ \o QVariant::Point
+ \o QVariant::Rect
+ \o QVariant::Size
+ \o QVariant::SizePolicy
+ \o QVariant::String
+ \o QVariant::Time
+ \o QVariant::UInt
+ \endlist
+
+ For a complete example using the QDesignerCustomWidgetInterface
+ class, see the \l {designer/customwidgetplugin}{Custom Widget
+ Example}. The example shows how to create a custom widget plugin
+ for \QD.
+
+ \sa QDesignerCustomWidgetCollectionInterface {Creating Custom
+ Widgets for Qt Designer}
+*/
+
+/*!
+ \fn QDesignerCustomWidgetInterface::~QDesignerCustomWidgetInterface()
+
+ Destroys the custom widget interface.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::name() const
+
+ Returns the class name of the custom widget supplied by the interface.
+
+ The name returned \e must be identical to the class name used for the
+ custom widget.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::group() const
+
+ Returns the name of the group to which the custom widget belongs.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::toolTip() const
+
+ Returns a short description of the widget that can be used by \QD
+ in a tool tip.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::whatsThis() const
+
+ Returns a description of the widget that can be used by \QD in
+ "What's This?" help for the widget.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::includeFile() const
+
+ Returns the path to the include file that \l uic uses when
+ creating code for the custom widget.
+*/
+
+/*!
+ \fn QIcon QDesignerCustomWidgetInterface::icon() const
+
+ Returns the icon used to represent the custom widget in \QD's
+ widget box.
+*/
+
+/*!
+ \fn bool QDesignerCustomWidgetInterface::isContainer() const
+
+ Returns true if the custom widget is intended to be used as a
+ container; otherwise returns false.
+
+ Most custom widgets are not used to hold other widgets, so their
+ implementations of this function will return false, but custom
+ containers will return true to ensure that they behave correctly
+ in \QD.
+*/
+
+/*!
+ \fn QWidget *QDesignerCustomWidgetInterface::createWidget(QWidget *parent)
+
+ Returns a new instance of the custom widget, with the given \a
+ parent.
+*/
+
+/*!
+ \fn bool QDesignerCustomWidgetInterface::isInitialized() const
+
+ Returns true if the widget has been initialized; otherwise returns
+ false.
+
+ \sa initialize()
+*/
+
+/*!
+ \fn void QDesignerCustomWidgetInterface::initialize(QDesignerFormEditorInterface *formEditor)
+
+ Initializes the widget for use with the specified \a formEditor
+ interface.
+
+ \sa isInitialized()
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::domXml() const
+
+ Returns the XML that is used to describe the custom widget's
+ properties to \QD.
+*/
+
+/*!
+ \fn QString QDesignerCustomWidgetInterface::codeTemplate() const
+
+ This function is reserved for future use by \QD.
+
+ \omit
+ Returns the code template that \QD includes in forms that contain
+ the custom widget when they are saved.
+ \endomit
+*/
+
+/*!
+ \macro QDESIGNER_WIDGET_EXPORT
+ \relates QDesignerCustomWidgetInterface
+ \since 4.1
+
+ This macro is used when defining custom widgets to ensure that they are
+ correctly exported from plugins for use with \QD.
+
+ On some platforms, the symbols required by \QD to create new widgets
+ are removed from plugins by the build system, making them unusable.
+ Using this macro ensures that the symbols are retained on those platforms,
+ and has no side effects on other platforms.
+
+ For example, the \l{designer/worldtimeclockplugin}{World Time Clock Plugin}
+ example exports a custom widget class with the following declaration:
+
+ \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 0
+ \dots
+ \snippet examples/designer/worldtimeclockplugin/worldtimeclock.h 2
+
+ \sa {Creating Custom Widgets for Qt Designer}
+*/
+
+
+
+
+
+/*!
+ \class QDesignerCustomWidgetCollectionInterface
+
+ \brief The QDesignerCustomWidgetCollectionInterface class allows
+ you to include several custom widgets in one single library.
+
+ \inmodule QtDesigner
+
+ When implementing a custom widget plugin, you build it as a
+ separate library. If you want to include several custom widget
+ plugins in the same library, you must in addition subclass
+ QDesignerCustomWidgetCollectionInterface.
+
+ QDesignerCustomWidgetCollectionInterface contains one single
+ function returning a list of the collection's
+ QDesignerCustomWidgetInterface objects. For example, if you have
+ several custom widgets \c CustomWidgetOne, \c CustomWidgetTwo and
+ \c CustomWidgetThree, the class definition may look like this:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 12
+
+ In the class constructor you add the interfaces to your custom
+ widgets to the list which you return in the customWidgets()
+ function:
+
+ \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 13
+
+ Note that instead of exporting each custom widget plugin using the
+ Q_EXPORT_PLUGIN2() macro, you export the entire collection. The
+ Q_EXPORT_PLUGIN2() macro ensures that \QD can access and construct
+ the custom widgets. Without this macro, there is no way for \QD to
+ use them.
+
+ \sa QDesignerCustomWidgetInterface, {Creating Custom Widgets for
+ Qt Designer}
+*/
+
+/*!
+ \fn QDesignerCustomWidgetCollectionInterface::~QDesignerCustomWidgetCollectionInterface() {
+
+ Destroys the custom widget collection interface.
+*/
+
+/*!
+ \fn QList<QDesignerCustomWidgetInterface*> QDesignerCustomWidgetCollectionInterface::customWidgets() const
+
+ Returns a list of interfaces to the collection's custom widgets.
+*/
diff --git a/tools/uilib/formbuilder.cpp b/tools/uilib/formbuilder.cpp
new file mode 100644
index 0000000000..b997cc9bc0
--- /dev/null
+++ b/tools/uilib/formbuilder.cpp
@@ -0,0 +1,570 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "customwidget.h"
+#include "formbuilder.h"
+#include "formbuilderextra_p.h"
+#include "ui4_p.h"
+
+#include <QtGui/QtGui>
+#include <QtCore/QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal {
+#endif
+
+/*!
+ \class QFormBuilder
+
+ \brief The QFormBuilder class is used to dynamically construct
+ user interfaces from UI files at run-time.
+
+ \inmodule QtDesigner
+
+ The QFormBuilder class provides a mechanism for dynamically
+ creating user interfaces at run-time, based on UI files
+ created with \QD. For example:
+
+ \snippet doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp 0
+
+ By including the user interface in the example's resources (\c
+ myForm.qrc), we ensure that it will be present when the example is
+ run:
+
+ \snippet doc/src/snippets/code/tools_designer_src_lib_uilib_formbuilder.cpp 1
+
+ QFormBuilder extends the QAbstractFormBuilder base class with a
+ number of functions that are used to support custom widget
+ plugins:
+
+ \list
+ \o pluginPaths() returns the list of paths that the form builder
+ searches when loading custom widget plugins.
+ \o addPluginPath() allows additional paths to be registered with
+ the form builder.
+ \o setPluginPath() is used to replace the existing list of paths
+ with a list obtained from some other source.
+ \o clearPluginPaths() removes all paths registered with the form
+ builder.
+ \o customWidgets() returns a list of interfaces to plugins that
+ can be used to create new instances of registered custom widgets.
+ \endlist
+
+ The QFormBuilder class is typically used by custom components and
+ applications that embed \QD. Standalone applications that need to
+ dynamically generate user interfaces at run-time use the
+ QUiLoader class, found in the QtUiTools module.
+
+ \sa QAbstractFormBuilder, {QtUiTools Module}
+*/
+
+/*!
+ \fn QFormBuilder::QFormBuilder()
+
+ Constructs a new form builder.
+*/
+
+QFormBuilder::QFormBuilder() : QAbstractFormBuilder()
+{
+}
+
+/*!
+ Destroys the form builder.
+*/
+QFormBuilder::~QFormBuilder()
+{
+}
+
+/*!
+ \internal
+*/
+QWidget *QFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidget)
+{
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
+ if (!fb->parentWidgetIsSet())
+ fb->setParentWidget(parentWidget);
+ // Is this a QLayoutWidget with a margin of 0: Not a known page-based
+ // container and no method for adding pages registered.
+ fb->setProcessingLayoutWidget(false);
+ if (ui_widget->attributeClass() == QFormBuilderStrings::instance().qWidgetClass && !ui_widget->hasAttributeNative()
+ && parentWidget
+#ifndef QT_NO_MAINWINDOW
+ && !qobject_cast<QMainWindow *>(parentWidget)
+#endif
+#ifndef QT_NO_TOOLBOX
+ && !qobject_cast<QToolBox *>(parentWidget)
+#endif
+#ifndef QT_NO_STACKEDWIDGET
+ && !qobject_cast<QStackedWidget *>(parentWidget)
+#endif
+#ifndef QT_NO_STACKEDWIDGET
+ && !qobject_cast<QTabWidget *>(parentWidget)
+#endif
+#ifndef QT_NO_SCROLLAREA
+ && !qobject_cast<QScrollArea *>(parentWidget)
+#endif
+#ifndef QT_NO_MDIAREA
+ && !qobject_cast<QMdiArea *>(parentWidget)
+#endif
+#ifndef QT_NO_DOCKWIDGET
+ && !qobject_cast<QDockWidget *>(parentWidget)
+#endif
+ ) {
+ const QString parentClassName = QLatin1String(parentWidget->metaObject()->className());
+ if (!fb->isCustomWidgetContainer(parentClassName))
+ fb->setProcessingLayoutWidget(true);
+ }
+ return QAbstractFormBuilder::create(ui_widget, parentWidget);
+}
+
+
+/*!
+ \internal
+*/
+QWidget *QFormBuilder::createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name)
+{
+ if (widgetName.isEmpty()) {
+ //: Empty class name passed to widget factory method
+ qWarning() << QCoreApplication::translate("QFormBuilder", "An empty class name was passed on to %1 (object name: '%2').").arg(QString::fromUtf8(Q_FUNC_INFO), name);
+ return 0;
+ }
+
+ QWidget *w = 0;
+
+#ifndef QT_NO_TABWIDGET
+ if (qobject_cast<QTabWidget*>(parentWidget))
+ parentWidget = 0;
+#endif
+#ifndef QT_NO_STACKEDWIDGET
+ if (qobject_cast<QStackedWidget*>(parentWidget))
+ parentWidget = 0;
+#endif
+#ifndef QT_NO_TOOLBOX
+ if (qobject_cast<QToolBox*>(parentWidget))
+ parentWidget = 0;
+#endif
+
+ // ### special-casing for Line (QFrame) -- fix for 4.2
+ do {
+ if (widgetName == QFormBuilderStrings::instance().lineClass) {
+ w = new QFrame(parentWidget);
+ static_cast<QFrame*>(w)->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ break;
+ }
+ const QByteArray widgetNameBA = widgetName.toUtf8();
+ const char *widgetNameC = widgetNameBA.constData();
+ if (w) { // symmetry for macro
+ }
+
+#define DECLARE_LAYOUT(L, C)
+#define DECLARE_COMPAT_WIDGET(W, C)
+#define DECLARE_WIDGET(W, C) else if (!qstrcmp(widgetNameC, #W)) { Q_ASSERT(w == 0); w = new W(parentWidget); }
+#define DECLARE_WIDGET_1(W, C) else if (!qstrcmp(widgetNameC, #W)) { Q_ASSERT(w == 0); w = new W(0, parentWidget); }
+
+#include "widgets.table"
+
+#undef DECLARE_COMPAT_WIDGET
+#undef DECLARE_LAYOUT
+#undef DECLARE_WIDGET
+#undef DECLARE_WIDGET_1
+
+ if (w)
+ break;
+
+ // try with a registered custom widget
+ QDesignerCustomWidgetInterface *factory = m_customWidgets.value(widgetName);
+ if (factory != 0)
+ w = factory->createWidget(parentWidget);
+ } while(false);
+
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
+ if (w == 0) { // Attempt to instantiate base class of promoted/custom widgets
+ const QString baseClassName = fb->customWidgetBaseClass(widgetName);
+ if (!baseClassName.isEmpty()) {
+ qWarning() << QCoreApplication::translate("QFormBuilder", "QFormBuilder was unable to create a custom widget of the class '%1'; defaulting to base class '%2'.").arg(widgetName, baseClassName);
+ return createWidget(baseClassName, parentWidget, name);
+ }
+ }
+
+ if (w == 0) { // nothing to do
+ qWarning() << QCoreApplication::translate("QFormBuilder", "QFormBuilder was unable to create a widget of the class '%1'.").arg(widgetName);
+ return 0;
+ }
+
+ w->setObjectName(name);
+
+ if (qobject_cast<QDialog *>(w))
+ w->setParent(parentWidget);
+
+ return w;
+}
+
+/*!
+ \internal
+*/
+QLayout *QFormBuilder::createLayout(const QString &layoutName, QObject *parent, const QString &name)
+{
+ QLayout *l = 0;
+
+ QWidget *parentWidget = qobject_cast<QWidget*>(parent);
+ QLayout *parentLayout = qobject_cast<QLayout*>(parent);
+
+ Q_ASSERT(parentWidget || parentLayout);
+
+#define DECLARE_WIDGET(W, C)
+#define DECLARE_COMPAT_WIDGET(W, C)
+
+#define DECLARE_LAYOUT(L, C) \
+ if (layoutName == QLatin1String(#L)) { \
+ Q_ASSERT(l == 0); \
+ l = parentLayout \
+ ? new L() \
+ : new L(parentWidget); \
+ }
+
+#include "widgets.table"
+
+#undef DECLARE_LAYOUT
+#undef DECLARE_COMPAT_WIDGET
+#undef DECLARE_WIDGET
+
+ if (l) {
+ l->setObjectName(name);
+ if (parentLayout) {
+ QWidget *w = qobject_cast<QWidget *>(parentLayout->parent());
+ if (w && w->inherits("Q3GroupBox")) {
+ l->setContentsMargins(w->style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
+ w->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
+ w->style()->pixelMetric(QStyle::PM_LayoutRightMargin),
+ w->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
+ QGridLayout *grid = qobject_cast<QGridLayout *>(l);
+ if (grid) {
+ grid->setHorizontalSpacing(-1);
+ grid->setVerticalSpacing(-1);
+ } else {
+ l->setSpacing(-1);
+ }
+ l->setAlignment(Qt::AlignTop);
+ }
+ }
+ } else {
+ qWarning() << QCoreApplication::translate("QFormBuilder", "The layout type `%1' is not supported.").arg(layoutName);
+ }
+
+ return l;
+}
+
+/*!
+ \internal
+*/
+bool QFormBuilder::addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout)
+{
+ return QAbstractFormBuilder::addItem(ui_item, item, layout);
+}
+
+/*!
+ \internal
+*/
+bool QFormBuilder::addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget)
+{
+ return QAbstractFormBuilder::addItem(ui_widget, widget, parentWidget);
+}
+
+/*!
+ \internal
+*/
+QWidget *QFormBuilder::widgetByName(QWidget *topLevel, const QString &name)
+{
+ Q_ASSERT(topLevel);
+ if (topLevel->objectName() == name)
+ return topLevel;
+
+ return topLevel->findChild<QWidget*>(name);
+}
+
+static QObject *objectByName(QWidget *topLevel, const QString &name)
+{
+ Q_ASSERT(topLevel);
+ if (topLevel->objectName() == name)
+ return topLevel;
+
+ return topLevel->findChild<QObject*>(name);
+}
+
+/*!
+ \internal
+*/
+void QFormBuilder::createConnections(DomConnections *ui_connections, QWidget *widget)
+{
+ typedef QList<DomConnection*> DomConnectionList;
+ Q_ASSERT(widget != 0);
+
+ if (ui_connections == 0)
+ return;
+
+ const DomConnectionList connections = ui_connections->elementConnection();
+ if (!connections.empty()) {
+ const DomConnectionList::const_iterator cend = connections.constEnd();
+ for (DomConnectionList::const_iterator it = connections.constBegin(); it != cend; ++it) {
+
+ QObject *sender = objectByName(widget, (*it)->elementSender());
+ QObject *receiver = objectByName(widget, (*it)->elementReceiver());
+ if (!sender || !receiver)
+ continue;
+
+ QByteArray sig = (*it)->elementSignal().toUtf8();
+ sig.prepend("2");
+ QByteArray sl = (*it)->elementSlot().toUtf8();
+ sl.prepend("1");
+ QObject::connect(sender, sig, receiver, sl);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+QWidget *QFormBuilder::create(DomUI *ui, QWidget *parentWidget)
+{
+ return QAbstractFormBuilder::create(ui, parentWidget);
+}
+
+/*!
+ \internal
+*/
+QLayout *QFormBuilder::create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
+{
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
+ // Is this a temporary layout widget used to represent QLayout hierarchies in Designer?
+ // Set its margins to 0.
+ bool layoutWidget = fb->processingLayoutWidget();
+ QLayout *l = QAbstractFormBuilder::create(ui_layout, layout, parentWidget);
+ if (layoutWidget) {
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ int left, top, right, bottom;
+ left = top = right = bottom = 0;
+ const DomPropertyHash properties = propertyMap(ui_layout->elementProperty());
+
+ if (DomProperty *prop = properties.value(strings.leftMarginProperty))
+ left = prop->elementNumber();
+
+ if (DomProperty *prop = properties.value(strings.topMarginProperty))
+ top = prop->elementNumber();
+
+ if (DomProperty *prop = properties.value(strings.rightMarginProperty))
+ right = prop->elementNumber();
+
+ if (DomProperty *prop = properties.value(strings.bottomMarginProperty))
+ bottom = prop->elementNumber();
+
+ l->setContentsMargins(left, top, right, bottom);
+ fb->setProcessingLayoutWidget(false);
+ }
+ return l;
+}
+
+/*!
+ \internal
+*/
+QLayoutItem *QFormBuilder::create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget)
+{
+ return QAbstractFormBuilder::create(ui_layoutItem, layout, parentWidget);
+}
+
+/*!
+ \internal
+*/
+QAction *QFormBuilder::create(DomAction *ui_action, QObject *parent)
+{
+ return QAbstractFormBuilder::create(ui_action, parent);
+}
+
+/*!
+ \internal
+*/
+QActionGroup *QFormBuilder::create(DomActionGroup *ui_action_group, QObject *parent)
+{
+ return QAbstractFormBuilder::create(ui_action_group, parent);
+}
+
+/*!
+ Returns the list of paths the form builder searches for plugins.
+
+ \sa addPluginPath()
+*/
+QStringList QFormBuilder::pluginPaths() const
+{
+ return m_pluginPaths;
+}
+
+/*!
+ Clears the list of paths that the form builder uses to search for
+ custom widget plugins.
+
+ \sa pluginPaths()
+*/
+void QFormBuilder::clearPluginPaths()
+{
+ m_pluginPaths.clear();
+ updateCustomWidgets();
+}
+
+/*!
+ Adds a new plugin path specified by \a pluginPath to the list of
+ paths that will be searched by the form builder when loading a
+ custom widget plugin.
+
+ \sa setPluginPath(), clearPluginPaths()
+*/
+void QFormBuilder::addPluginPath(const QString &pluginPath)
+{
+ m_pluginPaths.append(pluginPath);
+ updateCustomWidgets();
+}
+
+/*!
+ Sets the list of plugin paths to the list specified by \a pluginPaths.
+
+ \sa addPluginPath()
+*/
+void QFormBuilder::setPluginPath(const QStringList &pluginPaths)
+{
+ m_pluginPaths = pluginPaths;
+ updateCustomWidgets();
+}
+
+static void insertPlugins(QObject *o, QMap<QString, QDesignerCustomWidgetInterface*> *customWidgets)
+{
+ // step 1) try with a normal plugin
+ if (QDesignerCustomWidgetInterface *iface = qobject_cast<QDesignerCustomWidgetInterface *>(o)) {
+ customWidgets->insert(iface->name(), iface);
+ return;
+ }
+ // step 2) try with a collection of plugins
+ if (QDesignerCustomWidgetCollectionInterface *c = qobject_cast<QDesignerCustomWidgetCollectionInterface *>(o)) {
+ foreach (QDesignerCustomWidgetInterface *iface, c->customWidgets())
+ customWidgets->insert(iface->name(), iface);
+ }
+}
+
+/*!
+ \internal
+*/
+void QFormBuilder::updateCustomWidgets()
+{
+ m_customWidgets.clear();
+
+ foreach (const QString &path, m_pluginPaths) {
+ const QDir dir(path);
+ const QStringList candidates = dir.entryList(QDir::Files);
+
+ foreach (const QString &plugin, candidates) {
+ if (!QLibrary::isLibrary(plugin))
+ continue;
+
+ QString loaderPath = path;
+ loaderPath += QLatin1Char('/');
+ loaderPath += plugin;
+
+ QPluginLoader loader(loaderPath);
+ if (loader.load())
+ insertPlugins(loader.instance(), &m_customWidgets);
+ }
+ }
+ // Check statically linked plugins
+ const QObjectList staticPlugins = QPluginLoader::staticInstances();
+ if (!staticPlugins.empty())
+ foreach (QObject *o, staticPlugins)
+ insertPlugins(o, &m_customWidgets);
+}
+
+/*!
+ \fn QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const
+
+ Returns a list of the available plugins.
+*/
+QList<QDesignerCustomWidgetInterface*> QFormBuilder::customWidgets() const
+{
+ return m_customWidgets.values();
+}
+
+/*!
+ \internal
+*/
+
+void QFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties)
+{
+ typedef QList<DomProperty*> DomPropertyList;
+
+ if (properties.empty())
+ return;
+
+ QFormBuilderExtra *fb = QFormBuilderExtra::instance(this);
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+
+ const DomPropertyList::const_iterator cend = properties.constEnd();
+ for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) {
+ const QVariant v = toVariant(o->metaObject(), *it);
+ if (v.isNull())
+ continue;
+
+ const QString attributeName = (*it)->attributeName();
+ const bool isWidget = o->isWidgetType();
+ if (isWidget && o->parent() == fb->parentWidget() && attributeName == strings.geometryProperty) {
+ // apply only the size part of a geometry for the root widget
+ static_cast<QWidget*>(o)->resize(qvariant_cast<QRect>(v).size());
+ } else if (fb->applyPropertyInternally(o, attributeName, v)) {
+ } else if (isWidget && !qstrcmp("QFrame", o->metaObject()->className ()) && attributeName == strings.orientationProperty) {
+ // ### special-casing for Line (QFrame) -- try to fix me
+ o->setProperty("frameShape", v); // v is of QFrame::Shape enum
+ } else {
+ o->setProperty(attributeName.toUtf8(), v);
+ }
+ }
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+} // namespace QFormInternal
+#endif
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/formbuilder.h b/tools/uilib/formbuilder.h
new file mode 100644
index 0000000000..01aeb16a09
--- /dev/null
+++ b/tools/uilib/formbuilder.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FORMBUILDER_H
+#define FORMBUILDER_H
+
+#include <QtDesigner/uilib_global.h>
+#include <QtDesigner/QAbstractFormBuilder>
+
+#include <QtCore/QStringList>
+#include <QtCore/QMap>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+#if 0
+// pragma for syncqt, don't remove.
+
+#pragma qt_class(QFormBuilder)
+#endif
+
+class QDesignerCustomWidgetInterface;
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class QDESIGNER_UILIB_EXPORT QFormBuilder: public QAbstractFormBuilder
+{
+public:
+ QFormBuilder();
+ virtual ~QFormBuilder();
+
+ QStringList pluginPaths() const;
+
+ void clearPluginPaths();
+ void addPluginPath(const QString &pluginPath);
+ void setPluginPath(const QStringList &pluginPaths);
+
+ QList<QDesignerCustomWidgetInterface*> customWidgets() const;
+
+protected:
+ virtual QWidget *create(DomUI *ui, QWidget *parentWidget);
+ virtual QWidget *create(DomWidget *ui_widget, QWidget *parentWidget);
+ virtual QLayout *create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget);
+ virtual QLayoutItem *create(DomLayoutItem *ui_layoutItem, QLayout *layout, QWidget *parentWidget);
+ virtual QAction *create(DomAction *ui_action, QObject *parent);
+ virtual QActionGroup *create(DomActionGroup *ui_action_group, QObject *parent);
+
+ virtual QWidget *createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name);
+ virtual QLayout *createLayout(const QString &layoutName, QObject *parent, const QString &name);
+
+ virtual void createConnections(DomConnections *connections, QWidget *widget);
+
+ virtual bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout);
+ virtual bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget);
+
+ virtual void updateCustomWidgets();
+ virtual void applyProperties(QObject *o, const QList<DomProperty*> &properties);
+
+ static QWidget *widgetByName(QWidget *topLevel, const QString &name);
+
+private:
+ QStringList m_pluginPaths;
+ QMap<QString, QDesignerCustomWidgetInterface*> m_customWidgets;
+};
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // FORMBUILDER_H
diff --git a/tools/uilib/formbuilderextra.cpp b/tools/uilib/formbuilderextra.cpp
new file mode 100644
index 0000000000..ecc62886b9
--- /dev/null
+++ b/tools/uilib/formbuilderextra.cpp
@@ -0,0 +1,555 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "formbuilderextra_p.h"
+#include "abstractformbuilder.h"
+#include "resourcebuilder_p.h"
+#include "textbuilder_p.h"
+#include "ui4_p.h"
+
+#include <QtGui/QLabel>
+#include <QtGui/QBoxLayout>
+#include <QtGui/QGridLayout>
+
+#include <QtCore/QVariant>
+#include <QtCore/qdebug.h>
+#include <QtCore/QTextStream>
+#include <QtCore/QStringList>
+#include <QtCore/QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal {
+#endif
+
+void uiLibWarning(const QString &message) {
+ qWarning("Designer: %s", qPrintable(message));
+}
+
+
+QFormBuilderExtra::CustomWidgetData::CustomWidgetData() :
+ isContainer(false)
+{
+}
+
+QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw) :
+ addPageMethod(dcw->elementAddPageMethod()),
+ baseClass(dcw->elementExtends()),
+ isContainer(dcw->hasElementContainer() && dcw->elementContainer() != 0)
+{
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+ if (const DomScript *domScript = dcw->elementScript())
+ script = domScript->text();
+#endif
+}
+
+QFormBuilderExtra::QFormBuilderExtra() :
+ m_layoutWidget(false),
+ m_resourceBuilder(0),
+ m_textBuilder(0)
+{
+}
+
+QFormBuilderExtra::~QFormBuilderExtra()
+{
+ clearResourceBuilder();
+ clearTextBuilder();
+}
+
+void QFormBuilderExtra::clear()
+{
+ m_buddies.clear();
+ m_parentWidget = 0;
+ m_parentWidgetIsSet = false;
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+ m_FormScriptRunner.clearErrors();
+#endif
+ m_customWidgetDataHash.clear();
+ m_buttonGroups.clear();
+}
+
+
+bool QFormBuilderExtra::applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value)
+{
+ // Store buddies and apply them later on as the widgets might not exist yet.
+ QLabel *label = qobject_cast<QLabel*>(o);
+ if (!label || propertyName != QFormBuilderStrings::instance().buddyProperty)
+ return false;
+
+ m_buddies.insert(label, value.toString());
+ return true;
+}
+
+void QFormBuilderExtra::applyInternalProperties() const
+{
+ if (m_buddies.empty())
+ return;
+
+ const BuddyHash::const_iterator cend = m_buddies.constEnd();
+ for (BuddyHash::const_iterator it = m_buddies.constBegin(); it != cend; ++it )
+ applyBuddy(it.value(), BuddyApplyAll, it.key());
+}
+
+bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label)
+{
+ if (buddyName.isEmpty()) {
+ label->setBuddy(0);
+ return false;
+ }
+
+ const QWidgetList widgets = label->topLevelWidget()->findChildren<QWidget*>(buddyName);
+ if (widgets.empty()) {
+ label->setBuddy(0);
+ return false;
+ }
+
+ const QWidgetList::const_iterator cend = widgets.constEnd();
+ for ( QWidgetList::const_iterator it = widgets.constBegin(); it != cend; ++it) {
+ if (applyMode == BuddyApplyAll || !(*it)->isHidden()) {
+ label->setBuddy(*it);
+ return true;
+ }
+ }
+
+ label->setBuddy(0);
+ return false;
+}
+
+const QPointer<QWidget> &QFormBuilderExtra::parentWidget() const
+{
+ return m_parentWidget;
+}
+
+bool QFormBuilderExtra::parentWidgetIsSet() const
+{
+ return m_parentWidgetIsSet;
+}
+
+void QFormBuilderExtra::setParentWidget(const QPointer<QWidget> &w)
+{
+ // Parent widget requires special handling of the geometry property.
+ m_parentWidget = w;
+ m_parentWidgetIsSet = true;
+}
+
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+QFormScriptRunner &QFormBuilderExtra::formScriptRunner()
+{
+ return m_FormScriptRunner;
+}
+
+QString QFormBuilderExtra::customWidgetScript(const QString &className) const
+{
+ const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
+ if (it != m_customWidgetDataHash.constEnd())
+ return it.value().script;
+ return QString();
+}
+
+#endif
+
+void QFormBuilderExtra::storeCustomWidgetData(const QString &className, const DomCustomWidget *d)
+{
+ if (d)
+ m_customWidgetDataHash.insert(className, CustomWidgetData(d));
+}
+
+QString QFormBuilderExtra::customWidgetBaseClass(const QString &className) const
+{
+ const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
+ if (it != m_customWidgetDataHash.constEnd())
+ return it.value().baseClass;
+ return QString();
+}
+
+QString QFormBuilderExtra::customWidgetAddPageMethod(const QString &className) const
+{
+ const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
+ if (it != m_customWidgetDataHash.constEnd())
+ return it.value().addPageMethod;
+ return QString();
+}
+
+bool QFormBuilderExtra::isCustomWidgetContainer(const QString &className) const
+{
+ const QHash<QString, CustomWidgetData>::const_iterator it = m_customWidgetDataHash.constFind(className);
+ if (it != m_customWidgetDataHash.constEnd())
+ return it.value().isContainer;
+ return false;
+}
+
+namespace {
+ typedef QHash<const QAbstractFormBuilder *, QFormBuilderExtra *> FormBuilderPrivateHash;
+}
+
+Q_GLOBAL_STATIC(FormBuilderPrivateHash, g_FormBuilderPrivateHash)
+
+QFormBuilderExtra *QFormBuilderExtra::instance(const QAbstractFormBuilder *afb)
+{
+ FormBuilderPrivateHash &fbHash = *g_FormBuilderPrivateHash();
+
+ FormBuilderPrivateHash::iterator it = fbHash.find(afb);
+ if (it == fbHash.end())
+ it = fbHash.insert(afb, new QFormBuilderExtra);
+ return it.value();
+}
+
+void QFormBuilderExtra::removeInstance(const QAbstractFormBuilder *afb)
+{
+ FormBuilderPrivateHash &fbHash = *g_FormBuilderPrivateHash();
+
+ FormBuilderPrivateHash::iterator it = fbHash.find(afb);
+ if (it != fbHash.end()) {
+ delete it.value();
+ fbHash.erase(it);
+ }
+}
+
+void QFormBuilderExtra::setProcessingLayoutWidget(bool processing)
+{
+ m_layoutWidget = processing;
+}
+
+ bool QFormBuilderExtra::processingLayoutWidget() const
+{
+ return m_layoutWidget;
+}
+void QFormBuilderExtra::setResourceBuilder(QResourceBuilder *builder)
+{
+ if (m_resourceBuilder == builder)
+ return;
+ clearResourceBuilder();
+ m_resourceBuilder = builder;
+}
+
+QResourceBuilder *QFormBuilderExtra::resourceBuilder() const
+{
+ return m_resourceBuilder;
+}
+
+void QFormBuilderExtra::clearResourceBuilder()
+{
+ if (m_resourceBuilder) {
+ delete m_resourceBuilder;
+ m_resourceBuilder = 0;
+ }
+}
+
+void QFormBuilderExtra::setTextBuilder(QTextBuilder *builder)
+{
+ if (m_textBuilder == builder)
+ return;
+ clearTextBuilder();
+ m_textBuilder = builder;
+}
+
+QTextBuilder *QFormBuilderExtra::textBuilder() const
+{
+ return m_textBuilder;
+}
+
+void QFormBuilderExtra::clearTextBuilder()
+{
+ if (m_textBuilder) {
+ delete m_textBuilder;
+ m_textBuilder = 0;
+ }
+}
+
+void QFormBuilderExtra::registerButtonGroups(const DomButtonGroups *domGroups)
+{
+ typedef QList<DomButtonGroup*> DomButtonGroupList;
+ const DomButtonGroupList domGroupList = domGroups->elementButtonGroup();
+ const DomButtonGroupList::const_iterator cend = domGroupList.constEnd();
+ for (DomButtonGroupList::const_iterator it = domGroupList.constBegin(); it != cend; ++it) {
+ DomButtonGroup *domGroup = *it;
+ m_buttonGroups.insert(domGroup->attributeName(), ButtonGroupEntry(domGroup, 0));
+ }
+}
+
+// Utilities for parsing per-cell integer properties that have setters and
+// getters of the form 'setX(int idx, int value)' and 'x(int index)'
+// (converting them to comma-separated string lists and back).
+// Used for layout stretch and grid per-row/column properties.
+
+// Format a list of cell-properties of one dimension as a ','-separated list
+template <class Layout>
+inline QString perCellPropertyToString(const Layout *l, int count, int (Layout::*getter)(int) const)
+{
+ if (count == 0)
+ return QString();
+ QString rc;
+ {
+ QTextStream str(&rc);
+ for (int i = 0; i < count; i++) {
+ if (i)
+ str << QLatin1Char(',');
+ str << (l->*getter)(i);
+ }
+ }
+ return rc;
+}
+
+// Clear the property, set all cells to 0
+
+template <class Layout>
+inline void clearPerCellValue(Layout *l, int count, void (Layout::*setter)(int,int), int value = 0)
+{
+ for (int i = 0; i < count; i++)
+ (l->*setter)(i, value);
+}
+
+// Parse and set the property from a comma-separated list
+
+template <class Layout>
+inline bool parsePerCellProperty(Layout *l, int count, void (Layout::*setter)(int,int), const QString &s, int defaultValue = 0)
+{
+ if (s.isEmpty()) {
+ clearPerCellValue(l, count, setter, defaultValue);
+ return true;
+ }
+ const QStringList list = s.split(QLatin1Char(','));
+ if (list.empty()) {
+ clearPerCellValue(l, count, setter, defaultValue);
+ return true;
+ }
+ // Apply all values contained in list
+ const int ac = qMin(count, list.size());
+ bool ok;
+ int i = 0;
+ for ( ; i < ac; i++) {
+ const int value = list.at(i).toInt(&ok);
+ if (!ok || value < 0)
+ return false;
+ (l->*setter)(i, value);
+ }
+ // Clear rest
+ for ( ; i < count; i++)
+ (l->*setter)(i, defaultValue);
+ return true;
+}
+
+// Read and write stretch
+static QString msgInvalidStretch(const QString &objectName, const QString &stretch)
+{
+ //: Parsing layout stretch values
+ return QCoreApplication::translate("FormBuilder", "Invalid stretch value for '%1': '%2'").arg(objectName, stretch);
+}
+
+QString QFormBuilderExtra::boxLayoutStretch(const QBoxLayout *box)
+{
+ return perCellPropertyToString(box, box->count(), &QBoxLayout::stretch);
+}
+
+bool QFormBuilderExtra::setBoxLayoutStretch(const QString &s, QBoxLayout *box)
+{
+ const bool rc = parsePerCellProperty(box, box->count(), &QBoxLayout::setStretch, s);
+ if (!rc)
+ uiLibWarning(msgInvalidStretch(box->objectName(), s));
+ return rc;
+}
+
+void QFormBuilderExtra::clearBoxLayoutStretch(QBoxLayout *box)
+{
+ clearPerCellValue(box, box->count(), &QBoxLayout::setStretch);
+}
+
+QString QFormBuilderExtra::gridLayoutRowStretch(const QGridLayout *grid)
+{
+ return perCellPropertyToString(grid, grid->rowCount(), &QGridLayout::rowStretch);
+}
+
+bool QFormBuilderExtra::setGridLayoutRowStretch(const QString &s, QGridLayout *grid)
+{
+ const bool rc = parsePerCellProperty(grid, grid->rowCount(), &QGridLayout::setRowStretch, s);
+ if (!rc)
+ uiLibWarning(msgInvalidStretch(grid->objectName(), s));
+ return rc;
+}
+
+void QFormBuilderExtra::clearGridLayoutRowStretch(QGridLayout *grid)
+{
+ clearPerCellValue(grid, grid->rowCount(), &QGridLayout::setRowStretch);
+}
+
+QString QFormBuilderExtra::gridLayoutColumnStretch(const QGridLayout *grid)
+{
+ return perCellPropertyToString(grid, grid->columnCount(), &QGridLayout::columnStretch);
+}
+
+bool QFormBuilderExtra::setGridLayoutColumnStretch(const QString &s, QGridLayout *grid)
+{
+ const bool rc = parsePerCellProperty(grid, grid->columnCount(), &QGridLayout::setColumnStretch, s);
+ if (!rc)
+ uiLibWarning(msgInvalidStretch(grid->objectName(), s));
+ return rc;
+}
+
+void QFormBuilderExtra::clearGridLayoutColumnStretch(QGridLayout *grid)
+{
+ clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnStretch);
+}
+
+// Read and write grid layout row/column size limits
+
+static QString msgInvalidMinimumSize(const QString &objectName, const QString &ms)
+{
+ //: Parsing grid layout minimum size values
+ return QCoreApplication::translate("FormBuilder", "Invalid minimum size for '%1': '%2'").arg(objectName, ms);
+}
+
+QString QFormBuilderExtra::gridLayoutRowMinimumHeight(const QGridLayout *grid)
+{
+ return perCellPropertyToString(grid, grid->rowCount(), &QGridLayout::rowMinimumHeight);
+}
+
+bool QFormBuilderExtra::setGridLayoutRowMinimumHeight(const QString &s, QGridLayout *grid)
+{
+ const bool rc = parsePerCellProperty(grid, grid->rowCount(), &QGridLayout::setRowMinimumHeight, s);
+ if (!rc)
+ uiLibWarning(msgInvalidMinimumSize(grid->objectName(), s));
+ return rc;
+}
+
+void QFormBuilderExtra::clearGridLayoutRowMinimumHeight(QGridLayout *grid)
+{
+ clearPerCellValue(grid, grid->rowCount(), &QGridLayout::setRowMinimumHeight);
+}
+
+QString QFormBuilderExtra::gridLayoutColumnMinimumWidth(const QGridLayout *grid)
+{
+ return perCellPropertyToString(grid, grid->columnCount(), &QGridLayout::columnMinimumWidth);
+}
+
+bool QFormBuilderExtra::setGridLayoutColumnMinimumWidth(const QString &s, QGridLayout *grid)
+{
+ const bool rc = parsePerCellProperty(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth, s);
+ if (!rc)
+ uiLibWarning(msgInvalidMinimumSize(grid->objectName(), s));
+ return rc;
+}
+
+void QFormBuilderExtra::clearGridLayoutColumnMinimumWidth(QGridLayout *grid)
+{
+ clearPerCellValue(grid, grid->columnCount(), &QGridLayout::setColumnMinimumWidth);
+}
+
+// ------------ QFormBuilderStrings
+
+QFormBuilderStrings::QFormBuilderStrings() :
+ buddyProperty(QLatin1String("buddy")),
+ cursorProperty(QLatin1String("cursor")),
+ objectNameProperty(QLatin1String("objectName")),
+ trueValue(QLatin1String("true")),
+ falseValue(QLatin1String("false")),
+ horizontalPostFix(QLatin1String("Horizontal")),
+ separator(QLatin1String("separator")),
+ defaultTitle(QLatin1String("Page")),
+ titleAttribute(QLatin1String("title")),
+ labelAttribute(QLatin1String("label")),
+ toolTipAttribute(QLatin1String("toolTip")),
+ whatsThisAttribute(QLatin1String("whatsThis")),
+ flagsAttribute(QLatin1String("flags")),
+ iconAttribute(QLatin1String("icon")),
+ pixmapAttribute(QLatin1String("pixmap")),
+ textAttribute(QLatin1String("text")),
+ currentIndexProperty(QLatin1String("currentIndex")),
+ toolBarAreaAttribute(QLatin1String("toolBarArea")),
+ toolBarBreakAttribute(QLatin1String("toolBarBreak")),
+ dockWidgetAreaAttribute(QLatin1String("dockWidgetArea")),
+ marginProperty(QLatin1String("margin")),
+ spacingProperty(QLatin1String("spacing")),
+ leftMarginProperty(QLatin1String("leftMargin")),
+ topMarginProperty(QLatin1String("topMargin")),
+ rightMarginProperty(QLatin1String("rightMargin")),
+ bottomMarginProperty(QLatin1String("bottomMargin")),
+ horizontalSpacingProperty(QLatin1String("horizontalSpacing")),
+ verticalSpacingProperty(QLatin1String("verticalSpacing")),
+ sizeHintProperty(QLatin1String("sizeHint")),
+ sizeTypeProperty(QLatin1String("sizeType")),
+ orientationProperty(QLatin1String("orientation")),
+ styleSheetProperty(QLatin1String("styleSheet")),
+ qtHorizontal(QLatin1String("Qt::Horizontal")),
+ qtVertical(QLatin1String("Qt::Vertical")),
+ currentRowProperty(QLatin1String("currentRow")),
+ tabSpacingProperty(QLatin1String("tabSpacing")),
+ qWidgetClass(QLatin1String("QWidget")),
+ lineClass(QLatin1String("Line")),
+ geometryProperty(QLatin1String("geometry")),
+ scriptWidgetVariable(QLatin1String("widget")),
+ scriptChildWidgetsVariable(QLatin1String("childWidgets"))
+{
+ itemRoles.append(qMakePair(Qt::FontRole, QString::fromLatin1("font")));
+ itemRoles.append(qMakePair(Qt::TextAlignmentRole, QString::fromLatin1("textAlignment")));
+ itemRoles.append(qMakePair(Qt::BackgroundRole, QString::fromLatin1("background")));
+ itemRoles.append(qMakePair(Qt::ForegroundRole, QString::fromLatin1("foreground")));
+ itemRoles.append(qMakePair(Qt::CheckStateRole, QString::fromLatin1("checkState")));
+
+ foreach (const RoleNName &it, itemRoles)
+ treeItemRoleHash.insert(it.second, it.first);
+
+ itemTextRoles.append(qMakePair(qMakePair(Qt::EditRole, Qt::DisplayPropertyRole),
+ textAttribute)); // This must be first for the loop below
+ itemTextRoles.append(qMakePair(qMakePair(Qt::ToolTipRole, Qt::ToolTipPropertyRole),
+ toolTipAttribute));
+ itemTextRoles.append(qMakePair(qMakePair(Qt::StatusTipRole, Qt::StatusTipPropertyRole),
+ QString::fromLatin1("statusTip")));
+ itemTextRoles.append(qMakePair(qMakePair(Qt::WhatsThisRole, Qt::WhatsThisPropertyRole),
+ whatsThisAttribute));
+
+ // Note: this skips the first item!
+ QList<TextRoleNName>::const_iterator it = itemTextRoles.constBegin(), end = itemTextRoles.constEnd();
+ while (++it != end)
+ treeItemTextRoleHash.insert(it->second, it->first);
+}
+
+const QFormBuilderStrings &QFormBuilderStrings::instance()
+{
+ static const QFormBuilderStrings rc;
+ return rc;
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+} // namespace QFormInternal
+#endif
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/formbuilderextra_p.h b/tools/uilib/formbuilderextra_p.h
new file mode 100644
index 0000000000..cac882b8d8
--- /dev/null
+++ b/tools/uilib/formbuilderextra_p.h
@@ -0,0 +1,262 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTFORMBUILDERPRIVATE_H
+#define ABSTRACTFORMBUILDERPRIVATE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "uilib_global.h"
+
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+# include "formscriptrunner_p.h"
+#endif
+
+#include <QtCore/QHash>
+#include <QtCore/QPointer>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class QObject;
+class QVariant;
+class QWidget;
+class QObject;
+class QLabel;
+class QButtonGroup;
+
+class QBoxLayout;
+class QGridLayout;
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class DomButtonGroups;
+class DomButtonGroup;
+class DomCustomWidget;
+
+class QAbstractFormBuilder;
+class QResourceBuilder;
+class QTextBuilder;
+
+class QDESIGNER_UILIB_EXPORT QFormBuilderExtra
+{
+ QFormBuilderExtra();
+ ~QFormBuilderExtra();
+public:
+ struct CustomWidgetData {
+ CustomWidgetData();
+ explicit CustomWidgetData(const DomCustomWidget *dc);
+
+ QString addPageMethod;
+ QString script;
+ QString baseClass;
+ bool isContainer;
+ };
+
+ void clear();
+
+ bool applyPropertyInternally(QObject *o, const QString &propertyName, const QVariant &value);
+
+ enum BuddyMode { BuddyApplyAll, BuddyApplyVisibleOnly };
+
+ void applyInternalProperties() const;
+ static bool applyBuddy(const QString &buddyName, BuddyMode applyMode, QLabel *label);
+
+ const QPointer<QWidget> &parentWidget() const;
+ bool parentWidgetIsSet() const;
+ void setParentWidget(const QPointer<QWidget> &w);
+
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+ QFormScriptRunner &formScriptRunner();
+ QString customWidgetScript(const QString &className) const;
+#endif
+
+ void setProcessingLayoutWidget(bool processing);
+ bool processingLayoutWidget() const;
+
+ void setResourceBuilder(QResourceBuilder *builder);
+ QResourceBuilder *resourceBuilder() const;
+
+ void setTextBuilder(QTextBuilder *builder);
+ QTextBuilder *textBuilder() const;
+
+ static QFormBuilderExtra *instance(const QAbstractFormBuilder *afb);
+ static void removeInstance(const QAbstractFormBuilder *afb);
+
+ void storeCustomWidgetData(const QString &className, const DomCustomWidget *d);
+ QString customWidgetAddPageMethod(const QString &className) const;
+ QString customWidgetBaseClass(const QString &className) const;
+ bool isCustomWidgetContainer(const QString &className) const;
+
+ // --- Hash used in creating button groups on demand. Store a map of name and pair of dom group and real group
+ void registerButtonGroups(const DomButtonGroups *groups);
+
+ typedef QPair<DomButtonGroup *, QButtonGroup*> ButtonGroupEntry;
+ typedef QHash<QString, ButtonGroupEntry> ButtonGroupHash;
+ const ButtonGroupHash &buttonGroups() const { return m_buttonGroups; }
+ ButtonGroupHash &buttonGroups() { return m_buttonGroups; }
+
+ // return stretch as a comma-separated list
+ static QString boxLayoutStretch(const QBoxLayout*);
+ // apply stretch
+ static bool setBoxLayoutStretch(const QString &, QBoxLayout*);
+ static void clearBoxLayoutStretch(QBoxLayout*);
+
+ static QString gridLayoutRowStretch(const QGridLayout *);
+ static bool setGridLayoutRowStretch(const QString &, QGridLayout *);
+ static void clearGridLayoutRowStretch(QGridLayout *);
+
+ static QString gridLayoutColumnStretch(const QGridLayout *);
+ static bool setGridLayoutColumnStretch(const QString &, QGridLayout *);
+ static void clearGridLayoutColumnStretch(QGridLayout *);
+
+ // return the row/column sizes as comma-separated lists
+ static QString gridLayoutRowMinimumHeight(const QGridLayout *);
+ static bool setGridLayoutRowMinimumHeight(const QString &, QGridLayout *);
+ static void clearGridLayoutRowMinimumHeight(QGridLayout *);
+
+ static QString gridLayoutColumnMinimumWidth(const QGridLayout *);
+ static bool setGridLayoutColumnMinimumWidth(const QString &, QGridLayout *);
+ static void clearGridLayoutColumnMinimumWidth(QGridLayout *);
+
+private:
+ void clearResourceBuilder();
+ void clearTextBuilder();
+
+ typedef QHash<QLabel*, QString> BuddyHash;
+ BuddyHash m_buddies;
+
+#ifndef QT_FORMBUILDER_NO_SCRIPT
+ QFormScriptRunner m_FormScriptRunner;
+#endif
+
+ QHash<QString, CustomWidgetData> m_customWidgetDataHash;
+
+ ButtonGroupHash m_buttonGroups;
+
+ bool m_layoutWidget;
+ QResourceBuilder *m_resourceBuilder;
+ QTextBuilder *m_textBuilder;
+
+ QPointer<QWidget> m_parentWidget;
+ bool m_parentWidgetIsSet;
+};
+
+void uiLibWarning(const QString &message);
+
+// Struct with static accessor that provides most strings used in the form builder.
+struct QDESIGNER_UILIB_EXPORT QFormBuilderStrings {
+ QFormBuilderStrings();
+
+ static const QFormBuilderStrings &instance();
+
+ const QString buddyProperty;
+ const QString cursorProperty;
+ const QString objectNameProperty;
+ const QString trueValue;
+ const QString falseValue;
+ const QString horizontalPostFix;
+ const QString separator;
+ const QString defaultTitle;
+ const QString titleAttribute;
+ const QString labelAttribute;
+ const QString toolTipAttribute;
+ const QString whatsThisAttribute;
+ const QString flagsAttribute;
+ const QString iconAttribute;
+ const QString pixmapAttribute;
+ const QString textAttribute;
+ const QString currentIndexProperty;
+ const QString toolBarAreaAttribute;
+ const QString toolBarBreakAttribute;
+ const QString dockWidgetAreaAttribute;
+ const QString marginProperty;
+ const QString spacingProperty;
+ const QString leftMarginProperty;
+ const QString topMarginProperty;
+ const QString rightMarginProperty;
+ const QString bottomMarginProperty;
+ const QString horizontalSpacingProperty;
+ const QString verticalSpacingProperty;
+ const QString sizeHintProperty;
+ const QString sizeTypeProperty;
+ const QString orientationProperty;
+ const QString styleSheetProperty;
+ const QString qtHorizontal;
+ const QString qtVertical;
+ const QString currentRowProperty;
+ const QString tabSpacingProperty;
+ const QString qWidgetClass;
+ const QString lineClass;
+ const QString geometryProperty;
+ const QString scriptWidgetVariable;
+ const QString scriptChildWidgetsVariable;
+
+ typedef QPair<Qt::ItemDataRole, QString> RoleNName;
+ QList<RoleNName> itemRoles;
+ QHash<QString, Qt::ItemDataRole> treeItemRoleHash;
+
+ // first.first is primary role, first.second is shadow role.
+ // Shadow is used for either the translation source or the designer
+ // representation of the string value.
+ typedef QPair<QPair<Qt::ItemDataRole, Qt::ItemDataRole>, QString> TextRoleNName;
+ QList<TextRoleNName> itemTextRoles;
+ QHash<QString, QPair<Qt::ItemDataRole, Qt::ItemDataRole> > treeItemTextRoleHash;
+};
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // ABSTRACTFORMBUILDERPRIVATE_H
diff --git a/tools/uilib/formscriptrunner.cpp b/tools/uilib/formscriptrunner.cpp
new file mode 100644
index 0000000000..e349f6b318
--- /dev/null
+++ b/tools/uilib/formscriptrunner.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "formscriptrunner_p.h"
+#include "formbuilderextra_p.h"
+#include "ui4_p.h"
+
+#include <QtScript/QScriptEngine>
+#include <QtGui/QWidget>
+#include <QtCore/QDebug>
+#include <QtCore/QCoreApplication>
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+ enum { debugFormScriptRunner = 0 };
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal {
+#endif
+
+class QFormScriptRunner::QFormScriptRunnerPrivate {
+public:
+ QFormScriptRunnerPrivate() : m_options(DisableScripts) {}
+ void clearErrors() { m_errors.clear(); }
+
+ bool run(const QString &script, QWidget *widget, const WidgetList &children, QString *errorMessage);
+
+ static void initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine);
+ static QString engineError(QScriptEngine &scriptEngine);
+
+ Options options() const { return m_options; }
+ void setOptions(Options options) { m_options = options; }
+
+ Errors errors() const { return m_errors; }
+private:
+ QScriptEngine m_scriptEngine;
+ Options m_options;
+ Errors m_errors;
+};
+
+bool QFormScriptRunner::QFormScriptRunnerPrivate::run(const QString &script, QWidget *widget, const WidgetList &children, QString *errorMessage) {
+ bool rc = false;
+ initializeEngine(widget, children, m_scriptEngine);
+
+ do {
+ m_scriptEngine.evaluate(script);
+ if (m_scriptEngine.hasUncaughtException ()) {
+ *errorMessage = QCoreApplication::tr("Exception at line %1: %2").arg(m_scriptEngine.uncaughtExceptionLineNumber()).arg(engineError(m_scriptEngine));
+ break;
+ }
+ rc = true;
+ } while (false);
+ m_scriptEngine.popContext();
+
+ if (!rc) {
+ Error error;
+ error.objectName = widget->objectName();
+ error.script = script;
+ error.errorMessage = *errorMessage;
+ m_errors.push_back(error);
+ }
+ return rc;
+}
+
+void QFormScriptRunner::QFormScriptRunnerPrivate::initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine) {
+ // Populate the script variables. This pushes a context which must be popped.
+ QScriptContext *ctx = scriptEngine.pushContext();
+ QScriptValue widgetObject = scriptEngine.newQObject(w);
+ QScriptValue childrenArray = scriptEngine.newArray (children.size());
+
+ for(int i = 0; i < children.size(); i++) {
+ childrenArray.setProperty(i, scriptEngine.newQObject(children[i]));
+ }
+
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ ctx ->activationObject().setProperty(strings.scriptWidgetVariable, widgetObject);
+ ctx ->activationObject().setProperty(strings.scriptChildWidgetsVariable, childrenArray);
+}
+
+QString QFormScriptRunner::QFormScriptRunnerPrivate::engineError(QScriptEngine &scriptEngine) {
+ QScriptValue error = scriptEngine.evaluate(QLatin1String("Error"));
+ if (error.isValid())
+ return error.toString();
+ return QCoreApplication::tr("Unknown error");
+}
+// -- QFormScriptRunner
+
+QFormScriptRunner::QFormScriptRunner() : m_impl(new QFormScriptRunnerPrivate)
+{
+}
+
+QFormScriptRunner::~QFormScriptRunner()
+{
+ delete m_impl;
+}
+
+bool QFormScriptRunner::run(const DomWidget *domWidget,
+ const QString &customWidgetScript,
+ QWidget *widget, const WidgetList &children,
+ QString *errorMessage)
+{
+ typedef QList<DomScript*> DomScripts;
+
+ const Options scriptOptions = m_impl->options();
+ if (scriptOptions & DisableScripts)
+ return true;
+ // get list
+ const DomScripts domScripts = domWidget->elementScript();
+ // Concatenate snippets, starting with custom widget script
+ QString script = customWidgetScript;
+ if (script.isEmpty() && domScripts.empty())
+ return true;
+
+ foreach (const DomScript *scriptSnippet, domScripts) {
+ // Ensure new line
+ if (!script.isEmpty() && !script.endsWith(QLatin1Char('\n')))
+ script += QLatin1Char('\n');
+ script += scriptSnippet->text();
+ }
+
+ if (script.isEmpty())
+ return true;
+
+ const bool rc = m_impl->run(script, widget, children, errorMessage);
+
+ if (debugFormScriptRunner) {
+ qDebug() << "For " << widget << " with " << children.size() << " children, ran: " << script;
+ if (!rc)
+ qDebug() << *errorMessage;
+ }
+
+ if (!rc) {
+ if (!(scriptOptions & DisableWarnings)) {
+ const QString message = QCoreApplication::tr("An error occurred while running the script for %1: %2\nScript: %3").
+ arg(widget->objectName()).arg(*errorMessage).arg(script);
+ qWarning() << message;
+ }
+ }
+ return rc;
+}
+
+QFormScriptRunner::Options QFormScriptRunner::options() const
+{
+ return m_impl->options();
+}
+
+void QFormScriptRunner::setOptions(Options options)
+{
+ m_impl->setOptions(options);
+}
+
+
+QFormScriptRunner::Errors QFormScriptRunner::errors() const
+{
+ return m_impl->errors();
+}
+
+void QFormScriptRunner::clearErrors()
+{
+ m_impl->clearErrors();
+}
+
+
+#ifdef QFORMINTERNAL_NAMESPACE
+} // namespace QFormInternal
+#endif
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/formscriptrunner_p.h b/tools/uilib/formscriptrunner_p.h
new file mode 100644
index 0000000000..117b4e88ee
--- /dev/null
+++ b/tools/uilib/formscriptrunner_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FORMSCRIPTRUNNER_H
+#define FORMSCRIPTRUNNER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDesigner/uilib_global.h>
+#include <QtCore/QList>
+#include <QtCore/QFlags>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class QWidget;
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class DomWidget;
+
+class QDESIGNER_UILIB_EXPORT QFormScriptRunner
+{
+public:
+ QFormScriptRunner();
+ ~QFormScriptRunner();
+
+ typedef QList<QWidget*> WidgetList;
+
+ bool run(const DomWidget *domWidget,
+ const QString &customWidgetScript,
+ QWidget *widget, const WidgetList &children,
+ QString *errorMessage);
+
+ struct Error {
+ QString objectName;
+ QString script;
+ QString errorMessage;
+ };
+ typedef QList<Error> Errors;
+ Errors errors() const;
+ void clearErrors();
+
+ enum Option {
+ NoOptions = 0x0,
+ DisableWarnings = 0x1,
+ DisableScripts = 02
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ Options options() const;
+ void setOptions(Options options);
+
+private:
+ class QFormScriptRunnerPrivate;
+ QFormScriptRunnerPrivate *m_impl;
+
+ QFormScriptRunner(const QFormScriptRunner &);
+ void operator = (const QFormScriptRunner &);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFormScriptRunner::Options)
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // FORMSCRIPTRUNNER_H
diff --git a/tools/uilib/properties.cpp b/tools/uilib/properties.cpp
new file mode 100644
index 0000000000..67f4d11d22
--- /dev/null
+++ b/tools/uilib/properties.cpp
@@ -0,0 +1,681 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "properties_p.h"
+#include "ui4_p.h"
+#include "abstractformbuilder.h"
+#include "formbuilderextra_p.h"
+#include "resourcebuilder_p.h"
+
+#include <QtCore/QDateTime>
+#include <QtCore/QUrl>
+#include <QtCore/qdebug.h>
+
+#include <QtGui/QIcon>
+#include <QtGui/QPixmap>
+#include <QtGui/QFont>
+#include <QtGui/QFrame>
+#include <QtGui/QAbstractScrollArea>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+static inline void fixEnum(QString &s)
+{
+ int qualifierIndex = s.lastIndexOf(QLatin1Char(':'));
+ if (qualifierIndex == -1)
+ qualifierIndex = s.lastIndexOf(QLatin1Char('.'));
+ if (qualifierIndex != -1)
+ s.remove(0, qualifierIndex + 1);
+}
+// Convert complex DOM types with the help of QAbstractFormBuilder
+QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta,const DomProperty *p)
+{
+ // Complex types that need functions from QAbstractFormBuilder
+ switch(p->kind()) {
+ case DomProperty::String: {
+ const int index = meta->indexOfProperty(p->attributeName().toUtf8());
+ if (index != -1 && meta->property(index).type() == QVariant::KeySequence)
+ return QVariant::fromValue(QKeySequence(p->elementString()->text()));
+ }
+ break;
+
+ case DomProperty::Palette: {
+ const DomPalette *dom = p->elementPalette();
+ QPalette palette;
+
+ if (dom->elementActive())
+ afb->setupColorGroup(palette, QPalette::Active, dom->elementActive());
+
+ if (dom->elementInactive())
+ afb->setupColorGroup(palette, QPalette::Inactive, dom->elementInactive());
+
+ if (dom->elementDisabled())
+ afb->setupColorGroup(palette, QPalette::Disabled, dom->elementDisabled());
+
+ palette.setCurrentColorGroup(QPalette::Active);
+ return QVariant::fromValue(palette);
+ }
+
+ case DomProperty::Set: {
+ const QByteArray pname = p->attributeName().toUtf8();
+ const int index = meta->indexOfProperty(pname);
+ if (index == -1) {
+ uiLibWarning(QCoreApplication::translate("QFormBuilder", "The set-type property %1 could not be read.").arg(p->attributeName()));
+ return QVariant();
+ }
+
+ const QMetaEnum e = meta->property(index).enumerator();
+ Q_ASSERT(e.isFlag() == true);
+ return QVariant(e.keysToValue(p->elementSet().toUtf8()));
+ }
+
+ case DomProperty::Enum: {
+ const QByteArray pname = p->attributeName().toUtf8();
+ const int index = meta->indexOfProperty(pname);
+ QString enumValue = p->elementEnum();
+ // Triggers in case of objects in Designer like Spacer/Line for which properties
+ // are serialized using language introspection. On preview, however, these objects are
+ // emulated by hacks in the formbuilder (size policy/orientation)
+ fixEnum(enumValue);
+ if (index == -1) {
+ // ### special-casing for Line (QFrame) -- fix for 4.2. Jambi hack for enumerations
+ if (!qstrcmp(meta->className(), "QFrame")
+ && (pname == QByteArray("orientation"))) {
+ return QVariant(enumValue == QFormBuilderStrings::instance().horizontalPostFix ? QFrame::HLine : QFrame::VLine);
+ } else {
+ uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-type property %1 could not be read.").arg(p->attributeName()));
+ return QVariant();
+ }
+ }
+
+ const QMetaEnum e = meta->property(index).enumerator();
+ return QVariant(e.keyToValue(enumValue.toUtf8()));
+ }
+ case DomProperty::Brush:
+ return QVariant::fromValue(afb->setupBrush(p->elementBrush()));
+ default:
+ if (afb->resourceBuilder()->isResourceProperty(p)) {
+ return afb->resourceBuilder()->loadResource(afb->workingDirectory(), p);
+ }
+
+ break;
+ }
+
+ // simple type
+ return domPropertyToVariant(p);
+}
+
+// Convert simple DOM types
+QVariant domPropertyToVariant(const DomProperty *p)
+{
+ // requires non-const virtual nameToIcon, etc.
+ switch(p->kind()) {
+ case DomProperty::Bool:
+ return QVariant(p->elementBool() == QFormBuilderStrings::instance().trueValue);
+
+ case DomProperty::Cstring:
+ return QVariant(p->elementCstring().toUtf8());
+
+ case DomProperty::Point: {
+ const DomPoint *point = p->elementPoint();
+ return QVariant(QPoint(point->elementX(), point->elementY()));
+ }
+
+ case DomProperty::PointF: {
+ const DomPointF *pointf = p->elementPointF();
+ return QVariant(QPointF(pointf->elementX(), pointf->elementY()));
+ }
+
+ case DomProperty::Size: {
+ const DomSize *size = p->elementSize();
+ return QVariant(QSize(size->elementWidth(), size->elementHeight()));
+ }
+
+ case DomProperty::SizeF: {
+ const DomSizeF *sizef = p->elementSizeF();
+ return QVariant(QSizeF(sizef->elementWidth(), sizef->elementHeight()));
+ }
+
+ case DomProperty::Rect: {
+ const DomRect *rc = p->elementRect();
+ const QRect g(rc->elementX(), rc->elementY(), rc->elementWidth(), rc->elementHeight());
+ return QVariant(g);
+ }
+
+ case DomProperty::RectF: {
+ const DomRectF *rcf = p->elementRectF();
+ const QRectF g(rcf->elementX(), rcf->elementY(), rcf->elementWidth(), rcf->elementHeight());
+ return QVariant(g);
+ }
+
+ case DomProperty::String:
+ return QVariant(p->elementString()->text());
+
+ case DomProperty::Number:
+ return QVariant(p->elementNumber());
+
+ case DomProperty::UInt:
+ return QVariant(p->elementUInt());
+
+ case DomProperty::LongLong:
+ return QVariant(p->elementLongLong());
+
+ case DomProperty::ULongLong:
+ return QVariant(p->elementULongLong());
+
+ case DomProperty::Double:
+ return QVariant(p->elementDouble());
+
+ case DomProperty::Char: {
+ const DomChar *character = p->elementChar();
+ const QChar c(character->elementUnicode());
+ return QVariant::fromValue(c);
+ }
+
+ case DomProperty::Color: {
+ const DomColor *color = p->elementColor();
+ QColor c(color->elementRed(), color->elementGreen(), color->elementBlue());
+ if (color->hasAttributeAlpha())
+ c.setAlpha(color->attributeAlpha());
+ return QVariant::fromValue(c);
+ }
+
+ case DomProperty::Font: {
+ const DomFont *font = p->elementFont();
+
+ QFont f;
+ if (font->hasElementFamily() && !font->elementFamily().isEmpty())
+ f.setFamily(font->elementFamily());
+ if (font->hasElementPointSize() && font->elementPointSize() > 0)
+ f.setPointSize(font->elementPointSize());
+ if (font->hasElementWeight() && font->elementWeight() > 0)
+ f.setWeight(font->elementWeight());
+ if (font->hasElementItalic())
+ f.setItalic(font->elementItalic());
+ if (font->hasElementBold())
+ f.setBold(font->elementBold());
+ if (font->hasElementUnderline())
+ f.setUnderline(font->elementUnderline());
+ if (font->hasElementStrikeOut())
+ f.setStrikeOut(font->elementStrikeOut());
+ if (font->hasElementKerning())
+ f.setKerning(font->elementKerning());
+ if (font->hasElementAntialiasing())
+ f.setStyleStrategy(font->elementAntialiasing() ? QFont::PreferDefault : QFont::NoAntialias);
+ if (font->hasElementStyleStrategy()) {
+ f.setStyleStrategy(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QFont::StyleStrategy>("styleStrategy", font->elementStyleStrategy().toLatin1()));
+ }
+ return QVariant::fromValue(f);
+ }
+
+ case DomProperty::Date: {
+ const DomDate *date = p->elementDate();
+ return QVariant(QDate(date->elementYear(), date->elementMonth(), date->elementDay()));
+ }
+
+ case DomProperty::Time: {
+ const DomTime *t = p->elementTime();
+ return QVariant(QTime(t->elementHour(), t->elementMinute(), t->elementSecond()));
+ }
+
+ case DomProperty::DateTime: {
+ const DomDateTime *dateTime = p->elementDateTime();
+ const QDate d(dateTime->elementYear(), dateTime->elementMonth(), dateTime->elementDay());
+ const QTime tm(dateTime->elementHour(), dateTime->elementMinute(), dateTime->elementSecond());
+ return QVariant(QDateTime(d, tm));
+ }
+
+ case DomProperty::Url: {
+ const DomUrl *url = p->elementUrl();
+ return QVariant(QUrl(url->elementString()->text()));
+ }
+
+#ifndef QT_NO_CURSOR
+ case DomProperty::Cursor:
+ return QVariant::fromValue(QCursor(static_cast<Qt::CursorShape>(p->elementCursor())));
+
+ case DomProperty::CursorShape:
+ return QVariant::fromValue(QCursor(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, Qt::CursorShape>("cursorShape", p->elementCursorShape().toLatin1())));
+#endif
+
+ case DomProperty::Locale: {
+ const DomLocale *locale = p->elementLocale();
+ return QVariant::fromValue(QLocale(enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Language>("language", locale->attributeLanguage().toLatin1()),
+ enumKeyOfObjectToValue<QAbstractFormBuilderGadget, QLocale::Country>("country", locale->attributeCountry().toLatin1())));
+ }
+ case DomProperty::SizePolicy: {
+ const DomSizePolicy *sizep = p->elementSizePolicy();
+
+ QSizePolicy sizePolicy;
+ sizePolicy.setHorizontalStretch(sizep->elementHorStretch());
+ sizePolicy.setVerticalStretch(sizep->elementVerStretch());
+
+ const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
+
+ if (sizep->hasElementHSizeType()) {
+ sizePolicy.setHorizontalPolicy((QSizePolicy::Policy) sizep->elementHSizeType());
+ } else if (sizep->hasAttributeHSizeType()) {
+ const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeHSizeType().toLatin1());
+ sizePolicy.setHorizontalPolicy(sp);
+ }
+
+ if (sizep->hasElementVSizeType()) {
+ sizePolicy.setVerticalPolicy((QSizePolicy::Policy) sizep->elementVSizeType());
+ } else if (sizep->hasAttributeVSizeType()) {
+ const QSizePolicy::Policy sp = enumKeyToValue<QSizePolicy::Policy>(sizeType_enum, sizep->attributeVSizeType().toLatin1());
+ sizePolicy.setVerticalPolicy(sp);
+ }
+
+ return QVariant::fromValue(sizePolicy);
+ }
+
+ case DomProperty::StringList:
+ return QVariant(p->elementStringList()->elementString());
+
+ default:
+ uiLibWarning(QCoreApplication::translate("QFormBuilder", "Reading properties of the type %1 is not supported yet.").arg(p->kind()));
+ break;
+ }
+
+ return QVariant();
+}
+
+// Apply a simple variant type to a DOM property
+static bool applySimpleProperty(const QVariant &v, bool translateString, DomProperty *dom_prop)
+{
+ switch (v.type()) {
+ case QVariant::String: {
+ DomString *str = new DomString();
+ str->setText(v.toString());
+ if (!translateString)
+ str->setAttributeNotr(QLatin1String("true"));
+ dom_prop->setElementString(str);
+ }
+ return true;
+
+ case QVariant::ByteArray:
+ dom_prop->setElementCstring(QString::fromUtf8(v.toByteArray()));
+ return true;
+
+ case QVariant::Int:
+ dom_prop->setElementNumber(v.toInt());
+ return true;
+
+ case QVariant::UInt:
+ dom_prop->setElementUInt(v.toUInt());
+ return true;
+
+ case QVariant::LongLong:
+ dom_prop->setElementLongLong(v.toLongLong());
+ return true;
+
+ case QVariant::ULongLong:
+ dom_prop->setElementULongLong(v.toULongLong());
+ return true;
+
+ case QVariant::Double:
+ dom_prop->setElementDouble(v.toDouble());
+ return true;
+
+ case QVariant::Bool:
+ dom_prop->setElementBool(v.toBool() ? QFormBuilderStrings::instance().trueValue : QFormBuilderStrings::instance().falseValue);
+ return true;
+
+ case QVariant::Char: {
+ DomChar *ch = new DomChar();
+ const QChar character = v.toChar();
+ ch->setElementUnicode(character.unicode());
+ dom_prop->setElementChar(ch);
+ }
+ return true;
+
+ case QVariant::Point: {
+ DomPoint *pt = new DomPoint();
+ const QPoint point = v.toPoint();
+ pt->setElementX(point.x());
+ pt->setElementY(point.y());
+ dom_prop->setElementPoint(pt);
+ }
+ return true;
+
+ case QVariant::PointF: {
+ DomPointF *ptf = new DomPointF();
+ const QPointF pointf = v.toPointF();
+ ptf->setElementX(pointf.x());
+ ptf->setElementY(pointf.y());
+ dom_prop->setElementPointF(ptf);
+ }
+ return true;
+
+ case QVariant::Color: {
+ DomColor *clr = new DomColor();
+ const QColor color = qvariant_cast<QColor>(v);
+ clr->setElementRed(color.red());
+ clr->setElementGreen(color.green());
+ clr->setElementBlue(color.blue());
+ const int alphaChannel = color.alpha();
+ if (alphaChannel != 255)
+ clr->setAttributeAlpha(alphaChannel);
+ dom_prop->setElementColor(clr);
+ }
+ return true;
+
+ case QVariant::Size: {
+ DomSize *sz = new DomSize();
+ const QSize size = v.toSize();
+ sz->setElementWidth(size.width());
+ sz->setElementHeight(size.height());
+ dom_prop->setElementSize(sz);
+ }
+ return true;
+
+ case QVariant::SizeF: {
+ DomSizeF *szf = new DomSizeF();
+ const QSizeF sizef = v.toSizeF();
+ szf->setElementWidth(sizef.width());
+ szf->setElementHeight(sizef.height());
+ dom_prop->setElementSizeF(szf);
+ }
+ return true;
+
+ case QVariant::Rect: {
+ DomRect *rc = new DomRect();
+ const QRect rect = v.toRect();
+ rc->setElementX(rect.x());
+ rc->setElementY(rect.y());
+ rc->setElementWidth(rect.width());
+ rc->setElementHeight(rect.height());
+ dom_prop->setElementRect(rc);
+ }
+ return true;
+
+ case QVariant::RectF: {
+ DomRectF *rcf = new DomRectF();
+ const QRectF rectf = v.toRectF();
+ rcf->setElementX(rectf.x());
+ rcf->setElementY(rectf.y());
+ rcf->setElementWidth(rectf.width());
+ rcf->setElementHeight(rectf.height());
+ dom_prop->setElementRectF(rcf);
+ }
+ return true;
+
+ case QVariant::Font: {
+ DomFont *fnt = new DomFont();
+ const QFont font = qvariant_cast<QFont>(v);
+ const uint mask = font.resolve();
+ if (mask & QFont::WeightResolved) {
+ fnt->setElementBold(font.bold());
+ fnt->setElementWeight(font.weight());
+ }
+ if (mask & QFont::FamilyResolved)
+ fnt->setElementFamily(font.family());
+ if (mask & QFont::StyleResolved)
+ fnt->setElementItalic(font.italic());
+ if (mask & QFont::SizeResolved)
+ fnt->setElementPointSize(font.pointSize());
+ if (mask & QFont::StrikeOutResolved)
+ fnt->setElementStrikeOut(font.strikeOut());
+ if (mask & QFont::UnderlineResolved)
+ fnt->setElementUnderline(font.underline());
+ if (mask & QFont::KerningResolved)
+ fnt->setElementKerning(font.kerning());
+ if (mask & QFont::StyleStrategyResolved) {
+ const QMetaEnum styleStrategy_enum = metaEnum<QAbstractFormBuilderGadget>("styleStrategy");
+ fnt->setElementStyleStrategy(QLatin1String(styleStrategy_enum.valueToKey(font.styleStrategy())));
+ }
+ dom_prop->setElementFont(fnt);
+ }
+ return true;
+
+#ifndef QT_NO_CURSOR
+ case QVariant::Cursor: {
+ const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape");
+ dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape())));
+ }
+ return true;
+#endif
+
+ case QVariant::KeySequence: {
+ DomString *s = new DomString();
+ s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText));
+ dom_prop->setElementString(s);
+ }
+ return true;
+
+ case QVariant::Locale: {
+ DomLocale *dom = new DomLocale();
+ const QLocale locale = qvariant_cast<QLocale>(v);
+
+ const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language");
+ const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country");
+
+ dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language())));
+ dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country())));
+
+ dom_prop->setElementLocale(dom);
+ }
+ return true;
+
+ case QVariant::SizePolicy: {
+ DomSizePolicy *dom = new DomSizePolicy();
+ const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v);
+
+ dom->setElementHorStretch(sizePolicy.horizontalStretch());
+ dom->setElementVerStretch(sizePolicy.verticalStretch());
+
+ const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
+
+ dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy())));
+ dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy())));
+
+ dom_prop->setElementSizePolicy(dom);
+ }
+ return true;
+
+ case QVariant::Date: {
+ DomDate *dom = new DomDate();
+ const QDate date = qvariant_cast<QDate>(v);
+
+ dom->setElementYear(date.year());
+ dom->setElementMonth(date.month());
+ dom->setElementDay(date.day());
+
+ dom_prop->setElementDate(dom);
+ }
+ return true;
+
+ case QVariant::Time: {
+ DomTime *dom = new DomTime();
+ const QTime time = qvariant_cast<QTime>(v);
+
+ dom->setElementHour(time.hour());
+ dom->setElementMinute(time.minute());
+ dom->setElementSecond(time.second());
+
+ dom_prop->setElementTime(dom);
+ }
+ return true;
+
+ case QVariant::DateTime: {
+ DomDateTime *dom = new DomDateTime();
+ const QDateTime dateTime = qvariant_cast<QDateTime>(v);
+
+ dom->setElementHour(dateTime.time().hour());
+ dom->setElementMinute(dateTime.time().minute());
+ dom->setElementSecond(dateTime.time().second());
+ dom->setElementYear(dateTime.date().year());
+ dom->setElementMonth(dateTime.date().month());
+ dom->setElementDay(dateTime.date().day());
+
+ dom_prop->setElementDateTime(dom);
+ }
+ return true;
+
+ case QVariant::Url: {
+ DomUrl *dom = new DomUrl();
+ const QUrl url = v.toUrl();
+
+ DomString *str = new DomString();
+ str->setText(url.toString());
+ dom->setElementString(str);
+
+ dom_prop->setElementUrl(dom);
+ }
+ return true;
+
+ case QVariant::StringList: {
+ DomStringList *sl = new DomStringList;
+ sl->setElementString(qvariant_cast<QStringList>(v));
+ dom_prop->setElementStringList(sl);
+ }
+ return true;
+
+ default:
+ break;
+ }
+
+ return false;
+}
+static QString msgCannotWriteProperty(const QString &pname, const QVariant &v)
+{
+ return QCoreApplication::translate("QFormBuilder", "The property %1 could not be written. The type %2 is not supported yet.").
+ arg(pname).arg(QLatin1String(v.typeName()));
+
+}
+
+static bool isOfType(const QMetaObject *what, const QMetaObject *type)
+{
+ do {
+ if (what == type)
+ return true;
+ } while ((what = what->superClass()));
+ return false;
+}
+
+static bool isTranslatable(const QString &pname, const QVariant &v, const QMetaObject *meta)
+{
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+ if (pname == strings.objectNameProperty)
+ return false;
+ if (pname == strings.styleSheetProperty && v.type() == QVariant::String && isOfType(meta, &QWidget::staticMetaObject))
+ return false;
+ return true;
+}
+
+// Convert complex variant types to DOM properties with the help of QAbstractFormBuilder
+// Does not perform a check using QAbstractFormBuilder::checkProperty().
+DomProperty *variantToDomProperty(QAbstractFormBuilder *afb, const QMetaObject *meta,
+ const QString &pname, const QVariant &v)
+{
+ const QFormBuilderStrings &strings = QFormBuilderStrings::instance();
+
+ DomProperty *dom_prop = new DomProperty();
+ dom_prop->setAttributeName(pname);
+
+ const int pindex = meta->indexOfProperty(pname.toLatin1());
+ if (pindex != -1) {
+ QMetaProperty meta_property = meta->property(pindex);
+ if ((v.type() == QVariant::Int || v.type() == QVariant::UInt) && meta_property.isEnumType()) {
+ const QMetaEnum e = meta_property.enumerator();
+ if (e.isFlag())
+ dom_prop->setElementSet(QString::fromAscii(e.valueToKeys(v.toInt())));
+ else
+ dom_prop->setElementEnum(QString::fromAscii(e.valueToKey(v.toInt())));
+ return dom_prop;
+ }
+ if (!meta_property.hasStdCppSet() || (isOfType(meta, &QAbstractScrollArea::staticMetaObject) && pname == strings.cursorProperty))
+ dom_prop->setAttributeStdset(0);
+ }
+
+ // Try simple properties
+ if (applySimpleProperty(v, isTranslatable(pname, v, meta), dom_prop))
+ return dom_prop;
+
+ // Complex properties
+ switch (v.type()) {
+ case QVariant::Palette: {
+ DomPalette *dom = new DomPalette();
+ QPalette palette = qvariant_cast<QPalette>(v);
+
+ palette.setCurrentColorGroup(QPalette::Active);
+ dom->setElementActive(afb->saveColorGroup(palette));
+
+ palette.setCurrentColorGroup(QPalette::Inactive);
+ dom->setElementInactive(afb->saveColorGroup(palette));
+
+ palette.setCurrentColorGroup(QPalette::Disabled);
+ dom->setElementDisabled(afb->saveColorGroup(palette));
+
+ dom_prop->setElementPalette(dom);
+ } break;
+ case QVariant::Brush:
+ dom_prop->setElementBrush(afb->saveBrush(qvariant_cast<QBrush>(v)));
+ break;
+ default: {
+ const bool hadAttributeStdset = dom_prop->hasAttributeStdset();
+ const bool attributeStdset = dom_prop->attributeStdset();
+ delete dom_prop;
+ if (afb->resourceBuilder()->isResourceType(v)) {
+ dom_prop = afb->resourceBuilder()->saveResource(afb->workingDirectory(), v);
+ if (dom_prop) {
+ dom_prop->setAttributeName(pname);
+ if (hadAttributeStdset)
+ dom_prop->setAttributeStdset(attributeStdset);
+ }
+ break;
+ }
+ uiLibWarning(msgCannotWriteProperty(pname, v));
+ } return 0;
+ }
+ return dom_prop;
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/properties_p.h b/tools/uilib/properties_p.h
new file mode 100644
index 0000000000..5f40f87d32
--- /dev/null
+++ b/tools/uilib/properties_p.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of Qt Designer. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef UILIBPROPERTIES_H
+#define UILIBPROPERTIES_H
+
+#include <QtDesigner/uilib_global.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QMetaProperty>
+#include <QtCore/QLocale>
+#include <QtCore/QCoreApplication>
+
+#include <QtGui/QWidget>
+
+#include "formbuilderextra_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class QAbstractFormBuilder;
+class DomProperty;
+
+QDESIGNER_UILIB_EXPORT DomProperty *variantToDomProperty(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const QString &propertyName, const QVariant &value);
+
+
+QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(const DomProperty *property);
+QDESIGNER_UILIB_EXPORT QVariant domPropertyToVariant(QAbstractFormBuilder *abstractFormBuilder, const QMetaObject *meta, const DomProperty *property);
+
+// This class exists to provide meta information
+// for enumerations only.
+class QAbstractFormBuilderGadget: public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::ItemFlags itemFlags READ fakeItemFlags)
+ Q_PROPERTY(Qt::CheckState checkState READ fakeCheckState)
+ Q_PROPERTY(Qt::Alignment textAlignment READ fakeAlignment)
+ Q_PROPERTY(Qt::Orientation orientation READ fakeOrientation)
+ Q_PROPERTY(QSizePolicy::Policy sizeType READ fakeSizeType)
+ Q_PROPERTY(QPalette::ColorRole colorRole READ fakeColorRole)
+ Q_PROPERTY(QPalette::ColorGroup colorGroup READ fakeColorGroup)
+ Q_PROPERTY(QFont::StyleStrategy styleStrategy READ fakeStyleStrategy)
+ Q_PROPERTY(Qt::CursorShape cursorShape READ fakeCursorShape)
+ Q_PROPERTY(Qt::BrushStyle brushStyle READ fakeBrushStyle)
+ Q_PROPERTY(Qt::ToolBarArea toolBarArea READ fakeToolBarArea)
+ Q_PROPERTY(QGradient::Type gradientType READ fakeGradientType)
+ Q_PROPERTY(QGradient::Spread gradientSpread READ fakeGradientSpread)
+ Q_PROPERTY(QGradient::CoordinateMode gradientCoordinate READ fakeGradientCoordinate)
+ Q_PROPERTY(QLocale::Language language READ fakeLanguage)
+ Q_PROPERTY(QLocale::Country country READ fakeCountry)
+public:
+ QAbstractFormBuilderGadget() { Q_ASSERT(0); }
+
+ Qt::Orientation fakeOrientation() const { Q_ASSERT(0); return Qt::Horizontal; }
+ QSizePolicy::Policy fakeSizeType() const { Q_ASSERT(0); return QSizePolicy::Expanding; }
+ QPalette::ColorGroup fakeColorGroup() const { Q_ASSERT(0); return static_cast<QPalette::ColorGroup>(0); }
+ QPalette::ColorRole fakeColorRole() const { Q_ASSERT(0); return static_cast<QPalette::ColorRole>(0); }
+ QFont::StyleStrategy fakeStyleStrategy() const { Q_ASSERT(0); return QFont::PreferDefault; }
+ Qt::CursorShape fakeCursorShape() const { Q_ASSERT(0); return Qt::ArrowCursor; }
+ Qt::BrushStyle fakeBrushStyle() const { Q_ASSERT(0); return Qt::NoBrush; }
+ Qt::ToolBarArea fakeToolBarArea() const { Q_ASSERT(0); return Qt::NoToolBarArea; }
+ QGradient::Type fakeGradientType() const { Q_ASSERT(0); return QGradient::NoGradient; }
+ QGradient::Spread fakeGradientSpread() const { Q_ASSERT(0); return QGradient::PadSpread; }
+ QGradient::CoordinateMode fakeGradientCoordinate() const { Q_ASSERT(0); return QGradient::LogicalMode; }
+ QLocale::Language fakeLanguage() const { Q_ASSERT(0); return QLocale::C; }
+ QLocale::Country fakeCountry() const { Q_ASSERT(0); return QLocale::AnyCountry; }
+ Qt::ItemFlags fakeItemFlags() const { Q_ASSERT(0); return Qt::NoItemFlags; }
+ Qt::CheckState fakeCheckState() const { Q_ASSERT(0); return Qt::Unchecked; }
+ Qt::Alignment fakeAlignment() const { Q_ASSERT(0); return Qt::AlignLeft; }
+};
+
+// Convert key to value for a given QMetaEnum
+template <class EnumType>
+inline EnumType enumKeyToValue(const QMetaEnum &metaEnum,const char *key, const EnumType* = 0)
+{
+ int val = metaEnum.keyToValue(key);
+ if (val == -1) {
+
+ uiLibWarning(QCoreApplication::translate("QFormBuilder", "The enumeration-value '%1' is invalid. The default value '%2' will be used instead.")
+ .arg(QString::fromUtf8(key)).arg(QString::fromUtf8(metaEnum.key(0))));
+ val = metaEnum.value(0);
+ }
+ return static_cast<EnumType>(val);
+}
+
+// Convert keys to value for a given QMetaEnum
+template <class EnumType>
+inline EnumType enumKeysToValue(const QMetaEnum &metaEnum,const char *keys, const EnumType* = 0)
+{
+ int val = metaEnum.keysToValue(keys);
+ if (val == -1) {
+
+ uiLibWarning(QCoreApplication::translate("QFormBuilder", "The flag-value '%1' is invalid. Zero will be used instead.")
+ .arg(QString::fromUtf8(keys)));
+ val = 0;
+ }
+ return static_cast<EnumType>(QFlag(val));
+}
+
+// Access meta enumeration object of a qobject
+template <class QObjectType>
+inline QMetaEnum metaEnum(const char *name, const QObjectType* = 0)
+{
+ const int e_index = QObjectType::staticMetaObject.indexOfProperty(name);
+ Q_ASSERT(e_index != -1);
+ return QObjectType::staticMetaObject.property(e_index).enumerator();
+}
+
+// Convert key to value for enumeration by name
+template <class QObjectType, class EnumType>
+inline EnumType enumKeyOfObjectToValue(const char *enumName, const char *key, const QObjectType* = 0, const EnumType* = 0)
+{
+ const QMetaEnum me = metaEnum<QObjectType>(enumName);
+ return enumKeyToValue<EnumType>(me, key);
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // UILIBPROPERTIES_H
diff --git a/tools/uilib/qdesignerexportwidget.h b/tools/uilib/qdesignerexportwidget.h
new file mode 100644
index 0000000000..a6f0f64426
--- /dev/null
+++ b/tools/uilib/qdesignerexportwidget.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDESIGNEREXPORTWIDGET_H
+#define QDESIGNEREXPORTWIDGET_H
+
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+#if 0
+// pragma for syncqt, don't remove.
+#pragma qt_class(QDesignerExportWidget)
+#endif
+
+#if defined(QDESIGNER_EXPORT_WIDGETS)
+# define QDESIGNER_WIDGET_EXPORT Q_DECL_EXPORT
+#else
+# define QDESIGNER_WIDGET_EXPORT Q_DECL_IMPORT
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QDESIGNEREXPORTWIDGET_H
diff --git a/tools/uilib/resourcebuilder.cpp b/tools/uilib/resourcebuilder.cpp
new file mode 100644
index 0000000000..0ea5d4cf75
--- /dev/null
+++ b/tools/uilib/resourcebuilder.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "resourcebuilder_p.h"
+#include "ui4_p.h"
+#include <QtCore/QVariant>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QDebug>
+#include <QtGui/QPixmap>
+#include <QtGui/QIcon>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal {
+#endif
+
+enum { themeDebug = 0 };
+
+QResourceBuilder::QResourceBuilder()
+{
+
+}
+
+QResourceBuilder::~QResourceBuilder()
+{
+
+}
+
+int QResourceBuilder::iconStateFlags(const DomResourceIcon *dpi)
+{
+ int rc = 0;
+ if (dpi->hasElementNormalOff())
+ rc |= NormalOff;
+ if (dpi->hasElementNormalOn())
+ rc |= NormalOn;
+ if (dpi->hasElementDisabledOff())
+ rc |= DisabledOff;
+ if (dpi->hasElementDisabledOn())
+ rc |= DisabledOn;
+ if (dpi->hasElementActiveOff())
+ rc |= ActiveOff;
+ if (dpi->hasElementActiveOn())
+ rc |= ActiveOn;
+ if (dpi->hasElementSelectedOff())
+ rc |= SelectedOff;
+ if (dpi->hasElementSelectedOn())
+ rc |= SelectedOn;
+ return rc;
+}
+
+QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomProperty *property) const
+{
+ switch (property->kind()) {
+ case DomProperty::Pixmap: {
+ const DomResourcePixmap *dpx = property->elementPixmap();
+ QPixmap pixmap(QFileInfo(workingDirectory, dpx->text()).absoluteFilePath());
+ return QVariant::fromValue(pixmap);
+ }
+ case DomProperty::IconSet: {
+ const DomResourceIcon *dpi = property->elementIconSet();
+ if (!dpi->attributeTheme().isEmpty()) {
+ const QString theme = dpi->attributeTheme();
+ const bool known = QIcon::hasThemeIcon(theme);
+ if (themeDebug)
+ qDebug("Theme %s known %d", qPrintable(theme), known);
+ if (known)
+ return qVariantFromValue(QIcon::fromTheme(dpi->attributeTheme()));
+ } // non-empty theme
+ if (const int flags = iconStateFlags(dpi)) { // new, post 4.4 format
+ QIcon icon;
+ if (flags & NormalOff)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOff()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::Off);
+ if (flags & NormalOn)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementNormalOn()->text()).absoluteFilePath(), QSize(), QIcon::Normal, QIcon::On);
+ if (flags & DisabledOff)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOff()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::Off);
+ if (flags & DisabledOn)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementDisabledOn()->text()).absoluteFilePath(), QSize(), QIcon::Disabled, QIcon::On);
+ if (flags & ActiveOff)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOff()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::Off);
+ if (flags & ActiveOn)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementActiveOn()->text()).absoluteFilePath(), QSize(), QIcon::Active, QIcon::On);
+ if (flags & SelectedOff)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOff()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::Off);
+ if (flags & SelectedOn)
+ icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOn()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::On);
+ return QVariant::fromValue(icon);
+ } else { // 4.3 legacy
+ const QIcon icon(QFileInfo(workingDirectory, dpi->text()).absoluteFilePath());
+ return QVariant::fromValue(icon);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+QVariant QResourceBuilder::toNativeValue(const QVariant &value) const
+{
+ return value;
+}
+
+DomProperty *QResourceBuilder::saveResource(const QDir &workingDirectory, const QVariant &value) const
+{
+ Q_UNUSED(workingDirectory)
+ Q_UNUSED(value)
+ return 0;
+}
+
+bool QResourceBuilder::isResourceProperty(const DomProperty *p) const
+{
+ switch (p->kind()) {
+ case DomProperty::Pixmap:
+ case DomProperty::IconSet:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+bool QResourceBuilder::isResourceType(const QVariant &value) const
+{
+ switch (value.type()) {
+ case QVariant::Pixmap:
+ case QVariant::Icon:
+ return true;
+ default:
+ break;
+ }
+ return false;
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+} // namespace QFormInternal
+#endif
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/resourcebuilder_p.h b/tools/uilib/resourcebuilder_p.h
new file mode 100644
index 0000000000..a3ccbf8168
--- /dev/null
+++ b/tools/uilib/resourcebuilder_p.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef RESOURCEBUILDER_H
+#define RESOURCEBUILDER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDesigner/uilib_global.h>
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class QDir;
+class QVariant;
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class DomProperty;
+class DomResourceIcon;
+
+class QDESIGNER_UILIB_EXPORT QResourceBuilder
+{
+public:
+ enum IconStateFlags {
+ NormalOff = 0x1, NormalOn = 0x2, DisabledOff = 0x4, DisabledOn = 0x8,
+ ActiveOff = 0x10, ActiveOn = 0x20, SelectedOff = 0x40, SelectedOn = 0x80
+ };
+
+ QResourceBuilder();
+ virtual ~QResourceBuilder();
+
+ virtual QVariant loadResource(const QDir &workingDirectory, const DomProperty *property) const;
+
+ virtual QVariant toNativeValue(const QVariant &value) const;
+
+ virtual DomProperty *saveResource(const QDir &workingDirectory, const QVariant &value) const;
+
+ virtual bool isResourceProperty(const DomProperty *p) const;
+
+ virtual bool isResourceType(const QVariant &value) const;
+
+ static int iconStateFlags(const DomResourceIcon *resIcon);
+};
+
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // RESOURCEBUILDER_H
diff --git a/tools/uilib/textbuilder.cpp b/tools/uilib/textbuilder.cpp
new file mode 100644
index 0000000000..2006a43806
--- /dev/null
+++ b/tools/uilib/textbuilder.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textbuilder_p.h"
+#include "ui4_p.h"
+#include <QtCore/QVariant>
+
+QT_BEGIN_NAMESPACE
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal {
+#endif
+
+QTextBuilder::QTextBuilder()
+{
+
+}
+
+QTextBuilder::~QTextBuilder()
+{
+
+}
+
+QVariant QTextBuilder::loadText(const DomProperty *property) const
+{
+ if (property->kind() == DomProperty::String)
+ return property->elementString()->text();
+ return QVariant();
+}
+
+QVariant QTextBuilder::toNativeValue(const QVariant &value) const
+{
+ return value;
+}
+
+DomProperty *QTextBuilder::saveText(const QVariant &value) const
+{
+ Q_UNUSED(value)
+ return 0;
+}
+
+#ifdef QFORMINTERNAL_NAMESPACE
+} // namespace QFormInternal
+#endif
+
+QT_END_NAMESPACE
diff --git a/tools/uilib/textbuilder_p.h b/tools/uilib/textbuilder_p.h
new file mode 100644
index 0000000000..8da296d041
--- /dev/null
+++ b/tools/uilib/textbuilder_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Designer of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTBUILDER_H
+#define TEXTBUILDER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDesigner/uilib_global.h>
+#include <QtCore/QList>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+
+class QDir;
+class QVariant;
+
+#ifdef QFORMINTERNAL_NAMESPACE
+namespace QFormInternal
+{
+#endif
+
+class DomProperty;
+class DomString;
+
+class QDESIGNER_UILIB_EXPORT QTextBuilder
+{
+public:
+ QTextBuilder();
+ virtual ~QTextBuilder();
+
+ virtual QVariant loadText(const DomProperty *property) const;
+
+ virtual QVariant toNativeValue(const QVariant &value) const;
+
+ virtual DomProperty *saveText(const QVariant &value) const;
+};
+
+
+#ifdef QFORMINTERNAL_NAMESPACE
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // TEXTBUILDER_H
diff --git a/tools/uilib/ui4.cpp b/tools/uilib/ui4.cpp
new file mode 100644
index 0000000000..f79543f4a2
--- /dev/null
+++ b/tools/uilib/ui4.cpp
@@ -0,0 +1,11154 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "ui4_p.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_childre