MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / data

Method data

pcsx2-qt/GameList/GameListModel.cpp:232–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232QVariant GameListModel::data(const QModelIndex& index, const int role) const
233{
234 if (!index.isValid())
235 return QVariant();
236
237 const int row = index.row();
238 if (row < 0 || row >= static_cast<int>(GameList::GetEntryCount()))
239 return QVariant();
240
241 const auto lock = GameList::GetLock();
242 const GameList::Entry* ge = GameList::GetEntryByIndex(row);
243 if (!ge)
244 return QVariant();
245
246 // See: https://doc.qt.io/qt-6/qt.html#ItemDataRole-enum
247 switch (role)
248 {
249 case Qt::DisplayRole:
250 {
251 switch (index.column())
252 {
253 case Column_Serial:
254 return QString::fromStdString(ge->serial);
255
256 case Column_Title:
257 return QString::fromStdString(ge->GetTitle(m_prefer_english_titles));
258
259 case Column_FileTitle:
260 return QtUtils::StringViewToQString(Path::GetFileTitle(ge->path));
261
262 case Column_CRC:
263 return QString::fromStdString(fmt::format("{:08X}", ge->crc));
264
265 case Column_TimePlayed:
266 return ge->total_played_time ? formatTimespan(ge->total_played_time) : QVariant();
267
268 case Column_LastPlayed:
269 return QString::fromStdString(GameList::FormatTimestamp(ge->last_played_time));
270
271 case Column_Size:
272 return QString("%1 MB").arg(static_cast<double>(ge->total_size) / 1048576.0, 0, 'f', 2);
273
274 case Column_Cover:
275 return m_show_titles_for_covers ? QString::fromStdString(ge->GetTitle(m_prefer_english_titles)) : QVariant();
276
277 default:
278 return QVariant();
279 }
280 }
281
282 case Qt::DecorationRole:
283 {
284 switch (index.column())
285 {
286 case Column_Type:
287 return m_type_pixmaps[static_cast<u32>(ge->type)];
288
289 case Column_Region:

Callers 2

paintMethod · 0.45
lessThanMethod · 0.45

Calls 10

QVariantClass · 0.85
StringViewToQStringFunction · 0.85
isValidMethod · 0.80
GetTitleMethod · 0.80
argMethod · 0.80
loadOrGenerateCoverMethod · 0.80
formatFunction · 0.50
maxFunction · 0.50
LookupMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected