summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-10-02 21:17:00 +0200
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-10-03 18:49:43 +0000
commitcb4e7f4176e6135d4af0604a6e5c32682b38d33d (patch)
tree060f24b823414e61b2822486452a8e51e2d00313 /tests/auto/widgets/itemviews
parenta890df0283b8c36998d2d8edce341de81024fea9 (diff)
QHeaderView: add test for rows/columns moved
Add a testcase to make sure the signals for moveing rows are properly connected from the model to the corresponding QHeaderView slots. Task-number: QTBUG-117698 Pick-to: 6.6 6.5 Change-Id: I354f8836d3de58a8bf51da7a8c0859a673ec9339 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 3552699770..7835a40904 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -227,6 +227,7 @@ private slots:
void statusTips();
void testRemovingColumnsViaLayoutChanged();
void testModelMovingColumns();
+ void testModelMovingRows();
protected:
void setupTestData(bool use_reset_model = false);
@@ -307,6 +308,12 @@ public:
endRemoveRows();
}
+ void moveRow(int from, int to)
+ {
+ beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ endMoveRows();
+ }
+
void removeOneColumn(int col)
{
beginRemoveColumns(QModelIndex(), col, col);
@@ -3644,10 +3651,33 @@ void tst_QHeaderView::testModelMovingColumns()
hv.setModel(&model);
hv.resizeSections(QHeaderView::ResizeToContents);
hv.show();
+ hv.hideSection(3);
+ QVERIFY(!hv.isSectionHidden(1));
+ QVERIFY(hv.isSectionHidden(3));
QPersistentModelIndex index3 = model.index(0, 3);
model.moveColumn(3, 1);
QCOMPARE(index3.column(), 1);
+ QVERIFY(hv.isSectionHidden(1));
+ QVERIFY(!hv.isSectionHidden(3));
+}
+
+void tst_QHeaderView::testModelMovingRows()
+{
+ QtTestModel model(10, 10);
+ QHeaderView hv(Qt::Vertical);
+ hv.setModel(&model);
+ hv.resizeSections(QHeaderView::ResizeToContents);
+ hv.show();
+ hv.hideSection(3);
+ QVERIFY(!hv.isSectionHidden(1));
+ QVERIFY(hv.isSectionHidden(3));
+
+ QPersistentModelIndex index3 = model.index(3, 0);
+ model.moveRow(3, 1);
+ QCOMPARE(index3.row(), 1);
+ QVERIFY(hv.isSectionHidden(1));
+ QVERIFY(!hv.isSectionHidden(3));
}
QTEST_MAIN(tst_QHeaderView)