summaryrefslogtreecommitdiffstats
path: root/examples/declarative/objectlistmodel
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/objectlistmodel')
-rw-r--r--examples/declarative/objectlistmodel/dataobject.cpp10
-rw-r--r--examples/declarative/objectlistmodel/dataobject.h8
-rw-r--r--examples/declarative/objectlistmodel/view.qml2
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 }
}
}