Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
pokemonboxselectmodel.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
21
class
PokemonStorageModel
;
22
class
Storage
;
23
class
PlayerPokemon
;
24
36
class
PokemonBoxSelectModel
:
public
QAbstractListModel
37
{
38
Q_OBJECT
39
40
public
:
42
enum
PokemonBoxSelectModelRoles
{
43
NameRole
= Qt::UserRole + 1,
44
ValueRole
,
45
DisabledRole
,
46
IndRole
,
47
};
48
49
PokemonBoxSelectModel
(
PokemonStorageModel
*
pairedModel
);
50
51
QString
curBoxSym
=
"▷"
;
52
53
QString
boxSelect
[13] = {
54
"Party"
,
55
"Storage Box 1"
,
56
"Storage Box 2"
,
57
"Storage Box 3"
,
58
"Storage Box 4"
,
59
"Storage Box 5"
,
60
"Storage Box 6"
,
61
"Storage Box 7"
,
62
"Storage Box 8"
,
63
"Storage Box 9"
,
64
"Storage Box 10"
,
65
"Storage Box 11"
,
66
"Storage Box 12"
,
67
};
68
69
virtual
int
rowCount
(
const
QModelIndex& parent)
const override
;
70
virtual
QVariant
data
(
const
QModelIndex& index,
int
role)
const override
;
71
virtual
QHash<int, QByteArray>
roleNames
()
const override
;
72
virtual
bool
setData
(
const
QModelIndex& index,
const
QVariant& value,
int
role)
override
;
73
74
Q_INVOKABLE
void
onBoxChange
();
75
void
onPairedBoxChange
();
76
QString
getDecoratedName
(
int
box)
const
;
77
78
// This needs to be paired to a PokemonStorageModel, it interacts with the
79
// model and controls it's current box. If the model updates its own box
80
// this updates as well
81
PokemonStorageModel
*
pairedModel
=
nullptr
;
82
Storage
*
storage
=
nullptr
;
83
PlayerPokemon
*
party
=
nullptr
;
84
};
PlayerPokemon
The player's active party – a specialized PokemonStorageBox.
Definition
playerpokemon.h:42
PokemonBoxSelectModel::onPairedBoxChange
void onPairedBoxChange()
React to the paired model's box changing.
PokemonBoxSelectModel::onBoxChange
void onBoxChange()
React to this selector changing.
Definition
pokemonboxselectmodel.cpp:135
PokemonBoxSelectModel::party
PlayerPokemon * party
The party (box 0).
Definition
pokemonboxselectmodel.h:83
PokemonBoxSelectModel::PokemonBoxSelectModelRoles
PokemonBoxSelectModelRoles
Columns (mapped in roleNames()).
Definition
pokemonboxselectmodel.h:42
PokemonBoxSelectModel::DisabledRole
@ DisabledRole
Definition
pokemonboxselectmodel.h:45
PokemonBoxSelectModel::IndRole
@ IndRole
Definition
pokemonboxselectmodel.h:46
PokemonBoxSelectModel::ValueRole
@ ValueRole
Definition
pokemonboxselectmodel.h:44
PokemonBoxSelectModel::NameRole
@ NameRole
Definition
pokemonboxselectmodel.h:43
PokemonBoxSelectModel::boxSelect
QString boxSelect[13]
Row labels: Party plus the 12 boxes.
Definition
pokemonboxselectmodel.h:53
PokemonBoxSelectModel::getDecoratedName
QString getDecoratedName(int box) const
Row label with its fill-status symbol.
Definition
pokemonboxselectmodel.cpp:141
PokemonBoxSelectModel::setData
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
Selection write-back.
Definition
pokemonboxselectmodel.cpp:118
PokemonBoxSelectModel::roleNames
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
Definition
pokemonboxselectmodel.cpp:106
PokemonBoxSelectModel::pairedModel
PokemonStorageModel * pairedModel
The storage model this selector drives (see note).
Definition
pokemonboxselectmodel.h:81
PokemonBoxSelectModel::storage
Storage * storage
The PC storage (for fill status).
Definition
pokemonboxselectmodel.h:82
PokemonBoxSelectModel::rowCount
virtual int rowCount(const QModelIndex &parent) const override
Row count (13).
Definition
pokemonboxselectmodel.cpp:54
PokemonBoxSelectModel::PokemonBoxSelectModel
PokemonBoxSelectModel(PokemonStorageModel *pairedModel)
Definition
pokemonboxselectmodel.cpp:30
PokemonBoxSelectModel::curBoxSym
QString curBoxSym
Decoration: current-box marker (points at the label). Fill status is conveyed by the (N/Max) count.
Definition
pokemonboxselectmodel.h:51
PokemonBoxSelectModel::data
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
Definition
pokemonboxselectmodel.cpp:63
PokemonStorageModel
Editable list model for a PC box (or the party), with checkbox selection.
Definition
pokemonstoragemodel.h:49
Storage
The PC: the item storage box and all 12 Pokemon boxes.
Definition
storage.h:49
projects
app
src
mvc
pokemonboxselectmodel.h
Generated by
1.17.0