Commit 7b5d701f authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: compile fix qmlpuppet with Qt 5

This patch allows compiling the qml(1)puppet with Qt 5.
Some minor fixes for private headers, cleaning up some old code
and QUrl::UrlFormattingOption got renamed.

Change-Id: I732f9f9ef0b831d09134b1d2c013efda55e36e11
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
(cherry picked from commit fee6b56a)
parent 2afcd57f
...@@ -94,11 +94,7 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString & ...@@ -94,11 +94,7 @@ void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &
if (metaProperty.isReadable() if (metaProperty.isReadable()
&& QDeclarativeMetaType::isList(metaProperty.userType())) { && QDeclarativeMetaType::isList(metaProperty.userType())) {
QDeclarativeListReference list(spiedObject, metaProperty.name()); QDeclarativeListReference list(spiedObject, metaProperty.name());
#if QT_VERSION<0x050000
if (list.canCount() && list.canAt()) { if (list.canCount() && list.canAt()) {
#else
if (list.isReadable()) {
#endif
for (int i = 0; i < list.count(); i++) { for (int i = 0; i < list.count(); i++) {
QObject *propertyObject = list.at(i); QObject *propertyObject = list.at(i);
if (propertyObject) if (propertyObject)
......
...@@ -287,12 +287,8 @@ static QVariant objectToVariant(QObject *object) ...@@ -287,12 +287,8 @@ static QVariant objectToVariant(QObject *object)
static bool hasFullImplementedListInterface(const QDeclarativeListReference &list) static bool hasFullImplementedListInterface(const QDeclarativeListReference &list)
{ {
#if QT_VERSION<0x050000
return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear(); return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear();
#else
return list.isChangeable();
#endif
} }
static void removeObjectFromList(const QDeclarativeProperty &property, QObject *objectToBeRemoved, QDeclarativeEngine * engine) static void removeObjectFromList(const QDeclarativeProperty &property, QObject *objectToBeRemoved, QDeclarativeEngine * engine)
...@@ -543,7 +539,11 @@ void ObjectNodeInstance::refreshProperty(const QString &name) ...@@ -543,7 +539,11 @@ void ObjectNodeInstance::refreshProperty(const QString &name)
property.write(resetValue(name)); property.write(resetValue(name));
if (oldValue.type() == QVariant::Url) { if (oldValue.type() == QVariant::Url) {
#if QT_VERSION >= 0x050000
QByteArray key = oldValue.toUrl().toEncoded(QUrl::UrlFormattingOption(0x100));
#else
QByteArray key = oldValue.toUrl().toEncoded(QUrl::FormattingOption(0x100)); QByteArray key = oldValue.toUrl().toEncoded(QUrl::FormattingOption(0x100));
#endif
QString pixmapKey = QString::fromLatin1(key.constData(), key.count()); QString pixmapKey = QString::fromLatin1(key.constData(), key.count());
QPixmapCache::remove(pixmapKey); QPixmapCache::remove(pixmapKey);
} }
...@@ -774,11 +774,7 @@ void allSubObject(QObject *object, QObjectList &objectList) ...@@ -774,11 +774,7 @@ void allSubObject(QObject *object, QObjectList &objectList)
if (metaProperty.isReadable() if (metaProperty.isReadable()
&& QDeclarativeMetaType::isList(metaProperty.userType())) { && QDeclarativeMetaType::isList(metaProperty.userType())) {
QDeclarativeListReference list(object, metaProperty.name()); QDeclarativeListReference list(object, metaProperty.name());
#if QT_VERSION<0x050000
if (list.canCount() && list.canAt()) { if (list.canCount() && list.canAt()) {
#else
if (list.isReadable()) {
#endif
for (int i = 0; i < list.count(); i++) { for (int i = 0; i < list.count(); i++) {
QObject *propertyObject = list.at(i); QObject *propertyObject = list.at(i);
allSubObject(propertyObject, objectList); allSubObject(propertyObject, objectList);
......
...@@ -38,12 +38,8 @@ ...@@ -38,12 +38,8 @@
#include "qmlstatenodeinstance.h" #include "qmlstatenodeinstance.h"
#include "anchorchangesnodeinstance.h" #include "anchorchangesnodeinstance.h"
#if QT_VERSION >= 0x050000
#include "sgitemnodeinstance.h"
#else
#include "qmlgraphicsitemnodeinstance.h" #include "qmlgraphicsitemnodeinstance.h"
#include "positionernodeinstance.h" #include "positionernodeinstance.h"
#endif
#include "nodeinstanceserver.h" #include "nodeinstanceserver.h"
#include "instancecontainer.h" #include "instancecontainer.h"
...@@ -52,10 +48,6 @@ ...@@ -52,10 +48,6 @@
#include <QSet> #include <QSet>
#include <QDebug> #include <QDebug>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QSGItem>
#endif
#include <QDeclarativeEngine> #include <QDeclarativeEngine>
/*! /*!
...@@ -178,15 +170,10 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject ...@@ -178,15 +170,10 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject
if (objectToBeWrapped == 0) if (objectToBeWrapped == 0)
instance = Internal::DummyNodeInstance::create(); instance = Internal::DummyNodeInstance::create();
#if QT_VERSION >= 0x050000
else if (isSubclassOf(objectToBeWrapped, "QSGItem"))
instance = Internal::SGItemNodeInstance::create(objectToBeWrapped);
#else
else if (isSubclassOf(objectToBeWrapped, "QDeclarativeBasePositioner")) else if (isSubclassOf(objectToBeWrapped, "QDeclarativeBasePositioner"))
instance = Internal::PositionerNodeInstance::create(objectToBeWrapped); instance = Internal::PositionerNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QDeclarativeItem")) else if (isSubclassOf(objectToBeWrapped, "QDeclarativeItem"))
instance = Internal::QmlGraphicsItemNodeInstance::create(objectToBeWrapped); instance = Internal::QmlGraphicsItemNodeInstance::create(objectToBeWrapped);
#endif
else if (isSubclassOf(objectToBeWrapped, "QDeclarativeComponent")) else if (isSubclassOf(objectToBeWrapped, "QDeclarativeComponent"))
instance = Internal::ComponentNodeInstance::create(objectToBeWrapped); instance = Internal::ComponentNodeInstance::create(objectToBeWrapped);
else if (objectToBeWrapped->inherits("QDeclarativeAnchorChanges")) else if (objectToBeWrapped->inherits("QDeclarativeAnchorChanges"))
...@@ -225,11 +212,7 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe ...@@ -225,11 +212,7 @@ ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceSe
} }
if ((object == 0) && (instanceContainer.metaType() == InstanceContainer::ItemMetaType)) //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead. if ((object == 0) && (instanceContainer.metaType() == InstanceContainer::ItemMetaType)) //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead.
#if QT_VERSION >= 0x050000
object = Internal::ObjectNodeInstance::createPrimitive("QSGItem", 2, 0, nodeInstanceServer->context());
#else
object = Internal::ObjectNodeInstance::createPrimitive("QtQuick/Item", 1, 0, nodeInstanceServer->context()); object = Internal::ObjectNodeInstance::createPrimitive("QtQuick/Item", 1, 0, nodeInstanceServer->context());
#endif
ServerNodeInstance instance(createInstance(object)); ServerNodeInstance instance(createInstance(object));
...@@ -550,13 +533,6 @@ QObject *ServerNodeInstance::internalObject() const ...@@ -550,13 +533,6 @@ QObject *ServerNodeInstance::internalObject() const
return m_nodeInstance->object(); return m_nodeInstance->object();
} }
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSGItem *ServerNodeInstance::internalSGItem() const
{
return qobject_cast<QSGItem*>(internalObject());
}
#endif
void ServerNodeInstance::activateState() void ServerNodeInstance::activateState()
{ {
m_nodeInstance->activateState(); m_nodeInstance->activateState();
......
...@@ -44,9 +44,6 @@ class QStyleOptionGraphicsItem; ...@@ -44,9 +44,6 @@ class QStyleOptionGraphicsItem;
class QDeclarativeContext; class QDeclarativeContext;
class QGraphicsItem; class QGraphicsItem;
class QGraphicsTransform; class QGraphicsTransform;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
class QSGItem;
#endif
QT_END_NAMESPACE QT_END_NAMESPACE
namespace QmlDesigner { namespace QmlDesigner {
...@@ -199,9 +196,6 @@ private: // functions ...@@ -199,9 +196,6 @@ private: // functions
QObject *internalObject() const; // should be not used outside of the nodeinstances!!!! QObject *internalObject() const; // should be not used outside of the nodeinstances!!!!
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QSGItem *internalSGItem() const;
#endif
private: // variables private: // variables
QSharedPointer<Internal::ObjectNodeInstance> m_nodeInstance; QSharedPointer<Internal::ObjectNodeInstance> m_nodeInstance;
......
QT += core gui declarative network QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4) {
QT += quick1 quick1-private core-private widgets-private gui-private script-private
} else {
QT += declarative
}
contains (QT_CONFIG, webkit) { contains (QT_CONFIG, webkit) {
QT += webkit QT += webkit
......
...@@ -3,8 +3,13 @@ TEMPLATE = subdirs ...@@ -3,8 +3,13 @@ TEMPLATE = subdirs
include(../../../qtcreator.pri) include(../../../qtcreator.pri)
include(../../private_headers.pri) include(../../private_headers.pri)
exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativecontext_p.h) { greaterThan(QT_MAJOR_VERSION, 4) {
minQtVersion(4, 7, 1) { QT += qtquick1-private core-private
SUBDIRS += qmlpuppet SUBDIRS += qmlpuppet
} else {
exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativecontext_p.h) {
minQtVersion(4, 7, 1) {
SUBDIRS += qmlpuppet
}
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment