summaryrefslogtreecommitdiff
path: root/src/modlistview.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-16 13:22:20 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-16 13:29:36 +0100
commit8fafcce33f1d5633cf1cb1acbb067fd485869bbf (patch)
tree2fdcb2fc60767cf111b0dcc4d55c9e169b35c8ca /src/modlistview.cpp
parent899308b31d541e78a3e4395bf33cd66c5ec4f769 (diff)
Add send to last conflict action for modlist.
Diffstat (limited to 'src/modlistview.cpp')
-rw-r--r--src/modlistview.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/modlistview.cpp b/src/modlistview.cpp
index ae905a6e..ad75631c 100644
--- a/src/modlistview.cpp
+++ b/src/modlistview.cpp
@@ -397,10 +397,22 @@ 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(); });
}