diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-02 07:12:10 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-02 07:12:10 (GMT) |
commit | 6891a96bbc818f0bbfb1837d2912bdb24211572e (patch) | |
tree | 35e6a0c4c9095e22dd4f922d0ec9eac94a336fef /src/declarative | |
parent | a0c07728c391f6c209fef7678a708a83084fac6a (diff) | |
download | Qt-6891a96bbc818f0bbfb1837d2912bdb24211572e.zip Qt-6891a96bbc818f0bbfb1837d2912bdb24211572e.tar.gz Qt-6891a96bbc818f0bbfb1837d2912bdb24211572e.tar.bz2 |
NOTIFY ListModel::count
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 4 | ||||
-rw-r--r-- | 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; |