aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types/qqmldelegatemodel_p_p.h
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-06-06 15:53:16 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2018-06-09 16:58:13 +0000
commit7d55fb4029f4cc9bc5e5b4cef7ef5a456d42f83f (patch)
tree2be582752ffde4fa72dbe67c5528b963cd11b143 /src/qml/types/qqmldelegatemodel_p_p.h
parent90fea15e0dfc62ecd668d1b0462d121dba5c1b7e (diff)
QQmlDelegateModelItem: move row and column up to the base class
Change 8c33c70 injected row and column (alongside index) into the QML context of a delegate when the view had a QAbstractItemModel as model. Rather than only inject those properties when using QAIM, this patch will move the code to the base class. This way, if a view uses e.g a javascript list as model, row and column is still be available. This is useful, since then the delegate can bind to both row and column regardless of what kind of model the view uses. In the case of a list model, the column property will always be 0. Change-Id: I1d9f11c0b7d7a5beb83198184ba12cc1e48cd100 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/types/qqmldelegatemodel_p_p.h')
-rw-r--r--src/qml/types/qqmldelegatemodel_p_p.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h
index 2c0383a7e2..d5f79fab62 100644
--- a/src/qml/types/qqmldelegatemodel_p_p.h
+++ b/src/qml/types/qqmldelegatemodel_p_p.h
@@ -95,6 +95,8 @@ class QQmlDelegateModelItem : public QObject
{
Q_OBJECT
Q_PROPERTY(int index READ modelIndex NOTIFY modelIndexChanged)
+ Q_PROPERTY(int row MEMBER row NOTIFY rowChanged)
+ Q_PROPERTY(int column MEMBER column NOTIFY columnChanged)
Q_PROPERTY(QObject *model READ modelObject CONSTANT)
public:
QQmlDelegateModelItem(QQmlDelegateModelItemMetaType *metaType, int modelIndex);
@@ -121,7 +123,7 @@ public:
int groupIndex(Compositor::Group group);
int modelIndex() const { return index; }
- virtual void setModelIndex(int idx) { index = idx; Q_EMIT modelIndexChanged(); }
+ virtual void setModelIndex(int idx);
virtual QV4::ReturnedValue get() { return QV4::QObjectWrapper::wrap(v4, this); }
@@ -148,9 +150,13 @@ public:
Q_SIGNALS:
void modelIndexChanged();
+ void rowChanged();
+ void columnChanged();
protected:
void objectDestroyed(QObject *);
+ int row;
+ int column;
};
namespace QV4 {