Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
PokemonBoxSelectModel Class Reference

The "which PC box" selector model (Party + 12 boxes). More...

#include <pokemonboxselectmodel.h>

Inheritance diagram for PokemonBoxSelectModel:
Collaboration diagram for PokemonBoxSelectModel:

Public Types

enum  PokemonBoxSelectModelRoles { NameRole = Qt::UserRole + 1 , ValueRole , DisabledRole , IndRole }
 Columns (mapped in roleNames()). More...

Public Member Functions

 PokemonBoxSelectModel (PokemonStorageModel *pairedModel)
virtual int rowCount (const QModelIndex &parent) const override
 Row count (13).
virtual QVariant data (const QModelIndex &index, int role) const override
 Row+role value.
virtual QHash< int, QByteArray > roleNames () const override
 Role -> QML name.
virtual bool setData (const QModelIndex &index, const QVariant &value, int role) override
 Selection write-back.
void onBoxChange ()
 React to this selector changing.
void onPairedBoxChange ()
 React to the paired model's box changing.
QString getDecoratedName (int box) const
 Row label with its fill-status symbol.

Public Attributes

QString curBoxSym = "▷"
 Decoration: current-box marker (points at the label). Fill status is conveyed by the (N/Max) count.
QString boxSelect [13]
 Row labels: Party plus the 12 boxes.
PokemonStorageModelpairedModel = nullptr
 The storage model this selector drives (see note).
Storagestorage = nullptr
 The PC storage (for fill status).
PlayerPokemonparty = nullptr
 The party (box 0).

Detailed Description

The "which PC box" selector model (Party + 12 boxes).

A combo-box model listing the party and the twelve storage boxes. Each row shows a (filled count / max) tally and the current box is marked with a leading ▷. It is paired to a PokemonStorageModel: selecting a box here drives that model's current box, and vice versa (see the note at pairedModel). setData() handles the selection write-back. Exposed as brg.pokemonBoxSelectModel1/2.

See also
PokemonStorageModel (the paired model), Storage, PlayerPokemon.

Definition at line 36 of file pokemonboxselectmodel.h.

Member Enumeration Documentation

◆ PokemonBoxSelectModelRoles

Columns (mapped in roleNames()).

Enumerator
NameRole 
ValueRole 
DisabledRole 
IndRole 

Definition at line 42 of file pokemonboxselectmodel.h.

Constructor & Destructor Documentation

◆ PokemonBoxSelectModel()

PokemonBoxSelectModel::PokemonBoxSelectModel ( PokemonStorageModel * pairedModel)

Member Function Documentation

◆ data()

QVariant PokemonBoxSelectModel::data ( const QModelIndex & index,
int role ) const
overridevirtual

Row+role value.

Definition at line 63 of file pokemonboxselectmodel.cpp.

References DisabledRole, getDecoratedName(), IndRole, NameRole, pairedModel, storage, and ValueRole.

◆ getDecoratedName()

QString PokemonBoxSelectModel::getDecoratedName ( int box) const

Row label with its fill-status symbol.

Definition at line 141 of file pokemonboxselectmodel.cpp.

References boxSelect, curBoxSym, party, PokemonStorageBox::pokemonCount(), PokemonStorageBox::pokemonMax(), and storage.

Referenced by data().

◆ onBoxChange()

void PokemonBoxSelectModel::onBoxChange ( )

React to this selector changing.

Definition at line 135 of file pokemonboxselectmodel.cpp.

Referenced by PokemonBoxSelectModel().

◆ onPairedBoxChange()

void PokemonBoxSelectModel::onPairedBoxChange ( )

React to the paired model's box changing.

◆ roleNames()

QHash< int, QByteArray > PokemonBoxSelectModel::roleNames ( ) const
overridevirtual

Role -> QML name.

Definition at line 106 of file pokemonboxselectmodel.cpp.

References DisabledRole, IndRole, NameRole, and ValueRole.

◆ rowCount()

int PokemonBoxSelectModel::rowCount ( const QModelIndex & parent) const
overridevirtual

Row count (13).

Definition at line 54 of file pokemonboxselectmodel.cpp.

◆ setData()

bool PokemonBoxSelectModel::setData ( const QModelIndex & index,
const QVariant & value,
int role )
overridevirtual

Selection write-back.

Definition at line 118 of file pokemonboxselectmodel.cpp.

References IndRole, and pairedModel.

Member Data Documentation

◆ boxSelect

QString PokemonBoxSelectModel::boxSelect[13]
Initial value:
= {
"Party",
"Storage Box 1",
"Storage Box 2",
"Storage Box 3",
"Storage Box 4",
"Storage Box 5",
"Storage Box 6",
"Storage Box 7",
"Storage Box 8",
"Storage Box 9",
"Storage Box 10",
"Storage Box 11",
"Storage Box 12",
}

Row labels: Party plus the 12 boxes.

Definition at line 53 of file pokemonboxselectmodel.h.

Referenced by getDecoratedName().

◆ curBoxSym

QString PokemonBoxSelectModel::curBoxSym = "▷"

Decoration: current-box marker (points at the label). Fill status is conveyed by the (N/Max) count.

Definition at line 51 of file pokemonboxselectmodel.h.

Referenced by getDecoratedName().

◆ pairedModel

PokemonStorageModel* PokemonBoxSelectModel::pairedModel = nullptr

The storage model this selector drives (see note).

Definition at line 81 of file pokemonboxselectmodel.h.

Referenced by data(), PokemonBoxSelectModel(), and setData().

◆ party

PlayerPokemon* PokemonBoxSelectModel::party = nullptr

The party (box 0).

Definition at line 83 of file pokemonboxselectmodel.h.

Referenced by getDecoratedName(), and PokemonBoxSelectModel().

◆ storage

Storage* PokemonBoxSelectModel::storage = nullptr

The PC storage (for fill status).

Definition at line 82 of file pokemonboxselectmodel.h.

Referenced by data(), getDecoratedName(), and PokemonBoxSelectModel().


The documentation for this class was generated from the following files: