From 6ec2652b4562119ccf45d3bc455ef865fdfbd3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 4 Aug 2016 22:57:16 +0200 Subject: GH-1273 allow extended selection in mod lists --- api/logic/minecraft/ModList.cpp | 27 +++------------------------ api/logic/minecraft/ModList.h | 8 +------- 2 files changed, 4 insertions(+), 31 deletions(-) (limited to 'api') diff --git a/api/logic/minecraft/ModList.cpp b/api/logic/minecraft/ModList.cpp index ad588f16..b9c7d9ba 100644 --- a/api/logic/minecraft/ModList.cpp +++ b/api/logic/minecraft/ModList.cpp @@ -175,35 +175,14 @@ bool ModList::installMod(const QString &filename) return false; } -bool ModList::deleteMod(int index) +bool ModList::deleteMods(const QModelIndexList& indexes) { - if (index >= mods.size() || index < 0) - return false; - Mod &m = mods[index]; - if (m.destroy()) - { - emit changed(); + if(indexes.isEmpty()) return true; - } - return false; -} -bool ModList::deleteMods(int first, int last) -{ - for (int i = first; i <= last; i++) - { - Mod &m = mods[i]; - m.destroy(); - } - emit changed(); - return true; -} - -bool ModList::deleteMods(const QVector &indexes) -{ for (auto i: indexes) { - Mod &m = mods[i]; + Mod &m = mods[i.row()]; m.destroy(); } emit changed(); diff --git a/api/logic/minecraft/ModList.h b/api/logic/minecraft/ModList.h index 24dcdaa4..14b102e1 100644 --- a/api/logic/minecraft/ModList.h +++ b/api/logic/minecraft/ModList.h @@ -83,14 +83,8 @@ public: */ bool installMod(const QString& filename); - /// Deletes the mod at the given index. - virtual bool deleteMod(int index); - - /// Deletes all the selected mods - virtual bool deleteMods(int first, int last); - /// Deletes all the selected mods - virtual bool deleteMods(const QVector &indexes); + virtual bool deleteMods(const QModelIndexList &indexes); void startWatching(); void stopWatching(); -- cgit v1.2.3