aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlitemmodels
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-06 19:27:22 +0100
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2015-03-22 16:20:29 +0000
commit0271609d5136fa681306c2647973a26dadc7acb3 (patch)
tree4889a233a919266fbf38551a056cf8b49d7f2bd4 /tests/auto/qml/qqmlitemmodels
parentae1c3eba3e7e11a9b1ab4d18792c82c9bb6e62de (diff)
Remove QItemSelection value-type, use Array instead
We implement this by adding QItemSelection to the set of sequence types. Change-Id: Ia3db376c806d8f062639e22c7f4bf392f114c266 Reviewed-by: Stephen Kelly <steveire@gmail.com>
Diffstat (limited to 'tests/auto/qml/qqmlitemmodels')
-rw-r--r--tests/auto/qml/qqmlitemmodels/data/itemselection.qml23
-rw-r--r--tests/auto/qml/qqmlitemmodels/testtypes.h16
-rw-r--r--tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp14
3 files changed, 33 insertions, 20 deletions
diff --git a/tests/auto/qml/qqmlitemmodels/data/itemselection.qml b/tests/auto/qml/qqmlitemmodels/data/itemselection.qml
index 57cb6436e9..c2da71627a 100644
--- a/tests/auto/qml/qqmlitemmodels/data/itemselection.qml
+++ b/tests/auto/qml/qqmlitemmodels/data/itemselection.qml
@@ -1,9 +1,10 @@
import Test 1.0
ItemModelsTest {
- property var itemSelection
property int count
property bool contains: false
+ property var itemSelectionBinding: itemSelection
+ property var itemSelectionRead
function range(top, bottom, left, right, parent) {
if (parent === undefined)
@@ -14,23 +15,15 @@ ItemModelsTest {
}
onModelChanged: {
- itemSelection = createItemSelection()
- itemSelection.prepend(range(0, 0, 0, 5))
- itemSelection.append(range(0, 5, 0, 0))
+ itemSelection = []
+ itemSelection.push(range(0, 0, 0, 5))
+ itemSelection.push(range(0, 5, 0, 0))
for (var i = 0; i < 3; i++)
- itemSelection.insert(i, range(i, i + 1, i + 2, i + 3))
+ itemSelection.splice(i, 0, range(i, i + 1, i + 2, i + 3))
- var itemSelection2 = createItemSelection()
- for (i = 3; i < 6; i++)
- itemSelection2.select(model.index(i, i + 1), model.index(i + 2, i + 3))
-
- itemSelection.merge(itemSelection2, 2 /*ItemSelectionModel.Select*/)
+ itemSelectionRead = itemSelection
count = itemSelection.length
- contains = itemSelection.contains(model.index(0, 0))
-
- itemSelection.removeAt(3)
- itemSelection.removeFirst()
- itemSelection.removeLast()
+ contains = itemSelection.some(function (range, idx) { return range.contains(model.index(0, 0)) })
}
}
diff --git a/tests/auto/qml/qqmlitemmodels/testtypes.h b/tests/auto/qml/qqmlitemmodels/testtypes.h
index d61064fcad..69da24ec6e 100644
--- a/tests/auto/qml/qqmlitemmodels/testtypes.h
+++ b/tests/auto/qml/qqmlitemmodels/testtypes.h
@@ -46,6 +46,7 @@ class ItemModelsTest : public QObject
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)
+ Q_PROPERTY(QItemSelection itemSelection READ itemSelection WRITE setItemSelection NOTIFY changed)
public:
ItemModelsTest(QObject *parent = 0)
@@ -84,6 +85,11 @@ public:
return list;
}
+ QItemSelection itemSelection() const
+ {
+ return m_itemSelection;
+ }
+
void emitChanged()
{
emit changed();
@@ -161,6 +167,15 @@ public slots:
emit changed();
}
+ void setItemSelection(QItemSelection arg)
+ {
+ if (m_itemSelection == arg)
+ return;
+
+ m_itemSelection = arg;
+ emit changed();
+ }
+
signals:
void changed();
@@ -174,6 +189,7 @@ private:
QPersistentModelIndex m_persistentModelIndex;
QAbstractItemModel *m_model;
QModelIndexList m_modelIndexList;
+ QItemSelection m_itemSelection;
};
#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp b/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp
index cd00593ee6..637b9e4b90 100644
--- a/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp
+++ b/tests/auto/qml/qqmlitemmodels/tst_qqmlitemmodels.cpp
@@ -184,14 +184,18 @@ void tst_qqmlitemmodels::itemSelection()
TestModel model(10, 10);
object->setModel(&model);
- QCOMPARE(object->property("count").toInt(), 8);
+ QCOMPARE(object->property("count").toInt(), 5);
QCOMPARE(object->property("contains").toBool(), true);
- QVariant milVariant = object->property("itemSelection");
- QCOMPARE(milVariant.userType(), qMetaTypeId<QItemSelection>());
+ const char *propNames[] = { "itemSelectionRead", "itemSelectionBinding", 0 };
+ for (const char **name = propNames; *name; name++) {
+ QVariant isVariant = object->property(*name);
+ QCOMPARE(isVariant.userType(), qMetaTypeId<QItemSelection>());
- const QItemSelection &mil = milVariant.value<QItemSelection>();
- QCOMPARE(mil.count(), 5);
+ const QItemSelection &sel = isVariant.value<QItemSelection>();
+ QCOMPARE(sel.count(), object->itemSelection().count());
+ QCOMPARE(sel, object->itemSelection());
+ }
}
void tst_qqmlitemmodels::modelIndexList()