diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-09-23 03:05:48 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-09-23 03:10:12 (GMT) |
commit | 4bd27d5c8c1f2dd759e20e4a6b3ac224799e2318 (patch) | |
tree | 5fabc4cc912f04516927f2b7100d7b496b378575 /src/declarative | |
parent | b22994c3e1574716c8fc6a1da52251443d3c9cc6 (diff) | |
download | Qt-4bd27d5c8c1f2dd759e20e4a6b3ac224799e2318.zip Qt-4bd27d5c8c1f2dd759e20e4a6b3ac224799e2318.tar.gz Qt-4bd27d5c8c1f2dd759e20e4a6b3ac224799e2318.tar.bz2 |
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.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp | 5 |
1 files changed, 3 insertions, 2 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; } |