diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-05 04:38:55 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-05 04:38:55 (GMT) |
commit | ce9bc843443f2c61361afa75a62a7d39029557e6 (patch) | |
tree | a097566f26f14a1e0d2aa650cb803beb6ed1bddb /examples/declarative/objectlistmodel | |
parent | 02df0ce446a89298109e1c7d0ef1e790d41d442f (diff) | |
download | Qt-ce9bc843443f2c61361afa75a62a7d39029557e6.zip Qt-ce9bc843443f2c61361afa75a62a7d39029557e6.tar.gz Qt-ce9bc843443f2c61361afa75a62a7d39029557e6.tar.bz2 |
QList<QObject*> models now update their properties when they change.
Task-number: QTBUG-10348
Diffstat (limited to 'examples/declarative/objectlistmodel')
-rw-r--r-- | examples/declarative/objectlistmodel/dataobject.cpp | 10 | ||||
-rw-r--r-- | examples/declarative/objectlistmodel/dataobject.h | 8 | ||||
-rw-r--r-- | examples/declarative/objectlistmodel/view.qml | 2 |
3 files changed, 15 insertions, 5 deletions
diff --git a/examples/declarative/objectlistmodel/dataobject.cpp b/examples/declarative/objectlistmodel/dataobject.cpp index 4c44ee4..14be1b9 100644 --- a/examples/declarative/objectlistmodel/dataobject.cpp +++ b/examples/declarative/objectlistmodel/dataobject.cpp @@ -59,7 +59,10 @@ QString DataObject::name() const void DataObject::setName(const QString &name) { - m_name = name; + if (name != m_name) { + m_name = name; + emit nameChanged(); + } } QString DataObject::color() const @@ -69,5 +72,8 @@ QString DataObject::color() const void DataObject::setColor(const QString &color) { - m_color = color; + if (color != m_color) { + m_color = color; + emit colorChanged(); + } } diff --git a/examples/declarative/objectlistmodel/dataobject.h b/examples/declarative/objectlistmodel/dataobject.h index 6804474..852110d 100644 --- a/examples/declarative/objectlistmodel/dataobject.h +++ b/examples/declarative/objectlistmodel/dataobject.h @@ -48,8 +48,8 @@ class DataObject : public QObject { Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString color READ color WRITE setColor) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) public: DataObject(QObject *parent=0); @@ -61,6 +61,10 @@ public: QString color() const; void setColor(const QString &color); +signals: + void nameChanged(); + void colorChanged(); + private: QString m_name; QString m_color; diff --git a/examples/declarative/objectlistmodel/view.qml b/examples/declarative/objectlistmodel/view.qml index 908e388..2b8383f 100644 --- a/examples/declarative/objectlistmodel/view.qml +++ b/examples/declarative/objectlistmodel/view.qml @@ -9,7 +9,7 @@ ListView { Rectangle { height: 25 width: 100 - color: model.color + color: model.modelData.color Text { text: name } } } |