diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-18 20:05:13 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-18 20:05:13 +0100 |
| commit | 792a402782f979c2fe5747d30b8faffb054a4c26 (patch) | |
| tree | b79922a015644aff9a17751b1c2c836f62d34da2 /src/modlistviewactions.cpp | |
| parent | 59f055ba93381b965cdc04557ac1dce2df36bd07 (diff) | |
Modify 'Install mod... ' in context menu to install above current mod.
Diffstat (limited to 'src/modlistviewactions.cpp')
| -rw-r--r-- | src/modlistviewactions.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/modlistviewactions.cpp b/src/modlistviewactions.cpp index 5af79b3b..fe0bfc38 100644 --- a/src/modlistviewactions.cpp +++ b/src/modlistviewactions.cpp @@ -50,8 +50,18 @@ ModListViewActions::ModListViewActions( } -void ModListViewActions::installMod(const QString& archivePath) const +void ModListViewActions::installMod(const QString& archivePath, 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()); + + // descending order, we need to fix the priority + if (m_view->sortOrder() == Qt::DescendingOrder) { + newPriority++; + } + } + try { QString path = archivePath; if (path.isEmpty()) { @@ -68,7 +78,7 @@ void ModListViewActions::installMod(const QString& archivePath) const return; } else { - m_core.installMod(path, false, nullptr, QString()); + m_core.installMod(path, newPriority, false, nullptr, QString()); } } catch (const std::exception& e) { @@ -864,7 +874,7 @@ void ModListViewActions::reinstallMod(const QModelIndex& index) const fullInstallationFile = m_core.downloadManager()->getOutputDirectory() + "/" + installationFile; } if (QFile::exists(fullInstallationFile)) { - m_core.installMod(fullInstallationFile, true, modInfo, modInfo->name()); + m_core.installMod(fullInstallationFile, -1, true, modInfo, modInfo->name()); } else { QMessageBox::information(m_parent, tr("Failed"), tr("Installation file no longer exists")); |
