mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-27 07:07:54 -05:00
yuzu-qt: Track play time
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user