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.5 Change-Id: I354f8836d3de58a8bf51da7a8c0859a673ec9339 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit cb4e7f4176e6135d4af0604a6e5c32682b38d33d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
6f6f6c4c7a
commit
ad27a2e579
@ -227,6 +227,7 @@ private slots:
|
|||||||
void statusTips();
|
void statusTips();
|
||||||
void testRemovingColumnsViaLayoutChanged();
|
void testRemovingColumnsViaLayoutChanged();
|
||||||
void testModelMovingColumns();
|
void testModelMovingColumns();
|
||||||
|
void testModelMovingRows();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setupTestData(bool use_reset_model = false);
|
void setupTestData(bool use_reset_model = false);
|
||||||
@ -307,6 +308,12 @@ public:
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void moveRow(int from, int to)
|
||||||
|
{
|
||||||
|
beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
|
||||||
|
endMoveRows();
|
||||||
|
}
|
||||||
|
|
||||||
void removeOneColumn(int col)
|
void removeOneColumn(int col)
|
||||||
{
|
{
|
||||||
beginRemoveColumns(QModelIndex(), col, col);
|
beginRemoveColumns(QModelIndex(), col, col);
|
||||||
@ -3644,10 +3651,33 @@ void tst_QHeaderView::testModelMovingColumns()
|
|||||||
hv.setModel(&model);
|
hv.setModel(&model);
|
||||||
hv.resizeSections(QHeaderView::ResizeToContents);
|
hv.resizeSections(QHeaderView::ResizeToContents);
|
||||||
hv.show();
|
hv.show();
|
||||||
|
hv.hideSection(3);
|
||||||
|
QVERIFY(!hv.isSectionHidden(1));
|
||||||
|
QVERIFY(hv.isSectionHidden(3));
|
||||||
|
|
||||||
QPersistentModelIndex index3 = model.index(0, 3);
|
QPersistentModelIndex index3 = model.index(0, 3);
|
||||||
model.moveColumn(3, 1);
|
model.moveColumn(3, 1);
|
||||||
QCOMPARE(index3.column(), 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)
|
QTEST_MAIN(tst_QHeaderView)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user