summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-09-30 04:40:25 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-09-30 04:40:25 (GMT)
commit1248d9cda792b100215237ed64305b5f659b5424 (patch)
treecca874c99199a46e1c737c474580b6dc1affb771 /src/declarative
parent452c49a6e238e8069583933acf8a2b8f3ee33c31 (diff)
downloadQt-1248d9cda792b100215237ed64305b5f659b5424.zip
Qt-1248d9cda792b100215237ed64305b5f659b5424.tar.gz
Qt-1248d9cda792b100215237ed64305b5f659b5424.tar.bz2
Have repeater handle items being added/removed/moved by the model.
Currently this just recreates every item. Once repeater is able to correctly insert child items this needs to be revisited. Task-number: QT-745
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfxrepeater.cpp22
-rw-r--r--src/declarative/fx/qfxrepeater.h5
2 files changed, 24 insertions, 3 deletions
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 5ef7b10..f887060 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -154,15 +154,15 @@ void QFxRepeater::setModel(const QVariant &model)
{
Q_D(QFxRepeater);
clear();
- /*
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ /*
disconnect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
- }
*/
+ }
d->dataSource = model;
QObject *object = qvariant_cast<QObject*>(model);
QFxVisualModel *vim = 0;
@@ -181,10 +181,10 @@ void QFxRepeater::setModel(const QVariant &model)
dataModel->setModel(model);
}
if (d->model) {
- /*
connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
+ /*
connect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
connect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
*/
@@ -304,4 +304,20 @@ void QFxRepeater::regenerate()
foreach(QGraphicsItem* other, otherChildren)
other->setParentItem(parentItem());
}
+
+void QFxRepeater::itemsInserted(int, int)
+{
+ regenerate();
+}
+
+void QFxRepeater::itemsRemoved(int, int)
+{
+ regenerate();
+}
+
+void QFxRepeater::itemsMoved(int,int,int)
+{
+ regenerate();
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index 7d64d86..7a0318b 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -84,6 +84,11 @@ protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent);
+private Q_SLOTS:
+ void itemsInserted(int,int);
+ void itemsRemoved(int,int);
+ void itemsMoved(int,int,int);
+
private:
Q_DISABLE_COPY(QFxRepeater)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxRepeater)