File: GameListModel.h

package info (click to toggle)
dolphin-emu 5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 28,976 kB
  • ctags: 35,666
  • sloc: cpp: 213,139; java: 6,252; asm: 2,277; xml: 1,998; ansic: 1,514; python: 462; sh: 279; pascal: 247; makefile: 124; perl: 97
file content (57 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download | duplicates (2)
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
// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <QAbstractTableModel>
#include <QString>

#include "DolphinQt2/GameList/GameFile.h"
#include "DolphinQt2/GameList/GameTracker.h"

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;

	// Path of the Game at the specified index.
	QString GetPath(int index) const { return m_games[index]->GetPath(); }

	enum
	{
		COL_PLATFORM = 0,
		COL_ID,
		COL_BANNER,
		COL_TITLE,
		COL_DESCRIPTION,
		COL_MAKER,
		COL_SIZE,
		COL_COUNTRY,
		COL_RATING,
		NUM_COLS
	};

public slots:
	void UpdateGame(QSharedPointer<GameFile> game);
	void RemoveGame(const QString& path);

signals:
	void DirectoryAdded(const QString& dir);
	void DirectoryRemoved(const QString& dir);

private:
	// Index in m_games, or -1 if it isn't found
	int FindGame(const QString& path) const;

	GameTracker m_tracker;
	QList<QSharedPointer<GameFile>> m_games;
};