summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-25 23:13:30 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-25 23:13:30 (GMT)
commitc08941ea0780779e6600e03ab0c62ce3461e2660 (patch)
tree391139f6f55c50aede50a93165c17fa205d51a2b
parentde85d147d38acb1d9dd3feacf968c72cb74490e8 (diff)
parent778e1fd21f5a6c94656dfbb99a7613656d0569a1 (diff)
downloadQt-c08941ea0780779e6600e03ab0c62ce3461e2660.zip
Qt-c08941ea0780779e6600e03ab0c62ce3461e2660.tar.gz
Qt-c08941ea0780779e6600e03ab0c62ce3461e2660.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp6
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p.h2
-rw-r--r--src/declarative/util/qdeclarativelistmodelworkeragent.cpp2
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp26
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp43
5 files changed, 52 insertions, 27 deletions
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 3e25234..3904458 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();
}
}
@@ -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();
}
}
diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h
index 6a0426b..d09062e 100644
--- a/src/declarative/util/qdeclarativelistmodel_p.h
+++ b/src/declarative/util/qdeclarativelistmodel_p.h
@@ -91,7 +91,7 @@ public:
QDeclarativeListModelWorkerAgent *agent();
Q_SIGNALS:
- void countChanged(int);
+ void countChanged();
private:
friend class QDeclarativeListModelParser;
diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
index 2951262..0e38632 100644
--- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
+++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp
@@ -229,7 +229,7 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e)
}
if (cc)
- emit m_orig->countChanged(m_copy->count());
+ emit m_orig->countChanged();
}
}
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index f7beeaa..3e08854 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -173,22 +173,6 @@ public:
return job.queryId;
}
- QList<QList<QVariant> > modelData() {
- QMutexLocker locker(&m_mutex);
- return m_modelData;
- }
-
- QList<QDeclarativeXmlListRange> insertedItemRanges() {
- QMutexLocker locker(&m_mutex);
- return m_insertedItemRanges;
- }
-
- QList<QDeclarativeXmlListRange> removedItemRanges() {
- QMutexLocker locker(&m_mutex);
- return m_removedItemRanges;
- }
-
-
Q_SIGNALS:
void queryCompleted(const QDeclarativeXmlQueryResult &);
@@ -254,13 +238,10 @@ void QDeclarativeXmlQuery::doQueryJob()
query.setQuery(job.namespaces + job.query);
query.evaluateTo(&r);
- //qDebug() << r;
-
//always need a single root element
QByteArray xml = "<dummy:items xmlns:dummy=\"http://qtsotware.com/dummy\">\n" + r.toUtf8() + "</dummy:items>";
QBuffer b(&xml);
b.open(QIODevice::ReadOnly);
- //qDebug() << xml;
QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + job.namespaces;
QString prefix = QLatin1String("doc($inputDocument)/dummy:items") +
@@ -278,7 +259,6 @@ void QDeclarativeXmlQuery::doQueryJob()
if (item.isAtomicValue())
count = item.toAtomicValue().toInt();
}
- //qDebug() << count;
job.data = xml;
m_prefix = namespaces + prefix + QLatin1Char('/');
@@ -552,7 +532,7 @@ QHash<int,QVariant> QDeclarativeXmlListModel::data(int index, const QList<int> &
for (int i = 0; i < roles.size(); ++i) {
int role = roles.at(i);
int roleIndex = d->roles.indexOf(role);
- rv.insert(role, roleIndex == -1 ? QVariant() : d->data.at(roleIndex).at(index));
+ rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index));
}
return rv;
}
@@ -561,7 +541,7 @@ QVariant QDeclarativeXmlListModel::data(int index, int role) const
{
Q_D(const QDeclarativeXmlListModel);
int roleIndex = d->roles.indexOf(role);
- return (roleIndex == -1) ? QVariant() : d->data.at(roleIndex).at(index);
+ return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index);
}
/*!
@@ -748,6 +728,8 @@ void QDeclarativeXmlListModel::componentComplete()
Otherwise, items are only added if the model does not already
contain items with matching key role values.
+
+ \sa XmlRole::isKey
*/
void QDeclarativeXmlListModel::reload()
{
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 81cc922..e3aa5cc 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -69,6 +69,8 @@ private slots:
void roles();
void roleErrors();
void uniqueRoleNames();
+ void status();
+ void data();
void reload();
void useKeys();
void useKeys_data();
@@ -247,6 +249,47 @@ void tst_qdeclarativexmllistmodel::uniqueRoleNames()
delete model;
}
+void tst_qdeclarativexmllistmodel::status()
+{
+ QDeclarativeXmlListModel *model;
+ model = new QDeclarativeXmlListModel;
+ QCOMPARE(model->status(), QDeclarativeXmlListModel::Null);
+
+ model->setXml("<data></data>");
+ QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready);
+ delete model;
+
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+ QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading);
+
+ QTRY_COMPARE(model->count(), 9);
+ QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready);
+
+ delete model;
+}
+
+void tst_qdeclarativexmllistmodel::data()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+
+ QHash<int,QVariant> blank;
+ for (int i=0; i<model->roles().count(); i++)
+ blank.insert(model->roles()[i], QVariant());
+ for (int i=0; i<9; i++) {
+ QCOMPARE(model->data(i, model->roles()), blank);
+ for (int j=0; j<model->roles().count(); j++) {
+ QCOMPARE(model->data(i, j), QVariant());
+ }
+ }
+ QTRY_COMPARE(model->count(), 9);
+
+ delete model;
+}
+
void tst_qdeclarativexmllistmodel::reload()
{
// If no keys are used, the model should be rebuilt from scratch when