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

Map picker model, tied to the current AreaMap. More...

#include <mapselectmodel.h>

Inheritance diagram for MapSelectModel:
Collaboration diagram for MapSelectModel:

Public Types

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

Public Member Functions

 MapSelectModel (AreaMap *map)
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 mapToListIndex (int ind)
 Row index for map ind.
void rebuild ()
 Rebuild the cached list.

Public Attributes

QVector< MapSelectEntry * > mapListCache
 Cached picker rows.
AreaMapmap
 The live area map this picker targets.

Detailed Description

Map picker model, tied to the current AreaMap.

Select-model variant (see SpeciesSelectModel) holding the live map so rebuild() can refresh against it; mapToListIndex() highlights the current map. Backs the "place player on a map" picker. Exposed as brg.mapSelectModel.

Definition at line 39 of file mapselectmodel.h.

Member Enumeration Documentation

◆ ItemRoles

Picker columns (mapped in roleNames()).

Enumerator
IndRole 
NameRole 

Definition at line 45 of file mapselectmodel.h.

Constructor & Destructor Documentation

◆ MapSelectModel()

MapSelectModel::MapSelectModel ( AreaMap * map)
Parameters
mapthe live area map.

Definition at line 35 of file mapselectmodel.cpp.

References AreaMap::curMapChanged(), map, and rebuild().

Member Function Documentation

◆ data()

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

Row+role value.

Definition at line 54 of file mapselectmodel.cpp.

References IndRole, mapListCache, and NameRole.

◆ mapToListIndex()

int MapSelectModel::mapToListIndex ( int ind)

Row index for map ind.

Definition at line 89 of file mapselectmodel.cpp.

References mapListCache.

◆ rebuild()

void MapSelectModel::rebuild ( )

Rebuild the cached list.

Definition at line 104 of file mapselectmodel.cpp.

References MapsDB::getIndAt(), MapsDB::inst(), map, and mapListCache.

Referenced by MapSelectModel().

◆ roleNames()

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

Role -> QML name.

Definition at line 79 of file mapselectmodel.cpp.

References IndRole, and NameRole.

◆ rowCount()

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

Row count.

Definition at line 45 of file mapselectmodel.cpp.

References mapListCache.

Member Data Documentation

◆ map

AreaMap* MapSelectModel::map

The live area map this picker targets.

Definition at line 64 of file mapselectmodel.h.

Referenced by MapSelectModel(), and rebuild().

◆ mapListCache

QVector<MapSelectEntry*> MapSelectModel::mapListCache

Cached picker rows.

Definition at line 56 of file mapselectmodel.h.

Referenced by data(), mapToListIndex(), rebuild(), and rowCount().


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