MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / data

Method data

launcher/meta/VersionList.cpp:64–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

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
containsMethod · 0.45

Tested by

no test coverage detected