From 8fafcce33f1d5633cf1cb1acbb067fd485869bbf Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sat, 16 Jan 2021 13:22:20 +0100 Subject: Add send to last conflict action for modlist. --- src/modlistview.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/modlistview.cpp') diff --git a/src/modlistview.cpp b/src/modlistview.cpp index ae905a6e..ad75631c 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -396,11 +396,23 @@ void ModListView::setSelected(const QModelIndex& current, const QModelIndexList& } void ModListView::scrollToAndSelect(const QModelIndex& index) +{ + scrollToAndSelect(QModelIndexList{index}); +} + +void ModListView::scrollToAndSelect(const QModelIndexList& indexes, const QModelIndex& current) { // focus, scroll to and select - scrollTo(index); - setCurrentIndex(index); - selectionModel()->select(index, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); + if (!current.isValid() && indexes.isEmpty()) { + return; + } + scrollTo(current.isValid() ? current : indexes.first()); + setCurrentIndex(current.isValid() ? current : indexes.first()); + QItemSelection selection; + for (auto& idx : indexes) { + selection.select(idx, idx); + } + selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows); QTimer::singleShot(50, [=] { setFocus(); }); } -- cgit v1.3.1