summaryrefslogtreecommitdiff
path: root/src/modlistviewactions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modlistviewactions.cpp')
-rw-r--r--src/modlistviewactions.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp
index 9957618a..14c4ab46 100644
--- a/src/modlistviewactions.cpp
+++ b/src/modlistviewactions.cpp
@@ -97,8 +97,30 @@ void ModListViewActions::createEmptyMod(const QModelIndex& index) const
}
int newPriority = -1;
- if (index.isValid() && m_view->sortColumn() == ModList::COL_PRIORITY) {
- newPriority = m_core.currentProfile()->getModPriority(index.data(ModList::IndexRole).toInt());
+ if (index.isValid() && index.data(ModList::IndexRole).isValid()
+ && m_view->sortColumn() == ModList::COL_PRIORITY) {
+ auto mIndex = index.data(ModList::IndexRole).toInt();
+ auto info = ModInfo::getByIndex(mIndex);
+ newPriority = m_core.currentProfile()->getModPriority(mIndex);
+ if (info->isSeparator()) {
+ auto& ibp = m_core.currentProfile()->getAllIndexesByPriority();
+
+ // start right after the current priority and look for the next
+ // separator
+ auto it = ibp.find(newPriority + 1);
+ for (; it != ibp.end(); ++it) {
+ auto info = ModInfo::getByIndex(it->second);
+ if (info->isSeparator()) {
+ newPriority = it->first;
+ break;
+ }
+ }
+
+ // no separator found, create at the end
+ if (it == ibp.end()) {
+ newPriority = -1;
+ }
+ }
}
IModInterface* newMod = m_core.createMod(name);
@@ -108,9 +130,12 @@ void ModListViewActions::createEmptyMod(const QModelIndex& index) const
m_core.refresh();
+ const auto mIndex = ModInfo::getIndex(name);
if (newPriority >= 0) {
- m_core.modList()->changeModPriority(ModInfo::getIndex(name), newPriority);
+ m_core.modList()->changeModPriority(mIndex, newPriority);
}
+
+ m_view->scrollToAndSelect(m_view->indexModelToView(m_core.modList()->index(mIndex, 0)));
}
void ModListViewActions::createSeparator(const QModelIndex& index) const