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

The Pokedex grid model – seen/owned state, with cycling sort orders. More...

#include <pokedexmodel.h>

Inheritance diagram for PokedexModel:
Collaboration diagram for PokedexModel:

Public Types

enum  PokemonStarterRoles { IndRole = Qt::UserRole + 1 , NameRole , StateRole }
 Columns (mapped in roleNames()). More...
enum  PokemonSortSelect {
  SortBegin , SortDex , SortName , SortInternal ,
  SortEnd
}
 The available sort orders (cycled by dexSortCycle()). More...

Public Member Functions

 PokedexModel (PlayerPokedex *pokedex, Router *router)
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.
void dataChanged (int ind)
 Notify that dex entry ind changed.
void dexSortCycle ()
 Advance to the next sort order.
void dexSort ()
 Apply the current sort.
void dexSortName ()
 Sort alphabetically.
void dexSortNum ()
 Sort by dex number.
void dexSortInternal ()
 Sort by internal id.
void pageClosing ()
 Hook for when the dex page closes.
int dexToListIndex (int ind)
 Row index for species ind under the current sort.

Public Attributes

int dexSortSelect = SortDex
QVector< PokedexEntryData * > dexListCache
 Cached, currently-sorted rows.
PlayerPokedexpokedex = nullptr
 The save's dex.
Routerrouter = nullptr
 For page open/close hooks.

Detailed Description

The Pokedex grid model – seen/owned state, with cycling sort orders.

Wraps the save's PlayerPokedex for the dex screen. Each row carries a tri-state StateRole (none/seen/owned). dexSortSelect cycles through dex/name/ internal order via dexSortCycle(). Holds the router to react to page open/ close. Exposed as brg.pokedexModel.

Definition at line 43 of file pokedexmodel.h.

Member Enumeration Documentation

◆ PokemonSortSelect

The available sort orders (cycled by dexSortCycle()).

Enumerator
SortBegin 
SortDex 
SortName 
SortInternal 
SortEnd 

Definition at line 61 of file pokedexmodel.h.

◆ PokemonStarterRoles

Columns (mapped in roleNames()).

Enumerator
IndRole 
NameRole 
StateRole 

Definition at line 54 of file pokedexmodel.h.

Constructor & Destructor Documentation

◆ PokedexModel()

PokedexModel::PokedexModel ( PlayerPokedex * pokedex,
Router * router )

Member Function Documentation

◆ data()

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

Row+role value.

Definition at line 72 of file pokedexmodel.cpp.

References dexListCache, PokemonDB::getIndAt(), IndRole, PokemonDB::inst(), NameRole, pokedex, pokemonDexCount, and StateRole.

◆ dataChanged()

void PokedexModel::dataChanged ( int ind)

Notify that dex entry ind changed.

Definition at line 114 of file pokedexmodel.cpp.

References dexToListIndex().

Referenced by PokedexModel().

◆ dexSort()

void PokedexModel::dexSort ( )

Apply the current sort.

Definition at line 133 of file pokedexmodel.cpp.

References dexSortInternal(), dexSortName(), dexSortNum(), dexSortSelect, SortDex, SortInternal, and SortName.

Referenced by pageClosing(), and PokedexModel().

◆ dexSortCycle()

void PokedexModel::dexSortCycle ( )

Advance to the next sort order.

Definition at line 124 of file pokedexmodel.cpp.

References dexSortSelect, SortBegin, and SortEnd.

◆ dexSortInternal()

void PokedexModel::dexSortInternal ( )

Sort by internal id.

Definition at line 185 of file pokedexmodel.cpp.

References dexListCache.

Referenced by dexSort().

◆ dexSortName()

void PokedexModel::dexSortName ( )

Sort alphabetically.

Definition at line 158 of file pokedexmodel.cpp.

References dexListCache.

Referenced by dexSort().

◆ dexSortNum()

void PokedexModel::dexSortNum ( )

Sort by dex number.

Definition at line 175 of file pokedexmodel.cpp.

References dexListCache.

Referenced by dexSort().

◆ dexToListIndex()

int PokedexModel::dexToListIndex ( int ind)

Row index for species ind under the current sort.

Definition at line 204 of file pokedexmodel.cpp.

References dexListCache.

Referenced by dataChanged().

◆ pageClosing()

void PokedexModel::pageClosing ( )

Hook for when the dex page closes.

Definition at line 195 of file pokedexmodel.cpp.

References dexSort(), dexSortSelect, and SortDex.

Referenced by PokedexModel().

◆ roleNames()

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

Role -> QML name.

Definition at line 103 of file pokedexmodel.cpp.

References IndRole, NameRole, and StateRole.

◆ rowCount()

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

Row count.

Definition at line 63 of file pokedexmodel.cpp.

References pokemonDexCount.

Member Data Documentation

◆ dexListCache

QVector<PokedexEntryData*> PokedexModel::dexListCache

Cached, currently-sorted rows.

Definition at line 88 of file pokedexmodel.h.

Referenced by data(), dexSortInternal(), dexSortName(), dexSortNum(), dexToListIndex(), and PokedexModel().

◆ dexSortSelect

int PokedexModel::dexSortSelect = SortDex
See also
dexSortSelect property.

Definition at line 87 of file pokedexmodel.h.

Referenced by dexSort(), dexSortCycle(), and pageClosing().

◆ pokedex

PlayerPokedex* PokedexModel::pokedex = nullptr

The save's dex.

Definition at line 89 of file pokedexmodel.h.

Referenced by data(), and PokedexModel().

◆ router

Router* PokedexModel::router = nullptr

For page open/close hooks.

Definition at line 90 of file pokedexmodel.h.

Referenced by PokedexModel().


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