aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitemview_p.h
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/qquickitemview_p.h
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/qquickitemview_p.h')
-rw-r--r--src/quick/items/qquickitemview_p.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index ad026a3152..57635d7780 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -43,6 +43,7 @@
#define QQUICKITEMVIEW_P_H
#include "qquickflickable_p.h"
+#include <qpointer.h>
QT_BEGIN_NAMESPACE
@@ -282,6 +283,7 @@ class Q_AUTOTEST_EXPORT QQuickItemViewAttached : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QQuickItemView *view READ view NOTIFY viewChanged)
Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged)
@@ -294,6 +296,14 @@ public:
: QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
~QQuickItemViewAttached() {}
+ QQuickItemView *view() { return m_view; }
+ void setView(QQuickItemView *view) {
+ if (view != m_view) {
+ m_view = view;
+ Q_EMIT viewChanged();
+ }
+ }
+
bool isCurrentItem() const { return m_isCurrent; }
void setIsCurrentItem(bool c) {
if (m_isCurrent != c) {
@@ -353,6 +363,7 @@ public:
void emitRemove() { Q_EMIT remove(); }
Q_SIGNALS:
+ void viewChanged();
void currentItemChanged();
void delayRemoveChanged();
@@ -364,6 +375,7 @@ Q_SIGNALS:
void nextSectionChanged();
public:
+ QPointer<QQuickItemView> m_view;
bool m_isCurrent : 1;
bool m_delayRemove : 1;