From ec62d8e97334d3b5a30cea00858e7035468f3609 Mon Sep 17 00:00:00 2001 From: flow Date: Tue, 9 Aug 2022 01:58:22 -0300 Subject: refactor: move general code from mod model to its own model This aims to continue decoupling other types of resources (e.g. resource packs, shader packs, etc) from mods, so that we don't have to continuously watch our backs for changes to one of them affecting the others. To do so, this creates a more general list model for resources, based on the mods one, that allows you to extend it with functionality for other resources. I had to do some template and preprocessor stuff to get around the QObject limitation of not allowing templated classes, so that's sadge :c On the other hand, I tried cleaning up most general-purpose code in the mod model, and added some documentation, because it looks nice :D Signed-off-by: flow --- launcher/ui/pages/instance/ExternalResourcesPage.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'launcher/ui') diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index 39fbe3e2..da7c4af0 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -32,12 +32,12 @@ class SortProxy : public QSortFilterProxyModel { const auto& mod = model->at(source_row); - if (filterRegularExpression().match(mod.name()).hasMatch()) + if (filterRegularExpression().match(mod->name()).hasMatch()) return true; - if (filterRegularExpression().match(mod.description()).hasMatch()) + if (filterRegularExpression().match(mod->description()).hasMatch()) return true; - for (auto& author : mod.authors()) { + for (auto& author : mod->authors()) { if (filterRegularExpression().match(author).hasMatch()) { return true; } @@ -292,6 +292,6 @@ void ExternalResourcesPage::current(const QModelIndex& current, const QModelInde auto sourceCurrent = m_filterModel->mapToSource(current); int row = sourceCurrent.row(); - Mod& m = m_model->operator[](row); + Mod& m = *m_model->operator[](row); ui->frame->updateWithMod(m); } -- cgit