diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-03-03 18:36:51 +0100 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-03-22 16:20:10 +0000 |
commit | ae1c3eba3e7e11a9b1ab4d18792c82c9bb6e62de (patch) | |
tree | 0afbf5ed19f00a91ff8873ef52c190f50acc1436 /tests/auto/qml/qqmlitemmodels/testtypes.h | |
parent | 226419514e9a05040e691ac84bae5e1fb5e5191a (diff) |
Remove QModelIndexList value type, use Array instead
We implement this by adding QModelIndexList to the
set of sequence types.
Change-Id: If7e0e88ab0c2916c2b65a926f8241549520d7391
Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'tests/auto/qml/qqmlitemmodels/testtypes.h')
-rw-r--r-- | tests/auto/qml/qqmlitemmodels/testtypes.h | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/tests/auto/qml/qqmlitemmodels/testtypes.h b/tests/auto/qml/qqmlitemmodels/testtypes.h index 5345609cd3..d61064fcad 100644 --- a/tests/auto/qml/qqmlitemmodels/testtypes.h +++ b/tests/auto/qml/qqmlitemmodels/testtypes.h @@ -45,8 +45,15 @@ class ItemModelsTest : public QObject Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QModelIndex modelIndex READ modelIndex WRITE setModelIndex NOTIFY changed) Q_PROPERTY(QPersistentModelIndex persistentModelIndex READ persistentModelIndex WRITE setPersistentModelIndex NOTIFY changed) + Q_PROPERTY(QModelIndexList modelIndexList READ modelIndexList WRITE setModelIndexList NOTIFY changed) public: + ItemModelsTest(QObject *parent = 0) + : QObject(parent) + , m_model(0) + { + } + QModelIndex modelIndex() const { return m_modelIndex; @@ -57,6 +64,26 @@ public: return m_persistentModelIndex; } + QModelIndexList modelIndexList() + { + static bool firstTime = true; + if (firstTime && m_model && m_modelIndexList.isEmpty()) { + firstTime = false; + for (int i = 0; i < m_model->rowCount(); i++) + m_modelIndexList << m_model->index(i, 0); + } + return m_modelIndexList; + } + + Q_INVOKABLE QModelIndexList someModelIndexList() const + { + QModelIndexList list; + if (m_model) + for (int i = 0; i < m_model->rowCount(); i++) + list << m_model->index(i, 0); + return list; + } + void emitChanged() { emit changed(); @@ -82,11 +109,6 @@ public: return QModelIndex(); } - Q_INVOKABLE QModelIndexList createModelIndexList() const - { - return QModelIndexList(); - } - Q_INVOKABLE QItemSelectionRange createItemSelectionRange(const QModelIndex &tl, const QModelIndex &br) const { return QItemSelectionRange(tl, br); @@ -130,6 +152,15 @@ public slots: emit modelChanged(arg); } + void setModelIndexList(QModelIndexList arg) + { + if (m_modelIndexList == arg) + return; + + m_modelIndexList = arg; + emit changed(); + } + signals: void changed(); @@ -142,6 +173,7 @@ private: QModelIndex m_modelIndex; QPersistentModelIndex m_persistentModelIndex; QAbstractItemModel *m_model; + QModelIndexList m_modelIndexList; }; #endif // TESTTYPES_H |