From 28ec928bfd1bb4fb5bf6fb6a7445db4f52a36a0c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 20 Jan 2010 14:06:17 +1000 Subject: Compile with Qt 4.6.1 --- src/declarative/qml/qml.pri | 4 +- src/declarative/qml/qmlbindingvme.cpp | 6 ++ src/declarative/qml/qmlcontextscriptclass.cpp | 4 +- src/declarative/qml/qmlcontextscriptclass_p.h | 9 +-- src/declarative/qml/qmlengine.cpp | 6 +- src/declarative/qml/qmlengine_p.h | 10 --- src/declarative/qml/qmlexpression.cpp | 21 ++++++ src/declarative/qml/qmllistscriptclass.cpp | 4 +- src/declarative/qml/qmllistscriptclass_p.h | 6 +- src/declarative/qml/qmlobjectscriptclass.cpp | 18 ++++- src/declarative/qml/qmlobjectscriptclass_p.h | 16 +++-- src/declarative/qml/qmlscriptclass_p.h | 89 +++++++++++++++++++++++++ src/declarative/qml/qmltypenamescriptclass.cpp | 5 +- src/declarative/qml/qmltypenamescriptclass_p.h | 6 +- src/declarative/qml/qmlvaluetypescriptclass.cpp | 4 +- src/declarative/qml/qmlvaluetypescriptclass_p.h | 8 +-- src/declarative/util/qmlpixmapcache.cpp | 7 ++ tools/qmlviewer/qmlviewer.cpp | 10 +++ 18 files changed, 186 insertions(+), 47 deletions(-) create mode 100644 src/declarative/qml/qmlscriptclass_p.h diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 1b35442..b3a3905 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -119,7 +119,9 @@ HEADERS += \ $$PWD/qmlvaluetypescriptclass_p.h \ $$PWD/qmltypenamescriptclass_p.h \ $$PWD/qmllistscriptclass_p.h \ - $$PWD/qmlworkerscript_p.h + $$PWD/qmlworkerscript_p.h \ + $$PWD/qmlscriptclass_p.h \ + $$PWD/qmlguard_p.h QT += sql diff --git a/src/declarative/qml/qmlbindingvme.cpp b/src/declarative/qml/qmlbindingvme.cpp index 0403e2e..815e585 100644 --- a/src/declarative/qml/qmlbindingvme.cpp +++ b/src/declarative/qml/qmlbindingvme.cpp @@ -383,8 +383,14 @@ inline void subscribe(QObject *o, int notifyIndex, QmlBindingVME::Config::Subscription *s = config->subscriptions + subIndex; if (o != s->source || notifyIndex != s->notifyIndex) { if (s->source) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(s->source, s->notifyIndex, config->target, config->targetSlot + subIndex); +#else + // QTBUG-6781 + QMetaObject::disconnect(s->source, s->notifyIndex, + config->target, config->targetSlot + subIndex); +#endif s->source = o; s->notifyIndex = notifyIndex; if (s->source && s->notifyIndex != -1) diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 71b77d5..eecc611 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -77,7 +77,7 @@ struct ContextData : public QScriptDeclarativeClass::Object { via QtScript. */ QmlContextScriptClass::QmlContextScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine), +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine), lastScopeObject(0), lastContext(0), lastData(0), lastPropertyIndex(-1), lastDefaultObject(-1) { } @@ -196,7 +196,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje return 0; } -QmlContextScriptClass::Value +QmlContextScriptClass::ScriptValue QmlContextScriptClass::property(Object *object, const Identifier &name) { Q_UNUSED(object); diff --git a/src/declarative/qml/qmlcontextscriptclass_p.h b/src/declarative/qml/qmlcontextscriptclass_p.h index f652371..f98d44f 100644 --- a/src/declarative/qml/qmlcontextscriptclass_p.h +++ b/src/declarative/qml/qmlcontextscriptclass_p.h @@ -54,16 +54,13 @@ // #include "qmltypenamecache_p.h" - -#include - -#include +#include "qmlscriptclass_p.h" QT_BEGIN_NAMESPACE class QmlEngine; class QmlContext; -class QmlContextScriptClass : public QScriptDeclarativeClass +class QmlContextScriptClass : public QmlScriptClass { public: QmlContextScriptClass(QmlEngine *); @@ -77,7 +74,7 @@ public: protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); private: diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index b5e7c2d..122eb07 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -64,6 +64,7 @@ #include "qmlglobal_p.h" #include "qmlworkerscript_p.h" #include "qmlcomponent_p.h" +#include "qmlscriptclass_p.h" #include @@ -1056,9 +1057,8 @@ QVariant QmlEnginePrivate::scriptValueToVariant(const QScriptValue &val) } } -QmlScriptClass::QmlScriptClass(QmlEngine *bindengine) -: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)), - engine(bindengine) +QmlScriptClass::QmlScriptClass(QScriptEngine *engine) +: QScriptDeclarativeClass(engine) { } diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 490a4ce..13c1afb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -308,16 +308,6 @@ public: }; -class QmlScriptClass : public QScriptClass -{ -public: - QmlScriptClass(QmlEngine *); - - static QVariant toVariant(QmlEngine *, const QScriptValue &); -protected: - QmlEngine *engine; -}; - QT_END_NAMESPACE #endif // QMLENGINE_P_H diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index cd6f582..c00e552 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -641,9 +641,16 @@ void QmlExpressionPrivate::clearGuards() for (int ii = 0; ii < data->guardListLength; ++ii) { if (data->guardList[ii].data()) { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(data->guardList[ii].data(), data->guardList[ii].notifyIndex, q, notifyIdx); +#else + // QTBUG-6781 + QMetaObject::disconnect(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); +#endif } } @@ -684,9 +691,16 @@ void QmlExpressionPrivate::updateGuards(const QPODVectorguardList[ii].data() && !data->guardList[ii].isDuplicate) { // Cache miss +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(data->guardList[ii].data(), data->guardList[ii].notifyIndex, q, notifyIdx); +#else + // QTBUG-6781 + QMetaObject::disconnect(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); +#endif } /* else { // Cache miss, but nothing to do @@ -732,9 +746,16 @@ void QmlExpressionPrivate::updateGuards(const QPODVectorguardListLength; ++ii) { if (data->guardList[ii].data() && !data->guardList[ii].isDuplicate) { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QMetaObject::disconnectOne(data->guardList[ii].data(), data->guardList[ii].notifyIndex, q, notifyIdx); +#else + // QTBUG-6781 + QMetaObject::disconnect(data->guardList[ii].data(), + data->guardList[ii].notifyIndex, + q, notifyIdx); +#endif } } diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index 4b8b056..441c410 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -53,7 +53,7 @@ struct ListData : public QScriptDeclarativeClass::Object { }; QmlListScriptClass::QmlListScriptClass(QmlEngine *e) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(e)), engine(e) +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(e)), engine(e) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); Q_UNUSED(scriptEngine); @@ -100,7 +100,7 @@ QmlListScriptClass::queryProperty(Object *object, const Identifier &name, } } -QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identifier &name) +QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const Identifier &name) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h index 43ca929..0c6c5b2 100644 --- a/src/declarative/qml/qmllistscriptclass_p.h +++ b/src/declarative/qml/qmllistscriptclass_p.h @@ -53,12 +53,12 @@ // We mean it. // -#include +#include QT_BEGIN_NAMESPACE class QmlEngine; -class QmlListScriptClass : public QScriptDeclarativeClass +class QmlListScriptClass : public QmlScriptClass { public: QmlListScriptClass(QmlEngine *); @@ -70,7 +70,7 @@ public: protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); private: PersistentIdentifier m_lengthId; diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 485d240..86f0afc 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -69,7 +69,10 @@ struct ObjectData : public QScriptDeclarativeClass::Object { QtScript for QML. */ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), methods(bindEngine), +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) + methods(bindEngine), +#endif lastData(0), engine(bindEngine) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -192,13 +195,13 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name, return 0; } -QmlObjectScriptClass::Value +QmlObjectScriptClass::ScriptValue QmlObjectScriptClass::property(Object *object, const Identifier &name) { return property(toQObject(object), name); } -QmlObjectScriptClass::Value +QmlObjectScriptClass::ScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name) { QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); @@ -226,10 +229,15 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) if (lastData->flags & QmlPropertyCache::Data::IsVMEFunction) { return Value(scriptEngine, ((QmlVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex)); } else { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) // Uncomment to use QtScript method call logic // QScriptValue sobj = scriptEngine->newQObject(obj); // return Value(scriptEngine, sobj.property(toString(name))); return Value(scriptEngine, methods.newMethod(obj, lastData)); +#else + QScriptValue sobj = scriptEngine->newQObject(obj); + return Value(scriptEngine, sobj.property(toString(name))); +#endif } } else { if (enginePriv->captureProperties && !(lastData->flags & QmlPropertyCache::Data::IsConstant)) { @@ -428,6 +436,8 @@ QStringList QmlObjectScriptClass::propertyNames(Object *object) return cache->propertyNames(); } +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) + struct MethodData : public QScriptDeclarativeClass::Object { MethodData(QObject *o, const QmlPropertyCache::Data &d) : object(o), data(d) {} @@ -665,5 +675,7 @@ QmlObjectMethodScriptClass::Value QmlObjectMethodScriptClass::call(Object *o, QS return Value(); } +#endif + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h index 025e491..36ba44f 100644 --- a/src/declarative/qml/qmlobjectscriptclass_p.h +++ b/src/declarative/qml/qmlobjectscriptclass_p.h @@ -56,9 +56,7 @@ #include "qmlpropertycache_p.h" #include "qmltypenamecache_p.h" -#include - -#include +#include QT_BEGIN_NAMESPACE @@ -67,6 +65,7 @@ class QScriptContext; class QScriptEngine; class QmlContext; +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) class Q_AUTOTEST_EXPORT QmlObjectMethodScriptClass : public QScriptDeclarativeClass { public: @@ -80,8 +79,9 @@ protected: private: QmlEngine *engine; }; +#endif -class Q_AUTOTEST_EXPORT QmlObjectScriptClass : public QScriptDeclarativeClass +class Q_AUTOTEST_EXPORT QmlObjectScriptClass : public QmlScriptClass { public: QmlObjectScriptClass(QmlEngine *); @@ -101,7 +101,9 @@ public: QScriptClass::QueryFlags flags, QmlContext *evalContext, QueryHints hints = 0); - Value property(QObject *, const Identifier &); + + ScriptValue property(QObject *, const Identifier &); + void setProperty(QObject *, const Identifier &name, const QScriptValue &, QmlContext *evalContext = 0); virtual QStringList propertyNames(Object *); @@ -110,13 +112,15 @@ protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual bool isQObject() const; virtual QObject *toQObject(Object *, bool *ok = 0); private: +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QmlObjectMethodScriptClass methods; +#endif QmlTypeNameCache::Data *lastTNData; QmlPropertyCache::Data *lastData; diff --git a/src/declarative/qml/qmlscriptclass_p.h b/src/declarative/qml/qmlscriptclass_p.h new file mode 100644 index 0000000..4fee59d --- /dev/null +++ b/src/declarative/qml/qmlscriptclass_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module 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 QMLSCRIPTCLASS_P_H +#define QMLSCRIPTCLASS_P_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 +#include + +QT_BEGIN_NAMESPACE + +class QmlEngine; +class QmlScriptClass : public QScriptDeclarativeClass +{ +public: + QmlScriptClass(QScriptEngine *); + + static QVariant toVariant(QmlEngine *, const QScriptValue &); + +#if (QT_VERSION < QT_VERSION_CHECK(4, 6, 2)) + struct Value : public QScriptValue { + Value() : QScriptValue() {} + Value(QScriptEngine *engine, int v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, uint v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, bool v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, double v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, float v) : QScriptValue(engine, v) {} + Value(QScriptEngine *engine, const QString &v) : QScriptValue(engine, v) {} + Value(QScriptEngine *, const QScriptValue &v) : QScriptValue(v) {} + }; + + typedef QScriptValue ScriptValue; +#else + typedef Value QScriptValue; +#endif +}; + +QT_END_NAMESPACE + +#endif // QMLSCRIPTCLASS_P_H diff --git a/src/declarative/qml/qmltypenamescriptclass.cpp b/src/declarative/qml/qmltypenamescriptclass.cpp index 3c57223..14c8652 100644 --- a/src/declarative/qml/qmltypenamescriptclass.cpp +++ b/src/declarative/qml/qmltypenamescriptclass.cpp @@ -62,7 +62,7 @@ struct TypeNameData : public QScriptDeclarativeClass::Object { }; QmlTypeNameScriptClass::QmlTypeNameScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine), object(0), type(0) { } @@ -139,7 +139,8 @@ QmlTypeNameScriptClass::queryProperty(Object *obj, const Identifier &name, return 0; } -QmlTypeNameScriptClass::Value QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) +QmlTypeNameScriptClass::ScriptValue +QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) { QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); diff --git a/src/declarative/qml/qmltypenamescriptclass_p.h b/src/declarative/qml/qmltypenamescriptclass_p.h index 702930f..cf8c621 100644 --- a/src/declarative/qml/qmltypenamescriptclass_p.h +++ b/src/declarative/qml/qmltypenamescriptclass_p.h @@ -56,14 +56,14 @@ #include -#include +#include QT_BEGIN_NAMESPACE class QmlEngine; class QmlType; class QmlTypeNameCache; -class QmlTypeNameScriptClass : public QScriptDeclarativeClass +class QmlTypeNameScriptClass : public QmlScriptClass { public: QmlTypeNameScriptClass(QmlEngine *); @@ -77,7 +77,7 @@ protected: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); private: diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp index 90de6e7..5e222a1 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass.cpp +++ b/src/declarative/qml/qmlvaluetypescriptclass.cpp @@ -53,7 +53,7 @@ struct QmlValueTypeReference : public QScriptDeclarativeClass::Object { }; QmlValueTypeScriptClass::QmlValueTypeScriptClass(QmlEngine *bindEngine) -: QScriptDeclarativeClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine) +: QmlScriptClass(QmlEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine) { } @@ -98,7 +98,7 @@ QmlValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name, return rv; } -QmlValueTypeScriptClass::Value QmlValueTypeScriptClass::property(Object *obj, const Identifier &) +QmlValueTypeScriptClass::ScriptValue QmlValueTypeScriptClass::property(Object *obj, const Identifier &) { QmlValueTypeReference *ref = static_cast(obj); diff --git a/src/declarative/qml/qmlvaluetypescriptclass_p.h b/src/declarative/qml/qmlvaluetypescriptclass_p.h index 9214987..09af967 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass_p.h +++ b/src/declarative/qml/qmlvaluetypescriptclass_p.h @@ -52,15 +52,15 @@ // // We mean it. // -#include -#include + +#include QT_BEGIN_NAMESPACE class QmlEngine; class QmlValueType; -class QmlValueTypeScriptClass : public QScriptDeclarativeClass +class QmlValueTypeScriptClass : public QmlScriptClass { public: QmlValueTypeScriptClass(QmlEngine *); @@ -70,7 +70,7 @@ public: virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - virtual Value property(Object *, const Identifier &); + virtual ScriptValue property(Object *, const Identifier &); virtual void setProperty(Object *, const Identifier &name, const QScriptValue &); virtual QVariant toVariant(Object *, bool *ok = 0); diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 130d646..48e8975 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -60,6 +60,13 @@ QT_BEGIN_NAMESPACE +#if (QT_VERSION < QT_VERSION_CHECK(4, 6, 2)) +static uint qHash(const QUrl &u) +{ + return qHash(u.toString()); +} +#endif + class QmlImageReader : public QThread { Q_OBJECT diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 4d1d4ce..7dfecc8 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -51,7 +51,9 @@ #include #include "deviceskin.h" +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) #include +#endif #include #include @@ -763,16 +765,19 @@ void QmlViewer::reload() void QmlViewer::open(const QString& doc) { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) if (doc.endsWith(".wgt",Qt::CaseInsensitive) || doc.endsWith(".wgz",Qt::CaseInsensitive) || doc.endsWith(".zip",Qt::CaseInsensitive)) openWgt(doc); else +#endif openQml(doc); } void QmlViewer::openWgt(const QString& doc) { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) // XXX This functionality could be migrated to QmlView once refined QUrl url(doc); @@ -782,8 +787,10 @@ void QmlViewer::openWgt(const QString& doc) QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); wgtreply = nam->get(QNetworkRequest(url)); connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt())); +#endif } +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) static void removeRecursive(const QString& dirname) { QDir dir(dirname); @@ -795,9 +802,11 @@ static void removeRecursive(const QString& dirname) dir.remove(entries[i].fileName()); QDir().rmdir(dirname); } +#endif void QmlViewer::unpackWgt() { +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) QByteArray all = wgtreply->readAll(); QBuffer buf(&all); buf.open(QIODevice::ReadOnly); @@ -851,6 +860,7 @@ void QmlViewer::unpackWgt() } openQml(rootfile); +#endif } void QmlViewer::openFile() -- cgit v0.12