summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativelistmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/util/qdeclarativelistmodel.cpp')
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 340e9ac..1a28176 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -365,7 +365,7 @@ void QDeclarativeListModel::clear()
if (!m_isWorkerCopy) {
emit itemsRemoved(0, cleared);
- emit countChanged(0);
+ emit countChanged();
}
}
@@ -390,7 +390,7 @@ void QDeclarativeListModel::remove(int index)
if (!m_isWorkerCopy) {
emit itemsRemoved(index, 1);
- emit countChanged(this->count());
+ emit countChanged();
}
}
@@ -401,7 +401,7 @@ void QDeclarativeListModel::remove(int index)
values in \a dict.
\code
- FruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
+ fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"})
\endcode
The \a index must be to an existing item in the list, or one past
@@ -424,7 +424,7 @@ void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap)
bool ok = m_flat ? m_flat->insert(index, valuemap) : m_nested->insert(index, valuemap);
if (ok && !m_isWorkerCopy) {
emit itemsInserted(index, 1);
- emit countChanged(this->count());
+ emit countChanged();
}
}
@@ -437,7 +437,7 @@ void QDeclarativeListModel::insert(int index, const QScriptValue& valuemap)
to the end of the list:
\code
- FruitModel.move(0,FruitModel.count-3,3)
+ fruitModel.move(0,fruitModel.count-3,3)
\endcode
\sa append()
@@ -479,7 +479,7 @@ void QDeclarativeListModel::move(int from, int to, int n)
values in \a dict.
\code
- FruitModel.append({"cost": 5.95, "name":"Pizza"})
+ fruitModel.append({"cost": 5.95, "name":"Pizza"})
\endcode
\sa set() remove()
@@ -500,8 +500,8 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap)
Returns the item at \a index in the list model.
\code
- FruitModel.append({"cost": 5.95, "name":"Jackfruit"})
- FruitModel.get(0).cost
+ fruitModel.append({"cost": 5.95, "name":"Jackfruit"})
+ fruitModel.get(0).cost
\endcode
The \a index must be an element in the list.
@@ -510,10 +510,10 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap)
will also be models, and this get() method is used to access elements:
\code
- FruitModel.append(..., "attributes":
+ fruitModel.append(..., "attributes":
[{"name":"spikes","value":"7mm"},
{"name":"color","value":"green"}]);
- FruitModel.get(0).attributes.get(1).value; // == "green"
+ fruitModel.get(0).attributes.get(1).value; // == "green"
\endcode
\sa append()
@@ -536,7 +536,7 @@ QScriptValue QDeclarativeListModel::get(int index) const
are left unchanged.
\code
- FruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
+ fruitModel.set(3, {"cost": 5.95, "name":"Pizza"})
\endcode
The \a index must be an element in the list.
@@ -574,7 +574,7 @@ void QDeclarativeListModel::set(int index, const QScriptValue& valuemap)
Changes the \a property of the item at \a index in the list model to \a value.
\code
- FruitModel.set(3, "cost", 5.95)
+ fruitModel.set(3, "cost", 5.95)
\endcode
The \a index must be an element in the list.
@@ -1250,14 +1250,9 @@ ModelNode::ModelNode()
ModelNode::~ModelNode()
{
- ModelNode *node;
-
- QList<ModelNode *> nodeValues = properties.values();
- for (int ii = 0; ii < nodeValues.count(); ++ii) {
- node = nodeValues[ii];
- if (node) { delete node; node = 0; }
- }
+ qDeleteAll(properties.values());
+ ModelNode *node;
for (int ii = 0; ii < values.count(); ++ii) {
node = qvariant_cast<ModelNode *>(values.at(ii));
if (node) { delete node; node = 0; }
@@ -1279,7 +1274,9 @@ void ModelNode::setObjectValue(const QScriptValue& valuemap) {
} else {
value->values << v.toVariant();
}
- properties.insert(it.name(),value);
+ if (properties.contains(it.name()))
+ delete properties[it.name()];
+ properties.insert(it.name(), value);
}
}