diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-09-04 17:02:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 17:02:52 +0200 |
commit | 546d49e183303b1e16741f72ce8583f0583423af (patch) | |
tree | cf57f5b10f75549fe888360cd0b3e1449f62b1dd /launcher/minecraft | |
parent | e9ecdd05b915456cb0292acdb7d7ddfc00338171 (diff) | |
parent | b0e197de38858c3fe6bc5fbb62570efd3359c802 (diff) | |
download | PrismLauncher-546d49e183303b1e16741f72ce8583f0583423af.tar.gz PrismLauncher-546d49e183303b1e16741f72ce8583f0583423af.tar.bz2 PrismLauncher-546d49e183303b1e16741f72ce8583f0583423af.zip |
Merge pull request #1530 from Trial97/metadata_delete
Diffstat (limited to 'launcher/minecraft')
-rw-r--r-- | launcher/minecraft/mod/Mod.cpp | 18 | ||||
-rw-r--r-- | launcher/minecraft/mod/Mod.h | 2 | ||||
-rw-r--r-- | launcher/minecraft/mod/ModFolderModel.cpp | 19 | ||||
-rw-r--r-- | launcher/minecraft/mod/ModFolderModel.h | 1 |
4 files changed, 34 insertions, 6 deletions
diff --git a/launcher/minecraft/mod/Mod.cpp b/launcher/minecraft/mod/Mod.cpp index ae3dea8d..c9952998 100644 --- a/launcher/minecraft/mod/Mod.cpp +++ b/launcher/minecraft/mod/Mod.cpp @@ -132,17 +132,23 @@ auto Mod::destroy(QDir& index_dir, bool preserve_metadata, bool attempt_trash) - if (!preserve_metadata) { qDebug() << QString("Destroying metadata for '%1' on purpose").arg(name()); - if (metadata()) { - Metadata::remove(index_dir, metadata()->slug); - } else { - auto n = name(); - Metadata::remove(index_dir, n); - } + destroyMetadata(index_dir); } return Resource::destroy(attempt_trash); } +void Mod::destroyMetadata(QDir& index_dir) +{ + if (metadata()) { + Metadata::remove(index_dir, metadata()->slug); + } else { + auto n = name(); + Metadata::remove(index_dir, n); + } + m_local_details.metadata = nullptr; +} + auto Mod::details() const -> const ModDetails& { return m_local_details; diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h index 6dafecfc..e97ee9d3 100644 --- a/launcher/minecraft/mod/Mod.h +++ b/launcher/minecraft/mod/Mod.h @@ -93,6 +93,8 @@ class Mod : public Resource { // Delete all the files of this mod auto destroy(QDir& index_dir, bool preserve_metadata = false, bool attempt_trash = true) -> bool; + // Delete the metadata only + void destroyMetadata(QDir& index_dir); void finishResolvingWithDetails(ModDetails&& details); diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index eed35615..a5f1489d 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -233,6 +233,25 @@ bool ModFolderModel::deleteMods(const QModelIndexList& indexes) return true; } +bool ModFolderModel::deleteModsMetadata(const QModelIndexList& indexes) +{ + if (indexes.isEmpty()) + return true; + + for (auto i : indexes) { + if (i.column() != 0) { + continue; + } + auto m = at(i.row()); + auto index_dir = indexDir(); + m->destroyMetadata(index_dir); + } + + update(); + + return true; +} + bool ModFolderModel::isValid() { return m_dir.exists() && m_dir.isReadable(); diff --git a/launcher/minecraft/mod/ModFolderModel.h b/launcher/minecraft/mod/ModFolderModel.h index f1890e87..61d840f9 100644 --- a/launcher/minecraft/mod/ModFolderModel.h +++ b/launcher/minecraft/mod/ModFolderModel.h @@ -81,6 +81,7 @@ class ModFolderModel : public ResourceFolderModel { /// Deletes all the selected mods bool deleteMods(const QModelIndexList& indexes); + bool deleteModsMetadata(const QModelIndexList& indexes); bool isValid(); |