src/platform/qt/BattleChipModel.h (view raw)
1/* Copyright (c) 2013-2019 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 <QAbstractListModel>
9#include <QPixmap>
10
11namespace QGBA {
12
13class BattleChipModel : public QAbstractListModel {
14Q_OBJECT
15
16public:
17 BattleChipModel(QObject* parent = nullptr);
18
19 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
20 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
21 virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
22 virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
23 virtual Qt::DropActions supportedDropActions() const override;
24 virtual QStringList mimeTypes() const override;
25 virtual QMimeData* mimeData(const QModelIndexList& indices) const override;
26 virtual bool dropMimeData(const QMimeData* data, Qt::DropAction, int row, int column, const QModelIndex& parent) override;
27
28 int flavor() const { return m_flavor; }
29 QMap<int, QString> chipNames() const { return m_chipIdToName; }
30
31public slots:
32 void setFlavor(int);
33 void addChip(int id);
34 void removeChip(const QModelIndex&);
35 void setChips(QList<int> ids);
36 void clear();
37 void setScale(int);
38
39private:
40 struct BattleChip {
41 int id;
42 QString name;
43 QPixmap icon;
44 };
45
46 BattleChip createChip(int id) const;
47
48 QMap<int, QString> m_chipIdToName;
49 int m_flavor;
50 int m_scale = 1;
51
52 QList<BattleChip> m_deck;
53};
54
55}