From 7fafeb4a3464f8f5dfaef77d2a0c9544c4600192 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 7 Sep 2018 21:08:48 +0200 Subject: QTreeView: sync keyboard search behavior with other itemviews QTreeView has a special implementation of keyboardSearch() which is not consistent to the base implementation regarding the selection behavior: - currentSelectionStartIndex is not set which results in a wrong mouse selection behavior afterwards - only the current index is set but not the current selection Sync the behavior by calling setCurrentIndex() directly in QTreeView too. One problem remains with this patch - the key handling is still different between QAbstractItemView and QTreeView for repeating key presses. Task-number: QTBUG-18862 Change-Id: Ife79d146cf16d6ecbf9f86540777dae15aa1ffb0 Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qtreeview.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index b534de5c6a..920e3b346b 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1088,15 +1088,8 @@ void QTreeView::keyboardSearch(const QString &search) if (start.column() > 0) index = index.sibling(index.row(), start.column()); - if (index.isValid()) { - QItemSelectionModel::SelectionFlags flags = (d->selectionMode == SingleSelection - ? QItemSelectionModel::SelectionFlags( - QItemSelectionModel::ClearAndSelect - |d->selectionBehaviorFlags()) - : QItemSelectionModel::SelectionFlags( - QItemSelectionModel::NoUpdate)); - selectionModel()->setCurrentIndex(index, flags); - } + if (index.isValid()) + setCurrentIndex(index); } /*! -- cgit v1.2.3