summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2020-01-08 21:12:45 +0100
committerPetr Mrázek <peterix@gmail.com>2020-01-08 21:12:45 +0100
commit355e5e24da45c69ffa92bfa76c8c40439a107e7c (patch)
treeccd0cd241e7405960790db9629e7724471a3c2e6
parent8bdff97ac0ff39f4a20e7e929b14b70427878b10 (diff)
downloadMultiMC-355e5e24da45c69ffa92bfa76c8c40439a107e7c.tar
MultiMC-355e5e24da45c69ffa92bfa76c8c40439a107e7c.tar.gz
MultiMC-355e5e24da45c69ffa92bfa76c8c40439a107e7c.tar.lz
MultiMC-355e5e24da45c69ffa92bfa76c8c40439a107e7c.tar.xz
MultiMC-355e5e24da45c69ffa92bfa76c8c40439a107e7c.zip
GH-2819 mod list filter now also looks at descriptions and authors
-rw-r--r--api/logic/minecraft/mod/ModFolderModel.h4
-rw-r--r--application/pages/instance/ModFolderPage.cpp20
2 files changed, 24 insertions, 0 deletions
diff --git a/api/logic/minecraft/mod/ModFolderModel.h b/api/logic/minecraft/mod/ModFolderModel.h
index 8394e405..03c584a9 100644
--- a/api/logic/minecraft/mod/ModFolderModel.h
+++ b/api/logic/minecraft/mod/ModFolderModel.h
@@ -85,6 +85,10 @@ public:
{
return mods[index];
}
+ const Mod &at(size_t index) const
+ {
+ return mods.at(index);
+ }
/// Reloads the mod list and returns true if the list changed.
bool update();
diff --git a/application/pages/instance/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp
index d449f8bf..ec4bf3c9 100644
--- a/application/pages/instance/ModFolderPage.cpp
+++ b/application/pages/instance/ModFolderPage.cpp
@@ -51,6 +51,26 @@ public:
}
protected:
+ bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override {
+ ModFolderModel *model = qobject_cast<ModFolderModel *>(sourceModel());
+ if(!model) {
+ return false;
+ }
+ const auto &mod = model->at(source_row);
+ if(mod.name().contains(filterRegExp())) {
+ return true;
+ }
+ if(mod.description().contains(filterRegExp())) {
+ return true;
+ }
+ for(auto & author: mod.authors()) {
+ if (author.contains(filterRegExp())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
bool lessThan(const QModelIndex & source_left, const QModelIndex & source_right) const override
{
ModFolderModel *model = qobject_cast<ModFolderModel *>(sourceModel());