summaryrefslogtreecommitdiffstats
path: root/src/tools/uic/cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2017-05-31 11:44:02 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2017-06-12 12:04:42 +0000
commitd6d76df9e0ed0e9e6c761a1d3c2581ec317d3ebb (patch)
tree31d81bd1fd0bf8ef99ae2c057298b52d847c1f3e /src/tools/uic/cpp
parentd57bf5e8aa6c575c4e3b9d80793e9becf1469d82 (diff)
Remove ancient embedded pixmaps and scripts from uic
Change-Id: Iec06e1af91a6d61226ae484325b1ec82810d634d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/tools/uic/cpp')
-rw-r--r--src/tools/uic/cpp/cpp.pri12
-rw-r--r--src/tools/uic/cpp/cppextractimages.cpp140
-rw-r--r--src/tools/uic/cpp/cppextractimages.h64
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.cpp63
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.h3
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.cpp172
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.h68
-rw-r--r--src/tools/uic/cpp/cppwriteicondeclaration.cpp67
-rw-r--r--src/tools/uic/cpp/cppwriteicondeclaration.h63
-rw-r--r--src/tools/uic/cpp/cppwriteiconinitialization.cpp102
-rw-r--r--src/tools/uic/cpp/cppwriteiconinitialization.h68
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.cpp22
-rw-r--r--src/tools/uic/cpp/cppwriteincludes.h5
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp82
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.h11
15 files changed, 10 insertions, 932 deletions
diff --git a/src/tools/uic/cpp/cpp.pri b/src/tools/uic/cpp/cpp.pri
index 49c71a6dfa..a6b6188117 100644
--- a/src/tools/uic/cpp/cpp.pri
+++ b/src/tools/uic/cpp/cpp.pri
@@ -3,18 +3,10 @@ INCLUDEPATH += $$PWD $$QT_BUILD_TREE/src/tools/uic
DEFINES += QT_UIC_CPP_GENERATOR
# Input
-HEADERS += $$PWD/cppextractimages.h \
- $$PWD/cppwritedeclaration.h \
- $$PWD/cppwriteicondata.h \
- $$PWD/cppwriteicondeclaration.h \
- $$PWD/cppwriteiconinitialization.h \
+HEADERS += $$PWD/cppwritedeclaration.h \
$$PWD/cppwriteincludes.h \
$$PWD/cppwriteinitialization.h
-SOURCES += $$PWD/cppextractimages.cpp \
- $$PWD/cppwritedeclaration.cpp \
- $$PWD/cppwriteicondata.cpp \
- $$PWD/cppwriteicondeclaration.cpp \
- $$PWD/cppwriteiconinitialization.cpp \
+SOURCES += $$PWD/cppwritedeclaration.cpp \
$$PWD/cppwriteincludes.cpp \
$$PWD/cppwriteinitialization.cpp
diff --git a/src/tools/uic/cpp/cppextractimages.cpp b/src/tools/uic/cpp/cppextractimages.cpp
deleted file mode 100644
index 4d06d08dae..0000000000
--- a/src/tools/uic/cpp/cppextractimages.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "cppextractimages.h"
-#include "cppwriteicondata.h"
-#include "driver.h"
-#include "ui4.h"
-#include "utils.h"
-#include "uic.h"
-
-#include <qtextstream.h>
-#include <qtextcodec.h>
-#include <qdir.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace CPP {
-
-ExtractImages::ExtractImages(const Option &opt)
- : m_output(0), m_option(opt)
-{
-}
-
-void ExtractImages::acceptUI(DomUI *node)
-{
- if (!m_option.extractImages)
- return;
-
- if (node->elementImages() == 0)
- return;
-
- QString className = node->elementClass() + m_option.postfix;
-
- QFile f;
- if (m_option.qrcOutputFile.size()) {
- f.setFileName(m_option.qrcOutputFile);
- if (!f.open(QIODevice::WriteOnly | QFile::Text)) {
- fprintf(stderr, "%s: Error: Could not create resource file\n", qPrintable(m_option.messagePrefix()));
- return;
- }
-
- QFileInfo fi(m_option.qrcOutputFile);
- QDir dir = fi.absoluteDir();
- if (!dir.exists(QLatin1String("images")) && !dir.mkdir(QLatin1String("images"))) {
- fprintf(stderr, "%s: Error: Could not create image dir\n", qPrintable(m_option.messagePrefix()));
- return;
- }
- dir.cd(QLatin1String("images"));
- m_imagesDir = dir;
-
- m_output = new QTextStream(&f);
-#ifndef QT_NO_TEXTCODEC
- m_output->setCodec(QTextCodec::codecForName("UTF-8"));
-#endif
-
- QTextStream &out = *m_output;
-
- out << "<RCC>\n";
- out << " <qresource prefix=\"/" << className << "\" >\n";
- TreeWalker::acceptUI(node);
- out << " </qresource>\n";
- out << "</RCC>\n";
-
- f.close();
- delete m_output;
- m_output = 0;
- }
-}
-
-void ExtractImages::acceptImages(DomImages *images)
-{
- TreeWalker::acceptImages(images);
-}
-
-void ExtractImages::acceptImage(DomImage *image)
-{
- QString format = image->elementData()->attributeFormat();
- QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower();
- QString fname = m_imagesDir.absoluteFilePath(image->attributeName() + QLatin1Char('.') + extension);
-
- *m_output << " <file>images/" << image->attributeName() << QLatin1Char('.') + extension << "</file>\n";
-
- QFile f;
- f.setFileName(fname);
- const bool isXPM_GZ = format == QLatin1String("XPM.GZ");
- QIODevice::OpenMode openMode = QIODevice::WriteOnly;
- if (isXPM_GZ)
- openMode |= QIODevice::Text;
- if (!f.open(openMode)) {
- fprintf(stderr, "%s: Error: Could not create image file %s: %s",
- qPrintable(m_option.messagePrefix()),
- qPrintable(fname), qPrintable(f.errorString()));
- return;
- }
-
- if (isXPM_GZ) {
- QTextStream *imageOut = new QTextStream(&f);
-#ifndef QT_NO_TEXTCODEC
- imageOut->setCodec(QTextCodec::codecForName("UTF-8"));
-#endif
-
- CPP::WriteIconData::writeImage(*imageOut, QString(), m_option.limitXPM_LineLength, image);
- delete imageOut;
- } else {
- CPP::WriteIconData::writeImage(f, image);
- }
-
- f.close();
-}
-
-} // namespace CPP
-
-QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppextractimages.h b/src/tools/uic/cpp/cppextractimages.h
deleted file mode 100644
index d012de8d0a..0000000000
--- a/src/tools/uic/cpp/cppextractimages.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CPPEXTRACTIMAGES_H
-#define CPPEXTRACTIMAGES_H
-
-#include "treewalker.h"
-#include <qdir.h>
-
-QT_BEGIN_NAMESPACE
-
-class QTextStream;
-class Driver;
-class Uic;
-
-struct Option;
-
-namespace CPP {
-
-class ExtractImages : public TreeWalker
-{
-public:
- ExtractImages(const Option &opt);
-
- void acceptUI(DomUI *node) Q_DECL_OVERRIDE;
- void acceptImages(DomImages *images) Q_DECL_OVERRIDE;
- void acceptImage(DomImage *image) Q_DECL_OVERRIDE;
-
-private:
- QTextStream *m_output;
- const Option &m_option;
- QDir m_imagesDir;
-};
-
-} // namespace CPP
-
-QT_END_NAMESPACE
-
-#endif // CPPEXTRACTIMAGES_H
diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp
index 3aadc878e3..e384a1e194 100644
--- a/src/tools/uic/cpp/cppwritedeclaration.cpp
+++ b/src/tools/uic/cpp/cppwritedeclaration.cpp
@@ -27,10 +27,7 @@
****************************************************************************/
#include "cppwritedeclaration.h"
-#include "cppwriteicondeclaration.h"
#include "cppwriteinitialization.h"
-#include "cppwriteiconinitialization.h"
-#include "cppextractimages.h"
#include "driver.h"
#include "ui4.h"
#include "uic.h"
@@ -56,47 +53,15 @@ namespace {
output << "} // namespace " << *it << "\n";
}
}
-
- void writeScriptContextClass(const QString &indent, QTextStream &str) {
- str << indent << "class ScriptContext\n"
- << indent << "{\n"
- << indent << "public:\n"
- << indent << " void run(const QString &script, QWidget *widget, const QWidgetList &childWidgets)\n"
- << indent << " {\n"
- << indent << " QScriptValue widgetObject = scriptEngine.newQObject(widget);\n"
- << indent << " QScriptValue childWidgetArray = scriptEngine.newArray (childWidgets.size());\n"
- << indent << " for (int i = 0; i < childWidgets.size(); i++)\n"
- << indent << " childWidgetArray.setProperty(i, scriptEngine.newQObject(childWidgets[i]));\n"
- << indent << " QScriptContext *ctx = scriptEngine.pushContext();\n"
- << indent << " ctx ->activationObject().setProperty(QLatin1String(\"widget\"), widgetObject);\n"
- << indent << " ctx ->activationObject().setProperty(QLatin1String(\"childWidgets\"), childWidgetArray);\n\n"
- << indent << " scriptEngine.evaluate(script);\n"
- << indent << " if (scriptEngine.hasUncaughtException ()) {\n"
- << indent << " qWarning() << \"An exception occurred at line \" << scriptEngine.uncaughtExceptionLineNumber()\n"
- << indent << " << \" of the script for \" << widget->objectName() << \": \" << engineError() << '\\n'\n"
- << indent << " << script;\n"
- << indent << " }\n\n"
- << indent << " scriptEngine.popContext();\n"
- << indent << " }\n\n"
- << indent << "private:\n"
- << indent << " QString engineError()\n"
- << indent << " {\n"
- << indent << " QScriptValue error = scriptEngine.evaluate(\"Error\");\n"
- << indent << " return error.toString();\n"
- << indent << " }\n\n"
- << indent << " QScriptEngine scriptEngine;\n"
- << indent << "};\n\n";
- }
}
namespace CPP {
-WriteDeclaration::WriteDeclaration(Uic *uic, bool activateScripts) :
+WriteDeclaration::WriteDeclaration(Uic *uic) :
m_uic(uic),
m_driver(uic->driver()),
m_output(uic->output()),
- m_option(uic->option()),
- m_activateScripts(activateScripts)
+ m_option(uic->option())
{
}
@@ -154,29 +119,7 @@ void WriteDeclaration::acceptUI(DomUI *node)
m_output << "\n";
- WriteInitialization(m_uic, m_activateScripts).acceptUI(node);
-
- if (node->elementImages()) {
- if (m_option.extractImages) {
- ExtractImages(m_uic->option()).acceptUI(node);
- } else {
- m_output << "\n"
- << "protected:\n"
- << m_option.indent << "enum IconID\n"
- << m_option.indent << "{\n";
- WriteIconDeclaration(m_uic).acceptUI(node);
-
- m_output << m_option.indent << m_option.indent << "unknown_ID\n"
- << m_option.indent << "};\n";
-
- WriteIconInitialization(m_uic).acceptUI(node);
- }
- }
-
- if (m_activateScripts) {
- m_output << "\nprivate:\n\n";
- writeScriptContextClass(m_option.indent, m_output);
- }
+ WriteInitialization(m_uic).acceptUI(node);
m_output << "};\n\n";
diff --git a/src/tools/uic/cpp/cppwritedeclaration.h b/src/tools/uic/cpp/cppwritedeclaration.h
index baa57c5978..ca2122293c 100644
--- a/src/tools/uic/cpp/cppwritedeclaration.h
+++ b/src/tools/uic/cpp/cppwritedeclaration.h
@@ -43,7 +43,7 @@ namespace CPP {
struct WriteDeclaration : public TreeWalker
{
- WriteDeclaration(Uic *uic, bool activateScripts);
+ WriteDeclaration(Uic *uic);
void acceptUI(DomUI *node) Q_DECL_OVERRIDE;
void acceptWidget(DomWidget *node) Q_DECL_OVERRIDE;
@@ -58,7 +58,6 @@ private:
Driver *m_driver;
QTextStream &m_output;
const Option &m_option;
- const bool m_activateScripts;
};
} // namespace CPP
diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp
deleted file mode 100644
index 4601a4c5e9..0000000000
--- a/src/tools/uic/cpp/cppwriteicondata.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "cppwriteicondata.h"
-#include "driver.h"
-#include "ui4.h"
-#include "uic.h"
-
-#include <qtextstream.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace CPP {
-
-static QByteArray transformImageData(const QString &data)
-{
- int baSize = data.length() / 2;
- uchar *ba = new uchar[baSize];
- for (int i = 0; i < baSize; ++i) {
- char h = data[2 * (i)].toLatin1();
- char l = data[2 * (i) + 1].toLatin1();
- uchar r = 0;
- if (h <= '9')
- r += h - '0';
- else
- r += h - 'a' + 10;
- r = r << 4;
- if (l <= '9')
- r += l - '0';
- else
- r += l - 'a' + 10;
- ba[i] = r;
- }
- QByteArray ret(reinterpret_cast<const char *>(ba), baSize);
- delete [] ba;
- return ret;
-}
-
-static QByteArray unzipXPM(const QString &data, ulong &length)
-{
-#ifndef QT_NO_COMPRESS
- const int lengthOffset = 4;
- QByteArray ba(lengthOffset, ' ');
-
- // qUncompress() expects the first 4 bytes to be the expected length of the
- // uncompressed data
- ba[0] = (length & 0xff000000) >> 24;
- ba[1] = (length & 0x00ff0000) >> 16;
- ba[2] = (length & 0x0000ff00) >> 8;
- ba[3] = (length & 0x000000ff);
- ba.append(transformImageData(data));
- QByteArray baunzip = qUncompress(ba);
- return baunzip;
-#else
- Q_UNUSED(data);
- Q_UNUSED(length);
- return QByteArray();
-#endif
-}
-
-
-WriteIconData::WriteIconData(Uic *uic)
- : driver(uic->driver()), output(uic->output()), option(uic->option())
-{
-}
-
-void WriteIconData::acceptUI(DomUI *node)
-{
- TreeWalker::acceptUI(node);
-}
-
-void WriteIconData::acceptImages(DomImages *images)
-{
- TreeWalker::acceptImages(images);
-}
-
-void WriteIconData::acceptImage(DomImage *image)
-{
- // Limit line length when writing code.
- writeImage(output, option.indent, true, image);
-}
-
-void WriteIconData::writeImage(QTextStream &output, const QString &indent,
- bool limitXPM_LineLength, const DomImage *image)
-{
- QString img = image->attributeName() + QLatin1String("_data");
- QString data = image->elementData()->text();
- QString fmt = image->elementData()->attributeFormat();
- int size = image->elementData()->attributeLength();
-
- if (fmt == QLatin1String("XPM.GZ")) {
- ulong length = size;
- QByteArray baunzip = unzipXPM(data, length);
- length = baunzip.size();
- // shouldn't we test the initial 'length' against the
- // resulting 'length' to catch corrupt UIC files?
- int a = 0;
- int column = 0;
- bool inQuote = false;
- output << indent << "/* XPM */\n"
- << indent << "static const char* const " << img << "[] = { \n";
- while (baunzip[a] != '\"')
- a++;
- for (; a < (int) length; a++) {
- output << baunzip[a];
- if (baunzip[a] == '\n') {
- column = 0;
- } else if (baunzip[a] == '"') {
- inQuote = !inQuote;
- }
-
- column++;
- if (limitXPM_LineLength && column >= 512 && inQuote) {
- output << "\"\n\""; // be nice with MSVC & Co.
- column = 1;
- }
- }
-
- if (! baunzip.trimmed ().endsWith ("};"))
- output << "};";
-
- output << "\n\n";
- } else {
- output << indent << "static const unsigned char " << img << "[] = { \n";
- output << indent;
- int a ;
- for (a = 0; a < (int) (data.length()/2)-1; a++) {
- output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << ',';
- if (a % 12 == 11)
- output << '\n' << indent;
- else
- output << ' ';
- }
- output << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << '\n';
- output << "};\n\n";
- }
-}
-
-void WriteIconData::writeImage(QIODevice &output, DomImage *image)
-{
- const QByteArray array = transformImageData(image->elementData()->text());
- output.write(array.constData(), array.size());
-}
-
-} // namespace CPP
-
-QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwriteicondata.h b/src/tools/uic/cpp/cppwriteicondata.h
deleted file mode 100644
index c496d5a85b..0000000000
--- a/src/tools/uic/cpp/cppwriteicondata.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CPPWRITEICONDATA_H
-#define CPPWRITEICONDATA_H
-
-#include "treewalker.h"
-
-QT_BEGIN_NAMESPACE
-
-class QTextStream;
-class QIODevice;
-class Driver;
-class Uic;
-
-struct Option;
-
-namespace CPP {
-
-class WriteIconData : public TreeWalker
-{
-public:
- WriteIconData(Uic *uic);
-
- void acceptUI(DomUI *node) Q_DECL_OVERRIDE;
- void acceptImages(DomImages *images) Q_DECL_OVERRIDE;
- void acceptImage(DomImage *image) Q_DECL_OVERRIDE;
-
- static void writeImage(QTextStream &output, const QString &indent,
- bool limitXPM_LineLength, const DomImage *image);
- static void writeImage(QIODevice &output, DomImage *image);
-
-private:
- Driver *driver;
- QTextStream &output;
- const Option &option;
-};
-
-} // namespace CPP
-
-QT_END_NAMESPACE
-
-#endif // CPPWRITEICONDATA_H
diff --git a/src/tools/uic/cpp/cppwriteicondeclaration.cpp b/src/tools/uic/cpp/cppwriteicondeclaration.cpp
deleted file mode 100644
index 5264e3de54..0000000000
--- a/src/tools/uic/cpp/cppwriteicondeclaration.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "cppwriteicondeclaration.h"
-#include "driver.h"
-#include "ui4.h"
-#include "uic.h"
-
-#include <qtextstream.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace CPP {
-
-WriteIconDeclaration::WriteIconDeclaration(Uic *uic)
- : driver(uic->driver()), output(uic->output()), option(uic->option())
-{
-}
-
-void WriteIconDeclaration::acceptUI(DomUI *node)
-{
- TreeWalker::acceptUI(node);
-}
-
-void WriteIconDeclaration::acceptImages(DomImages *images)
-{
- TreeWalker::acceptImages(images);
-}
-
-void WriteIconDeclaration::acceptImage(DomImage *image)
-{
- QString name = image->attributeName();
- if (name.isEmpty())
- return;
-
- driver->insertPixmap(name);
- output << option.indent << option.indent << name << "_ID,\n";
-}
-
-} // namespace CPP
-
-QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwriteicondeclaration.h b/src/tools/uic/cpp/cppwriteicondeclaration.h
deleted file mode 100644
index 6483b8bf4a..0000000000
--- a/src/tools/uic/cpp/cppwriteicondeclaration.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CPPWRITEICONDECLARATION_H
-#define CPPWRITEICONDECLARATION_H
-
-#include "treewalker.h"
-
-QT_BEGIN_NAMESPACE
-
-class QTextStream;
-class Driver;
-class Uic;
-
-struct Option;
-
-namespace CPP {
-
-class WriteIconDeclaration : public TreeWalker
-{
-public:
- WriteIconDeclaration(Uic *uic);
-
- void acceptUI(DomUI *node) Q_DECL_OVERRIDE;
- void acceptImages(DomImages *images) Q_DECL_OVERRIDE;
- void acceptImage(DomImage *image) Q_DECL_OVERRIDE;
-
-private:
- Driver *driver;
- QTextStream &output;
- const Option &option;
-};
-
-} // namespace CPP
-
-QT_END_NAMESPACE
-
-#endif // CPPWRITEICONDECLARATION_H
diff --git a/src/tools/uic/cpp/cppwriteiconinitialization.cpp b/src/tools/uic/cpp/cppwriteiconinitialization.cpp
deleted file mode 100644
index 33d1c8402e..0000000000
--- a/src/tools/uic/cpp/cppwriteiconinitialization.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "cppwriteiconinitialization.h"
-#include "cppwriteicondata.h"
-#include "driver.h"
-#include "ui4.h"
-#include "utils.h"
-#include "uic.h"
-
-#include <qtextstream.h>
-#include <qstring.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace CPP {
-
-WriteIconInitialization::WriteIconInitialization(Uic *uic)
- : driver(uic->driver()), output(uic->output()), option(uic->option())
-{
- this->uic = uic;
-}
-
-void WriteIconInitialization::acceptUI(DomUI *node)
-{
- if (node->elementImages() == 0)
- return;
-
- QString className = node->elementClass() + option.postfix;
-
- output << option.indent << "static QPixmap " << iconFromDataFunction() << "(IconID id)\n"
- << option.indent << "{\n";
-
- WriteIconData(uic).acceptUI(node);
-
- output << option.indent << "switch (id) {\n";
-
- TreeWalker::acceptUI(node);
-
- output << option.indent << option.indent << "default: return QPixmap();\n";
-
- output << option.indent << "} // switch\n"
- << option.indent << "} // icon\n\n";
-}
-
-QString WriteIconInitialization::iconFromDataFunction()
-{
- return QLatin1String("qt_get_icon");
-}
-
-void WriteIconInitialization::acceptImages(DomImages *images)
-{
- TreeWalker::acceptImages(images);
-}
-
-void WriteIconInitialization::acceptImage(DomImage *image)
-{
- QString img = image->attributeName() + QLatin1String("_data");
- QString data = image->elementData()->text();
- QString fmt = image->elementData()->attributeFormat();
-
- QString imageId = image->attributeName() + QLatin1String("_ID");
- QString imageData = image->attributeName() + QLatin1String("_data");
- QString ind = option.indent + option.indent;
-
- output << ind << "case " << imageId << ": ";
-
- if (fmt == QLatin1String("XPM.GZ")) {
- output << "return " << "QPixmap((const char**)" << imageData << ");\n";
- } else {
- output << " { QImage img; img.loadFromData(" << imageData << ", sizeof(" << imageData << "), " << fixString(fmt, ind) << "); return QPixmap::fromImage(img); }\n";
- }
-}
-
-} // namespace CPP
-
-QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwriteiconinitialization.h b/src/tools/uic/cpp/cppwriteiconinitialization.h
deleted file mode 100644
index 588cb1bc67..0000000000
--- a/src/tools/uic/cpp/cppwriteiconinitialization.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CPPWRITEICONINITIALIZATION_H
-#define CPPWRITEICONINITIALIZATION_H
-
-#include "treewalker.h"
-
-class QString;
-
-QT_BEGIN_NAMESPACE
-
-class QTextStream;
-class Driver;
-class Uic;
-
-struct Option;
-
-namespace CPP {
-
-class WriteIconInitialization : public TreeWalker
-{
-public:
- WriteIconInitialization(Uic *uic);
-
- void acceptUI(DomUI *node) Q_DECL_OVERRIDE;
- void acceptImages(DomImages *images) Q_DECL_OVERRIDE;
- void acceptImage(DomImage *image) Q_DECL_OVERRIDE;
-
- static QString iconFromDataFunction();
-
-private:
- Uic *uic;
- Driver *driver;
- QTextStream &output;
- const Option &option;
-};
-
-} // namespace CPP
-
-QT_END_NAMESPACE
-
-#endif // CPPWRITEICONINITIALIZATION_H
diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp
index dcbe400224..de64b85219 100644
--- a/src/tools/uic/cpp/cppwriteincludes.cpp
+++ b/src/tools/uic/cpp/cppwriteincludes.cpp
@@ -69,7 +69,7 @@ static inline QString moduleHeader(const QString &module, const QString &header)
namespace CPP {
WriteIncludes::WriteIncludes(Uic *uic)
- : m_uic(uic), m_output(uic->output()), m_scriptsActivated(false), m_laidOut(false)
+ : m_uic(uic), m_output(uic->output()), m_laidOut(false)
{
// When possible (no namespace) use the "QtModule/QClass" convention
// and create a re-mapping of the old header "qclass.h" to it. Do not do this
@@ -92,7 +92,6 @@ WriteIncludes::WriteIncludes(Uic *uic)
void WriteIncludes::acceptUI(DomUI *node)
{
- m_scriptsActivated = false;
m_laidOut = false;
m_localIncludes.clear();
m_globalIncludes.clear();
@@ -231,10 +230,6 @@ void WriteIncludes::acceptCustomWidget(DomCustomWidget *node)
if (className.isEmpty())
return;
- if (const DomScript *domScript = node->elementScript())
- if (!domScript->text().isEmpty())
- activateScripts();
-
if (!node->elementHeader() || node->elementHeader()->text().isEmpty()) {
add(className, false); // no header specified
} else {
@@ -296,21 +291,6 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global)
}
}
-void WriteIncludes::acceptWidgetScripts(const DomScripts &scripts, DomWidget *, const DomWidgets &)
-{
- if (!scripts.empty()) {
- activateScripts();
- }
-}
-
-void WriteIncludes::activateScripts()
-{
- if (!m_scriptsActivated) {
- add(QLatin1String("QScriptEngine"));
- add(QLatin1String("QDebug"));
- m_scriptsActivated = true;
- }
-}
} // namespace CPP
QT_END_NAMESPACE
diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h
index 7a6a499536..0d9c293efc 100644
--- a/src/tools/uic/cpp/cppwriteincludes.h
+++ b/src/tools/uic/cpp/cppwriteincludes.h
@@ -54,7 +54,6 @@ struct WriteIncludes : public TreeWalker
void acceptLayout(DomLayout *node) Q_DECL_OVERRIDE;
void acceptSpacer(DomSpacer *node) Q_DECL_OVERRIDE;
void acceptProperty(DomProperty *node) Q_DECL_OVERRIDE;
- void acceptWidgetScripts(const DomScripts &, DomWidget *, const DomWidgets &) Q_DECL_OVERRIDE;
//
// custom widgets
@@ -68,8 +67,6 @@ struct WriteIncludes : public TreeWalker
void acceptIncludes(DomIncludes *node) Q_DECL_OVERRIDE;
void acceptInclude(DomInclude *node) Q_DECL_OVERRIDE;
- bool scriptsActivated() const { return m_scriptsActivated; }
-
private:
void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false);
@@ -79,7 +76,6 @@ private:
void insertInclude(const QString &header, bool global);
void writeHeaders(const OrderedSet &headers, bool global);
QString headerForClassName(const QString &className) const;
- void activateScripts();
const Uic *m_uic;
QTextStream &m_output;
@@ -94,7 +90,6 @@ private:
StringMap m_classToHeader;
StringMap m_oldHeaderToNewHeader;
- bool m_scriptsActivated;
bool m_laidOut;
};
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 327e3500f2..2fb44952be 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "cppwriteinitialization.h"
-#include "cppwriteiconinitialization.h"
#include "driver.h"
#include "ui4.h"
#include "utils.h"
@@ -130,11 +129,6 @@ namespace {
str << indent << varName << "->" << setter << '(' << v << ");\n";
}
- void writeSetupUIScriptVariableDeclarations(const QString &indent, QTextStream &str) {
- str << indent << "ScriptContext scriptContext;\n"
- << indent << "QWidgetList childWidgets;\n";
- }
-
static inline bool iconHasStatePixmaps(const DomResourceIcon *i) {
return i->hasElementNormalOff() || i->hasElementNormalOn() ||
i->hasElementDisabledOff() || i->hasElementDisabledOn() ||
@@ -464,7 +458,7 @@ static bool needsTranslation(const DomElement *element)
}
// --- WriteInitialization
-WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) :
+WriteInitialization::WriteInitialization(Uic *uic) :
m_uic(uic),
m_driver(uic->driver()), m_output(uic->output()), m_option(uic->option()),
m_indent(m_option.indent + m_option.indent),
@@ -475,14 +469,13 @@ WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) :
m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly),
m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly),
m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly),
- m_activateScripts(activateScripts), m_layoutWidget(false),
+ m_layoutWidget(false),
m_firstThemeIcon(true)
{
}
void WriteInitialization::acceptUI(DomUI *node)
{
- m_registeredImages.clear();
m_actionGroupChain.push(0);
m_widgetChain.push(0);
m_layoutChain.push(0);
@@ -493,9 +486,6 @@ void WriteInitialization::acceptUI(DomUI *node)
if (node->elementCustomWidgets())
TreeWalker::acceptCustomWidgets(node->elementCustomWidgets());
- if (node->elementImages())
- TreeWalker::acceptImages(node->elementImages());
-
if (m_option.generateImplemetation)
m_output << "#include <" << m_driver->headerFileName() << ">\n\n";
@@ -515,9 +505,6 @@ void WriteInitialization::acceptUI(DomUI *node)
m_output << m_option.indent << "void " << "setupUi(" << widgetClassName << " *" << varName << ")\n"
<< m_option.indent << "{\n";
- if (m_activateScripts)
- writeSetupUIScriptVariableDeclarations(m_indent, m_output);
-
const QStringList connections = m_uic->databaseInfo()->connections();
for (int i=0; i<connections.size(); ++i) {
QString connection = connections.at(i);
@@ -1895,23 +1882,6 @@ QString WriteInitialization::pixCall(const QString &t, const QString &text) cons
type += QLatin1String("()");
return type;
}
- if (const DomImage *image = findImage(text)) {
- if (m_option.extractImages) {
- const QString format = image->elementData()->attributeFormat();
- const QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower();
- return QLatin1String("QPixmap(QString::fromUtf8(\":/")
- + m_generatedClass
- + QLatin1String("/images/")
- + text
- + QLatin1Char('.')
- + extension
- + QLatin1String("\"))");
- }
- return WriteIconInitialization::iconFromDataFunction()
- + QLatin1Char('(')
- + text
- + QLatin1String("_ID)");
- }
QString pixFunc = m_uic->pixmapFunction();
if (pixFunc.isEmpty())
@@ -2429,11 +2399,6 @@ void WriteInitialization::acceptConnection(DomConnection *connection)
<< ");\n";
}
-DomImage *WriteInitialization::findImage(const QString &name) const
-{
- return m_registeredImages.value(name);
-}
-
DomWidget *WriteInitialization::findWidget(QLatin1String widgetClass)
{
for (int i = m_widgetChain.count() - 1; i >= 0; --i) {
@@ -2446,49 +2411,6 @@ DomWidget *WriteInitialization::findWidget(QLatin1String widgetClass)
return 0;
}
-void WriteInitialization::acceptImage(DomImage *image)
-{
- if (!image->hasAttributeName())
- return;
-
- m_registeredImages.insert(image->attributeName(), image);
-}
-
-void WriteInitialization::acceptWidgetScripts(const DomScripts &widgetScripts, DomWidget *node, const DomWidgets &childWidgets)
-{
- // Add the per-class custom scripts to the per-widget ones.
- DomScripts scripts(widgetScripts);
-
- if (DomScript *customWidgetScript = m_uic->customWidgetsInfo()->customWidgetScript(node->attributeClass()))
- scripts.push_front(customWidgetScript);
-
- if (scripts.empty())
- return;
-
- // concatenate script snippets
- QString script;
- for (const DomScript *domScript : qAsConst(scripts)) {
- const QString snippet = domScript->text();
- if (!snippet.isEmpty())
- script += QStringRef(&snippet).trimmed() + QLatin1Char('\n');
- }
- if (script.isEmpty())
- return;
-
- // Build the list of children and insert call
- m_output << m_indent << "childWidgets.clear();\n";
- if (!childWidgets.empty()) {
- m_output << m_indent << "childWidgets";
- for (DomWidget *child : childWidgets)
- m_output << " << " << m_driver->findOrInsertWidget(child);
- m_output << ";\n";
- }
- m_output << m_indent << "scriptContext.run("
- << writeString(script, m_dindent) << ", "
- << m_driver->findOrInsertWidget(node) << ", childWidgets);\n";
-}
-
-
static void generateMultiDirectiveBegin(QTextStream &outputStream, const QSet<QString> &directives)
{
if (directives.isEmpty())
diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h
index 5e7ec200b7..187ba8378e 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.h
+++ b/src/tools/uic/cpp/cppwriteinitialization.h
@@ -88,14 +88,13 @@ struct WriteInitialization : public TreeWalker
typedef QList<DomProperty*> DomPropertyList;
typedef QHash<QString, DomProperty*> DomPropertyMap;
- WriteInitialization(Uic *uic, bool activateScripts);
+ WriteInitialization(Uic *uic);
//
// widgets
//
void acceptUI(DomUI *node) Q_DECL_OVERRIDE;
void acceptWidget(DomWidget *node) Q_DECL_OVERRIDE;
- void acceptWidgetScripts(const DomScripts &, DomWidget *node, const DomWidgets &childWidgets) Q_DECL_OVERRIDE;
void acceptLayout(DomLayout *node) Q_DECL_OVERRIDE;
void acceptSpacer(DomSpacer *node) Q_DECL_OVERRIDE;
@@ -130,11 +129,6 @@ struct WriteInitialization : public TreeWalker
//
void acceptConnection(DomConnection *connection) Q_DECL_OVERRIDE;
-//
-// images
-//
- void acceptImage(DomImage *image) Q_DECL_OVERRIDE;
-
enum {
Use43UiFile = 0,
TopLevelMargin,
@@ -229,7 +223,6 @@ private:
QString findDeclaration(const QString &name);
DomWidget *findWidget(QLatin1String widgetClass);
- DomImage *findImage(const QString &name) const;
bool isValidObject(const QString &name) const;
@@ -263,7 +256,6 @@ private:
QSet<QString> m_buttonGroups;
QHash<QString, DomWidget*> m_registeredWidgets;
- QHash<QString, DomImage*> m_registeredImages;
QHash<QString, DomAction*> m_registeredActions;
typedef QHash<uint, QString> ColorBrushHash;
ColorBrushHash m_colorBrushHash;
@@ -314,7 +306,6 @@ private:
QString m_delayedActionInitialization;
QTextStream m_actionOut;
- const bool m_activateScripts;
bool m_layoutWidget;
bool m_firstThemeIcon;