aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickgridview.cpp
diff options
context:
space:
mode:
authorNils Jeisecke <jeisecke@saltation.de>2013-10-07 11:55:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-26 09:19:23 +0100
commit1061c7e5cfae88a336f1327cc20b2d8a0a3c6015 (patch)
tree058e8a07c1da7671ac8fcd9c91b91b386d106a2e /src/quick/items/qquickgridview.cpp
parent7d25db8ff452926e58b7a66608666b35c194fc69 (diff)
Make GridView/ListView attached "view" property available to all delegate types
This is useful for accessing the view (e.g. "width", "cellWidth", ... properties) from within section (ListView only), header, footer and highlight delegate components. A typical usecase are components that are used in multiple views and therefore cannot use the views's id for access. The only attached property valid for those non-item delegates is "view". This has been added to the documentation. Change-Id: I33d976da778be23ed531a3b193ceee95ed9800d2 Task-number: QTBUG-32836 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src/quick/items/qquickgridview.cpp')
-rw-r--r--src/quick/items/qquickgridview.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 8587da5ac3..f97229a76a 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -65,8 +65,8 @@ QT_BEGIN_NAMESPACE
class FxGridItemSG : public FxViewItem
{
public:
- FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own) : FxViewItem(i, v, own), view(v) {
- attached = static_cast<QQuickGridViewAttached*>(qmlAttachedPropertiesObject<QQuickGridView>(item));
+ FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own) : FxViewItem(i, v, own, static_cast<QQuickItemViewAttached*>(qmlAttachedPropertiesObject<QQuickGridView>(i))), view(v)
+ {
}
qreal position() const {
@@ -1283,7 +1283,8 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
\qmlattachedproperty GridView QtQuick::GridView::view
This attached property holds the view that manages this delegate instance.
- It is attached to each instance of the delegate.
+ It is attached to each instance of the delegate and also to the header, the footer
+ and the highlight delegates.
\snippet qml/gridview/gridview.qml isCurrentItem
*/
@@ -2127,6 +2128,9 @@ void QQuickGridView::geometryChanged(const QRectF &newGeometry, const QRectF &ol
void QQuickGridView::initItem(int index, QObject *obj)
{
QQuickItemView::initItem(index, obj);
+
+ // setting the view from the FxViewItem wrapper is too late if the delegate
+ // needs access to the view in Component.onCompleted
QQuickItem *item = qmlobject_cast<QQuickItem*>(obj);
if (item) {
QQuickGridViewAttached *attached = static_cast<QQuickGridViewAttached *>(