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

Method data

launcher/VersionProxyModel.cpp:153–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153QVariant VersionProxyModel::data(const QModelIndex& index, int role) const
154{
155 if (!index.isValid()) {
156 return QVariant();
157 }
158 auto column = m_columns[index.column()];
159 auto parentIndex = mapToSource(index);
160 switch (role) {
161 case Qt::DisplayRole: {
162 switch (column) {
163 case Name: {
164 QString version = sourceModel()->data(parentIndex, BaseVersionList::VersionRole).toString();
165 if (version == m_currentVersion) {
166 return tr("%1 (installed)").arg(version);
167 }
168 return version;
169 }
170 case ParentVersion:
171 return sourceModel()->data(parentIndex, BaseVersionList::ParentVersionRole);
172 case Branch:
173 return sourceModel()->data(parentIndex, BaseVersionList::BranchRole);
174 case Type:
175 return sourceModel()->data(parentIndex, BaseVersionList::TypeRole);
176 case CPUArchitecture:
177 return sourceModel()->data(parentIndex, BaseVersionList::CPUArchitectureRole);
178 case Path:
179 return sourceModel()->data(parentIndex, BaseVersionList::PathRole);
180 case JavaName:
181 return sourceModel()->data(parentIndex, BaseVersionList::JavaNameRole);
182 case JavaMajor:
183 return sourceModel()->data(parentIndex, BaseVersionList::JavaMajorRole);
184 case Time:
185 return sourceModel()->data(parentIndex, Meta::VersionList::TimeRole).toDate();
186 default:
187 return QVariant();
188 }
189 }
190 case Qt::ToolTipRole: {
191 if (column == Name && hasRecommended) {
192 auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
193 if (value.toBool()) {
194 return tr("Recommended");
195 } else if (hasLatest) {
196 auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
197 if (value.toBool()) {
198 return tr("Latest");
199 }
200 }
201 } else {
202 return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole);
203 }
204 }
205 case Qt::DecorationRole: {
206 switch (column) {
207 case Name: {
208 if (hasRecommended) {
209 auto recommenced = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
210 if (recommenced.toBool()) {

Callers 3

filterAcceptsRowMethod · 0.45
getRecommendedMethod · 0.45
getVersionMethod · 0.45

Calls 5

getThemedIconMethod · 0.80
fillMethod · 0.80
isValidMethod · 0.45
toStringMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected