From da4ae1bc1ec74cdb4e75f4ebac30886ba4a1909c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 24 Mar 2017 02:26:06 +0100 Subject: NOISSUE reimplement package dependencies It is now stored as a hashmap There is also a parentUid to limit depsolving by encapsulating by version --- api/logic/meta/VersionList.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'api/logic/meta/VersionList.cpp') 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" -- cgit v1.2.3