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

Move picker model – context-aware on a chosen Pokemon. More...

#include <moveselectmodel.h>

Inheritance diagram for MoveSelectModel:
Collaboration diagram for MoveSelectModel:

Public Types

enum  ItemRoles { IndRole = Qt::UserRole + 1 , NameRole }
 Picker columns (mapped in roleNames()). More...

Public Member Functions

 MoveSelectModel ()
virtual int rowCount (const QModelIndex &parent) const override
 Row count.
virtual QVariant data (const QModelIndex &index, int role) const override
 Row+role value.
virtual QHash< int, QByteArray > roleNames () const override
 Role -> QML name.
int moveToListIndex (int ind)
 Row index for move ind.
void onMonChange ()
 React to mon changing.
void rebuildListGeneral ()
 Rebuild with all moves.
void rebuildListSpecific ()
 Rebuild with mon's legal moves only.
void monFromBox (PokemonBox *box)
 Set mon from a QML-passed PokemonBox.

Public Attributes

QVector< MoveSelectEntry * > moveListCache
 Cached picker rows.
PokemonDBEntrymon = nullptr

Detailed Description

Move picker model – context-aware on a chosen Pokemon.

Select-model variant (see SpeciesSelectModel) with a twist: when mon is set (via monFromBox() from the details editor) the list rebuilds to that species' legal moves (rebuildListSpecific); otherwise it shows the general move list. Exposed as brg.moveSelectModel.

Definition at line 45 of file moveselectmodel.h.

Member Enumeration Documentation

◆ ItemRoles

Picker columns (mapped in roleNames()).

Enumerator
IndRole 
NameRole 

Definition at line 56 of file moveselectmodel.h.

Constructor & Destructor Documentation

◆ MoveSelectModel()

MoveSelectModel::MoveSelectModel ( )

Definition at line 35 of file moveselectmodel.cpp.

References onMonChange().

Member Function Documentation

◆ data()

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

Row+role value.

Definition at line 50 of file moveselectmodel.cpp.

References IndRole, moveListCache, and NameRole.

◆ monFromBox()

void MoveSelectModel::monFromBox ( PokemonBox * box)

Set mon from a QML-passed PokemonBox.

Definition at line 452 of file moveselectmodel.cpp.

References mon, PokemonDBEntry::pokedex, and PokemonBox::toData().

◆ moveToListIndex()

int MoveSelectModel::moveToListIndex ( int ind)

Row index for move ind.

Definition at line 85 of file moveselectmodel.cpp.

References moveListCache.

◆ onMonChange()

void MoveSelectModel::onMonChange ( )

React to mon changing.

Definition at line 100 of file moveselectmodel.cpp.

References mon, moveListCache, rebuildListGeneral(), and rebuildListSpecific().

Referenced by MoveSelectModel().

◆ rebuildListGeneral()

void MoveSelectModel::rebuildListGeneral ( )

Rebuild with all moves.

Definition at line 116 of file moveselectmodel.cpp.

References MovesDB::inst(), and moveListCache.

Referenced by onMonChange(), and rebuildListSpecific().

◆ rebuildListSpecific()

void MoveSelectModel::rebuildListSpecific ( )

Rebuild with mon's legal moves only.

Definition at line 209 of file moveselectmodel.cpp.

References MovesDB::inst(), mon, moveListCache, and rebuildListGeneral().

Referenced by onMonChange().

◆ roleNames()

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

Role -> QML name.

Definition at line 75 of file moveselectmodel.cpp.

References IndRole, and NameRole.

◆ rowCount()

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

Row count.

Definition at line 41 of file moveselectmodel.cpp.

References moveListCache.

Member Data Documentation

◆ mon

PokemonDBEntry* MoveSelectModel::mon = nullptr
See also
mon property.

Definition at line 78 of file moveselectmodel.h.

Referenced by monFromBox(), onMonChange(), and rebuildListSpecific().

◆ moveListCache

QVector<MoveSelectEntry*> MoveSelectModel::moveListCache

Cached picker rows.

Definition at line 77 of file moveselectmodel.h.

Referenced by data(), moveToListIndex(), onMonChange(), rebuildListGeneral(), rebuildListSpecific(), and rowCount().


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