summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-03-08 02:28:01 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-08 02:57:56 (GMT)
commit7142fbe52cfca2887cb8ee083d4d91c35ef249f8 (patch)
tree69d9d4c11656fb01c3b2f32c95199b03ec12ac86
parent2458cb45665b0fe3144266122f876bd541de9c42 (diff)
downloadQt-7142fbe52cfca2887cb8ee083d4d91c35ef249f8.zip
Qt-7142fbe52cfca2887cb8ee083d4d91c35ef249f8.tar.gz
Qt-7142fbe52cfca2887cb8ee083d4d91c35ef249f8.tar.bz2
QTableView: fix navigating with keyboard with spans not scrolling
We cannot use isIndexHidden in ScrollTo because that would return true if the index is in a span. Task-number: QTBUG-8777 Reviewed-by: Markus Goetz
-rw-r--r--src/gui/itemviews/qtableview.cpp2
-rw-r--r--tests/auto/qtableview/tst_qtableview.cpp16
2 files changed, 16 insertions, 2 deletions
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index cf1b542..c824a8a 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -2554,7 +2554,7 @@ void QTableView::scrollTo(const QModelIndex &index, ScrollHint hint)
// check if we really need to do anything
if (!d->isIndexValid(index)
|| (d->model->parent(index) != d->root)
- || isIndexHidden(index))
+ || isRowHidden(index.row()) || isColumnHidden(index.column()))
return;
QSpanCollection::Span span;
diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp
index 35fba52..54e32218 100644
--- a/tests/auto/qtableview/tst_qtableview.cpp
+++ b/tests/auto/qtableview/tst_qtableview.cpp
@@ -201,6 +201,7 @@ private slots:
void taskQTBUG_5237_wheelEventOnHeader();
void taskQTBUG_8585_crashForNoGoodReason();
void taskQTBUG_7774_RtoLVisualRegionForSelection();
+ void taskQTBUG_8777_scrollToSpans();
void mouseWheel_data();
void mouseWheel();
@@ -3994,7 +3995,6 @@ void tst_QTableView::taskQTBUG_8585_crashForNoGoodReason()
}
}
-
class TableView7774 : public QTableView
{
public:
@@ -4020,5 +4020,19 @@ void tst_QTableView::taskQTBUG_7774_RtoLVisualRegionForSelection()
QCOMPARE(region.rects().at(0), view.visualRect(range.topLeft()) | view.visualRect(range.bottomRight()));
}
+void tst_QTableView::taskQTBUG_8777_scrollToSpans()
+{
+ QTableWidget table(75,5);
+ for (int i=0; i<50; i++)
+ table.setSpan(2+i, 0, 1, 5);
+ table.setCurrentCell(0,2);
+ table.show();
+
+ for (int i = 0; i < 45; ++i)
+ QTest::keyClick(&table, Qt::Key_Down);
+
+ QVERIFY(table.verticalScrollBar()->value() > 10);
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"