summaryrefslogtreecommitdiffstats
path: root/api/logic/meta/VersionList.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-03-24 02:26:06 +0100
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:20:02 +0200
commitda4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c (patch)
treec6db08bd02bd991c2370ca62f43249afaf3fe156 /api/logic/meta/VersionList.cpp
parent77f27a628f33a591f7562ca05c206ac604212443 (diff)
downloadMultiMC-da4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c.tar
MultiMC-da4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c.tar.gz
MultiMC-da4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c.tar.lz
MultiMC-da4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c.tar.xz
MultiMC-da4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c.zip
NOISSUE reimplement package dependencies
It is now stored as a hashmap There is also a parentUid to limit depsolving by encapsulating by version
Diffstat (limited to 'api/logic/meta/VersionList.cpp')
-rw-r--r--api/logic/meta/VersionList.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/api/logic/meta/VersionList.cpp b/api/logic/meta/VersionList.cpp
index 28d9dd26..c2712155 100644
--- a/api/logic/meta/VersionList.cpp
+++ b/api/logic/meta/VersionList.cpp
@@ -19,7 +19,6 @@
#include "Version.h"
#include "JsonFormat.h"
-#include "Reference.h"
namespace Meta
{
@@ -76,14 +75,17 @@ QVariant VersionList::data(const QModelIndex &index, int role) const
return version->version();
case ParentGameVersionRole:
{
- const auto end = version->requires().end();
- const auto it = std::find_if(version->requires().begin(), end,
- [](const Reference &ref) { return ref.uid() == "net.minecraft"; });
- if (it != end)
+ auto parentUid = this->parentUid();
+ if(parentUid.isEmpty())
{
- return (*it).version();
+ return QVariant();
+ }
+ auto & reqs = version->requires();
+ auto iter = reqs.find(parentUid);
+ if (iter != reqs.end())
+ {
+ return iter.value();
}
- return QVariant();
}
case TypeRole: return version->type();
@@ -175,6 +177,11 @@ void VersionList::merge(const BaseEntity::Ptr &other)
setName(list->m_name);
}
+ if(m_parentUid != list->m_parentUid)
+ {
+ setParentUid(list->m_parentUid);
+ }
+
if (m_versions.isEmpty())
{
setVersions(list->m_versions);
@@ -228,5 +235,10 @@ BaseVersionPtr VersionList::getRecommended() const
}
+void Meta::VersionList::setParentUid(const QString& parentUid)
+{
+ m_parentUid = parentUid;
+}
+
#include "VersionList.moc"