summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-08-04 21:13:50 +0200
committerPetr Mrázek <peterix@gmail.com>2019-08-04 21:13:50 +0200
commit4ed67413ac33f0814b76ffc76ad8c1dae734febf (patch)
tree2ef6033e7835a10c740d5492b474bd6979d7c864 /api/logic
parentd31184f9a4d96644e8cef249045d511b1960096f (diff)
downloadMultiMC-4ed67413ac33f0814b76ffc76ad8c1dae734febf.tar
MultiMC-4ed67413ac33f0814b76ffc76ad8c1dae734febf.tar.gz
MultiMC-4ed67413ac33f0814b76ffc76ad8c1dae734febf.tar.lz
MultiMC-4ed67413ac33f0814b76ffc76ad8c1dae734febf.tar.xz
MultiMC-4ed67413ac33f0814b76ffc76ad8c1dae734febf.zip
GH-988 add ability to toggle mods with keyboard
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/minecraft/mod/ModFolderModel.cpp20
-rw-r--r--api/logic/minecraft/mod/ModFolderModel.h9
2 files changed, 22 insertions, 7 deletions
diff --git a/api/logic/minecraft/mod/ModFolderModel.cpp b/api/logic/minecraft/mod/ModFolderModel.cpp
index c9a69995..14907dea 100644
--- a/api/logic/minecraft/mod/ModFolderModel.cpp
+++ b/api/logic/minecraft/mod/ModFolderModel.cpp
@@ -312,15 +312,29 @@ bool ModFolderModel::enableMods(const QModelIndexList& indexes, bool enable)
if(indexes.isEmpty())
return true;
- for (auto i: indexes)
+ for (auto index: indexes)
{
- Mod &m = mods[i.row()];
+ Mod &m = mods[index.row()];
m.enable(enable);
- emit dataChanged(i, i);
+ emit dataChanged(index, index);
}
return true;
}
+void ModFolderModel::toggleEnabled(const QModelIndex& index)
+{
+ if(interaction_disabled) {
+ return;
+ }
+ if(!index.isValid()) {
+ return;
+ }
+
+ Mod &m = mods[index.row()];
+ m.enable(!m.enabled());
+ emit dataChanged(index, index);
+}
+
bool ModFolderModel::deleteMods(const QModelIndexList& indexes)
{
if(interaction_disabled) {
diff --git a/api/logic/minecraft/mod/ModFolderModel.h b/api/logic/minecraft/mod/ModFolderModel.h
index ff56be4a..624345be 100644
--- a/api/logic/minecraft/mod/ModFolderModel.h
+++ b/api/logic/minecraft/mod/ModFolderModel.h
@@ -82,7 +82,7 @@ public:
}
/// Reloads the mod list and returns true if the list changed.
- virtual bool update();
+ bool update();
/**
* Adds the given mod to the list at the given index - if the list supports custom ordering
@@ -90,15 +90,16 @@ public:
bool installMod(const QString& filename);
/// Deletes all the selected mods
- virtual bool deleteMods(const QModelIndexList &indexes);
+ bool deleteMods(const QModelIndexList &indexes);
/// Enable or disable listed mods
- virtual bool enableMods(const QModelIndexList &indexes, bool enable = true);
+ bool enableMods(const QModelIndexList &indexes, bool enable = true);
+ void toggleEnabled(const QModelIndex &index);
void startWatching();
void stopWatching();
- virtual bool isValid();
+ bool isValid();
QDir dir()
{