Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
moveselectmodel.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QObject>
18#include <QString>
19#include <QAbstractListModel>
20#include <QVector>
21
22// monFromBox() takes a PokemonBox from QML (PokemonDetails passes its boxData).
23// Full include so the parameter is a real, matchable PokemonBox QObject type.
25
26class PokemonDBEntry;
27class PokemonBox;
28
31 MoveSelectEntry(QString name, int ind);
32
33 QString name;
34 int ind;
35};
36
45class MoveSelectModel : public QAbstractListModel
46{
47 Q_OBJECT
48
49 Q_PROPERTY(PokemonDBEntry* mon MEMBER mon NOTIFY monChanged)
50
51signals:
52 void monChanged();
53
54public:
56 enum ItemRoles {
57 IndRole = Qt::UserRole + 1,
59 };
60
62
63 virtual int rowCount(const QModelIndex& parent) const override;
64 virtual QVariant data(const QModelIndex& index, int role) const override;
65 virtual QHash<int, QByteArray> roleNames() const override;
66
67 Q_INVOKABLE int moveToListIndex(int ind);
68
69 void onMonChange();
70 void rebuildListGeneral();
71 void rebuildListSpecific();
72
73public slots:
74 void monFromBox(PokemonBox* box);
75
76public:
77 QVector<MoveSelectEntry*> moveListCache;
78 PokemonDBEntry* mon = nullptr;
79};
QVector< MoveSelectEntry * > moveListCache
Cached picker rows.
void rebuildListGeneral()
Rebuild with all moves.
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
void rebuildListSpecific()
Rebuild with mon's legal moves only.
void monFromBox(PokemonBox *box)
Set mon from a QML-passed PokemonBox.
void onMonChange()
React to mon changing.
virtual int rowCount(const QModelIndex &parent) const override
Row count.
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
int moveToListIndex(int ind)
Row index for move ind.
ItemRoles
Picker columns (mapped in roleNames()).
PokemonDBEntry * mon
A single Pokemon record – the most property-rich object in the tree.
Definition pokemonbox.h:213
MoveSelectEntry(QString name, int ind)
int ind
Move index.
QString name
Display name.
One species' complete static data – the richest entry in the db layer.
Definition pokemon.h:98