aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/ResourceModel.cpp
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-04-22 01:18:27 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-04-22 01:18:27 +0300
commit460e83207f9ae087846fc9ca210799e41f51a326 (patch)
tree45033e7dcc04f4bc7725ac07bb9ae037f6f5742a /launcher/ui/pages/modplatform/ResourceModel.cpp
parent75116364c6daea5affb029038d2a7d20bc601beb (diff)
downloadPrismLauncher-460e83207f9ae087846fc9ca210799e41f51a326.tar.gz
PrismLauncher-460e83207f9ae087846fc9ca210799e41f51a326.tar.bz2
PrismLauncher-460e83207f9ae087846fc9ca210799e41f51a326.zip
Fixed removeIf for Qt version
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/pages/modplatform/ResourceModel.cpp')
-rw-r--r--launcher/ui/pages/modplatform/ResourceModel.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/launcher/ui/pages/modplatform/ResourceModel.cpp b/launcher/ui/pages/modplatform/ResourceModel.cpp
index 0e74395f..459c8c72 100644
--- a/launcher/ui/pages/modplatform/ResourceModel.cpp
+++ b/launcher/ui/pages/modplatform/ResourceModel.cpp
@@ -458,7 +458,39 @@ void ResourceModel::infoRequestSucceeded(QJsonDocument& doc, ModPlatform::Indexe
void ResourceModel::removePack(QString& rem)
{
- m_selected.removeIf([&rem](ModPlatform::IndexedPack i) { return rem == i.name; });
+ auto pred = [&rem](ModPlatform::IndexedPack i) { return rem == i.name; };
+#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
+ m_selected.removeIf(pred);
+#else
+ { // well partial implementation of remove_if in case the QT Version is not high enough
+ const auto cbegin = m_selected.cbegin();
+ const auto cend = m_selected.cend();
+ const auto t_it = std::find_if(cbegin, cend, pred);
+ auto result = std::distance(cbegin, t_it);
+ if (result != m_selected.size()) {
+ // now detach:
+ const auto e = m_selected.end();
+
+ auto it = std::next(m_selected.begin(), result);
+ auto dest = it;
+
+ // Loop Invariants:
+ // - it != e
+ // - [next(it), e[ still to be checked
+ // - [c.begin(), dest[ are result
+ while (++it != e) {
+ if (!pred(*it)) {
+ *dest = std::move(*it);
+ ++dest;
+ }
+ }
+
+ result = std::distance(dest, e);
+ m_selected.erase(dest, e);
+ }
+ }
+#endif
+ // m_selected.removeAt(qsizetype i)
auto pack = std::find_if(m_packs.begin(), m_packs.end(), [&rem](ModPlatform::IndexedPack i) { return rem == i.name; });
if (pack == m_packs.end()) { // ignore it if is not in the current search
return;