diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2017-10-31 16:05:58 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-01-06 05:17:00 +0000 |
commit | 20604ea554b282efa80502c68a499824f8692e7a (patch) | |
tree | ed1c27e6e482913d65c687c2a77ba68aa72c4df6 /tests/auto/widgets/itemviews/qtableview | |
parent | 1c0ac8c4b8646e898aa1636f93dcfd34949611cf (diff) |
QHeaderView: respect min/maximumSectionSize property
QHeaderView::resizeSection() did not check if the given section size is
inside the min/max property bounds.
Also on calling setMin/MaximumSectionSize() the current section sizes
were not checked if they are inside the new given bounds.
This is a small behavior change when a user is setting the section size
via resizeSection() without respecting the min/maxSectionSizes.
Task-number: QTBUG-64173
Change-Id: Ia9c9eebf058d60c776ab5f8f8336642013ec553f
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qtableview')
-rw-r--r-- | tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index b558bd9b4e..06c80bf8d2 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -426,6 +426,9 @@ public: this, SLOT(slotCurrentChanged(QModelIndex,QModelIndex))); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemSelectionChanged(QItemSelection,QItemSelection))); + // Allow small sections in this test, since this test was made before we correctly enforced minimum sizes. + horizontalHeader()->setMinimumSectionSize(0); + verticalHeader()->setMinimumSectionSize(0); } // enum CursorAction and moveCursor() are protected in QTableView. @@ -738,6 +741,8 @@ void tst_QTableView::headerSections() QHeaderView *vheader = view.verticalHeader(); view.setModel(&model); + hheader->setMinimumSectionSize(columnWidth); + vheader->setMinimumSectionSize(rowHeight); view.show(); hheader->doItemsLayout(); @@ -1147,6 +1152,9 @@ void tst_QTableView::moveCursor() QtTestTableView view; view.setModel(&model); + // we have to make sure that PgUp/PgDown can scroll to the bottom/top + view.resize(view.horizontalHeader()->length() + 50, + view.verticalHeader()->length() + 50); view.hideRow(hideRow); view.hideColumn(hideColumn); if (moveColumn.first != moveColumn.second) @@ -2085,6 +2093,8 @@ void tst_QTableView::visualRect() QTableView view; view.setModel(&model); + view.horizontalHeader()->setMinimumSectionSize(0); + view.verticalHeader()->setMinimumSectionSize(0); // Make sure that it has 1 pixel between each cell. view.setGridStyle(Qt::SolidLine); for (int i = 0; i < view.verticalHeader()->count(); ++i) @@ -3533,6 +3543,9 @@ void tst_QTableView::editSpanFromDirections() TableViewWithCursorExposed view; view.setModel(model.data()); + // we have to make sure that PgUp/PgDown can scroll to the bottom/top + view.resize(view.horizontalHeader()->length() + 50, + view.verticalHeader()->length() + 50); view.setSpan(row, column, rowSpan, columnSpan); view.show(); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -3978,7 +3991,7 @@ void tst_QTableView::mouseWheel_data() << 10 + qApp->wheelScrollLines() << 10 + qApp->wheelScrollLines(); QTest::newRow("scroll down per pixel") << int(QAbstractItemView::ScrollPerPixel) << -120 - << 10 + qApp->wheelScrollLines() * 89 << 10 + qApp->wheelScrollLines() * 28; + << 10 + qApp->wheelScrollLines() * 91 << 10 + qApp->wheelScrollLines() * 46; } void tst_QTableView::mouseWheel() @@ -3992,16 +4005,17 @@ void tst_QTableView::mouseWheel() QWidget topLevel; QtTestTableView view(&topLevel); view.resize(500, 500); - for (int r = 0; r < 100; ++r) - view.setRowHeight(r, 50); - for (int c = 0; c < 100; ++c) - view.setColumnWidth(c, 100); topLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); view.setModel(&model); + for (int r = 0; r < 100; ++r) + view.setRowHeight(r, 50); + for (int c = 0; c < 100; ++c) + view.setColumnWidth(c, 100); + view.setHorizontalScrollMode((QAbstractItemView::ScrollMode)scrollMode); view.setVerticalScrollMode((QAbstractItemView::ScrollMode)scrollMode); view.horizontalScrollBar()->setValue(10); |