From c0ac46d5c020bfb9292a812b2c52dc3c6236c7b3 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Fri, 1 Jan 2021 20:59:30 +0100 Subject: Fix create empty mod/separator position. --- src/modlistviewactions.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/modlistviewactions.cpp') diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index cb212e0b..9957618a 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -75,7 +75,7 @@ void ModListViewActions::installMod(const QString& archivePath) const } } -void ModListViewActions::createEmptyMod(int modIndex) const +void ModListViewActions::createEmptyMod(const QModelIndex& index) const { GuessedValue name; name.setFilter(&fixDirectoryName); @@ -97,8 +97,8 @@ void ModListViewActions::createEmptyMod(int modIndex) const } int newPriority = -1; - if (modIndex >= 0 && m_view->sortColumn() == ModList::COL_PRIORITY) { - newPriority = m_core.currentProfile()->getModPriority(modIndex); + if (index.isValid() && m_view->sortColumn() == ModList::COL_PRIORITY) { + newPriority = m_core.currentProfile()->getModPriority(index.data(ModList::IndexRole).toInt()); } IModInterface* newMod = m_core.createMod(name); @@ -113,12 +113,11 @@ void ModListViewActions::createEmptyMod(int modIndex) const } } -void ModListViewActions::createSeparator(int modIndex) const +void ModListViewActions::createSeparator(const QModelIndex& index) const { GuessedValue name; name.setFilter(&fixDirectoryName); - while (name->isEmpty()) - { + while (name->isEmpty()) { bool ok; name.update(QInputDialog::getText(m_parent, tr("Create Separator..."), tr("This will create a new separator.\n" @@ -126,28 +125,24 @@ void ModListViewActions::createSeparator(int modIndex) const GUESS_USER); if (!ok) { return; } } - if (m_core.modList()->getMod(name) != nullptr) - { + if (m_core.modList()->getMod(name) != nullptr) { reportError(tr("A separator with this name already exists")); return; } name->append("_separator"); - if (m_core.modList()->getMod(name) != nullptr) - { + if (m_core.modList()->getMod(name) != nullptr) { return; } int newPriority = -1; - if (modIndex >= 0 && m_view->sortColumn() == ModList::COL_PRIORITY) - { - newPriority = m_core.currentProfile()->getModPriority(modIndex); + if (index.isValid() && m_view->sortColumn() == ModList::COL_PRIORITY) { + newPriority = m_core.currentProfile()->getModPriority(index.data(ModList::IndexRole).toInt()); } if (m_core.createMod(name) == nullptr) { return; } m_core.refresh(); - if (newPriority >= 0) - { + if (newPriority >= 0) { m_core.modList()->changeModPriority(ModInfo::getIndex(name), newPriority); } -- cgit v1.3.1