summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-06 06:11:22 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-06 06:11:22 (GMT)
commit95db707e2fe96eb7b6e5edcbd2850149b16e23b2 (patch)
tree59e044ff384d0a0f90acc138bbc53a7bd706a141
parent4c4fbc3fb731a4195d66f761ed4a58da5db00aa3 (diff)
downloadQt-95db707e2fe96eb7b6e5edcbd2850149b16e23b2.zip
Qt-95db707e2fe96eb7b6e5edcbd2850149b16e23b2.tar.gz
Qt-95db707e2fe96eb7b6e5edcbd2850149b16e23b2.tar.bz2
Enable updating of XmlListModel from Qml.
Made the fetch() method a slot so it will be accessible from QML.
-rw-r--r--src/declarative/extra/qmlxmllistmodel.cpp11
-rw-r--r--src/declarative/extra/qmlxmllistmodel.h2
-rw-r--r--src/declarative/fx/qfxpathview.cpp6
3 files changed, 15 insertions, 4 deletions
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp
index badc6fb..af72ecc 100644
--- a/src/declarative/extra/qmlxmllistmodel.cpp
+++ b/src/declarative/extra/qmlxmllistmodel.cpp
@@ -239,12 +239,15 @@ void QmlXmlListModel::classComplete()
void QmlXmlListModel::fetch()
{
Q_D(QmlXmlListModel);
+
+ //clear existing data
+ d->size = 0;
+ int count = d->data.count();
+ d->data.clear();
+ emit itemsRemoved(0, count);
+
if (d->src.isEmpty()) {
qWarning() << "Can't fetch empty src string";
- //clear existing data?
- //int count = d->data.count();
- //d->data.clear();
- //emit itemsRemoved(0, count);
return;
}
diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h
index d06cabf..acc54a9 100644
--- a/src/declarative/extra/qmlxmllistmodel.h
+++ b/src/declarative/extra/qmlxmllistmodel.h
@@ -116,6 +116,8 @@ public:
void setNamespaceDeclarations(const QString&);
virtual void classComplete();
+
+public Q_SLOTS:
void fetch();
protected:
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 810a359..ca6379f 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -699,6 +699,12 @@ void QFxPathView::itemsRemoved(int modelIndex, int count)
d->regenerate();
}
+ if (d->model->count() == 0) {
+ d->currentIndex == -1;
+ d->moveOffset.setValue(0);
+ return;
+ }
+
// make sure the current item is still at the snap position
if (d->currentIndex >= d->model->count())
d->currentIndex = d->model->count() - 1;