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#pragma once
7
8#include <QAbstractItemModel>
9#include <QFont>
10
11struct mCheatDevice;
12struct mCheatSet;
13
14namespace QGBA {
15
16class CheatsModel : public QAbstractItemModel {
17Q_OBJECT
18
19public:
20 CheatsModel(mCheatDevice* m_device, QObject* parent = nullptr);
21
22 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
23 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
24
25 virtual QModelIndex index(int row, int column, const QModelIndex& parent) const override;
26 virtual QModelIndex parent(const QModelIndex& index) const override;
27
28 virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override;
29 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
30 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
31
32 mCheatSet* itemAt(const QModelIndex& index);
33 void removeAt(const QModelIndex& index);
34 QString toString(const QModelIndexList& indices) const;
35
36 void beginAppendRow(const QModelIndex& index);
37 void endAppendRow();
38
39 void loadFile(const QString& path);
40 void saveFile(const QString& path);
41
42 void addSet(mCheatSet* set);
43
44public slots:
45 void invalidated();
46
47private:
48 mCheatDevice* m_device;
49 QFont m_font;
50};
51
52}