diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-01 17:17:56 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:19 +0100 |
| commit | 011e4d522ed7b0df52cdeb014608e9881f8bc76b (patch) | |
| tree | 3b4a960c72b484e48a2d030576d08c3697c44173 /src/modlistviewactions.cpp | |
| parent | 21ab4ad78b2b7007dc06ed432d707fc6edf98d6e (diff) | |
Fix setting the primary category of multiple mods at once.
Diffstat (limited to 'src/modlistviewactions.cpp')
| -rw-r--r-- | src/modlistviewactions.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index 8d24a8d5..cb212e0b 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -956,7 +956,6 @@ void ModListViewActions::setCategories(const QModelIndexList& selected, const QM { ModInfo::Ptr refMod = ModInfo::getByIndex(ref.data(ModList::IndexRole).toInt()); if (selected.size() > 1) { - for (auto& idx : selected) { if (idx.row() != ref.row()) { setCategoriesIf( @@ -982,6 +981,23 @@ void ModListViewActions::setCategories(const QModelIndexList& selected, const QM } } +void ModListViewActions::setPrimaryCategory(const QModelIndexList& selected, int category, bool force) +{ + for (auto& idx : selected) { + ModInfo::Ptr info = ModInfo::getByIndex(idx.data(ModList::IndexRole).toInt()); + if (force || info->categorySet(category)) { + info->setCategory(category, true); + info->setPrimaryCategory(category); + } + } + + // reset the selection manually - still needed + auto viewIndices = m_view->indexModelToView(selected); + for (auto& idx : viewIndices) { + m_view->selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows); + } +} + void ModListViewActions::openExplorer(const QModelIndexList& index) const { for (auto& idx : index) { |
