Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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.
24
#include <
pse-savefile/expanded/fragments/pokemonbox.h
>
25
26
class
PokemonDBEntry
;
27
class
PokemonBox
;
28
30
struct
MoveSelectEntry
{
31
MoveSelectEntry
(QString
name
,
int
ind
);
32
33
QString
name
;
34
int
ind
;
35
};
36
45
class
MoveSelectModel
:
public
QAbstractListModel
46
{
47
Q_OBJECT
48
49
Q_PROPERTY(
PokemonDBEntry
*
mon
MEMBER
mon
NOTIFY monChanged)
50
51
signals:
52
void
monChanged();
53
54
public
:
56
enum
ItemRoles
{
57
IndRole
= Qt::UserRole + 1,
58
NameRole
,
59
};
60
61
MoveSelectModel
();
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
73
public
slots:
74
void
monFromBox
(
PokemonBox
* box);
75
76
public
:
77
QVector<MoveSelectEntry*>
moveListCache
;
78
PokemonDBEntry
*
mon
=
nullptr
;
79
};
MoveSelectModel::moveListCache
QVector< MoveSelectEntry * > moveListCache
Cached picker rows.
Definition
moveselectmodel.h:77
MoveSelectModel::MoveSelectModel
MoveSelectModel()
Definition
moveselectmodel.cpp:35
MoveSelectModel::rebuildListGeneral
void rebuildListGeneral()
Rebuild with all moves.
Definition
moveselectmodel.cpp:116
MoveSelectModel::roleNames
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
Definition
moveselectmodel.cpp:75
MoveSelectModel::rebuildListSpecific
void rebuildListSpecific()
Rebuild with mon's legal moves only.
Definition
moveselectmodel.cpp:209
MoveSelectModel::monFromBox
void monFromBox(PokemonBox *box)
Set mon from a QML-passed PokemonBox.
Definition
moveselectmodel.cpp:452
MoveSelectModel::onMonChange
void onMonChange()
React to mon changing.
Definition
moveselectmodel.cpp:100
MoveSelectModel::rowCount
virtual int rowCount(const QModelIndex &parent) const override
Row count.
Definition
moveselectmodel.cpp:41
MoveSelectModel::data
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
Definition
moveselectmodel.cpp:50
MoveSelectModel::moveToListIndex
int moveToListIndex(int ind)
Row index for move ind.
Definition
moveselectmodel.cpp:85
MoveSelectModel::ItemRoles
ItemRoles
Picker columns (mapped in roleNames()).
Definition
moveselectmodel.h:56
MoveSelectModel::NameRole
@ NameRole
Definition
moveselectmodel.h:58
MoveSelectModel::IndRole
@ IndRole
Definition
moveselectmodel.h:57
MoveSelectModel::mon
PokemonDBEntry * mon
Definition
moveselectmodel.h:78
PokemonBox
A single Pokemon record – the most property-rich object in the tree.
Definition
pokemonbox.h:213
pokemonbox.h
MoveSelectEntry::MoveSelectEntry
MoveSelectEntry(QString name, int ind)
Definition
moveselectmodel.cpp:30
MoveSelectEntry::ind
int ind
Move index.
Definition
moveselectmodel.h:34
MoveSelectEntry::name
QString name
Display name.
Definition
moveselectmodel.h:33
PokemonDBEntry
One species' complete static data – the richest entry in the db layer.
Definition
pokemon.h:98
projects
app
src
mvc
moveselectmodel.h
Generated by
1.17.0