Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
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
22class Storage;
23class PlayerPokemon;
24
36class PokemonBoxSelectModel : public QAbstractListModel
37{
38 Q_OBJECT
39
40public:
48
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();
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
82 Storage* storage = nullptr;
83 PlayerPokemon* party = nullptr;
84};
The player's active party – a specialized PokemonStorageBox.
void onPairedBoxChange()
React to the paired model's box changing.
void onBoxChange()
React to this selector changing.
PlayerPokemon * party
The party (box 0).
PokemonBoxSelectModelRoles
Columns (mapped in roleNames()).
QString boxSelect[13]
Row labels: Party plus the 12 boxes.
QString getDecoratedName(int box) const
Row label with its fill-status symbol.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
Selection write-back.
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
PokemonStorageModel * pairedModel
The storage model this selector drives (see note).
Storage * storage
The PC storage (for fill status).
virtual int rowCount(const QModelIndex &parent) const override
Row count (13).
PokemonBoxSelectModel(PokemonStorageModel *pairedModel)
QString curBoxSym
Decoration: current-box marker (points at the label). Fill status is conveyed by the (N/Max) count.
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
Editable list model for a PC box (or the party), with checkbox selection.
The PC: the item storage box and all 12 Pokemon boxes.
Definition storage.h:49