aboutsummaryrefslogtreecommitdiff
path: root/launcher/VersionProxyModel.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-06-28 13:21:00 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-06-28 13:21:00 +0300
commitc04cee7ff75730df2c859ecae4567abb4e98dcd4 (patch)
treea0e3025c131099576f79efd6dfb79caf7b926975 /launcher/VersionProxyModel.cpp
parent2680dba0aa74abefea58903dadad6578381101cb (diff)
parentfaec21d572549793293bf41127e384811f8a66dc (diff)
downloadPrismLauncher-c04cee7ff75730df2c859ecae4567abb4e98dcd4.tar.gz
PrismLauncher-c04cee7ff75730df2c859ecae4567abb4e98dcd4.tar.bz2
PrismLauncher-c04cee7ff75730df2c859ecae4567abb4e98dcd4.zip
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into feat/acknowledge_release_type
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/VersionProxyModel.cpp')
-rw-r--r--launcher/VersionProxyModel.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/launcher/VersionProxyModel.cpp b/launcher/VersionProxyModel.cpp
index 6aba268d..e5c66566 100644
--- a/launcher/VersionProxyModel.cpp
+++ b/launcher/VersionProxyModel.cpp
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ * Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -54,9 +55,14 @@ public:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
const auto &filters = m_parent->filters();
+ const QString &search = m_parent->search();
+ const QModelIndex idx = sourceModel()->index(source_row, 0, source_parent);
+
+ if (!search.isEmpty() && !sourceModel()->data(idx, BaseVersionList::VersionRole).toString().contains(search, Qt::CaseInsensitive))
+ return false;
+
for (auto it = filters.begin(); it != filters.end(); ++it)
{
- auto idx = sourceModel()->index(source_row, 0, source_parent);
auto data = sourceModel()->data(idx, it.key());
auto match = data.toString();
if(!it.value()->accepts(match))
@@ -206,10 +212,6 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
return tr("Latest");
}
}
- else if(index.row() == 0)
- {
- return tr("Latest");
- }
}
}
default:
@@ -239,10 +241,6 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
return APPLICATION->getThemedIcon("bug");
}
}
- else if(index.row() == 0)
- {
- return APPLICATION->getThemedIcon("bug");
- }
QPixmap pixmap;
QPixmapCache::find("placeholder", &pixmap);
if(!pixmap)
@@ -431,6 +429,7 @@ QModelIndex VersionProxyModel::getVersion(const QString& version) const
void VersionProxyModel::clearFilters()
{
m_filters.clear();
+ m_search.clear();
filterModel->filterChanged();
}
@@ -440,11 +439,21 @@ void VersionProxyModel::setFilter(const BaseVersionList::ModelRoles column, Filt
filterModel->filterChanged();
}
+void VersionProxyModel::setSearch(const QString &search) {
+ m_search = search;
+ filterModel->filterChanged();
+}
+
const VersionProxyModel::FilterMap &VersionProxyModel::filters() const
{
return m_filters;
}
+const QString &VersionProxyModel::search() const
+{
+ return m_search;
+}
+
void VersionProxyModel::sourceAboutToBeReset()
{
beginResetModel();