diff options
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 |