NOISSUE add versioning to component metadata format and use it

This commit is contained in:
Petr Mrázek
2017-12-29 00:37:14 +01:00
parent 50ca6cbb4d
commit 719f3e863a
10 changed files with 94 additions and 136 deletions

View File

@ -76,20 +76,17 @@ QVariant VersionList::data(const QModelIndex &index, int role) const
return version->version();
case ParentVersionRole:
{
auto parentUid = this->parentUid();
if(parentUid.isEmpty())
{
return QVariant();
}
// FIXME: HACK: this should be generic and be replaced by something else. Anything that is a hard 'equals' dep is a 'parent uid'.
auto & reqs = version->requires();
auto iter = std::find_if(reqs.begin(), reqs.end(), [&parentUid](const Require & req)
auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Require & req)
{
return req.uid == parentUid;
return req.uid == "net.minecraft";
});
if (iter != reqs.end())
{
return (*iter).equalsVersion;
}
return QVariant();
}
case TypeRole: return version->type();
@ -196,11 +193,6 @@ void VersionList::mergeFromIndex(const VersionListPtr &other)
{
setName(other->m_name);
}
if(m_parentUid != other->m_parentUid)
{
setParentUid(other->m_parentUid);
}
}
void VersionList::merge(const VersionListPtr &other)
@ -210,11 +202,6 @@ void VersionList::merge(const VersionListPtr &other)
setName(other->m_name);
}
if(m_parentUid != other->m_parentUid)
{
setParentUid(other->m_parentUid);
}
// TODO: do not reset the whole model. maybe?
beginResetModel();
m_versions.clear();
@ -256,8 +243,3 @@ BaseVersionPtr VersionList::getRecommended() const
}
}
void Meta::VersionList::setParentUid(const QString& parentUid)
{
m_parentUid = parentUid;
}