diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-02-25 06:25:07 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-02-25 06:25:07 (GMT) |
commit | 5c82031a7357f4f3d100be30c0bfe4e878712829 (patch) | |
tree | 77a806156f50ee1aa1f41c9f02432134f1fc0aac /src/declarative | |
parent | 4c5292a36360821a3ba4a7bc4532688dff7b7ae9 (diff) | |
parent | c58554711e678421cd70f103ad78506b3e1f8d85 (diff) | |
download | Qt-5c82031a7357f4f3d100be30c0bfe4e878712829.zip Qt-5c82031a7357f4f3d100be30c0bfe4e878712829.tar.gz Qt-5c82031a7357f4f3d100be30c0bfe4e878712829.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src/declarative')
13 files changed, 120 insertions, 10 deletions
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: |