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

Method data

launcher/VersionProxyModel.cpp:149–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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