src/platform/qt/CheatsModel.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef QGBA_CHEATS_MODEL
7#define QGBA_CHEATS_MODEL
8
9#include <QAbstractItemModel>
10#include <QFont>
11
12struct mCheatDevice;
13struct mCheatSet;
14
15namespace QGBA {
16
17class CheatsModel : public QAbstractItemModel {
18Q_OBJECT
19
20public:
21 CheatsModel(mCheatDevice* m_device, QObject* parent = nullptr);
22
23 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
24 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
25
26 virtual QModelIndex index(int row, int column, const QModelIndex& parent) const override;
27 virtual QModelIndex parent(const QModelIndex& index) const override;
28
29 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
30 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
31 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
32
33 mCheatSet* itemAt(const QModelIndex& index);
34 void removeAt(const QModelIndex& index);
35 QString toString(const QModelIndexList& indices) const;
36
37 void beginAppendRow(const QModelIndex& index);
38 void endAppendRow();
39
40 void loadFile(const QString& path);
41 void saveFile(const QString& path);
42
43 void addSet(mCheatSet* set);
44
45public slots:
46 void invalidated();
47
48private:
49 mCheatDevice* m_device;
50 QFont m_font;
51};
52
53}
54
55#endif