summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Martsum <tmartsum@gmail.com>2015-06-26 07:17:03 +0200
committerThorbjørn Lund Martsum <tmartsum@gmail.com>2015-06-27 07:08:46 +0000
commitf1b01b7d159bcf04a2b832dba36f876479669641 (patch)
tree00de1e7b439c0ac09fda339bf25df5a35810c96f
parent12b36aec2baf216756b6147abacaed22e73b2560 (diff)
QHeaderView - fix a logical / visual index mismatch
f9408317e70bc2e635a2f9baeff35d1c06227734 was unfortunately approved though it had an annoying bug. The patch had an assign of a visual index into a logical index. This patch fixes that issue. Change-Id: I9cc75e4e9701858c92e2c3e5817415041b42f8e8 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/widgets/itemviews/qheaderview.cpp2
-rw-r--r--tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index bca315f80b..4cb28d0804 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2450,7 +2450,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
case QHeaderViewPrivate::SelectSections: {
int logical = logicalIndexAt(qMax(-d->offset, pos));
if (logical == -1 && pos > 0)
- logical = d->lastVisibleVisualIndex();
+ logical = logicalIndex(d->lastVisibleVisualIndex());
if (logical == d->pressed)
return; // nothing to do
else if (d->pressed != -1)
diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
index 1e26af8f57..af11e2a098 100644
--- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
+++ b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
@@ -140,10 +140,12 @@ private:
QTableView *setupTableView()
{
tableView = new QTableView;
- m.setRowCount(500);
+ const int rowCount = 200;
+ m.setRowCount(rowCount);
m.setColumnCount(250);
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->setModel(&m);
+ tableView->verticalHeader()->swapSections(rowCount - 1, 5);
return tableView;
}