summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qcolumnview.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-03 15:02:34 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-12-05 07:57:46 +0100
commit8920200c97f0a514397e039ba74588127163c2b9 (patch)
tree2d73ada700dddcf044fbcd83f7fcd65ced1079c9 /src/widgets/itemviews/qcolumnview.cpp
parentc9f9eddc0f595b0382b070e3113122398c13876e (diff)
QColumnView: don't set an invalid index as the current one
When any item in a QColumnView gets selected, the next column gets normally set to show the children of that index. When we are on a leaf of a tree model, the next column will have an invalid root index, yet we set that root index as the "current index" for the current column. Due to the special handling for invalid indexes in QAbstractItemView::setCurrentIndex, this ends up breaking the current item AND the current selection in that column. Further clicks inside the column for instance trigger the entire column (up to the clicked index) to get selected, because of that broken first setCurrentIndex. The simple fix is to stop doing that when the next column has an invalid root index. Task-number: QTBUG-2329 Change-Id: Icd10c0b958e25cd868536e1315561787977b68bd Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/widgets/itemviews/qcolumnview.cpp')
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index 1c60d50922..3234e1e832 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -976,8 +976,11 @@ void QColumnViewPrivate::_q_changeCurrentColumn()
QAbstractItemView *view = columns.at(i);
view->setSelectionModel(replacementSelectionModel);
view->setFocusPolicy(Qt::NoFocus);
- if (columns.size() > i + 1)
- view->setCurrentIndex(columns.at(i+1)->rootIndex());
+ if (columns.size() > i + 1) {
+ const QModelIndex newRootIndex = columns.at(i + 1)->rootIndex();
+ if (newRootIndex.isValid())
+ view->setCurrentIndex(newRootIndex);
+ }
break;
}
}