summaryrefslogtreecommitdiff
path: root/src/modlistviewactions.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-01 20:59:30 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:19 +0100
commitc0ac46d5c020bfb9292a812b2c52dc3c6236c7b3 (patch)
tree3e41456b3253e34cb483974faf25577ec05cd60b /src/modlistviewactions.cpp
parentbd76c677307bf2106e0823477739680032a897d4 (diff)
Fix create empty mod/separator position.
Diffstat (limited to 'src/modlistviewactions.cpp')
-rw-r--r--src/modlistviewactions.cpp25
1 files changed, 10 insertions, 15 deletions
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<QString> 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<QString> 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);
}