MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / data

Method data

launcher/meta/VersionList.cpp:62–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62QVariant VersionList::data(const QModelIndex &index, int role) const
63{
64 if (!index.isValid() || index.row() < 0 || index.row() >= m_versions.size() || index.parent().isValid())
65 {
66 return QVariant();
67 }
68
69 VersionPtr version = m_versions.at(index.row());
70
71 switch (role)
72 {
73 case VersionPointerRole: return QVariant::fromValue(std::dynamic_pointer_cast<BaseVersion>(version));
74 case VersionRole:
75 case VersionIdRole:
76 return version->version();
77 case ParentVersionRole:
78 {
79 // FIXME: HACK: this should be generic and be replaced by something else. Anything that is a hard 'equals' dep is a 'parent uid'.
80 auto & reqs = version->required();
81 auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Require & req)
82 {
83 return req.uid == "net.minecraft";
84 });
85 if (iter != reqs.end())
86 {
87 return (*iter).equalsVersion;
88 }
89 return QVariant();
90 }
91 case TypeRole: return version->type();
92
93 case UidRole: return version->uid();
94 case TimeRole: return version->time();
95 case RequiresRole: return QVariant::fromValue(version->required());
96 case SortRole: return version->rawTime();
97 case VersionPtrRole: return QVariant::fromValue(version);
98 case RecommendedRole: return version->isRecommended();
99 // FIXME: this should be determined in whatever view/proxy is used...
100 // case LatestRole: return version == getLatestStable();
101 default: return QVariant();
102 }
103}
104
105BaseVersionList::RoleList VersionList::providesRoles() const
106{

Callers

nothing calls this directly

Calls 12

beginMethod · 0.80
endMethod · 0.80
timeMethod · 0.80
rawTimeMethod · 0.80
isRecommendedMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45
parentMethod · 0.45
atMethod · 0.45
versionMethod · 0.45
typeMethod · 0.45
uidMethod · 0.45

Tested by

no test coverage detected