mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-28 14:20:30 +00:00
Qt: Use GameList::FormatTimespan()
No point duplicating the logic since the core can handle plural translations now.
This commit is contained in:
parent
9ffded0e73
commit
bf4a89e82e
@ -1602,9 +1602,11 @@ TinyString GameList::FormatTimespan(std::time_t timespan, bool long_format)
|
||||
else
|
||||
{
|
||||
if (hours > 0)
|
||||
ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n hours", "", hours));
|
||||
ret.assign(TRANSLATE_PLURAL_SSTR("GameList", "%n hours", "", hours));
|
||||
else if (minutes > 0)
|
||||
ret.assign(TRANSLATE_PLURAL_SSTR("GameList", "%n minutes", "", minutes));
|
||||
else
|
||||
ret.assign(TRANSLATE_PLURAL_STR("GameList", "%n minutes", "", minutes));
|
||||
ret.assign(TRANSLATE_PLURAL_SSTR("GameList", "%n seconds", "", seconds));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -350,19 +350,6 @@ void GameListModel::invalidateCoverForPath(const std::string& path)
|
||||
emit dataChanged(mi, mi, {Qt::DecorationRole});
|
||||
}
|
||||
|
||||
QString GameListModel::formatTimespan(time_t timespan)
|
||||
{
|
||||
// avoid an extra string conversion
|
||||
const u32 hours = static_cast<u32>(timespan / 3600);
|
||||
const u32 minutes = static_cast<u32>((timespan % 3600) / 60);
|
||||
if (hours > 0)
|
||||
return qApp->translate("GameList", "%n hours", "", hours);
|
||||
else if (minutes > 0)
|
||||
return qApp->translate("GameList", "%n minutes", "", minutes);
|
||||
else
|
||||
return qApp->translate("GameList", "%n seconds", "", static_cast<u32>((timespan % 3600) % 60));
|
||||
}
|
||||
|
||||
const QPixmap& GameListModel::getIconPixmapForEntry(const GameList::Entry* ge) const
|
||||
{
|
||||
// We only do this for discs/disc sets for now.
|
||||
@ -571,7 +558,7 @@ QVariant GameListModel::data(const QModelIndex& index, int role, const GameList:
|
||||
if (ge->total_played_time == 0)
|
||||
return {};
|
||||
else
|
||||
return formatTimespan(ge->total_played_time);
|
||||
return QtUtils::StringViewToQString(GameList::FormatTimespan(ge->total_played_time, true));
|
||||
}
|
||||
|
||||
case Column_LastPlayed:
|
||||
|
@ -125,8 +125,6 @@ private:
|
||||
const QPixmap& getFlagPixmapForEntry(const GameList::Entry* ge) const;
|
||||
static void fixIconPixmapSize(QPixmap& pm);
|
||||
|
||||
static QString formatTimespan(time_t timespan);
|
||||
|
||||
std::optional<GameList::EntryList> m_taken_entries;
|
||||
|
||||
float m_cover_scale = 0.0f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user