summaryrefslogtreecommitdiffstats
path: root/examples/declarative/objectlistmodel
diff options
context:
space:
mode:
authorMartin Smith <msmith@trolltech.com>2010-05-12 13:12:13 (GMT)
committerMartin Smith <msmith@trolltech.com>2010-05-12 13:12:13 (GMT)
commitbd11cdf472674af3b00d7d64c64023adbf5ee725 (patch)
tree99eb333a12f7e0d109b9ce9ff51120c612669d7a /examples/declarative/objectlistmodel
parent50fa9ebe8fc0e7eca7536a8663c86cd6b98b2c04 (diff)
parent0ebc9783d8ca0c4b27208bbc002c53c52c19ab4c (diff)
downloadQt-bd11cdf472674af3b00d7d64c64023adbf5ee725.zip
Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.tar.gz
Qt-bd11cdf472674af3b00d7d64c64023adbf5ee725.tar.bz2
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
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 }
}
}