diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-09-17 07:01:00 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-09-17 07:01:00 (GMT) |
commit | 2a9bc5163553a05fee61c289d09ec2ba963911bc (patch) | |
tree | e3b7774591edca4e26e455b91355a01ac8c6d597 /src/declarative/util | |
parent | 6f75efdaf7f4fb378506cf52ec56588f02453806 (diff) | |
download | Qt-2a9bc5163553a05fee61c289d09ec2ba963911bc.zip Qt-2a9bc5163553a05fee61c289d09ec2ba963911bc.tar.gz Qt-2a9bc5163553a05fee61c289d09ec2ba963911bc.tar.bz2 |
Switch Repeater over to use VisualModel.
Also extend VisualModels to support the usage Repeater used to add.
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qmllistaccessor.cpp | 47 | ||||
-rw-r--r-- | src/declarative/util/qmllistaccessor.h | 6 |
2 files changed, 35 insertions, 18 deletions
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 0332b9e..1228952 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE QmlListAccessor::QmlListAccessor() -: type(Invalid) +: m_type(Invalid) { } @@ -65,31 +65,35 @@ void QmlListAccessor::setList(const QVariant &v) d = v; if (!d.isValid()) { - type = Invalid; + m_type = Invalid; } else if (d.type() == QVariant::StringList) { - type = StringList; + m_type = StringList; } else if (d.type() == QMetaType::QVariantList) { - type = VariantList; + m_type = VariantList; + } else if (d.canConvert(QVariant::Int)) { + qDebug() << "integer"; + m_type = Integer; } else if (d.type() != QVariant::UserType) { - type = Instance; + m_type = Instance; } else if (QmlMetaType::isObject(d.userType())) { QObject *data = 0; data = *(QObject **)v.constData(); d = QVariant::fromValue(data); - type = Instance; + m_type = Instance; } else if (QmlMetaType::isQmlList(d.userType())) { - type = QmlList; + m_type = QmlList; } else if (QmlMetaType::isList(d.userType())) { - type = QList; + qDebug() << "list"; + m_type = QList; } else { - type = Invalid; + m_type = Invalid; d = QVariant(); } } int QmlListAccessor::count() const { - switch(type) { + switch(m_type) { case Invalid: return 0; case StringList: @@ -105,6 +109,8 @@ int QmlListAccessor::count() const return QmlMetaType::listCount(d); case Instance: return 1; + case Integer: + return d.toInt(); } return 0; @@ -113,7 +119,7 @@ int QmlListAccessor::count() const QVariant QmlListAccessor::at(int idx) const { Q_ASSERT(idx >= 0 && idx < count()); - switch(type) { + switch(m_type) { case Invalid: return QVariant(); case StringList: @@ -131,6 +137,8 @@ QVariant QmlListAccessor::at(int idx) const return QmlMetaType::listAt(d, idx); case Instance: return d; + case Integer: + return QVariant(); } return QVariant(); @@ -138,7 +146,7 @@ QVariant QmlListAccessor::at(int idx) const void QmlListAccessor::append(const QVariant &value) { - switch(type) { + switch(m_type) { case Invalid: break; case StringList: @@ -162,6 +170,7 @@ void QmlListAccessor::append(const QVariant &value) QmlMetaType::append(d, value); break; case Instance: + case Integer: //do nothing break; } @@ -169,7 +178,7 @@ void QmlListAccessor::append(const QVariant &value) void QmlListAccessor::insert(int index, const QVariant &value) { - switch(type) { + switch(m_type) { case Invalid: break; case StringList: @@ -198,12 +207,14 @@ void QmlListAccessor::insert(int index, const QVariant &value) if (index == 0) setList(value); break; + case Integer: + break; } } void QmlListAccessor::removeAt(int index) { - switch(type) { + switch(m_type) { case Invalid: break; case StringList: @@ -227,12 +238,14 @@ void QmlListAccessor::removeAt(int index) if (index == 0) setList(QVariant()); break; + case Integer: + break; } } void QmlListAccessor::clear() { - switch(type) { + switch(m_type) { case Invalid: break; case StringList: @@ -254,12 +267,14 @@ void QmlListAccessor::clear() //XXX what should we do here? setList(QVariant()); break; + case Integer: + d = 0; } } bool QmlListAccessor::isValid() const { - return type != Invalid; + return m_type != Invalid; } QT_END_NAMESPACE diff --git a/src/declarative/util/qmllistaccessor.h b/src/declarative/util/qmllistaccessor.h index c3017e1..f0d293f 100644 --- a/src/declarative/util/qmllistaccessor.h +++ b/src/declarative/util/qmllistaccessor.h @@ -69,9 +69,11 @@ public: virtual void removeAt(int); virtual void clear(); + enum Type { Invalid, StringList, VariantList, QmlList, QList, Instance, Integer }; + Type type() const { return m_type; } + private: - enum Type { Invalid, StringList, VariantList, QmlList, QList, Instance }; - Type type; + Type m_type; QVariant d; }; |