diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-17 06:17:32 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-17 06:17:32 (GMT) |
commit | 84be245f709073a197591209d7af56686a40b8d7 (patch) | |
tree | caff5cf03adedafa3700a59ae5ecc68b4e92812f /src | |
parent | 4e126f5222a3c62a46037c4ac40743f9f2ee9026 (diff) | |
parent | 9b4124c699a7c958ffa132e31db6901cd719847c (diff) | |
download | Qt-84be245f709073a197591209d7af56686a40b8d7.zip Qt-84be245f709073a197591209d7af56686a40b8d7.tar.gz Qt-84be245f709073a197591209d7af56686a40b8d7.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/util/qmllistaccessor.cpp | 128 | ||||
-rw-r--r-- | src/declarative/util/qmllistaccessor_p.h | 5 | ||||
-rw-r--r-- | src/declarative/util/qmlstateoperations.cpp | 6 |
3 files changed, 137 insertions, 2 deletions
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 2c01081..910f2a5 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -149,6 +149,134 @@ 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<QStringList>(d).append(str); + break; + } + case VariantList: + { + qvariant_cast<QVariantList>(d).append(value); + break; + } + case QmlList: + { + QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); + li->append(const_cast<void *>(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<QStringList>(d).insert(index, str); + break; + } + case VariantList: + { + qvariant_cast<QVariantList>(d).insert(index, value); + break; + } + case QmlList: + { + QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); + li->insert(index, const_cast<void *>(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<QStringList>(d).removeAt(index); + break; + case VariantList: + qvariant_cast<QVariantList>(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<QStringList>(d).clear(); + break; + case VariantList: + qvariant_cast<QVariantList>(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 7b34d75..2697606 100644 --- a/src/declarative/util/qmllistaccessor_p.h +++ b/src/declarative/util/qmllistaccessor_p.h @@ -65,6 +65,11 @@ 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/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 0d977de..e2933b2 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -475,6 +475,8 @@ void QmlAnchorChanges::setReset(const QString &reset) Q_D(QmlAnchorChanges); d->resetString = reset; d->resetList = d->resetString.split(QLatin1Char(',')); + for (int i = 0; i < d->resetList.count(); ++i) + d->resetList[i] = d->resetList.at(i).trimmed(); } /*! @@ -766,8 +768,8 @@ bool QmlAnchorChanges::override(ActionEvent*other) return false; if (static_cast<ActionEvent*>(this) == other) return true; - //### can we do any other meaningful comparison? Do we need to attempt to merge the two - // somehow if they have the same target and some of the same anchors? + if (static_cast<QmlAnchorChanges*>(other)->object() == object()) + return true; return false; } |