diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-16 05:46:33 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-16 05:46:33 (GMT) |
commit | 1c029319fb787c1ef6bce0f76fff991679b944f2 (patch) | |
tree | 35f0d2ec9bdac1ac6f1a03ae249b2f9d7765b243 | |
parent | a62fbc821c3c32c0ebe63a77f2705d6f1db67394 (diff) | |
parent | ee6c7d5cdc7707a5eb50a46ba8056a6b43348159 (diff) | |
download | Qt-1c029319fb787c1ef6bce0f76fff991679b944f2.zip Qt-1c029319fb787c1ef6bce0f76fff991679b944f2.tar.gz Qt-1c029319fb787c1ef6bce0f76fff991679b944f2.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
13 files changed, 153 insertions, 53 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 29eb983..9465c4c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -843,6 +843,9 @@ QmlComponent *QmlGraphicsGridView::delegate() const void QmlGraphicsGridView::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsGridView); + if (delegate == this->delegate()) + return; + if (!d->ownModel) { d->model = new QmlGraphicsVisualDataModel(qmlContext(this)); d->ownModel = true; @@ -944,9 +947,11 @@ QmlComponent *QmlGraphicsGridView::highlight() const void QmlGraphicsGridView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsGridView); - delete d->highlightComponent; - d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); + if (highlight != d->highlightComponent) { + delete d->highlightComponent; + d->highlightComponent = highlight; + d->updateCurrent(d->currentIndex); + } } /*! @@ -978,12 +983,14 @@ bool QmlGraphicsGridView::highlightFollowsCurrentItem() const void QmlGraphicsGridView::setHighlightFollowsCurrentItem(bool autoHighlight) { Q_D(QmlGraphicsGridView); - d->autoHighlight = autoHighlight; - if (d->highlightXAnimator) { - d->highlightXAnimator->setEnabled(d->autoHighlight); - d->highlightYAnimator->setEnabled(d->autoHighlight); + if (d->autoHighlight != autoHighlight) { + d->autoHighlight = autoHighlight; + if (d->highlightXAnimator) { + d->highlightXAnimator->setEnabled(d->autoHighlight); + d->highlightYAnimator->setEnabled(d->autoHighlight); + } + d->updateHighlight(); } - d->updateHighlight(); } /*! diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index edcd094..c075a8a 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1158,6 +1158,8 @@ QmlComponent *QmlGraphicsListView::delegate() const void QmlGraphicsListView::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsListView); + if (delegate == this->delegate()) + return; if (!d->ownModel) { d->model = new QmlGraphicsVisualDataModel(qmlContext(this)); d->ownModel = true; @@ -1263,9 +1265,11 @@ QmlComponent *QmlGraphicsListView::highlight() const void QmlGraphicsListView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsListView); - delete d->highlightComponent; - d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); + if (highlight != d->highlightComponent) { + delete d->highlightComponent; + d->highlightComponent = highlight; + d->updateCurrent(d->currentIndex); + } } /*! @@ -1295,12 +1299,14 @@ bool QmlGraphicsListView::highlightFollowsCurrentItem() const void QmlGraphicsListView::setHighlightFollowsCurrentItem(bool autoHighlight) { Q_D(QmlGraphicsListView); - d->autoHighlight = autoHighlight; - if (d->highlightPosAnimator) { - d->highlightPosAnimator->setEnabled(d->autoHighlight); - d->highlightSizeAnimator->setEnabled(d->autoHighlight); + if (d->autoHighlight != autoHighlight) { + d->autoHighlight = autoHighlight; + if (d->highlightPosAnimator) { + d->highlightPosAnimator->setEnabled(d->autoHighlight); + d->highlightSizeAnimator->setEnabled(d->autoHighlight); + } + d->updateHighlight(); } - d->updateHighlight(); } /*! @@ -1520,8 +1526,7 @@ qreal QmlGraphicsListView::highlightMoveSpeed() const void QmlGraphicsListView::setHighlightMoveSpeed(qreal speed) { Q_D(QmlGraphicsListView);\ - if (d->highlightMoveSpeed != speed) - { + if (d->highlightMoveSpeed != speed) { d->highlightMoveSpeed = speed; if (d->highlightPosAnimator) d->highlightPosAnimator->setVelocity(d->highlightMoveSpeed); @@ -1538,8 +1543,7 @@ qreal QmlGraphicsListView::highlightResizeSpeed() const void QmlGraphicsListView::setHighlightResizeSpeed(qreal speed) { Q_D(QmlGraphicsListView);\ - if (d->highlightResizeSpeed != speed) - { + if (d->highlightResizeSpeed != speed) { d->highlightResizeSpeed = speed; if (d->highlightSizeAnimator) d->highlightSizeAnimator->setVelocity(d->highlightResizeSpeed); diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index ee13437..ca78797 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -111,9 +111,6 @@ HEADERS += qml/qmlparser_p.h \ qml/qmltypenamescriptclass_p.h \ qml/qmllistscriptclass_p.h -# for qtscript debugger -contains(QT_CONFIG, scripttools):QT += scripttools - QT += sql include(parser/parser.pri) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c8848fd..b9729ad 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -47,10 +47,6 @@ #include <private/qscriptdeclarativeclass_p.h> #include <private/qmlglobalscriptclass_p.h> -#ifdef QT_SCRIPTTOOLS_LIB -#include <QScriptEngineDebugger> -#endif - #include <QScriptClass> #include <QNetworkReply> #include <QNetworkRequest> @@ -101,7 +97,6 @@ Q_DECLARE_METATYPE(QList<QObject *>); QT_BEGIN_NAMESPACE -DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER) DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE) QML_DEFINE_TYPE(Qt,4,6,Object,QObject) @@ -229,12 +224,6 @@ void QmlEnginePrivate::init() typeNameClass = new QmlTypeNameScriptClass(q); listClass = new QmlListScriptClass(q); rootContext = new QmlContext(q,true); -#ifdef QT_SCRIPTTOOLS_LIB - if (qmlDebugger()){ - debugger = new QScriptEngineDebugger(q); - debugger->attachTo(&scriptEngine); - } -#endif if (QCoreApplication::instance()->thread() == q->thread() && QmlEngineDebugServer::isDebuggingEnabled()) { @@ -246,11 +235,6 @@ void QmlEnginePrivate::init() } } -QmlEnginePrivate::CapturedProperty::CapturedProperty(const QmlMetaProperty &p) -: object(p.object()), coreIndex(p.coreIndex()), notifyIndex(p.property().notifySignalIndex()) -{ -} - /*! \class QmlEngine \brief The QmlEngine class provides an environment for instantiating QML components. diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 2e880bb..2f41651 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -112,7 +112,6 @@ public: struct CapturedProperty { CapturedProperty(QObject *o, int c, int n) : object(o), coreIndex(c), notifyIndex(n) {} - CapturedProperty(const QmlMetaProperty &); QObject *object; int coreIndex; @@ -123,9 +122,6 @@ public: QmlContext *rootContext; QmlExpression *currentExpression; bool isDebugging; -#ifdef QT_SCRIPTTOOLS_LIB - QScriptEngineDebugger *debugger; -#endif struct ImportedNamespace; QmlContextScriptClass *contextClass; diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml index d9e9f27..32833d2 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml @@ -45,7 +45,7 @@ Rectangle { currentIndex: 5 cellWidth: 80 cellHeight: 60 - model: testModel delegate: myDelegate + model: testModel } } diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index d09aad7..d0b7462 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -390,7 +390,11 @@ void tst_QmlGraphicsGridView::removed() gridview->setViewportY(120); gridview->setCurrentIndex(10); + // let transitions settle. + QTest::qWait(300); + model.removeItem(1); + // let transitions settle. QTest::qWait(300); diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml index 65a9d8a..74f5ef4 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml @@ -43,8 +43,8 @@ Rectangle { width: 240 height: 320 keyNavigationWraps: testWrap - model: testModel delegate: myDelegate highlightMoveSpeed: 1000 + model: testModel } } diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml index ccefeba..ec8bb68 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml @@ -4,6 +4,29 @@ Rectangle { width: 240 height: 320 color: "#ffffff" + function checkProperties() { + testObject.error = false; + if (list.model != testModel) { + print("model property incorrect"); + testObject.error = true; + } + if (!testObject.animate && list.delegate != myDelegate) { + print("delegate property incorrect - expected myDelegate"); + testObject.error = true; + } + if (testObject.animate && list.delegate != animatedDelegate) { + print("delegate property incorrect - expected animatedDelegate"); + testObject.error = true; + } + if (testObject.invalidHighlight && list.highlight != invalidHl) { + print("highlight property incorrect - expected invalidHl"); + testObject.error = true; + } + if (!testObject.invalidHighlight && list.highlight != myHighlight) { + print("highlight property incorrect - expected myHighlight"); + testObject.error = true; + } + } resources: [ Component { id: myDelegate @@ -70,6 +93,14 @@ Rectangle { */ } } + }, + Component { + id: myHighlight + Rectangle { color: "green" } + }, + Component { + id: invalidHl + EaseFollow {} } ] ListView { @@ -79,7 +110,8 @@ Rectangle { width: 240 height: 320 model: testModel - delegate: testAnimate ? myDelegate : animatedDelegate + delegate: testObject.animate ? animatedDelegate : myDelegate + highlight: testObject.invalidHighlight ? invalidHl : myHighlight highlightMoveSpeed: 1000 highlightResizeSpeed: 1000 } diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index d416603..7e6dc0d 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -90,6 +90,38 @@ private: QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); }; +class TestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError) + Q_PROPERTY(bool animate READ animate NOTIFY changedAnim) + Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl) + +public: + TestObject(QObject *parent = 0) + : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) {} + + bool error() const { return mError; } + void setError(bool err) { mError = err; emit changedError(); } + + bool animate() const { return mAnimate; } + void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); } + + bool invalidHighlight() const { return mInvalidHighlight; } + void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); } + +signals: + void changedError(); + void changedAnim(); + void changedHl(); + +public: + bool mError; + bool mAnimate; + bool mInvalidHighlight; +}; + class TestModel : public QListModelInterface { Q_OBJECT @@ -243,7 +275,9 @@ void tst_QmlGraphicsListView::items() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -254,6 +288,9 @@ void tst_QmlGraphicsListView::items() QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + QCOMPARE(listview->count(), model.count()); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -269,6 +306,16 @@ void tst_QmlGraphicsListView::items() QCOMPARE(number->text(), model.number(i)); } + // switch to other delegate + testObject->setAnimate(true); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + + // set invalid highlight + testObject->setInvalidHighlight(true); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + // set an empty model and confirm that items are destroyed T model2; ctxt->setContextProperty("testModel", &model2); @@ -294,7 +341,9 @@ void tst_QmlGraphicsListView::changed() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -328,7 +377,9 @@ void tst_QmlGraphicsListView::inserted() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -415,7 +466,10 @@ void tst_QmlGraphicsListView::removed(bool animated) QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(animated)); + + TestObject *testObject = new TestObject; + testObject->setAnimate(animated); + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -526,7 +580,9 @@ void tst_QmlGraphicsListView::moved() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -665,7 +721,9 @@ void tst_QmlGraphicsListView::spacing() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -934,7 +992,9 @@ void tst_QmlGraphicsListView::cacheBuffer() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -944,6 +1004,9 @@ void tst_QmlGraphicsListView::cacheBuffer() QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); + QVERIFY(listview->delegate() != 0); + QVERIFY(listview->model() != 0); + QVERIFY(listview->highlight() == 0); // Confirm items positioned correctly int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); @@ -955,6 +1018,7 @@ void tst_QmlGraphicsListView::cacheBuffer() } listview->setCacheBuffer(400); + QVERIFY(listview->cacheBuffer() == 400); int newItemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); QVERIFY(newItemCount > itemCount); diff --git a/tests/auto/declarative/qmlqt/data/darker.qml b/tests/auto/declarative/qmlqt/data/darker.qml index 6369e8f..96ffa77 100644 --- a/tests/auto/declarative/qmlqt/data/darker.qml +++ b/tests/auto/declarative/qmlqt/data/darker.qml @@ -4,5 +4,8 @@ Object { property var test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) property var test2: Qt.darker() property var test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10) + property var test4: Qt.darker("red"); + property var test5: Qt.darker("perfectred"); // Non-existant color + property var test6: Qt.darker(10); } diff --git a/tests/auto/declarative/qmlqt/data/lighter.qml b/tests/auto/declarative/qmlqt/data/lighter.qml index 6c888e7..2e9fdc8 100644 --- a/tests/auto/declarative/qmlqt/data/lighter.qml +++ b/tests/auto/declarative/qmlqt/data/lighter.qml @@ -4,4 +4,7 @@ Object { property var test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) property var test2: Qt.lighter() property var test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10) + property var test4: Qt.lighter("red"); + property var test5: Qt.lighter("perfectred"); // Non-existant color + property var test6: Qt.lighter(10); } diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp index 13f4904..4d09aee 100644 --- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp +++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp @@ -213,6 +213,9 @@ void tst_qmlqt::lighter() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter()); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); delete object; } @@ -226,6 +229,9 @@ void tst_qmlqt::darker() QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker()); QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); delete object; } |