summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-07-10 13:30:01 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-07-10 13:30:56 (GMT)
commite2bf5eeee12329ad4aee941b5bb70af4ee5bb32f (patch)
tree829cdee2e9f94e28cbfc5c8f49b7c0b350b5ff8f
parentbc747a81f4f6f0978f71cd8d19f69060fc8a8041 (diff)
downloadQt-e2bf5eeee12329ad4aee941b5bb70af4ee5bb32f.zip
Qt-e2bf5eeee12329ad4aee941b5bb70af4ee5bb32f.tar.gz
Qt-e2bf5eeee12329ad4aee941b5bb70af4ee5bb32f.tar.bz2
QTableView: horizontal scrollbar could be inoperent with big columns
Task-number: 240266
-rw-r--r--src/gui/itemviews/qtableview.cpp4
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp26
2 files changed, 30 insertions, 0 deletions
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index c676237..882a213 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -1528,6 +1528,8 @@ void QTableView::updateGeometries()
++columnsInViewport;
}
}
+ columnsInViewport = qMax(columnsInViewport, 1); //there must be always at least 1 column
+
if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {
const int visibleColumns = columnCount - d->horizontalHeader->hiddenSectionCount();
horizontalScrollBar()->setRange(0, visibleColumns - columnsInViewport);
@@ -1554,6 +1556,8 @@ void QTableView::updateGeometries()
++rowsInViewport;
}
}
+ rowsInViewport = qMax(rowsInViewport, 1); //there must be always at least 1 row
+
if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
const int visibleRows = rowCount - d->verticalHeader->hiddenSectionCount();
verticalScrollBar()->setRange(0, visibleRows - rowsInViewport);
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index ae023ba..0a69b75 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -175,6 +175,7 @@ private slots:
// task-specific tests:
void task173773_updateVerticalHeader();
void task227953_setRootIndex();
+ void task240266_veryBigColumn();
void mouseWheel_data();
void mouseWheel();
@@ -3127,6 +3128,31 @@ void tst_QTableView::task227953_setRootIndex()
QVERIFY(!tableView.verticalHeader()->isHidden());
}
+void tst_QTableView::task240266_veryBigColumn()
+{
+ QTableView table;
+ table.setFixedSize(500, 300); //just to make sure we have the 2 first columns visible
+ QStandardItemModel model(1, 3);
+ table.setModel(&model);
+ table.setColumnWidth(0, 100); //normal column
+ table.setColumnWidth(1, 100); //normal column
+ table.setColumnWidth(2, 9000); //very big column
+ table.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(100);
+
+ QScrollBar *scroll = table.horizontalScrollBar();
+ QCOMPARE(scroll->minimum(), 0);
+ QCOMPARE(scroll->maximum(), model.columnCount() - 1);
+ QCOMPARE(scroll->singleStep(), 1);
+
+ //1 is not always a very correct value for pageStep. Ideally this should be dynamic.
+ //Maybe something for Qt 5 ;-)
+ QCOMPARE(scroll->pageStep(), 1);
+
+}
void tst_QTableView::mouseWheel_data()
{