From 24fe2f9f8e94e2a142bf0e17d7d03c5431eb0eab Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Sep 2010 08:54:39 +1000 Subject: Properly cleanup in QDeclarativeModulePlugin test. --- .../qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 2081f0e..e1022e0 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -117,6 +117,7 @@ void tst_qdeclarativemoduleplugin::importsPlugin() QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value").toInt(),123); + delete object; } QTEST_MAIN(tst_qdeclarativemoduleplugin) -- cgit v0.12 From cd5cd63750e39759b10b2edf85404db7173ac8ee Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Sep 2010 09:01:25 +1000 Subject: Remove dead code paths in declarative list model code. Reviewed-by: Bea Lam --- src/declarative/util/qdeclarativelistmodel.cpp | 37 ------------------------ src/declarative/util/qdeclarativelistmodel_p.h | 1 - src/declarative/util/qdeclarativelistmodel_p_p.h | 3 -- src/declarative/util/qlistmodelinterface_p.h | 3 -- 4 files changed, 44 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3263238..93a38f4 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -310,14 +310,6 @@ QString QDeclarativeListModel::toString(int role) const return m_flat ? m_flat->toString(role) : m_nested->toString(role); } -QHash QDeclarativeListModel::data(int index, const QList &roles) const -{ - if (index >= count() || index < 0) - return QHash(); - - return m_flat ? m_flat->data(index, roles) : m_nested->data(index, roles); -} - QVariant QDeclarativeListModel::data(int index, int role) const { if (index >= count() || index < 0) @@ -920,19 +912,6 @@ FlatListModel::~FlatListModel() qDeleteAll(m_nodeData); } -QHash FlatListModel::data(int index, const QList &roles) const -{ - Q_ASSERT(index >= 0 && index < m_values.count()); - - QHash row; - for (int i=0; i= 0 && index < m_values.count()); @@ -972,11 +951,6 @@ void FlatListModel::remove(int index) removedNode(index); } -bool FlatListModel::append(const QScriptValue &value) -{ - return insert(m_values.count(), value); -} - bool FlatListModel::insert(int index, const QScriptValue &value) { Q_ASSERT(index >= 0 && index <= m_values.count()); @@ -1350,17 +1324,6 @@ void NestedListModel::move(int from, int to, int n) qdeclarativelistmodel_move(from, to, n, &_root->values); } -bool NestedListModel::append(const QScriptValue& valuemap) -{ - if (!_root) { - _root = new ModelNode(this); - m_ownsRoot = true; - } - - insert(count(), valuemap); - return true; -} - QScriptValue NestedListModel::get(int index) const { QDeclarativeEngine *eng = qmlEngine(m_listModel); diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h index fe42ef6..e9673c8 100644 --- a/src/declarative/util/qdeclarativelistmodel_p.h +++ b/src/declarative/util/qdeclarativelistmodel_p.h @@ -76,7 +76,6 @@ public: virtual QList roles() const; virtual QString toString(int role) const; virtual int count() const; - virtual QHash data(int index, const QList &roles = (QList())) const; virtual QVariant data(int index, int role) const; Q_INVOKABLE void clear(); diff --git a/src/declarative/util/qdeclarativelistmodel_p_p.h b/src/declarative/util/qdeclarativelistmodel_p_p.h index d2d40ee..43a0a9b 100644 --- a/src/declarative/util/qdeclarativelistmodel_p_p.h +++ b/src/declarative/util/qdeclarativelistmodel_p_p.h @@ -79,7 +79,6 @@ public: FlatListModel(QDeclarativeListModel *base); ~FlatListModel(); - QHash data(int index, const QList &roles) const; QVariant data(int index, int role) const; QList roles() const; @@ -88,7 +87,6 @@ public: int count() const; void clear(); void remove(int index); - bool append(const QScriptValue&); bool insert(int index, const QScriptValue&); QScriptValue get(int index) const; void set(int index, const QScriptValue&, QList *roles); @@ -189,7 +187,6 @@ public: int count() const; void clear(); void remove(int index); - bool append(const QScriptValue&); bool insert(int index, const QScriptValue&); QScriptValue get(int index) const; void set(int index, const QScriptValue&, QList *roles); diff --git a/src/declarative/util/qlistmodelinterface_p.h b/src/declarative/util/qlistmodelinterface_p.h index 07592ad..8c8ebb3 100644 --- a/src/declarative/util/qlistmodelinterface_p.h +++ b/src/declarative/util/qlistmodelinterface_p.h @@ -59,10 +59,7 @@ class Q_DECLARATIVE_EXPORT QListModelInterface : public QObject virtual ~QListModelInterface() {} virtual int count() const = 0; - virtual QHash data(int index, const QList& roles = QList()) const = 0; virtual QVariant data(int index, int role) const = 0; - virtual bool setData(int index, const QHash& values) - { Q_UNUSED(index); Q_UNUSED(values); return false; } virtual QList roles() const = 0; virtual QString toString(int role) const = 0; -- cgit v0.12 From b1a5a49950b80469e4cd658f340f279a8fd75a27 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Sep 2010 10:17:48 +1000 Subject: Remove unused, unexported class. --- src/declarative/qml/qdeclarativeclassfactory.cpp | 50 ---------------- src/declarative/qml/qdeclarativeclassfactory_p.h | 74 ------------------------ src/declarative/qml/qdeclarativeengine_p.h | 1 - src/declarative/qml/qml.pri | 2 - 4 files changed, 127 deletions(-) delete mode 100644 src/declarative/qml/qdeclarativeclassfactory.cpp delete mode 100644 src/declarative/qml/qdeclarativeclassfactory_p.h diff --git a/src/declarative/qml/qdeclarativeclassfactory.cpp b/src/declarative/qml/qdeclarativeclassfactory.cpp deleted file mode 100644 index 798eacd..0000000 --- a/src/declarative/qml/qdeclarativeclassfactory.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativeclassfactory_p.h" - -QT_BEGIN_NAMESPACE - -QDeclarativeClassFactory::~QDeclarativeClassFactory() -{ -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeclassfactory_p.h b/src/declarative/qml/qdeclarativeclassfactory_p.h deleted file mode 100644 index 9f4a3de..0000000 --- a/src/declarative/qml/qdeclarativeclassfactory_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECLASSFACTORY_P_H -#define QDECLARATIVECLASSFACTORY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QByteArray; -class QUrl; -class QDeclarativeComponent; - -class QDeclarativeClassFactory -{ -public: - virtual ~QDeclarativeClassFactory(); - virtual QDeclarativeComponent *create(const QByteArray &, const QUrl& baseUrl, QDeclarativeEngine*) = 0; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVECLASSFACTORY_P_H diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index dc7315d..8539fbf 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -55,7 +55,6 @@ #include "qdeclarativeengine.h" -#include "private/qdeclarativeclassfactory_p.h" #include "private/qdeclarativetypeloader_p.h" #include "private/qdeclarativeimport_p.h" #include "private/qpodvector_p.h" diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 687ff52..66b69f9 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -22,7 +22,6 @@ SOURCES += \ $$PWD/qdeclarativerefcount.cpp \ $$PWD/qdeclarativemetatype.cpp \ $$PWD/qdeclarativestringconverters.cpp \ - $$PWD/qdeclarativeclassfactory.cpp \ $$PWD/qdeclarativeparserstatus.cpp \ $$PWD/qdeclarativetypeloader.cpp \ $$PWD/qdeclarativeinfo.cpp \ @@ -89,7 +88,6 @@ HEADERS += \ $$PWD/qdeclarativecontext.h \ $$PWD/qdeclarativeexpression.h \ $$PWD/qdeclarativestringconverters_p.h \ - $$PWD/qdeclarativeclassfactory_p.h \ $$PWD/qdeclarativeinfo.h \ $$PWD/qdeclarativeproperty_p.h \ $$PWD/qdeclarativecontext_p.h \ -- cgit v0.12 From 688b17d6c89414e34150846203edfb9ed6de737a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Sep 2010 10:43:10 +1000 Subject: Doc fix. --- src/imports/gestures/qdeclarativegesturearea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp index 500c6bf..0d19ba9 100644 --- a/src/imports/gestures/qdeclarativegesturearea.cpp +++ b/src/imports/gestures/qdeclarativegesturearea.cpp @@ -92,7 +92,7 @@ public: \e {This element is only functional on devices with touch input.} \qml - import Qt.labs.gestures 0.1 + import Qt.labs.gestures 1.0 GestureArea { anchors.fill: parent -- cgit v0.12 From b22994c3e1574716c8fc6a1da52251443d3c9cc6 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 23 Sep 2010 12:47:36 +1000 Subject: Improve docs for Qt.quit() --- src/declarative/qml/qdeclarativeengine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 80db230..26b3629 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1783,7 +1783,9 @@ void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const /*! \qmlmethod Qt::quit() This function causes the QDeclarativeEngine::quit() signal to be emitted. -Within the \l {QML Viewer}, this causes the launcher application to exit. +Within the \l {QML Viewer}, this causes the launcher application to exit; +to quit a C++ application when this method is called, connect the +QDeclarativeEngine::quit() signal to the QCoreApplication::quit() slot. */ QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e) -- cgit v0.12 From 4bd27d5c8c1f2dd759e20e4a6b3ac224799e2318 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 23 Sep 2010 13:05:48 +1000 Subject: Fix ListModel::set() so the implementation and docs are consistent. If index == count() the item should be appended. Also, this should happen regardless of whether the list is empty. --- src/declarative/util/qdeclarativelistmodel.cpp | 5 +++-- .../declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 93a38f4..398480e 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -552,7 +552,8 @@ QScriptValue QDeclarativeListModel::get(int index) const fruitModel.set(3, {"cost": 5.95, "name":"Pizza"}) \endcode - The \a index must be an element in the list. + If \a index is equal to count() then a new item is appended to the + list. Otherwise, \a index must be an element in the list. \sa append() */ @@ -562,7 +563,7 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap) qmlInfo(this) << tr("set: value is not an object"); return; } - if (count() == 0 || index > count() || index < 0) { + if (index > count() || index < 0) { qmlInfo(this) << tr("set: index %1 out of range").arg(index); return; } diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 31cb545..69df90b 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -260,7 +260,7 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << ""; QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; - QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << ": QML ListModel: set: index 0 out of range"; + QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << ""; QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << ": QML ListModel: set: index -1 out of range"; QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << ": QML ListModel: set: value is not an object"; QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << ": QML ListModel: set: value is not an object"; -- cgit v0.12 From e8c36529d78b99ce651e26779e96986561f63646 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 23 Sep 2010 12:52:54 +1000 Subject: Update QtDeclarative def files --- src/s60installs/bwins/QtDeclarativeu.def | 6 ++++-- src/s60installs/eabi/QtDeclarativeu.def | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index 43735a5..f417892 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -242,7 +242,7 @@ EXPORTS ?idString@QDeclarativeDebugObjectReference@@QBE?AVQString@@XZ @ 241 NONAME ; class QString QDeclarativeDebugObjectReference::idString(void) const ?customTypeData@QDeclarativeDomObject@@QBE?AVQByteArray@@XZ @ 242 NONAME ; class QByteArray QDeclarativeDomObject::customTypeData(void) const ?stop@QDeclarativeTransition@@QAEXXZ @ 243 NONAME ; void QDeclarativeTransition::stop(void) - ?data@QDeclarativeListModel@@UBE?AV?$QHash@HVQVariant@@@@HABV?$QList@H@@@Z @ 244 NONAME ; class QHash QDeclarativeListModel::data(int, class QList const &) const + ?data@QDeclarativeListModel@@UBE?AV?$QHash@HVQVariant@@@@HABV?$QList@H@@@Z @ 244 NONAME ABSENT ; class QHash QDeclarativeListModel::data(int, class QList const &) const ?verticalCenterOffset@QDeclarativeAnchors@@QBEMXZ @ 245 NONAME ; float QDeclarativeAnchors::verticalCenterOffset(void) const ?metaObject@QDeclarativeText@@UBEPBUQMetaObject@@XZ @ 246 NONAME ; struct QMetaObject const * QDeclarativeText::metaObject(void) const ??0QDeclarativeComponent@@QAE@PAVQDeclarativeEngine@@PAVQObject@@@Z @ 247 NONAME ; QDeclarativeComponent::QDeclarativeComponent(class QDeclarativeEngine *, class QObject *) @@ -608,7 +608,7 @@ EXPORTS ??_EQDeclarativeDebugObjectExpressionWatch@@UAE@I@Z @ 607 NONAME ; QDeclarativeDebugObjectExpressionWatch::~QDeclarativeDebugObjectExpressionWatch(unsigned int) ?computeTransformOrigin@QDeclarativeItemPrivate@@QBE?AVQPointF@@XZ @ 608 NONAME ; class QPointF QDeclarativeItemPrivate::computeTransformOrigin(void) const ??0QDeclarativeListReference@@QAE@PAVQObject@@PBDPAVQDeclarativeEngine@@@Z @ 609 NONAME ; QDeclarativeListReference::QDeclarativeListReference(class QObject *, char const *, class QDeclarativeEngine *) - ?setData@QListModelInterface@@UAE_NHABV?$QHash@HVQVariant@@@@@Z @ 610 NONAME ; bool QListModelInterface::setData(int, class QHash const &) + ?setData@QListModelInterface@@UAE_NHABV?$QHash@HVQVariant@@@@@Z @ 610 NONAME ABSENT ; bool QListModelInterface::setData(int, class QHash const &) ??0QDeclarativePen@@QAE@PAVQObject@@@Z @ 611 NONAME ; QDeclarativePen::QDeclarativePen(class QObject *) ?trUtf8@QPacketProtocol@@SA?AVQString@@PBD0H@Z @ 612 NONAME ; class QString QPacketProtocol::trUtf8(char const *, char const *, int) ?setContextObject@QDeclarativeContext@@QAEXPAVQObject@@@Z @ 613 NONAME ; void QDeclarativeContext::setContextObject(class QObject *) @@ -1798,4 +1798,6 @@ EXPORTS ?stop@QDeclarativeAbstractAnimation@@QAEXXZ @ 1797 NONAME ; void QDeclarativeAbstractAnimation::stop(void) ?start@QDeclarativeAbstractAnimation@@QAEXXZ @ 1798 NONAME ; void QDeclarativeAbstractAnimation::start(void) ?qt_metacall@QDeclarativeAbstractAnimation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1799 NONAME ; int QDeclarativeAbstractAnimation::qt_metacall(enum QMetaObject::Call, int, void * *) + ?getScriptEngine@QDeclarativeDebugHelper@@SAPAVQScriptEngine@@PAVQDeclarativeEngine@@@Z @ 1800 NONAME ; class QScriptEngine * QDeclarativeDebugHelper::getScriptEngine(class QDeclarativeEngine *) + ?setAnimationSlowDownFactor@QDeclarativeDebugHelper@@SAXM@Z @ 1801 NONAME ; void QDeclarativeDebugHelper::setAnimationSlowDownFactor(float) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 8aefb2c..c4cd9b6 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1351,7 +1351,7 @@ EXPORTS _ZNK21QDeclarativeDomObject8propertyERK10QByteArray @ 1350 NONAME _ZNK21QDeclarativeListModel10metaObjectEv @ 1351 NONAME _ZNK21QDeclarativeListModel3getEi @ 1352 NONAME - _ZNK21QDeclarativeListModel4dataEiRK5QListIiE @ 1353 NONAME + _ZNK21QDeclarativeListModel4dataEiRK5QListIiE @ 1353 NONAME ABSENT _ZNK21QDeclarativeListModel4dataEii @ 1354 NONAME _ZNK21QDeclarativeListModel5countEv @ 1355 NONAME _ZNK21QDeclarativeListModel5rolesEv @ 1356 NONAME @@ -1831,4 +1831,6 @@ EXPORTS _ZThn8_N29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1830 NONAME _ZThn8_N29QDeclarativeAbstractAnimationD0Ev @ 1831 NONAME _ZThn8_N29QDeclarativeAbstractAnimationD1Ev @ 1832 NONAME + _ZN23QDeclarativeDebugHelper15getScriptEngineEP18QDeclarativeEngine @ 1833 NONAME + _ZN23QDeclarativeDebugHelper26setAnimationSlowDownFactorEf @ 1834 NONAME -- cgit v0.12 From e1c895912a89824af6b8a826b6c28865ac13b392 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Sep 2010 14:07:33 +1000 Subject: Various declarative autotest additions. --- src/declarative/util/qdeclarativeview.cpp | 2 +- .../qdeclarativeconnection/data/error-object.qml | 7 +++++ .../qdeclarativeconnection/data/error-property.qml | 5 ++++ .../data/error-property2.qml | 5 ++++ .../qdeclarativeconnection/data/error-syntax.qml | 9 +++++++ .../tst_qdeclarativeconnection.cpp | 31 ++++++++++++++++++++++ .../tst_qdeclarativelistmodel.cpp | 16 +++++++++++ .../declarative/qdeclarativeview/data/error1.qml | 5 ++++ .../qdeclarativeview/tst_qdeclarativeview.cpp | 17 ++++++++++++ 9 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-object.qml create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-property.qml create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml create mode 100644 tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml create mode 100644 tests/auto/declarative/qdeclarativeview/data/error1.qml diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 8f06858..2381172 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -392,7 +392,7 @@ QDeclarativeView::Status QDeclarativeView::status() const /*! Return the list of errors that occurred during the last compile or create - operation. An empty list is returned if isError() is not set. + operation. When the status is not Error, an empty list is returned. */ QList QDeclarativeView::errors() const { diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml new file mode 100644 index 0000000..a8127a4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Item { + Connections { + onClicked: Item {} + } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml new file mode 100644 index 0000000..2791f56 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +Item { + Connections { fakeProperty: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml new file mode 100644 index 0000000..0205c0a --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +Item { + Connections { onfakeProperty: {} } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml new file mode 100644 index 0000000..867e4e2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml @@ -0,0 +1,9 @@ +import Qt 4.7 + +Item { + Connections { + onClicked { + onPressed: {} + } + } +} diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp index d384372..a623e96 100644 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -66,6 +66,8 @@ private slots: void targetChanged(); void unknownSignals_data(); void unknownSignals(); + void errors_data(); + void errors(); private: QDeclarativeEngine engine; @@ -195,9 +197,38 @@ void tst_qdeclarativeconnection::unknownSignals() QDeclarativeConnections *connections = item->findChild("connections"); QVERIFY(connections); + if (file == "connection-unknownsignals-ignored.qml") + QVERIFY(connections->ignoreUnknownSignals()); + delete item; } +void tst_qdeclarativeconnection::errors_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\""; + QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\""; + QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed"; + QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error"; +} + +void tst_qdeclarativeconnection::errors() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); + + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, url); + QVERIFY(c.isError() == true); + QList errors = c.errors(); + QVERIFY(errors.count() == 1); + QCOMPARE(errors.at(0).description(), error); +} + QTEST_MAIN(tst_qdeclarativeconnection) #include "tst_qdeclarativeconnection.moc" diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 69df90b..f8d2411 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -91,6 +91,7 @@ private slots: void enumerate(); void error_data(); void error(); + void syncError(); void set(); void get(); void get_data(); @@ -661,6 +662,21 @@ void tst_qdeclarativelistmodel::error() } } +void tst_qdeclarativelistmodel::syncError() +{ + QString qml = "import Qt 4.7\nListModel { id: lm; Component.onCompleted: lm.sync() }"; + QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript"; + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + QTest::ignoreMessage(QtWarningMsg,error.toUtf8()); + QObject *obj = component.create(); + QVERIFY(obj); + delete obj; +} + /* Test model changes from set() are available to the view */ diff --git a/tests/auto/declarative/qdeclarativeview/data/error1.qml b/tests/auto/declarative/qdeclarativeview/data/error1.qml new file mode 100644 index 0000000..c154716 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeview/data/error1.qml @@ -0,0 +1,5 @@ +import Qt 4.7 + +Rectangle { + nonExistentProperty: 5 +} diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index 6450e38..9ac79e4 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -62,6 +62,7 @@ public: private slots: void resizemodedeclarativeitem(); void resizemodegraphicswidget(); + void errors(); private: template @@ -255,6 +256,22 @@ void tst_QDeclarativeView::resizemodegraphicswidget() delete canvas; } +static void silentErrorsMsgHandler(QtMsgType, const char *) +{ +} + +void tst_QDeclarativeView::errors() +{ + QDeclarativeView *canvas = new QDeclarativeView; + QVERIFY(canvas); + QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/error1.qml")); + qInstallMsgHandler(old); + QVERIFY(canvas->status() == QDeclarativeView::Error); + QVERIFY(canvas->errors().count() == 1); + delete canvas; +} + template T *tst_QDeclarativeView::findItem(QGraphicsObject *parent, const QString &objectName) { -- cgit v0.12