From 6891a96bbc818f0bbfb1837d2912bdb24211572e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 2 Nov 2009 17:12:10 +1000 Subject: NOTIFY ListModel::count --- src/declarative/util/qmllistmodel.cpp | 4 +++- src/declarative/util/qmllistmodel_p.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index dba2203..17083db 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -457,6 +457,7 @@ void QmlListModel::remove(int index) if (node) delete node; emit itemsRemoved(index,1); + emit countChanged(_root->values.count()); } } @@ -488,6 +489,7 @@ void QmlListModel::insert(int index, const QScriptValue& valuemap) mn->setObjectValue(valuemap); _root->values.insert(index,qVariantFromValue(mn)); emit itemsInserted(index,1); + emit countChanged(_root->values.count()); } /*! @@ -563,6 +565,7 @@ void QmlListModel::append(const QScriptValue& valuemap) mn->setObjectValue(valuemap); _root->values << qVariantFromValue(mn); emit itemsInserted(count()-1,1); + emit countChanged(_root->values.count()); } /*! @@ -642,7 +645,6 @@ void QmlListModel::set(int index, const QString& property, const QVariant& value emit itemsChanged(index,1,roles); } - class QmlListModelParser : public QmlCustomParser { public: diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qmllistmodel_p.h index 8676024..31365d1 100644 --- a/src/declarative/util/qmllistmodel_p.h +++ b/src/declarative/util/qmllistmodel_p.h @@ -62,7 +62,7 @@ struct ModelNode; class QmlListModel : public QListModelInterface { Q_OBJECT - Q_PROPERTY(int count READ count) + Q_PROPERTY(int count READ count NOTIFY countChanged) public: QmlListModel(QObject *parent=0); @@ -81,6 +81,9 @@ public: Q_INVOKABLE void set(int index, const QString& property, const QVariant& value); Q_INVOKABLE void move(int from, int to, int count); +Q_SIGNALS: + void countChanged(int); + private: QVariant valueForNode(ModelNode *) const; mutable QStringList roleStrings; -- cgit v0.12