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

A species picker list model (the "select model" variant). More...

#include <speciesselectmodel.h>

Inheritance diagram for SpeciesSelectModel:
Collaboration diagram for SpeciesSelectModel:

Public Types

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

Public Member Functions

 SpeciesSelectModel ()
 Build the cache from the species DB.
virtual int rowCount (const QModelIndex &parent) const override
 Number of species rows.
virtual QVariant data (const QModelIndex &index, int role) const override
 Value for a row + role.
virtual QHash< int, QByteArray > roleNames () const override
 Role -> QML name map.
int speciesToListIndex (int ind)
 Row index for species ind (for combo highlighting).

Public Attributes

QVector< SpeciesSelectEntry * > speciesListCache
 Cached picker rows.

Detailed Description

A species picker list model (the "select model" variant).

The picker flavour of the mvc-model convention (see CreditsModel): besides the standard rowCount/data/roleNames, it holds a speciesListCache of SpeciesSelectEntry rows and adds speciesToListIndex() to map a species index to its row – so a combo box can highlight the current value. The other *SelectModel pickers (status/nature/move/map/item/box) follow the same shape.

See also
PokemonDB (the source), Bridge (exposes this as brg.speciesSelectModel).

Definition at line 41 of file speciesselectmodel.h.

Member Enumeration Documentation

◆ ItemRoles

Picker columns (mapped to names in roleNames()).

Enumerator
IndRole 
NameRole 

Definition at line 47 of file speciesselectmodel.h.

Constructor & Destructor Documentation

◆ SpeciesSelectModel()

SpeciesSelectModel::SpeciesSelectModel ( )

Build the cache from the species DB.

Definition at line 33 of file speciesselectmodel.cpp.

References PokemonDB::inst(), and speciesListCache.

Member Function Documentation

◆ data()

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

Value for a row + role.

Definition at line 97 of file speciesselectmodel.cpp.

References IndRole, NameRole, and speciesListCache.

◆ roleNames()

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

Role -> QML name map.

Definition at line 122 of file speciesselectmodel.cpp.

References IndRole, and NameRole.

◆ rowCount()

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

Number of species rows.

Definition at line 88 of file speciesselectmodel.cpp.

References speciesListCache.

◆ speciesToListIndex()

int SpeciesSelectModel::speciesToListIndex ( int ind)

Row index for species ind (for combo highlighting).

Definition at line 132 of file speciesselectmodel.cpp.

References speciesListCache.

Member Data Documentation

◆ speciesListCache

QVector<SpeciesSelectEntry*> SpeciesSelectModel::speciesListCache

Cached picker rows.

Definition at line 58 of file speciesselectmodel.h.

Referenced by data(), rowCount(), SpeciesSelectModel(), and speciesToListIndex().


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