summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-02-25 06:25:07 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-02-25 06:25:07 (GMT)
commit5c82031a7357f4f3d100be30c0bfe4e878712829 (patch)
tree77a806156f50ee1aa1f41c9f02432134f1fc0aac
parent4c5292a36360821a3ba4a7bc4532688dff7b7ae9 (diff)
parentc58554711e678421cd70f103ad78506b3e1f8d85 (diff)
downloadQt-5c82031a7357f4f3d100be30c0bfe4e878712829.zip
Qt-5c82031a7357f4f3d100be30c0bfe4e878712829.tar.gz
Qt-5c82031a7357f4f3d100be30c0bfe4e878712829.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
-rw-r--r--demos/declarative/snake/snake.qml4
-rw-r--r--doc/src/declarative/elements.qdoc1
-rw-r--r--examples/declarative/package/Delegate.qml44
-rw-r--r--examples/declarative/package/view.qml35
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp18
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater_p.h1
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp35
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h2
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h3
-rw-r--r--src/declarative/util/qdeclarativepackage.cpp27
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml39
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp43
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/displaylist.qml43
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp43
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/displaypath.qml60
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp41
23 files changed, 471 insertions, 12 deletions
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 3bec747..09b6b7f 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -172,14 +172,14 @@ Rectangle {
states: [
State {
name: "starting"
- when: startHeartbeatTimer.running;
+ when: startHeartbeatTimer.running
PropertyChanges {target: progressIndicator; width: 200}
PropertyChanges {target: title; opacity: 0}
PropertyChanges {target: progressBar; opacity: 1}
},
State {
name: "running"
- when: heartbeat.running
+ when: (heartbeat.running && !startHeartbeatTimer.running)
PropertyChanges {target: progressIndicator; width: 200}
PropertyChanges {target: title; opacity: 0}
PropertyChanges {target: skull; row: 0; column: 0; }
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 470a78c..da96b8e 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -89,6 +89,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l ListModel, \l ListElement
\o \l VisualItemModel
\o \l VisualDataModel
+\o \l Package
\o \l XmlListModel and XmlRole
\o \l DateTimeFormatter
\o \l NumberFormatter
diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml
new file mode 100644
index 0000000..4109633
--- /dev/null
+++ b/examples/declarative/package/Delegate.qml
@@ -0,0 +1,44 @@
+import Qt 4.6
+
+//![0]
+Package {
+ Text { id: listDelegate; width: 200; height: 25; text: "Empty"; Package.name: "list" }
+ Text { id: gridDelegate; width: 100; height: 50; text: "Empty"; Package.name: "grid" }
+
+ Rectangle {
+ id: wrapper
+ width: 200; height: 25
+ color: "lightsteelblue"
+ Text { text: display; anchors.centerIn: parent }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: {
+ if (wrapper.state == "inList")
+ wrapper.state = "inGrid";
+ else
+ wrapper.state = "inList";
+ }
+ }
+ state: "inList"
+ states: [
+ State {
+ name: 'inList'
+ ParentChange { target: wrapper; parent: listDelegate }
+ },
+ State {
+ name: 'inGrid'
+ ParentChange { target: wrapper; parent: gridDelegate }
+ PropertyChanges { target: wrapper; x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height }
+ }
+ ]
+ transitions: [
+ Transition {
+ SequentialAnimation {
+ ParentAction { target: wrapper }
+ NumberAnimation { targets: wrapper; properties: 'x,y,width,height'; duration: 300 }
+ }
+ }
+ ]
+ }
+}
+//![0]
diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml
new file mode 100644
index 0000000..07bba0c
--- /dev/null
+++ b/examples/declarative/package/view.qml
@@ -0,0 +1,35 @@
+import Qt 4.6
+
+Item {
+ width: 400
+ height: 200
+
+ ListModel {
+ id: myModel
+ ListElement { display: "One" }
+ ListElement { display: "Two" }
+ ListElement { display: "Three" }
+ ListElement { display: "Four" }
+ ListElement { display: "Five" }
+ ListElement { display: "Six" }
+ ListElement { display: "Seven" }
+ ListElement { display: "Eight" }
+ }
+ //![0]
+ VisualDataModel {
+ id: visualModel
+ delegate: Delegate {}
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ GridView {
+ x: 200; width: 200; height:200
+ cellHeight: 50
+ model: visualModel.parts.grid
+ }
+ //![0]
+}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 2ef6305..b378db2 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -787,6 +787,7 @@ void QDeclarativeGridView::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
}
@@ -821,6 +822,7 @@ void QDeclarativeGridView::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
emit countChanged();
@@ -1688,6 +1690,16 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count)
d->layout(removedBeforeVisible);
}
+void QDeclarativeGridView::modelReset()
+{
+ Q_D(QDeclarativeGridView);
+ d->clear();
+ refill();
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ emit countChanged();
+}
+
void QDeclarativeGridView::createdItem(int index, QDeclarativeItem *item)
{
Q_D(QDeclarativeGridView);
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index b36c4aa..b488475 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -144,6 +144,7 @@ private Q_SLOTS:
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
void itemsMoved(int from, int to, int count);
+ void modelReset();
void destroyRemoved();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 77e3a15..bd2f4fc 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1477,6 +1477,7 @@ void QDeclarativeListView::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
}
@@ -1511,6 +1512,7 @@ void QDeclarativeListView::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
emit countChanged();
@@ -2684,6 +2686,16 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count)
d->layout();
}
+void QDeclarativeListView::modelReset()
+{
+ Q_D(QDeclarativeListView);
+ d->clear();
+ refill();
+ d->moveReason = QDeclarativeListViewPrivate::SetIndex;
+ d->updateCurrent(d->currentIndex);
+ emit countChanged();
+}
+
void QDeclarativeListView::createdItem(int index, QDeclarativeItem *item)
{
Q_D(QDeclarativeListView);
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 1b6276e..5e3edb0 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -221,6 +221,7 @@ private Q_SLOTS:
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
void itemsMoved(int from, int to, int count);
+ void modelReset();
void destroyRemoved();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index ab6be1c..ec7aa62 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -143,7 +143,7 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
/*!
- \qmlclass MouseRegion QDeclarativeMouseRegion
+ \qmlclass MouseArea QDeclarativeMouseArea
\since 4.7
\brief The MouseArea item enables simple mouse handling.
\inherits Item
@@ -172,7 +172,7 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
/*!
\qmlsignal MouseArea::onEntered()
- This handler is called when the mouse enters the mouse region.
+ This handler is called when the mouse enters the mouse area.
By default the onEntered handler is only called while a button is
pressed. Setting hoverEnabled to true enables handling of
@@ -184,7 +184,7 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate()
/*!
\qmlsignal MouseArea::onExited()
- This handler is called when the mouse exists the mouse region.
+ This handler is called when the mouse exists the mouse area.
By default the onExited handler is only called while a button is
pressed. Setting hoverEnabled to true enables handling of
@@ -295,12 +295,12 @@ QDeclarativeMouseArea::~QDeclarativeMouseArea()
If the hoverEnabled property is false then these properties will only be valid
while a button is pressed, and will remain valid as long as the button is held
- even if the mouse is moved outside the region.
+ even if the mouse is moved outside the area.
If hoverEnabled is true then these properties will be valid:
\list
\i when no button is pressed, but the mouse is within the MouseArea (containsMouse is true).
- \i if a button is pressed and held, even if it has since moved out of the region.
+ \i if a button is pressed and held, even if it has since moved out of the area.
\endlist
The coordinates are relative to the MouseArea.
@@ -567,9 +567,9 @@ void QDeclarativeMouseArea::timerEvent(QTimerEvent *event)
/*!
\qmlproperty bool MouseArea::containsMouse
- This property holds whether the mouse is currently inside the mouse region.
+ This property holds whether the mouse is currently inside the mouse area.
- \warning This property is not updated if the region moves under the mouse: \e containsMouse will not change.
+ \warning This property is not updated if the area moves under the mouse: \e containsMouse will not change.
In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed.
*/
bool QDeclarativeMouseArea::hovered() const
@@ -580,7 +580,7 @@ bool QDeclarativeMouseArea::hovered() const
/*!
\qmlproperty bool MouseArea::pressed
- This property holds whether the mouse region is currently pressed.
+ This property holds whether the mouse area is currently pressed.
*/
bool QDeclarativeMouseArea::pressed() const
{
@@ -600,7 +600,7 @@ void QDeclarativeMouseArea::setHovered(bool h)
/*!
\qmlproperty Qt::MouseButtons MouseArea::acceptedButtons
- This property holds the mouse buttons that the mouse region reacts to.
+ This property holds the mouse buttons that the mouse area reacts to.
The available buttons are:
\list
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index b9e38ef..c131f4c 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -206,6 +206,7 @@ void QDeclarativePathView::setModel(const QVariant &model)
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(modelReset()), this, SLOT(modelReset()));
disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
for (int i=0; i<d->items.count(); i++){
QDeclarativeItem *p = d->items[i];
@@ -234,6 +235,7 @@ void QDeclarativePathView::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
}
d->firstIndex = 0;
@@ -782,7 +784,7 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
if (!d->isValid() || !isComponentComplete())
return;
if (d->pathItems == -1) {
- for (int i = 0; i < count; ++i) {
+ for (int i = 0; i < count && d->items.count() > modelIndex; ++i) {
QDeclarativeItem* p = d->items.takeAt(modelIndex);
d->model->release(p);
}
@@ -812,6 +814,12 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
d->moveOffset.setValue(targetOffset);
}
+void QDeclarativePathView::modelReset()
+{
+ Q_D(QDeclarativePathView);
+ d->regenerate();
+}
+
void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item)
{
Q_D(QDeclarativePathView);
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index d351a4e..709a4fc 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -115,6 +115,7 @@ private Q_SLOTS:
void ticked();
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
+ void modelReset();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index ca57d3c..e4cd499 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -166,6 +166,7 @@ void QDeclarativeRepeater::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
/*
disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
@@ -193,6 +194,7 @@ void QDeclarativeRepeater::setModel(const QVariant &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(modelReset()), this, SLOT(modelReset()));
/*
connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*)));
@@ -325,4 +327,9 @@ void QDeclarativeRepeater::itemsMoved(int,int,int)
regenerate();
}
+void QDeclarativeRepeater::modelReset()
+{
+ regenerate();
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p.h b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
index f58d1b6..db46699 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater_p.h
+++ b/src/declarative/graphicsitems/qdeclarativerepeater_p.h
@@ -88,6 +88,7 @@ private Q_SLOTS:
void itemsInserted(int,int);
void itemsRemoved(int,int);
void itemsMoved(int,int,int);
+ void modelReset();
private:
Q_DISABLE_COPY(QDeclarativeRepeater)
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index bfe8db9..2402648 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -660,6 +660,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model)
this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
+ QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
} else if (d->m_visualItemModel) {
QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
this, SIGNAL(itemsInserted(int,int)));
@@ -705,6 +706,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model)
this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
+ QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
d->m_metaDataCacheable = true;
return;
}
@@ -927,6 +929,33 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q
return stat;
}
+/*!
+ \qmlproperty object VisualDataModel::parts
+
+ The \a parts property selects a VisualDataModel which creates
+ delegates from the part named. This is used in conjunction with
+ the Package element.
+
+ For example, the code below selects a model which creates
+ delegates named \e list from a Package:
+
+ \code
+ VisualDataModel {
+ id: visualModel
+ delegate: Package {
+ Item { Package.name: "list" }
+ }
+ model: myModel
+ }
+
+ ListView {
+ width: 200; height:200
+ model: visualModel.parts.list
+ }
+ \endcode
+
+ \sa Package
+*/
QObject *QDeclarativeVisualDataModel::parts()
{
Q_D(QDeclarativeVisualDataModel);
@@ -1237,6 +1266,12 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const
_q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles);
}
+void QDeclarativeVisualDataModel::_q_modelReset()
+{
+ Q_D(QDeclarativeVisualDataModel);
+ emit modelReset();
+}
+
void QDeclarativeVisualDataModel::_q_createdPackage(int index, QDeclarativePackage *package)
{
Q_D(QDeclarativeVisualDataModel);
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index 76c8994..d34bcaf 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -93,6 +93,7 @@ Q_SIGNALS:
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
void itemsMoved(int from, int to, int count);
+ void modelReset();
void createdItem(int index, QDeclarativeItem *item);
void destroyingItem(QDeclarativeItem *item);
@@ -195,6 +196,7 @@ private Q_SLOTS:
void _q_rowsRemoved(const QModelIndex &,int,int);
void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
void _q_dataChanged(const QModelIndex&,const QModelIndex&);
+ void _q_modelReset();
void _q_createdPackage(int index, QDeclarativePackage *package);
void _q_destroyingPackage(QDeclarativePackage *package);
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index bb81fb3..65c9807 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -165,6 +165,9 @@ public:
protected:
virtual void updateCurrentValue(const QVariant &value)
{
+ if (state() == QAbstractAnimation::Stopped)
+ return;
+
if (animValue)
animValue->setValue(value.toReal());
}
diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp
index 356d7a1..34ae466 100644
--- a/src/declarative/util/qdeclarativepackage.cpp
+++ b/src/declarative/util/qdeclarativepackage.cpp
@@ -46,6 +46,33 @@
QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass Package QDeclarativePackage
+ \brief Package provides a collection of named items
+
+ The Package class is currently used in conjunction with
+ VisualDataModel to enable delegates with a shared context
+ to be provided to multiple views.
+
+ Any item within a Package may be assigned a name via the
+ \e {Package.name} attached property.
+
+ The example below creates a Package containing two named items;
+ \e list and \e grid. The third element in the package is parented to whichever
+ delegate it should appear in. This allows an item to move
+ between views.
+
+ \snippet examples/declarative/package/Delegate.qml 0
+
+ These named items are used as the delegates by the two views who
+ reference the special VisualDataModel.parts property to select
+ a model which provides the chosen delegate.
+
+ \snippet examples/declarative/package/view.qml 0
+
+*/
+
+
class QDeclarativePackagePrivate : public QObjectPrivate
{
public:
diff --git a/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml b/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml
new file mode 100644
index 0000000..d3cdcd8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml
@@ -0,0 +1,39 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.color: "blue"
+ Text {
+ text: index
+ }
+ Text {
+ y: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ }
+ ]
+ GridView {
+ id: grid
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ model: testModel
+ delegate: myDelegate
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 9c7468d..9c9d1d3 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -41,6 +41,7 @@
#include <qdeclarativeengine.h>
#include <qdeclarativecomponent.h>
+#include <QStringListModel>
#include <QtTest/QtTest>
#include <private/qlistmodelinterface_p.h>
#include <qdeclarativeview.h>
@@ -66,6 +67,7 @@ private slots:
void defaultValues();
void properties();
void positionViewAtIndex();
+ void resetModel();
void QTBUG_8456();
private:
@@ -884,6 +886,47 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
delete canvas;
}
+void tst_QDeclarativeGridView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaygrid.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QDeclarativeItem *viewport = gridview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
void tst_QDeclarativeGridView::QTBUG_8456()
{
QDeclarativeView *canvas = createView();
diff --git a/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
new file mode 100644
index 0000000..7b124a5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml
@@ -0,0 +1,43 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text {
+ text: index
+ }
+ Text {
+ x: 30
+ objectName: "displayText"
+ text: display
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+ }
+ },
+ Component {
+ id: myHighlight
+ Rectangle { color: "green" }
+ }
+ ]
+ ListView {
+ id: list
+ objectName: "list"
+ focus: true
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+ highlight: myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index daa40d1..9100522 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <QtTest/QtTest>
+#include <QStringListModel>
#include <private/qlistmodelinterface_p.h>
#include <qdeclarativeview.h>
#include <private/qdeclarativelistview_p.h>
@@ -80,6 +81,7 @@ private slots:
void sections();
void cacheBuffer();
void positionViewAtIndex();
+ void resetModel();
private:
template <class T> void items();
@@ -1232,6 +1234,47 @@ void tst_QDeclarativeListView::positionViewAtIndex()
delete canvas;
}
+void tst_QDeclarativeListView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml"));
+ qApp->processEvents();
+
+ QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+
+ QDeclarativeItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
void tst_QDeclarativeListView::qListModelInterface_items()
{
items<TestModel>();
diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
new file mode 100644
index 0000000..627f38a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml
@@ -0,0 +1,60 @@
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: "#ffffff"
+ resources: [
+ Component {
+ id: delegate
+ Rectangle {
+ id: wrapper
+ objectName: "wrapper"
+ height: 20
+ width: 60
+ color: "white"
+ border.color: "black"
+ Text {
+ text: index
+ }
+ Text {
+ x: 20
+ id: displayText
+ objectName: "displayText"
+ text: display
+ }
+ }
+ }
+ ]
+ PathView {
+ id: view
+ objectName: "view"
+ width: 240
+ height: 320
+ model: testModel
+ delegate: delegate
+ snapPosition: 0.01
+ path: Path {
+ startY: 120
+ startX: 160
+ PathQuad {
+ y: 120
+ x: 80
+ controlY: 330
+ controlX: 100
+ }
+ PathLine {
+ y: 160
+ x: 20
+ }
+ PathCubic {
+ y: 120
+ x: 160
+ control1Y: 0
+ control1X: 100
+ control2Y: 000
+ control2X: 200
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index 09f0f79..79bc607 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -49,6 +49,7 @@
#include <QtDeclarative/private/qdeclarativetext_p.h>
#include <QtDeclarative/private/qdeclarativerectangle_p.h>
#include <QAbstractListModel>
+#include <QStringListModel>
#include <QFile>
#include <private/qdeclarativevaluetype_p.h>
#include "../../../shared/util.h"
@@ -67,6 +68,7 @@ private slots:
void pathview3();
void path();
void pathMoved();
+ void resetModel();
private:
QDeclarativeView *createView();
@@ -425,6 +427,45 @@ void tst_QDeclarativePathView::pathMoved()
delete canvas;
}
+void tst_QDeclarativePathView::resetModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = findItem<QDeclarativePathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QDeclarativeText *display = findItem<QDeclarativeText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+}
+
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);