Added the option to sort instances by total playtime (#5701)

Signed-off-by: Anceph <yucehasan31@gmail.com>
This commit is contained in:
Anceph 2026-06-24 00:23:31 +03:00
parent f654ce8212
commit a607373ced
3 changed files with 26 additions and 1 deletions

View file

@ -62,6 +62,12 @@ bool InstanceProxyModel::subSortLessThan(const QModelIndex& left, const QModelIn
QString sortMode = APPLICATION->settings()->get("InstSortMode").toString();
if (sortMode == "LastLaunch") {
return pdataLeft->lastLaunch() > pdataRight->lastLaunch();
} else if (sortMode == "Playtime") {
if (pdataLeft->totalTimePlayed() == pdataRight->totalTimePlayed()) {
// fallback to name sorting if playtime is equal
return m_naturalSort.compare(pdataLeft->name(), pdataRight->name()) < 0;
}
return pdataLeft->totalTimePlayed() > pdataRight->totalTimePlayed();
} else {
return m_naturalSort.compare(pdataLeft->name(), pdataRight->name()) < 0;
}