From f01e6e8993856cdcddc51868e91ef25b35695546 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 13 Nov 2009 14:31:50 +1000 Subject: Remove unused methods of QmlListAccessor. --- src/declarative/util/qmllistaccessor.cpp | 128 --------------------- src/declarative/util/qmllistaccessor_p.h | 5 - .../qmllistaccessor/tst_qmllistaccessor.cpp | 36 +++--- 3 files changed, 18 insertions(+), 151 deletions(-) diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 910f2a5..2c01081 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -149,134 +149,6 @@ QVariant QmlListAccessor::at(int idx) const return QVariant(); } -void QmlListAccessor::append(const QVariant &value) -{ - switch(m_type) { - case Invalid: - break; - case StringList: - { - const QString &str = value.toString(); - qvariant_cast(d).append(str); - break; - } - case VariantList: - { - qvariant_cast(d).append(value); - break; - } - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->append(const_cast(value.constData())); //XXX - break; - } - case QList: - QmlMetaType::append(d, value); - break; - case Instance: - case Integer: - //do nothing - break; - } -} - -void QmlListAccessor::insert(int index, const QVariant &value) -{ - switch(m_type) { - case Invalid: - break; - case StringList: - { - const QString &str = value.toString(); - qvariant_cast(d).insert(index, str); - break; - } - case VariantList: - { - qvariant_cast(d).insert(index, value); - break; - } - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->insert(index, const_cast(value.constData())); //XXX - break; - } - case QList: - //XXX needs implementation - qWarning() << "insert function not yet implemented for QLists"; - break; - case Instance: - //XXX do nothing? - if (index == 0) - setList(value); - break; - case Integer: - break; - } -} - -void QmlListAccessor::removeAt(int index) -{ - switch(m_type) { - case Invalid: - break; - case StringList: - qvariant_cast(d).removeAt(index); - break; - case VariantList: - qvariant_cast(d).removeAt(index); - break; - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->removeAt(index); - break; - } - case QList: - //XXX needs implementation - qWarning() << "removeAt function not yet implemented for QLists"; - break; - case Instance: - //XXX do nothing? - if (index == 0) - setList(QVariant()); - break; - case Integer: - break; - } -} - -void QmlListAccessor::clear() -{ - switch(m_type) { - case Invalid: - break; - case StringList: - qvariant_cast(d).clear(); - break; - case VariantList: - qvariant_cast(d).clear(); - break; - case QmlList: - { - QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); - li->clear(); - break; - } - case QList: - QmlMetaType::clear(d); - break; - case Instance: - //XXX what should we do here? - setList(QVariant()); - break; - case Integer: - d = 0; - } -} - bool QmlListAccessor::isValid() const { return m_type != Invalid; diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h index 2697606..7b34d75 100644 --- a/src/declarative/util/qmllistaccessor_p.h +++ b/src/declarative/util/qmllistaccessor_p.h @@ -65,11 +65,6 @@ public: int count() const; QVariant at(int) const; - virtual void append(const QVariant &); - virtual void insert(int, const QVariant &); - virtual void removeAt(int); - virtual void clear(); - enum Type { Invalid, StringList, VariantList, QmlList, QList, Instance, Integer }; Type type() const { return m_type; } diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp index b2d42ff..4c8219a 100644 --- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp +++ b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp @@ -41,6 +41,7 @@ #include #include #include +#include class tst_QmlListAccessor : public QObject { @@ -51,7 +52,7 @@ public: private slots: void qmllist(); //void qlist(); - //void qstringlist(); + void qstringlist(); }; void tst_QmlListAccessor::qmllist() @@ -71,31 +72,30 @@ void tst_QmlListAccessor::qmllist() QVariant v = accessor.at(0); QCOMPARE(qvariant_cast(v), obj); - accessor.removeAt(3); - QVERIFY(accessor.count() == 1); - - accessor.removeAt(0); - QVERIFY(accessor.count() == 0); + QVERIFY(accessor.isValid()); +} - accessor.insert(4, qVariantFromValue(obj)); - QVERIFY(accessor.count() == 1); +void tst_QmlListAccessor::qstringlist() +{ + QStringList list; + list.append(QLatin1String("Item1")); + list.append(QLatin1String("Item2")); + QVERIFY(list.count() == 2); - v = accessor.at(0); - QCOMPARE(qvariant_cast(v), obj); + QmlListAccessor accessor; + accessor.setList(list); - QObject *obj2 = new QObject; - accessor.append(qVariantFromValue(obj2)); + QVERIFY(accessor.isValid()); QVERIFY(accessor.count() == 2); - v = accessor.at(1); - QCOMPARE(qvariant_cast(v), obj2); - - accessor.clear(); - QVERIFY(accessor.count() == 0); + QVariant v = accessor.at(0); + QCOMPARE(qvariant_cast(v), QLatin1String("Item1")); - QVERIFY(accessor.isValid()); + v = accessor.at(1); + QCOMPARE(qvariant_cast(v), QLatin1String("Item2")); } + QTEST_MAIN(tst_QmlListAccessor) #include "tst_qmllistaccessor.moc" -- cgit v0.12