From f208442b257015888d4903e6202772a7836d70a7 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 27 Apr 2010 14:49:46 +1000 Subject: make quitable --- demos/declarative/flickr/mobile/TitleBar.qml | 13 ++++++++++++- demos/declarative/flickr/mobile/images/quit.png | Bin 0 -> 2369 bytes 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 demos/declarative/flickr/mobile/images/quit.png diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index 71d9385..bb57429 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -18,10 +18,21 @@ Item { rssModel.tags = editor.text } + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + Text { id: categoryText anchors { - left: parent.left; right: tagButton.left; leftMargin: 10; rightMargin: 10 + left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10 verticalCenter: parent.verticalCenter } elide: Text.ElideLeft diff --git a/demos/declarative/flickr/mobile/images/quit.png b/demos/declarative/flickr/mobile/images/quit.png new file mode 100644 index 0000000..5bda1b6 Binary files /dev/null and b/demos/declarative/flickr/mobile/images/quit.png differ -- cgit v0.12 From c7e48e0ff2b49856e62379845731defd21d2134c Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 29 Apr 2010 09:55:46 +1000 Subject: Ignore QWS verbosity. --- .../declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index 36908d9..dc9c2b2 100644 --- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -122,6 +122,9 @@ void tst_qdeclarativefontloader::failLocalFont() { QString componentStr = "import Qt 4.7\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }"; QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData()); +#ifdef Q_WS_QWS + QTest::ignoreMessage(QtDebugMsg, QString("FT_New_Face failed with index 0 : 51 ").toLatin1()); +#endif QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); -- cgit v0.12 From 44708167042e95ab4b5cfef8a19a9ab4f9484a71 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 29 Apr 2010 10:31:18 +1000 Subject: Stricter (but controllable) error reporting on Connections signal-name error. And test. --- src/declarative/util/qdeclarativeconnections.cpp | 44 ++++++++++++++++++---- src/declarative/util/qdeclarativeconnections_p.h | 4 ++ .../tst_qdeclarativeconnection.cpp | 37 ++++++++++++++++++ 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp index 20d878b..c23b623 100644 --- a/src/declarative/util/qdeclarativeconnections.cpp +++ b/src/declarative/util/qdeclarativeconnections.cpp @@ -57,11 +57,13 @@ QT_BEGIN_NAMESPACE class QDeclarativeConnectionsPrivate : public QObjectPrivate { public: - QDeclarativeConnectionsPrivate() : target(0), componentcomplete(false) {} + QDeclarativeConnectionsPrivate() : target(0), ignoreUnknownSignals(false), componentcomplete(false) {} QList boundsignals; QObject *target; + bool targetSet; + bool ignoreUnknownSignals; bool componentcomplete; QByteArray data; @@ -139,17 +141,21 @@ QDeclarativeConnections::~QDeclarativeConnections() \qmlproperty Object Connections::target This property holds the object that sends the signal. - By default, the target is assumed to be the parent of the Connections. + If not set at all, the target defaults to be the parent of the Connections. + + If set to null, no connection is made and any signal handlers are ignored + until the target is not null. */ QObject *QDeclarativeConnections::target() const { Q_D(const QDeclarativeConnections); - return d->target ? d->target : parent(); + return d->targetSet ? d->target : parent(); } void QDeclarativeConnections::setTarget(QObject *obj) { Q_D(QDeclarativeConnections); + d->targetSet = true; // even if setting to 0, it is *set* if (d->target == obj) return; foreach (QDeclarativeBoundSignal *s, d->boundsignals) { @@ -166,6 +172,29 @@ void QDeclarativeConnections::setTarget(QObject *obj) emit targetChanged(); } +/*! + \qmlproperty bool Connections::ignoreUnknownSignals + + Normally, you will get a runtime error if you try to connect + to signals on an object which the object does not have. + + By setting this flag to true, such errors are ignored. This is + useful if you intend to connect to different types of object, handling + a different set of signals for each. +*/ +bool QDeclarativeConnections::ignoreUnknownSignals() const +{ + Q_D(const QDeclarativeConnections); + return d->ignoreUnknownSignals; +} + +void QDeclarativeConnections::setIgnoreUnknownSignals(bool ignore) +{ + Q_D(QDeclarativeConnections); + d->ignoreUnknownSignals = ignore; +} + + QByteArray QDeclarativeConnectionsParser::compile(const QList &props) @@ -220,7 +249,7 @@ void QDeclarativeConnectionsParser::setCustomData(QObject *object, void QDeclarativeConnections::connectSignals() { Q_D(QDeclarativeConnections); - if (!d->componentcomplete) + if (!d->componentcomplete || (d->targetSet && !target())) return; QDataStream ds(d->data); @@ -230,15 +259,14 @@ void QDeclarativeConnections::connectSignals() QString script; ds >> script; QDeclarativeProperty prop(target(), propName); - if (!prop.isValid()) { - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); - } else if (prop.type() & QDeclarativeProperty::SignalProperty) { + if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) { QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(target(), prop.method(), this); signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0)); d->boundsignals += signal; } else { - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); + if (!d->ignoreUnknownSignals) + qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); } } } diff --git a/src/declarative/util/qdeclarativeconnections_p.h b/src/declarative/util/qdeclarativeconnections_p.h index 3eacf12..b51899e 100644 --- a/src/declarative/util/qdeclarativeconnections_p.h +++ b/src/declarative/util/qdeclarativeconnections_p.h @@ -65,6 +65,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeConnections : public QObject, public QDec Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals) public: QDeclarativeConnections(QObject *parent=0); @@ -73,6 +74,9 @@ public: QObject *target() const; void setTarget(QObject *); + bool ignoreUnknownSignals() const; + void setIgnoreUnknownSignals(bool ignore); + Q_SIGNALS: void targetChanged(); diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp index 0efae3b..00e97ca 100644 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -59,6 +59,8 @@ private slots: void connection(); void trimming(); void targetChanged(); + void unknownSignals_data(); + void unknownSignals(); private: QDeclarativeEngine engine; @@ -156,6 +158,41 @@ void tst_qdeclarativeconnection::targetChanged() delete item; } +void tst_qdeclarativeconnection::unknownSignals_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error + QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error +} + +void tst_qdeclarativeconnection::unknownSignals() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); + if (!error.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1()); + } else { + // QTest has no way to insist no message (i.e. fail) + } + + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, url); + QDeclarativeItem *item = qobject_cast(c.create()); + QVERIFY(item != 0); + + // check that connection is created (they are all runtime errors) + QDeclarativeConnections *connections = item->findChild("connections"); + QVERIFY(connections); + + delete item; +} + QTEST_MAIN(tst_qdeclarativeconnection) #include "tst_qdeclarativeconnection.moc" -- cgit v0.12 From 1748ca68f3e129c0cff6b31000f1e7447297dfaf Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 29 Apr 2010 10:34:38 +1000 Subject: undebuggery --- tools/qml/qdeclarativefolderlistmodel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/qml/qdeclarativefolderlistmodel.cpp b/tools/qml/qdeclarativefolderlistmodel.cpp index 5a9d88b..2ac71ad 100644 --- a/tools/qml/qdeclarativefolderlistmodel.cpp +++ b/tools/qml/qdeclarativefolderlistmodel.cpp @@ -340,7 +340,6 @@ void QDeclarativeFolderListModel::removed(const QModelIndex &index, int start, i void QDeclarativeFolderListModel::dataChanged(const QModelIndex &start, const QModelIndex &end) { - qDebug() << "data changed"; if (start.parent() == d->folderIndex) emit itemsChanged(start.row(), end.row() - start.row() + 1, roles()); } -- cgit v0.12 From 9fb7035d59ffa582edabf53c5d617524ab92ae52 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 29 Apr 2010 15:32:34 +1000 Subject: Return enum property values as numbers, not QVariant values Task-number: QTBUG-10291 Reviewed-by: akennedy --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index bb5c8b7..671a262 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -265,7 +265,7 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); return Value(scriptEngine, rv); - } else if (lastData->propType == QMetaType::Int) { + } else if (lastData->propType == QMetaType::Int || lastData->flags & QDeclarativePropertyCache::Data::IsEnumType) { int rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); -- cgit v0.12 From 96551e8af08c6f5eb506468a1a79070f23525bca Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 29 Apr 2010 15:39:47 +1000 Subject: Remove Component's isReady, isLoading, isError and isNull properties. The Component status enum covers all of these properties already and removing these also makes the API consistent with Image and Loader. Note this change only affects the QML Component API; the methods are still available for QDeclarativeComponent. --- .../declarative/samegame/SamegameCore/samegame.js | 2 +- demos/declarative/snake/content/snake.js | 8 +-- doc/src/snippets/declarative/componentCreation.js | 6 +-- examples/declarative/dynamic/qml/itemCreation.js | 6 +-- .../tutorials/samegame/samegame2/samegame.js | 8 +-- .../tutorials/samegame/samegame3/samegame.js | 8 +-- .../samegame/samegame4/content/samegame.js | 8 +-- src/declarative/qml/qdeclarativecomponent.cpp | 58 ++-------------------- src/declarative/qml/qdeclarativecomponent.h | 5 +- 9 files changed, 28 insertions(+), 81 deletions(-) diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js index bf99ca3..cc0a70d 100755 --- a/demos/declarative/samegame/SamegameCore/samegame.js +++ b/demos/declarative/samegame/SamegameCore/samegame.js @@ -175,7 +175,7 @@ function createBlock(column,row){ // only work if the block QML is a local file. Otherwise the component will // not be ready immediately. There is a statusChanged signal on the // component you could use if you want to wait to load remote files. - if(component.isReady){ + if(component.status == Component.Ready){ var dynamicObject = component.createObject(); if(dynamicObject == null){ console.log("error creating block"); diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js index 02f9757..102bd87 100644 --- a/demos/declarative/snake/content/snake.js +++ b/demos/declarative/snake/content/snake.js @@ -52,8 +52,8 @@ function startNewGame() link.spawned = false; link.dying = false; } else { - if(linkComponent.isReady == false){ - if(linkComponent.isError == true) + if(linkComponent.status != Component.Ready) { + if(linkComponent.status == Component.Error) console.log(linkComponent.errorsString()); else console.log("Still loading linkComponent"); @@ -293,8 +293,8 @@ function createCookie(value) { } } - if(cookieComponent.isReady == false){ - if(cookieComponent.isError == true) + if(cookieComponent.status != Component.Ready) { + if(cookieComponent.status == Component.Error) console.log(cookieComponent.errorsString()); else console.log("Still loading cookieComponent"); diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js index be3e4d6..814545e 100644 --- a/doc/src/snippets/declarative/componentCreation.js +++ b/doc/src/snippets/declarative/componentCreation.js @@ -3,7 +3,7 @@ var component; var sprite; function finishCreation() { - if (component.isReady) { + if (component.status == Component.Ready) { sprite = component.createObject(); if (sprite == null) { // Error Handling @@ -13,7 +13,7 @@ function finishCreation() { sprite.y = 100; // ... } - } else if (component.isError()) { + } else if (component.status == Component.Error) { // Error Handling console.log("Error loading component:", component.errorsString()); } @@ -26,7 +26,7 @@ function createSpriteObjects() { //![2] component = Qt.createComponent("Sprite.qml"); - if (component.isReady) + if (component.status == Component.Ready) finishCreation(); else component.statusChanged.connect(finishCreation); diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js index 98d48a8..3c1b975 100644 --- a/examples/declarative/dynamic/qml/itemCreation.js +++ b/examples/declarative/dynamic/qml/itemCreation.js @@ -33,7 +33,7 @@ function loadComponent() { itemComponent = Qt.createComponent(itemButton.file); //console.log(itemButton.file) - if(itemComponent.isLoading){ + if(itemComponent.status == Component.Loading){ component.statusChanged.connect(finishCreation); }else{//Depending on the content, it can be ready or error immediately createItem(); @@ -41,7 +41,7 @@ function loadComponent() { } function createItem() { - if (itemComponent.isReady && draggedItem == null) { + if (itemComponent.status == Component.Ready && draggedItem == null) { draggedItem = itemComponent.createObject(); draggedItem.parent = window; draggedItem.image = itemButton.image; @@ -49,7 +49,7 @@ function createItem() { draggedItem.y = yOffset; startingZ = draggedItem.z; draggedItem.z = 4;//On top - } else if (itemComponent.isError) { + } else if (itemComponent.status == Component.Error) { draggedItem = null; console.log("error creating component"); console.log(component.errorsString()); diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js index e5c790d..bcfb5b6 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js @@ -37,10 +37,10 @@ function createBlock(column, row) { if (component == null) component = Qt.createComponent("Block.qml"); - // Note that if Block.qml was not a local file, component.isReady would be - // false and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and fully loaded before calling createObject(). - if (component.isReady) { + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { var dynamicObject = component.createObject(); if (dynamicObject == null) { console.log("error creating block"); diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js index da0f76e..4256aee 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js @@ -34,10 +34,10 @@ function createBlock(column, row) { if (component == null) component = Qt.createComponent("Block.qml"); - // Note that if Block.qml was not a local file, component.isReady would be - // false and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and fully loaded before calling createObject(). - if (component.isReady) { + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { var dynamicObject = component.createObject(); if (dynamicObject == null) { console.log("error creating block"); diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index 1454f0b..961cd66 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -45,10 +45,10 @@ function createBlock(column, row) { if (component == null) component = Qt.createComponent("content/BoomBlock.qml"); - // Note that if Block.qml was not a local file, component.isReady would be - // false and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and fully loaded before calling createObject(). - if (component.isReady) { + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { var dynamicObject = component.createObject(); if (dynamicObject == null) { console.log("error creating block"); diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index b83e9f4..f312497 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -269,19 +269,7 @@ QDeclarativeComponent::Status QDeclarativeComponent::status() const } /*! - \qmlproperty bool Component::isNull - - Is true if the component is in the Null state, false otherwise. - - Equivalent to status == Component.Null. -*/ - -/*! - \property QDeclarativeComponent::isNull - - Is true if the component is in the Null state, false otherwise. - - Equivalent to status() == QDeclarativeComponent::Null. + Returns true if status() == QDeclarativeComponent::Null. */ bool QDeclarativeComponent::isNull() const { @@ -289,19 +277,7 @@ bool QDeclarativeComponent::isNull() const } /*! - \qmlproperty bool Component::isReady - - Is true if the component is in the Ready state, false otherwise. - - Equivalent to status == Component.Ready. -*/ - -/*! - \property QDeclarativeComponent::isReady - - Is true if the component is in the Ready state, false otherwise. - - Equivalent to status() == QDeclarativeComponent::Ready. + Returns true if status() == QDeclarativeComponent::Ready. */ bool QDeclarativeComponent::isReady() const { @@ -309,21 +285,7 @@ bool QDeclarativeComponent::isReady() const } /*! - \qmlproperty bool Component::isError - - Is true if the component is in the Error state, false otherwise. - - Equivalent to status == Component.Error. - - Calling errorsString() will provide a human-readable description of any errors. -*/ - -/*! - \property QDeclarativeComponent::isError - - Is true if the component is in the Error state, false otherwise. - - Equivalent to status() == QDeclarativeComponent::Error. + Returns true if status() == QDeclarativeComponent::Error. */ bool QDeclarativeComponent::isError() const { @@ -331,19 +293,7 @@ bool QDeclarativeComponent::isError() const } /*! - \qmlproperty bool Component::isLoading - - Is true if the component is in the Loading state, false otherwise. - - Equivalent to status == Component::Loading. -*/ - -/*! - \property QDeclarativeComponent::isLoading - - Is true if the component is in the Loading state, false otherwise. - - Equivalent to status() == QDeclarativeComponent::Loading. + Returns true if status() == QDeclarativeComponent::Loading. */ bool QDeclarativeComponent::isLoading() const { diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h index f3cfe3c..b078174 100644 --- a/src/declarative/qml/qdeclarativecomponent.h +++ b/src/declarative/qml/qdeclarativecomponent.h @@ -64,10 +64,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeComponent : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeComponent) - Q_PROPERTY(bool isNull READ isNull NOTIFY statusChanged) - Q_PROPERTY(bool isReady READ isReady NOTIFY statusChanged) - Q_PROPERTY(bool isError READ isError NOTIFY statusChanged) - Q_PROPERTY(bool isLoading READ isLoading NOTIFY statusChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(QUrl url READ url CONSTANT) -- cgit v0.12 From a5e5b178615cea0dc795fd2008ef258030d2e8e6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 29 Apr 2010 15:41:55 +1000 Subject: Don't call qRegisterMetaType() in global scope --- src/declarative/qml/qdeclarativecomponent.cpp | 1 - src/declarative/qml/qdeclarativeengine.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index f312497..b81a32a 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE class QByteArray; -int statusId = qRegisterMetaType("QDeclarativeComponent::Status"); /*! \class QDeclarativeComponent diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index a22011a..19d4b57 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -347,6 +347,7 @@ void QDeclarativeEnginePrivate::init() qRegisterMetaType("QVariant"); qRegisterMetaType("QDeclarativeScriptString"); qRegisterMetaType("QScriptValue"); + qRegisterMetaType("QDeclarativeComponent::Status"); QDeclarativeData::init(); -- cgit v0.12 From 1517c4fb9199d32c69378808a27f83d2edf065b2 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 29 Apr 2010 16:05:51 +1000 Subject: Ensure filenames are correctly resolved Works around QUrl("file:a").isRelative() being false. Reviewed-by: Aaron Kennedy --- src/declarative/qml/qdeclarativecomponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index b83e9f4..a80f183 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -421,7 +421,7 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeEngine *engine, const Q { Q_D(QDeclarativeComponent); d->engine = engine; - loadUrl(QUrl::fromLocalFile(fileName)); + loadUrl(d->engine->baseUrl().resolved(QUrl::fromLocalFile(fileName))); } /*! -- cgit v0.12 From 42945f30e9b3cb70c43d51575aac204e3371fe33 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 29 Apr 2010 16:14:05 +1000 Subject: Update QmlChanges.txt --- src/declarative/QmlChanges.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 9c46467..7218f78 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -2,6 +2,8 @@ The changes below are pre Qt 4.7.0 RC Flickable: overShoot is replaced by boundsBehavior enumeration. +Component: isReady, isLoading, isError and isNull properties removed, use + status property instead C++ API ------- -- cgit v0.12 From 4eb2e50b97a9933ab249517aa42cce9b3b4115e2 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 29 Apr 2010 08:20:25 +0200 Subject: Mark some properties in QDeclarativeItem as private properties. QDeclarativeItem will be public, all properties that are relaying on private types must be private too. Reviewed-by:akennedy --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 128 +++-------- src/declarative/graphicsitems/qdeclarativeitem.h | 44 ++-- src/declarative/graphicsitems/qdeclarativeitem_p.h | 23 +- .../graphicsitems/qdeclarativepositioners.cpp | 8 +- .../util/qdeclarativestateoperations.cpp | 89 ++++---- .../tst_qdeclarativeanchors.cpp | 53 +++-- .../tst_qdeclarativeanimations.cpp | 21 +- .../tst_qdeclarativebehaviors.cpp | 25 ++- .../qdeclarativestates/tst_qdeclarativestates.cpp | 241 +++++++++++---------- 9 files changed, 295 insertions(+), 337 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 723ed34..65b996d 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1263,11 +1263,6 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec */ /*! - \property QDeclarativeItem::baseline - \internal -*/ - -/*! \property QDeclarativeItem::focus \internal */ @@ -1472,11 +1467,6 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const */ /*! - \property QDeclarativeItem::resources - \internal -*/ - -/*! Returns true if construction of the QML component is complete; otherwise returns false. @@ -1491,18 +1481,6 @@ bool QDeclarativeItem::isComponentComplete() const return d->_componentComplete; } -/*! - \property QDeclarativeItem::anchors - \internal -*/ - -/*! \internal */ -QDeclarativeAnchors *QDeclarativeItem::anchors() -{ - Q_D(QDeclarativeItem); - return d->anchors(); -} - void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty *prop, QObject *o) { if (!o) @@ -1625,14 +1603,13 @@ void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeN */ /*! - \property QDeclarativeItem::data \internal */ /*! \internal */ -QDeclarativeListProperty QDeclarativeItem::data() +QDeclarativeListProperty QDeclarativeItemPrivate::data() { - return QDeclarativeListProperty(this, 0, QDeclarativeItemPrivate::data_append); + return QDeclarativeListProperty(q_func(), 0, QDeclarativeItemPrivate::data_append); } /*! @@ -1860,98 +1837,61 @@ QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::left() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::left() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->left; + return anchorLines()->left; } /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::right() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::right() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->right; + return anchorLines()->right; } /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::horizontalCenter() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::horizontalCenter() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->hCenter; + return anchorLines()->hCenter; } /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::top() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::top() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->top; + return anchorLines()->top; } /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::bottom() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::bottom() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->bottom; + return anchorLines()->bottom; } /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::verticalCenter() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::verticalCenter() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->vCenter; + return anchorLines()->vCenter; } /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItem::baseline() const +QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const { - Q_D(const QDeclarativeItem); - return d->anchorLines()->baseline; + return anchorLines()->baseline; } /*! - \property QDeclarativeItem::top - \internal -*/ - -/*! - \property QDeclarativeItem::bottom - \internal -*/ - -/*! - \property QDeclarativeItem::left - \internal -*/ - -/*! - \property QDeclarativeItem::right - \internal -*/ - -/*! - \property QDeclarativeItem::horizontalCenter - \internal -*/ - -/*! - \property QDeclarativeItem::verticalCenter - \internal -*/ - -/*! \qmlproperty AnchorLine Item::top \qmlproperty AnchorLine Item::bottom \qmlproperty AnchorLine Item::left @@ -2291,9 +2231,9 @@ void QDeclarativeItemPrivate::focusChanged(bool flag) } /*! \internal */ -QDeclarativeListProperty QDeclarativeItem::resources() +QDeclarativeListProperty QDeclarativeItemPrivate::resources() { - return QDeclarativeListProperty(this, 0, QDeclarativeItemPrivate::resources_append, + return QDeclarativeListProperty(q_func(), 0, QDeclarativeItemPrivate::resources_append, QDeclarativeItemPrivate::resources_count, QDeclarativeItemPrivate::resources_at); } @@ -2315,15 +2255,10 @@ QDeclarativeListProperty QDeclarativeItem::resources() \sa {qmlstate}{States} */ -/*! - \property QDeclarativeItem::states - \internal -*/ /*! \internal */ -QDeclarativeListProperty QDeclarativeItem::states() +QDeclarativeListProperty QDeclarativeItemPrivate::states() { - Q_D(QDeclarativeItem); - return d->states()->statesProperty(); + return _states()->statesProperty(); } /*! @@ -2343,16 +2278,11 @@ QDeclarativeListProperty QDeclarativeItem::states() \sa {state-transitions}{Transitions} */ -/*! - \property QDeclarativeItem::transitions - \internal -*/ /*! \internal */ -QDeclarativeListProperty QDeclarativeItem::transitions() +QDeclarativeListProperty QDeclarativeItemPrivate::transitions() { - Q_D(QDeclarativeItem); - return d->states()->transitionsProperty(); + return _states()->transitionsProperty(); } /* @@ -2426,20 +2356,18 @@ QDeclarativeListProperty QDeclarativeItem::transitions() */ /*! \internal */ -QString QDeclarativeItem::state() const +QString QDeclarativeItemPrivate::state() const { - Q_D(const QDeclarativeItem); - if (!d->_stateGroup) + if (!_stateGroup) return QString(); else - return d->_stateGroup->state(); + return _stateGroup->state(); } /*! \internal */ -void QDeclarativeItem::setState(const QString &state) +void QDeclarativeItemPrivate::setState(const QString &state) { - Q_D(QDeclarativeItem); - d->states()->setState(state); + _states()->setState(state); } /*! @@ -2502,7 +2430,7 @@ void QDeclarativeItem::componentComplete() d->keyHandler->componentComplete(); } -QDeclarativeStateGroup *QDeclarativeItemPrivate::states() +QDeclarativeStateGroup *QDeclarativeItemPrivate::_states() { Q_Q(QDeclarativeItem); if (!_stateGroup) { diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index da5a36e..3b05b09 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -70,20 +70,20 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe Q_INTERFACES(QDeclarativeParserStatus) Q_PROPERTY(QDeclarativeItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL) - Q_PROPERTY(QDeclarativeListProperty data READ data DESIGNABLE false) - Q_PROPERTY(QDeclarativeListProperty resources READ resources DESIGNABLE false) - Q_PROPERTY(QDeclarativeListProperty states READ states DESIGNABLE false) - Q_PROPERTY(QDeclarativeListProperty transitions READ transitions DESIGNABLE false) - Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty data READ data DESIGNABLE false) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty resources READ resources DESIGNABLE false) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty states READ states DESIGNABLE false) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty transitions READ transitions DESIGNABLE false) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) - Q_PROPERTY(QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine left READ left CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine right READ right CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine top READ top CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine left READ left CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine right READ right CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine top READ top CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine bottom READ bottom CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine baseline READ baseline CONSTANT FINAL) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) @@ -107,21 +107,11 @@ public: QDeclarativeItem *parentItem() const; void setParentItem(QDeclarativeItem *parent); - QDeclarativeListProperty data(); - QDeclarativeListProperty resources(); - - QDeclarativeAnchors *anchors(); QRectF childrenRect(); bool clip() const; void setClip(bool); - QDeclarativeListProperty states(); - QDeclarativeListProperty transitions(); - - QString state() const; - void setState(const QString &); - qreal baselineOffset() const; void setBaselineOffset(qreal); @@ -159,14 +149,6 @@ public: Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const; Q_INVOKABLE void forceFocus(); - QDeclarativeAnchorLine left() const; - QDeclarativeAnchorLine right() const; - QDeclarativeAnchorLine horizontalCenter() const; - QDeclarativeAnchorLine top() const; - QDeclarativeAnchorLine bottom() const; - QDeclarativeAnchorLine verticalCenter() const; - QDeclarativeAnchorLine baseline() const; - Q_SIGNALS: void childrenChanged(); void childrenRectChanged(const QRectF &); diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h index 3f5bf1a..b4dd60a 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h @@ -150,6 +150,22 @@ public: void setHeight(qreal); void resetHeight(); + QDeclarativeListProperty data(); + QDeclarativeListProperty resources(); + + QDeclarativeListProperty states(); + QDeclarativeListProperty transitions(); + + QString state() const; + void setState(const QString &); + + QDeclarativeAnchorLine left() const; + QDeclarativeAnchorLine right() const; + QDeclarativeAnchorLine horizontalCenter() const; + QDeclarativeAnchorLine top() const; + QDeclarativeAnchorLine bottom() const; + QDeclarativeAnchorLine verticalCenter() const; + QDeclarativeAnchorLine baseline() const; // data property static void data_append(QDeclarativeListProperty *, QObject *); @@ -165,6 +181,11 @@ public: static QGraphicsTransform *transform_at(QDeclarativeListProperty *list, int); static void transform_clear(QDeclarativeListProperty *list); + static QDeclarativeItemPrivate* get(QDeclarativeItem *item) + { + return item->d_func(); + } + // Accelerated property accessors QDeclarativeNotifier parentNotifier; static void parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e); @@ -224,7 +245,7 @@ public: void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types); QPODVector changeListeners; - QDeclarativeStateGroup *states(); + QDeclarativeStateGroup *_states(); QDeclarativeStateGroup *_stateGroup; QDeclarativeItem::TransformOrigin origin:4; diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 13ee4e6..3f1d2ac 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -443,7 +443,7 @@ void QDeclarativeColumn::reportConflictingAnchors() for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { - QDeclarativeAnchors::Anchors usedAnchors = child.item->anchors()->usedAnchors(); + QDeclarativeAnchors::Anchors usedAnchors = QDeclarativeItemPrivate::get(child.item)->anchors()->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::TopAnchor || usedAnchors & QDeclarativeAnchors::BottomAnchor || usedAnchors & QDeclarativeAnchors::VCenterAnchor) { @@ -578,7 +578,7 @@ void QDeclarativeRow::reportConflictingAnchors() for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item) { - QDeclarativeAnchors::Anchors usedAnchors = child.item->anchors()->usedAnchors(); + QDeclarativeAnchors::Anchors usedAnchors = QDeclarativeItemPrivate::get(child.item)->anchors()->usedAnchors(); if (usedAnchors & QDeclarativeAnchors::LeftAnchor || usedAnchors & QDeclarativeAnchors::RightAnchor || usedAnchors & QDeclarativeAnchors::HCenterAnchor) { @@ -868,7 +868,7 @@ void QDeclarativeGrid::reportConflictingAnchors() bool childsWithConflictingAnchors(false); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); - if (child.item && child.item->anchors()->usedAnchors()) { + if (child.item && QDeclarativeItemPrivate::get(child.item)->anchors()->usedAnchors()) { childsWithConflictingAnchors = true; break; } @@ -1025,7 +1025,7 @@ void QDeclarativeFlow::reportConflictingAnchors() bool childsWithConflictingAnchors(false); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); - if (child.item && child.item->anchors()->usedAnchors()) { + if (child.item && QDeclarativeItemPrivate::get(child.item)->anchors()->usedAnchors()) { childsWithConflictingAnchors = true; break; } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 689f53c..a93a25d 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -1056,40 +1056,41 @@ void QDeclarativeAnchorChanges::execute(Reason reason) if (!d->target) return; + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //incorporate any needed "reverts" if (d->applyOrigLeft) { if (!d->origLeftBinding) - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); } if (d->applyOrigRight) { if (!d->origRightBinding) - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); } if (d->applyOrigHCenter) { if (!d->origHCenterBinding) - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); } if (d->applyOrigTop) { if (!d->origTopBinding) - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); } if (d->applyOrigBottom) { if (!d->origBottomBinding) - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); } if (d->applyOrigVCenter) { if (!d->origVCenterBinding) - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); } if (d->applyOrigBaseline) { if (!d->origBaselineBinding) - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); } @@ -1105,31 +1106,31 @@ void QDeclarativeAnchorChanges::execute(Reason reason) //reset any anchors that have been specified as "undefined" if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor) { - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor) { - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor) { - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor) { - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor) { - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor) { - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); } if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor) { - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); } @@ -1161,51 +1162,52 @@ void QDeclarativeAnchorChanges::reverse(Reason reason) if (!d->target) return; + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //reset any anchors set by the state if (d->leftBinding) { - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0); if (reason == ActualChange) { d->leftBinding->destroy(); d->leftBinding = 0; } } if (d->rightBinding) { - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0); if (reason == ActualChange) { d->rightBinding->destroy(); d->rightBinding = 0; } } if (d->hCenterBinding) { - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0); if (reason == ActualChange) { d->hCenterBinding->destroy(); d->hCenterBinding = 0; } } if (d->topBinding) { - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0); if (reason == ActualChange) { d->topBinding->destroy(); d->topBinding = 0; } } if (d->bottomBinding) { - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0); if (reason == ActualChange) { d->bottomBinding->destroy(); d->bottomBinding = 0; } } if (d->vCenterBinding) { - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0); if (reason == ActualChange) { d->vCenterBinding->destroy(); d->vCenterBinding = 0; } } if (d->baselineBinding) { - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0); if (reason == ActualChange) { d->baselineBinding->destroy(); d->baselineBinding = 0; @@ -1335,37 +1337,38 @@ void QDeclarativeAnchorChanges::clearBindings() d->fromWidth = d->target->width(); d->fromHeight = d->target->height(); + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //reset any anchors with corresponding reverts //reset any anchors that have been specified as "undefined" //reset any anchors that we'll be setting in the state QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->resetAnchors | d->anchorSet->d_func()->usedAnchors; if (d->applyOrigLeft || (combined & QDeclarativeAnchors::LeftAnchor)) { - d->target->anchors()->resetLeft(); + targetPrivate->anchors()->resetLeft(); QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); } if (d->applyOrigRight || (combined & QDeclarativeAnchors::RightAnchor)) { - d->target->anchors()->resetRight(); + targetPrivate->anchors()->resetRight(); QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); } if (d->applyOrigHCenter || (combined & QDeclarativeAnchors::HCenterAnchor)) { - d->target->anchors()->resetHorizontalCenter(); + targetPrivate->anchors()->resetHorizontalCenter(); QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); } if (d->applyOrigTop || (combined & QDeclarativeAnchors::TopAnchor)) { - d->target->anchors()->resetTop(); + targetPrivate->anchors()->resetTop(); QDeclarativePropertyPrivate::setBinding(d->topProp, 0); } if (d->applyOrigBottom || (combined & QDeclarativeAnchors::BottomAnchor)) { - d->target->anchors()->resetBottom(); + targetPrivate->anchors()->resetBottom(); QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); } if (d->applyOrigVCenter || (combined & QDeclarativeAnchors::VCenterAnchor)) { - d->target->anchors()->resetVerticalCenter(); + targetPrivate->anchors()->resetVerticalCenter(); QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); } if (d->applyOrigBaseline || (combined & QDeclarativeAnchors::BaselineAnchor)) { - d->target->anchors()->resetBaseline(); + targetPrivate->anchors()->resetBaseline(); QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); } } @@ -1387,21 +1390,22 @@ void QDeclarativeAnchorChanges::rewind() if (!d->target) return; + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); //restore previous anchors if (d->rewindLeft.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setLeft(d->rewindLeft); + targetPrivate->anchors()->setLeft(d->rewindLeft); if (d->rewindRight.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setRight(d->rewindRight); + targetPrivate->anchors()->setRight(d->rewindRight); if (d->rewindHCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setHorizontalCenter(d->rewindHCenter); + targetPrivate->anchors()->setHorizontalCenter(d->rewindHCenter); if (d->rewindTop.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setTop(d->rewindTop); + targetPrivate->anchors()->setTop(d->rewindTop); if (d->rewindBottom.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setBottom(d->rewindBottom); + targetPrivate->anchors()->setBottom(d->rewindBottom); if (d->rewindVCenter.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setVerticalCenter(d->rewindVCenter); + targetPrivate->anchors()->setVerticalCenter(d->rewindVCenter); if (d->rewindBaseline.anchorLine != QDeclarativeAnchorLine::Invalid) - d->target->anchors()->setBaseline(d->rewindBaseline); + targetPrivate->anchors()->setBaseline(d->rewindBaseline); d->target->setX(d->rewindX); d->target->setY(d->rewindY); @@ -1415,13 +1419,14 @@ void QDeclarativeAnchorChanges::saveCurrentValues() if (!d->target) return; - d->rewindLeft = d->target->anchors()->left(); - d->rewindRight = d->target->anchors()->right(); - d->rewindHCenter = d->target->anchors()->horizontalCenter(); - d->rewindTop = d->target->anchors()->top(); - d->rewindBottom = d->target->anchors()->bottom(); - d->rewindVCenter = d->target->anchors()->verticalCenter(); - d->rewindBaseline = d->target->anchors()->baseline(); + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + d->rewindLeft = targetPrivate->anchors()->left(); + d->rewindRight = targetPrivate->anchors()->right(); + d->rewindHCenter = targetPrivate->anchors()->horizontalCenter(); + d->rewindTop = targetPrivate->anchors()->top(); + d->rewindBottom = targetPrivate->anchors()->bottom(); + d->rewindVCenter = targetPrivate->anchors()->verticalCenter(); + d->rewindBaseline = targetPrivate->anchors()->baseline(); d->rewindX = d->target->x(); d->rewindY = d->target->y(); diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index dff62c7..e169fa2 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -48,6 +48,7 @@ #include #include #include +#include Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor) Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine) @@ -376,15 +377,16 @@ void tst_qdeclarativeanchors::reset() anchor.anchorLine = anchorLine; QDeclarativeItem *item = new QDeclarativeItem; + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - const QMetaObject *meta = item->anchors()->metaObject(); + const QMetaObject *meta = itemPrivate->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); - QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), true); + QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); + QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true); - QVERIFY(p.reset(item->anchors())); - QCOMPARE(item->anchors()->usedAnchors().testFlag(usedAnchor), false); + QVERIFY(p.reset(itemPrivate->anchors())); + QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false); delete item; delete baseItem; @@ -410,18 +412,19 @@ void tst_qdeclarativeanchors::resetConvenience() { QDeclarativeItem *baseItem = new QDeclarativeItem; QDeclarativeItem *item = new QDeclarativeItem; + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); //fill - item->anchors()->setFill(baseItem); - QVERIFY(item->anchors()->fill() == baseItem); - item->anchors()->resetFill(); - QVERIFY(item->anchors()->fill() == 0); + itemPrivate->anchors()->setFill(baseItem); + QVERIFY(itemPrivate->anchors()->fill() == baseItem); + itemPrivate->anchors()->resetFill(); + QVERIFY(itemPrivate->anchors()->fill() == 0); //centerIn - item->anchors()->setCenterIn(baseItem); - QVERIFY(item->anchors()->centerIn() == baseItem); - item->anchors()->resetCenterIn(); - QVERIFY(item->anchors()->centerIn() == 0); + itemPrivate->anchors()->setCenterIn(baseItem); + QVERIFY(itemPrivate->anchors()->centerIn() == baseItem); + itemPrivate->anchors()->resetCenterIn(); + QVERIFY(itemPrivate->anchors()->centerIn() == 0); delete item; delete baseItem; @@ -433,12 +436,13 @@ void tst_qdeclarativeanchors::nullItem() QDeclarativeAnchorLine anchor; QDeclarativeItem *item = new QDeclarativeItem; + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - const QMetaObject *meta = item->anchors()->metaObject(); + const QMetaObject *meta = itemPrivate->anchors()->metaObject(); QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); QTest::ignoreMessage(QtWarningMsg, ": QML Item: Cannot anchor to a null item."); - QVERIFY(p.write(item->anchors(), qVariantFromValue(anchor))); + QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); delete item; } @@ -486,15 +490,16 @@ void tst_qdeclarativeanchors::fill() qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); //Alter Offsets (tests QTBUG-6631) - rect->anchors()->setLeftMargin(20.0); - rect->anchors()->setRightMargin(0.0); - rect->anchors()->setBottomMargin(0.0); - rect->anchors()->setTopMargin(10.0); + rectPrivate->anchors()->setLeftMargin(20.0); + rectPrivate->anchors()->setRightMargin(0.0); + rectPrivate->anchors()->setBottomMargin(0.0); + rectPrivate->anchors()->setTopMargin(10.0); QCOMPARE(rect->x(), 0.0 + 20.0); QCOMPARE(rect->y(), 0.0 + 10.0); QCOMPARE(rect->width(), 200.0 - 20.0); @@ -509,11 +514,12 @@ void tst_qdeclarativeanchors::centerIn() qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 75.0 + 10); QCOMPARE(rect->y(), 75.0 + 30); //Alter Offsets (tests QTBUG-6631) - rect->anchors()->setHorizontalCenterOffset(-20.0); - rect->anchors()->setVerticalCenterOffset(-10.0); + rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); + rectPrivate->anchors()->setVerticalCenterOffset(-10.0); QCOMPARE(rect->x(), 75.0 - 20.0); QCOMPARE(rect->y(), 75.0 - 10.0); @@ -526,13 +532,14 @@ void tst_qdeclarativeanchors::margins() qApp->processEvents(); QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); - rect->anchors()->setTopMargin(0.0); - rect->anchors()->setMargins(20.0); + rectPrivate->anchors()->setTopMargin(0.0); + rectPrivate->anchors()->setMargins(20.0); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 20.0); diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index e217e34..ed7e506 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -324,7 +325,7 @@ void tst_qdeclarativeanimations::badTypes() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(1000 + 50); QDeclarativeRectangle *myRect = rect->findChild("MyRect"); QVERIFY(myRect); @@ -366,7 +367,7 @@ void tst_qdeclarativeanimations::mixedTypes() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(500); QDeclarativeRectangle *myRect = rect->findChild("MyRect"); QVERIFY(myRect); @@ -382,7 +383,7 @@ void tst_qdeclarativeanimations::mixedTypes() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(500); QDeclarativeRectangle *myRect = rect->findChild("MyRect"); QVERIFY(myRect); @@ -468,7 +469,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QDeclarativeRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); @@ -483,7 +484,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); QCOMPARE(myRect->y(),qreal(100)); QTest::qWait(waitDuration); @@ -498,7 +499,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); QCOMPARE(myRect->y(),qreal(100)); } @@ -511,7 +512,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -525,7 +526,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -539,7 +540,7 @@ void tst_qdeclarativeanimations::propertiesTransition() QDeclarativeRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(100)); @@ -709,7 +710,7 @@ void tst_qdeclarativeanimations::rotation() QDeclarativeRectangle *rr3 = rect->findChild("rr3"); QDeclarativeRectangle *rr4 = rect->findChild("rr4"); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QTest::qWait(800); qreal r1 = rr->rotation(); qreal r2 = rr2->rotation(); diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 5e0c9d5..1dc4b53 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include "../../../shared/util.h" class tst_qdeclarativebehaviors : public QObject @@ -81,7 +82,7 @@ void tst_qdeclarativebehaviors::simpleBehavior() QTRY_VERIFY(rect); QTRY_VERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered @@ -129,7 +130,7 @@ void tst_qdeclarativebehaviors::loop() QTRY_VERIFY(rect); //don't crash - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); delete rect; } @@ -141,7 +142,7 @@ void tst_qdeclarativebehaviors::colorBehavior() QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - rect->setState("red"); + QDeclarativeItemPrivate::get(rect)->setState("red"); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); //i.e. the behavior has been triggered @@ -156,7 +157,7 @@ void tst_qdeclarativebehaviors::parentBehavior() QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); @@ -170,7 +171,7 @@ void tst_qdeclarativebehaviors::replaceBinding() QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QTRY_VERIFY(innerRect); QTRY_VERIFY(innerRect->x() > 0); @@ -182,7 +183,7 @@ void tst_qdeclarativebehaviors::replaceBinding() rect->setProperty("movedx", 210); QTRY_COMPARE(innerRect->x(), (qreal)210); - rect->setState(""); + QDeclarativeItemPrivate::get(rect)->setState(""); QTRY_VERIFY(innerRect->x() > 10); QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered QTRY_COMPARE(innerRect->x(), (qreal)10); @@ -202,7 +203,7 @@ void tst_qdeclarativebehaviors::group() QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); //QTest::qWait(200); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); @@ -217,7 +218,7 @@ void tst_qdeclarativebehaviors::group() QDeclarativeRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered @@ -233,7 +234,7 @@ void tst_qdeclarativebehaviors::emptyBehavior() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately @@ -247,7 +248,7 @@ void tst_qdeclarativebehaviors::explicitSelection() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered @@ -262,7 +263,7 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior() QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately @@ -291,7 +292,7 @@ void tst_qdeclarativebehaviors::disabled() QVERIFY(rect); QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); - rect->setState("moved"); + QDeclarativeItemPrivate::get(rect)->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index a016fa7..d384d26 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -47,6 +47,7 @@ #include #include #include +#include class MyRect : public QDeclarativeRectangle @@ -128,63 +129,66 @@ void tst_qdeclarativestates::basicChanges() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),2); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),2); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); @@ -220,32 +224,33 @@ void tst_qdeclarativestates::basicExtension() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),2); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),1); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); - rect->setState("bordered"); + rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->border()->width(),2); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->border()->width(),1); } @@ -253,26 +258,27 @@ void tst_qdeclarativestates::basicExtension() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); } } @@ -284,77 +290,80 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("yellow")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("green")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("yellow")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("yellow")); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("red")); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor2", QColor("yellow")); QCOMPARE(rect->color(),QColor("yellow")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor2", QColor("green")); QCOMPARE(rect->color(),QColor("red")); @@ -365,27 +374,28 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("yellow")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); rect->setProperty("sourceColor", QColor("purple")); QCOMPARE(rect->color(),QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("purple")); - rect->setState("green"); + rectPrivate->setState("green"); QCOMPARE(rect->color(),QColor("green")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); } } @@ -403,7 +413,7 @@ void tst_qdeclarativestates::signalOverride() rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); - rect->setState("green"); + QDeclarativeItemPrivate::get(rect)->setState("green"); rect->doSomething(); QCOMPARE(rect->color(),QColor("green")); } @@ -418,8 +428,7 @@ void tst_qdeclarativestates::signalOverride() QCOMPARE(rect->color(),QColor("blue")); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); - - innerRect->setState("green"); + QDeclarativeItemPrivate::get(innerRect)->setState("green"); rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(innerRect->color(),QColor("green")); @@ -435,7 +444,7 @@ void tst_qdeclarativestates::signalOverrideCrash() MyRect *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - rect->setState("overridden"); + QDeclarativeItemPrivate::get(rect)->setState("overridden"); rect->doSomething(); } @@ -463,7 +472,7 @@ void tst_qdeclarativestates::parentChange() QCOMPARE(pChange->parent(), nParent); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(-133)); @@ -474,11 +483,11 @@ void tst_qdeclarativestates::parentChange() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - rect->setState("reparented"); + rectPrivate->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(15)); QCOMPARE(innerRect->scale(), qreal(.5)); QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); @@ -489,17 +498,17 @@ void tst_qdeclarativestates::parentChange() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - rect->setState("reparented"); + rectPrivate->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(-37)); QCOMPARE(innerRect->scale(), qreal(.25)); QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305)); QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -521,7 +530,7 @@ void tst_qdeclarativestates::parentChangeErrors() QVERIFY(innerRect != 0); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -537,7 +546,7 @@ void tst_qdeclarativestates::parentChangeErrors() QVERIFY(innerRect != 0); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); - rect->setState("reparented"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -552,6 +561,7 @@ void tst_qdeclarativestates::anchorChanges() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); @@ -564,14 +574,14 @@ void tst_qdeclarativestates::anchorChanges() QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("right"); + rectPrivate->setState("right"); QCOMPARE(innerRect->x(), qreal(150)); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->object()->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item); - QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(5)); delete rect; @@ -584,14 +594,15 @@ void tst_qdeclarativestates::anchorChanges2() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - rect->setState("right"); + rectPrivate->setState("right"); QCOMPARE(innerRect->x(), qreal(150)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(5)); delete rect; @@ -604,6 +615,7 @@ void tst_qdeclarativestates::anchorChanges3() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); @@ -622,23 +634,23 @@ void tst_qdeclarativestates::anchorChanges3() QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("reanchored"); + rectPrivate->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->object()->anchors()->left().item, leftGuideline->left().item); - QCOMPARE(aChanges->object()->anchors()->left().anchorLine, leftGuideline->left().anchorLine); - QCOMPARE(aChanges->object()->anchors()->right().item, rect->right().item); - QCOMPARE(aChanges->object()->anchors()->right().anchorLine, rect->right().anchorLine); - QCOMPARE(aChanges->object()->anchors()->top().item, rect->top().item); - QCOMPARE(aChanges->object()->anchors()->top().anchorLine, rect->top().anchorLine); - QCOMPARE(aChanges->object()->anchors()->bottom().item, bottomGuideline->bottom().item); - QCOMPARE(aChanges->object()->anchors()->bottom().anchorLine, bottomGuideline->bottom().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); QCOMPARE(innerRect->x(), qreal(10)); QCOMPARE(innerRect->y(), qreal(0)); QCOMPARE(innerRect->width(), qreal(190)); QCOMPARE(innerRect->height(), qreal(150)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(0)); QCOMPARE(innerRect->y(), qreal(10)); QCOMPARE(innerRect->width(), qreal(150)); @@ -672,12 +684,12 @@ void tst_qdeclarativestates::anchorChanges4() QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("reanchored"); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(aChanges->object()->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); - QCOMPARE(aChanges->object()->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); - QCOMPARE(aChanges->object()->anchors()->verticalCenter().item, leftGuideline->verticalCenter().item); - QCOMPARE(aChanges->object()->anchors()->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); delete rect; } @@ -707,7 +719,7 @@ void tst_qdeclarativestates::anchorChanges5() QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); - rect->setState("reanchored"); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); QCOMPARE(aChanges->object(), qobject_cast(innerRect)); //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); @@ -726,7 +738,7 @@ void tst_qdeclarativestates::anchorChangesCrash() QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - rect->setState("reanchored"); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); delete rect; } @@ -739,13 +751,13 @@ void tst_qdeclarativestates::script() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted } } @@ -757,13 +769,13 @@ void tst_qdeclarativestates::restoreEntryValues() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("blue")); } @@ -774,7 +786,7 @@ void tst_qdeclarativestates::explicitChanges() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QDeclarativeListReference list(rect, "states"); QDeclarativeState *state = qobject_cast(list.at(0)); QVERIFY(state != 0); @@ -786,18 +798,18 @@ void tst_qdeclarativestates::explicitChanges() QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); rect->setProperty("sourceColor", QColor("green")); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); rect->setProperty("sourceColor", QColor("yellow")); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("yellow")); } @@ -812,7 +824,7 @@ void tst_qdeclarativestates::propertyErrors() QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\""); - rect->setState("blue"); + QDeclarativeItemPrivate::get(rect)->setState("blue"); } void tst_qdeclarativestates::incorrectRestoreBug() @@ -822,22 +834,22 @@ void tst_qdeclarativestates::incorrectRestoreBug() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); // make sure if we change the base state value, we then restore to it correctly rect->setColor(QColor("green")); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("green")); } @@ -865,12 +877,12 @@ void tst_qdeclarativestates::deletingChange() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - - rect->setState("blue"); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->radius(),qreal(5)); - rect->setState(""); + rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->radius(),qreal(0)); @@ -883,7 +895,7 @@ void tst_qdeclarativestates::deletingChange() qmlExecuteDeferred(state); QCOMPARE(state->operationCount(), 1); - rect->setState("blue"); + rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("red")); QCOMPARE(rect->radius(),qreal(5)); @@ -928,11 +940,11 @@ void tst_qdeclarativestates::tempState() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QTest::ignoreMessage(QtDebugMsg, "entering placed"); QTest::ignoreMessage(QtDebugMsg, "entering idle"); - rect->setState("placed"); - QCOMPARE(rect->state(), QLatin1String("idle")); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("idle")); } void tst_qdeclarativestates::illegalTempState() @@ -942,10 +954,10 @@ void tst_qdeclarativestates::illegalTempState() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); - rect->setState("placed"); - QCOMPARE(rect->state(), QLatin1String("placed")); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("placed")); } void tst_qdeclarativestates::nonExistantProperty() @@ -955,10 +967,10 @@ void tst_qdeclarativestates::nonExistantProperty() QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - rect->setState("blue"); - QCOMPARE(rect->state(), QLatin1String("blue")); + rectPrivate->setState("blue"); + QCOMPARE(rectPrivate->state(), QLatin1String("blue")); } void tst_qdeclarativestates::reset() @@ -974,7 +986,7 @@ void tst_qdeclarativestates::reset() QCOMPARE(text->width(), qreal(40.)); QVERIFY(text->width() < text->height()); - rect->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); QVERIFY(text->width() > 41); QVERIFY(text->width() > text->height()); @@ -1000,19 +1012,20 @@ void tst_qdeclarativestates::whenOrdering() QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); QDeclarativeRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->state(), QLatin1String("")); + QCOMPARE(rectPrivate->state(), QLatin1String("")); rect->setProperty("condition2", true); - QCOMPARE(rect->state(), QLatin1String("state2")); + QCOMPARE(rectPrivate->state(), QLatin1String("state2")); rect->setProperty("condition1", true); - QCOMPARE(rect->state(), QLatin1String("state1")); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); rect->setProperty("condition2", false); - QCOMPARE(rect->state(), QLatin1String("state1")); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); rect->setProperty("condition2", true); - QCOMPARE(rect->state(), QLatin1String("state1")); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); rect->setProperty("condition1", false); rect->setProperty("condition2", false); - QCOMPARE(rect->state(), QLatin1String("")); + QCOMPARE(rectPrivate->state(), QLatin1String("")); } void tst_qdeclarativestates::urlResolution() @@ -1029,7 +1042,7 @@ void tst_qdeclarativestates::urlResolution() QDeclarativeImage *image3 = rect->findChild("image3"); QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); - myType->setState("SetImageState"); + QDeclarativeItemPrivate::get(myType)->setState("SetImageState"); QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png"); QCOMPARE(image1->source(), resolved); QCOMPARE(image2->source(), resolved); -- cgit v0.12 From 69efa1c869694666c66375179b43e2569cf2772b Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 29 Apr 2010 08:34:25 +0200 Subject: Update the input method sensitivity in case of complex widgets in QGraphicsProxyWidget. In case of a complex widget embedded in a proxy, we need to update the input method acceptance whenever the focus changes inside the proxy. Task-number:QTBUG-8847 Reviewed-by:janarve --- src/gui/kernel/qwidget.cpp | 6 ++++++ .../qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 20d1d30..60f38f2 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6232,6 +6232,12 @@ void QWidget::setFocus(Qt::FocusReason reason) QApplication::sendEvent(that->style(), &event); } if (!isHidden()) { +#ifndef QT_NO_GRAPHICSVIEW + // Update proxy state + if (QWExtra *topData = window()->d_func()->extra) + if (topData->proxyWidget && topData->proxyWidget->hasFocus()) + topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget(); +#endif // Send event to self QFocusEvent event(QEvent::FocusIn, reason); QPointer that = f; diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index d5f63d3..6cea834 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3436,6 +3436,21 @@ void tst_QGraphicsProxyWidget::inputMethod() qApp->sendEvent(proxy, &event); QCOMPARE(lineEdit->inputMethodEvents, i); } + + scene.clear(); + QGraphicsView view(&scene); + QWidget *w = new QWidget; + w->setLayout(new QVBoxLayout(w)); + QLineEdit *lineEdit = new QLineEdit; + lineEdit->setEchoMode(QLineEdit::Password); + w->layout()->addWidget(lineEdit); + lineEdit->setAttribute(Qt::WA_InputMethodEnabled, true); + QGraphicsProxyWidget *proxy = scene.addWidget(w); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(!(proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod)); + lineEdit->setFocus(); + QVERIFY((proxy->flags() & QGraphicsItem::ItemAcceptsInputMethod)); } void tst_QGraphicsProxyWidget::clickFocus() -- cgit v0.12