1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
// Copyright 2015 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <string>
#include <QAbstractTableModel>
#include <QMap>
#include <QString>
#include <QStringList>
#include <QVariant>
#include "Core/Core.h"
#include "Core/TimePlayed.h"
#include "Core/TitleDatabase.h"
#include "DolphinQt/GameList/GameTracker.h"
namespace UICommon
{
class GameFile;
}
class GameListModel final : public QAbstractTableModel
{
Q_OBJECT
public:
explicit GameListModel(QObject* parent = nullptr);
// Qt's Model/View stuff uses these overrides.
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex& parent) const override;
int columnCount(const QModelIndex& parent) const override;
std::shared_ptr<const UICommon::GameFile> GetGameFile(int index) const;
std::string GetNetPlayName(const UICommon::GameFile& game) const;
bool ShouldDisplayGameListItem(int index) const;
void SetSearchTerm(const QString& term);
// Using a custom sort role as it sometimes differs slightly from the default Qt::DisplayRole.
static constexpr int SORT_ROLE = Qt::UserRole;
enum class Column
{
Platform = 0,
Banner,
Title,
Description,
Maker,
ID,
Country,
Size,
FileName,
FilePath,
FileFormat,
BlockSize,
Compression,
TimePlayed,
Tags,
Count,
};
void AddGame(const std::shared_ptr<const UICommon::GameFile>& game);
void UpdateGame(const std::shared_ptr<const UICommon::GameFile>& game);
void RemoveGame(const std::string& path);
std::shared_ptr<const UICommon::GameFile> FindGame(const std::string& path) const;
std::shared_ptr<const UICommon::GameFile> FindSecondDisc(const UICommon::GameFile& game) const;
void SetScale(float scale);
float GetScale() const;
const QStringList& GetAllTags() const;
const QStringList GetGameTags(const std::string& path) const;
void AddGameTag(const std::string& path, const QString& name);
void RemoveGameTag(const std::string& path, const QString& name);
void NewTag(const QString& name);
void DeleteTag(const QString& name);
void PurgeCache();
private:
// Index in m_games, or -1 if it isn't found
int FindGameIndex(const std::string& path) const;
void OnEmulationStateChanged(Core::State state);
QStringList m_tag_list;
QMap<QString, QVariant> m_game_tags;
GameTracker m_tracker;
QList<std::shared_ptr<const UICommon::GameFile>> m_games;
Core::TitleDatabase m_title_database;
TimePlayed m_timer;
QString m_term;
float m_scale = 1.0;
};
|