diff options
author | Mario <mariodavo.20@gmail.com> | 2023-08-26 21:19:00 -0400 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2023-08-26 22:20:19 -0400 |
commit | 5464423667dedc0f09d48f85fc7871a3e56127a4 (patch) | |
tree | a981bb0c3f41050a476e791f4440bc4eae9e1ebf /src/yuzu/game_list_p.h | |
parent | 6c4abd23be375afda850661cdf164b65e52f8cb8 (diff) |
yuzu-qt: Track play time
Diffstat (limited to 'src/yuzu/game_list_p.h')
-rw-r--r-- | src/yuzu/game_list_p.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 1800f090f..33a929aae 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -18,6 +18,7 @@ #include "common/common_types.h" #include "common/logging/log.h" #include "common/string_util.h" +#include "yuzu/play_time.h" #include "yuzu/uisettings.h" #include "yuzu/util/util.h" @@ -221,6 +222,31 @@ public: } }; +/** + * GameListItem for Play Time values. + * This object stores the play time of a game in seconds, and its readable + * representation in minutes/hours + */ +class GameListItemPlayTime : public GameListItem { +public: + static constexpr int PlayTimeRole = SortRole; + + GameListItemPlayTime() = default; + explicit GameListItemPlayTime(const qulonglong time_seconds) { + setData(time_seconds, PlayTimeRole); + } + + void setData(const QVariant& value, int role) override { + qulonglong time_seconds = value.toULongLong(); + GameListItem::setData(PlayTime::ReadablePlayTime(time_seconds), Qt::DisplayRole); + GameListItem::setData(value, PlayTimeRole); + } + + bool operator<(const QStandardItem& other) const override { + return data(PlayTimeRole).toULongLong() < other.data(PlayTimeRole).toULongLong(); + } +}; + class GameListDir : public GameListItem { public: static constexpr int GameDirRole = Qt::UserRole + 2; |