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

Method data

launcher/minecraft/WorldList.cpp:179–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179QVariant WorldList::data(const QModelIndex &index, int role) const
180{
181 if (!index.isValid())
182 return QVariant();
183
184 int row = index.row();
185 int column = index.column();
186
187 if (row < 0 || row >= worlds.size())
188 return QVariant();
189
190 QLocale locale;
191
192 auto & world = worlds[row];
193 switch (role)
194 {
195 case Qt::DisplayRole:
196 switch (column)
197 {
198 case NameColumn:
199 return world.name();
200
201 case GameModeColumn:
202 return world.gameType().toTranslatedString();
203
204 case LastPlayedColumn:
205 return world.lastPlayed();
206
207 case SizeColumn:
208 return locale.formattedDataSize(world.bytes());
209
210 default:
211 return QVariant();
212 }
213
214 case Qt::UserRole:
215 switch (column)
216 {
217 case SizeColumn:
218 return QVariant::fromValue<qlonglong>(world.bytes());
219
220 default:
221 return data(index, Qt::DisplayRole);
222 }
223
224 case Qt::ToolTipRole:
225 {
226 return world.folderName();
227 }
228 case ObjectRole:
229 {
230 return QVariant::fromValue<void *>((void *)&world);
231 }
232 case FolderRole:
233 {
234 return QDir::toNativeSeparators(dir().absoluteFilePath(world.folderName()));
235 }
236 case SeedRole:

Callers 3

getVersionFileMethod · 0.45
serializeLevelDatFunction · 0.45
renameMethod · 0.45

Calls 11

dataFunction · 0.85
toTranslatedStringMethod · 0.80
gameTypeMethod · 0.80
lastPlayedMethod · 0.80
bytesMethod · 0.80
folderNameMethod · 0.80
seedMethod · 0.80
iconFileMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected