diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-16 13:22:20 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-16 13:29:36 +0100 |
| commit | 8fafcce33f1d5633cf1cb1acbb067fd485869bbf (patch) | |
| tree | 2fdcb2fc60767cf111b0dcc4d55c9e169b35c8ca /src/modlistview.cpp | |
| parent | 899308b31d541e78a3e4395bf33cd66c5ec4f769 (diff) | |
Add send to last conflict action for modlist.
Diffstat (limited to 'src/modlistview.cpp')
| -rw-r--r-- | src/modlistview.cpp | 18 |
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(); });
}
|
