Qt: Change Time Played format to show all time units.

In the List View in Desktop Mode, "Time Played" column displays only the largest time unit, with the others omitted.
This PR aligns the way value in "Time Played" is displayed with other parts of the application by reusing same function.
This commit is contained in:
Made in Slovakia authored and GitHub committed 2026-11-09 01:09:09 +01:00
1 parent b09e6d3fc0
commit 8fed63392a
2 files changed
+1 -17

No files matched your search

+1 -15
View File
@@ -215,20 +215,6 @@ int GameListModel::columnCount(const QModelIndex& parent) const
return parent.isValid() ? 0 : Column_Count;
}
QString GameListModel::formatTimespan(const time_t timespan)
{
// Avoid an extra string conversion over calling QString::fromStdString(GameList::FormatTimespan).
const u32 hours = static_cast<u32>(timespan / 3600);
if (hours > 0)
return qApp->translate("GameList", "%n hours", "", hours);
const u32 minutes = static_cast<u32>((timespan % 3600) / 60);
if (minutes > 0)
return qApp->translate("GameList", "%n minutes", "", minutes);
else
return qApp->translate("GameList", "%n seconds", "", static_cast<u32>((timespan % 3600) % 60));
}
QVariant GameListModel::data(const QModelIndex& index, const int role) const
{
if (!index.isValid())
@@ -267,7 +253,7 @@ QVariant GameListModel::data(const QModelIndex& index, const int role) const
return QString::fromStdString(fmt::format("{:08X}", ge->crc));
case Column_TimePlayed:
return ge->total_played_time ? formatTimespan(ge->total_played_time) : QVariant();
return QString::fromStdString(GameList::FormatTimespan(ge->total_played_time));
case Column_LastPlayed:
return QString::fromStdString(GameList::FormatTimestamp(ge->last_played_time));
-2
View File
@@ -90,8 +90,6 @@ private:
void loadOrGenerateCover(const GameList::Entry* ge);
void invalidateCoverForPath(const std::string& path);
static QString formatTimespan(const time_t timespan);
float m_cover_scale = 0.0f;
std::atomic<u32> m_cover_scale_counter{0};
bool m_show_titles_for_covers = false;