|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
Editable list model for a PC box (or the party), with checkbox selection. More...
#include <pokemonstoragemodel.h>
Public Types | |
| enum | BagItemRoles { IndRole = Qt::UserRole + 1 , DexRole , NameRole , CheckedRole , PlaceholderRole , NicknameRole , LevelRole , IsShinyRole , IsPartyRole , HpRole , HpMaxRole , StatusRole } |
| Columns (mapped in roleNames()). More... | |
| enum | BoxSelect { PartyBox = -1 } |
| Sentinel box index for the party. More... | |
Public Member Functions | |
| PokemonStorageModel (Router *router, Storage *storage, PlayerPokemon *party) | |
| virtual int | rowCount (const QModelIndex &parent) const override |
| Row count of the current box. | |
| virtual QVariant | data (const QModelIndex &index, int role) const override |
| Row+role value. | |
| virtual QHash< int, QByteArray > | roleNames () const override |
| Role -> QML name. | |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
| Edit a row (e.g. checkbox). | |
| QVariant | getPlaceHolderData (int role) const |
| The empty-slot placeholder row data. | |
| void | onMove (int from, int to) |
| React to a move. | |
| void | onRemove (int ind) |
| React to a removal. | |
| void | onInsert () |
| React to an insert. | |
| bool | hasChecked () |
| Are any rows checked (live)? | |
| bool | hasCheckedCached () |
| Cached form (backs the property). | |
| QVector< PokemonBox * > | getChecked () |
| The currently-checked mons. | |
| void | onBeforeRelocate (PokemonBox *item) |
| Cleanup hook before a mon relocates away. | |
| void | checkStateDirty () |
| Mark the checked-state cache stale. | |
| void | pageClosing () |
| Hook for when the page closes. | |
| PokemonBox * | getBoxMon (int index) |
Typed box mon at index (for the details screen). | |
| PokemonParty * | getPartyMon (int index) |
Typed party mon at index (for the details screen). | |
| void | dragReorder (int fromIndex, int toIndex, bool group) |
Reorder within this box: move fromIndex (or the checked set) to toIndex. | |
| void | dragTransfer (int fromIndex, int toIndex, bool group) |
Move fromIndex (or the checked set) from this box into the paired pane's box, inserting at toIndex there. | |
| void | deleteMon (int index, bool group) |
Delete the mon at index, or – when group – the whole checked set (the per-cell hover/checked delete button; replaces the old footer release). | |
| void | clearCheckedState () |
| Uncheck everything. | |
| void | clearCheckedStateGone () |
| Clear checked state for removed rows. | |
| void | onReset () |
| React to a reset. | |
| void | checkedMoveToTop () |
| Move checked mons to the top. | |
| void | checkedMoveUp () |
| Move checked mons up one. | |
| void | checkedMoveDown () |
| Move checked mons down one. | |
| void | checkedMoveToBottom () |
| Move checked mons to the bottom. | |
| void | checkedDelete () |
| Delete checked mons. | |
| void | checkedTransfer () |
| Transfer checked mons to the paired box. | |
| void | checkedToggleAll () |
| Toggle all checkboxes. | |
| void | switchBox (int newBox, bool force=false) |
Show box newBox. | |
| PokemonStorageBox * | getCurBox () const |
| The currently-shown box object. | |
| PokemonStorageBox * | getBox (int box) const |
The box object for index box. | |
Public Attributes | |
| int | curBox = PartyBox |
| Router * | router = nullptr |
| For page hooks. | |
| Storage * | storage = nullptr |
| The PC storage. | |
| PlayerPokemon * | party = nullptr |
| The party. | |
| PokemonStorageModel * | otherModel = nullptr |
| The paired sibling model (for transfers). | |
| bool | checkedStateDirty = false |
| Whether the checked-state cache needs refresh. | |
Static Public Attributes | |
| static constexpr const char * | isCheckedKey = "isChecked" |
| QML attached-property name for the per-row checkbox. | |
Editable list model for a PC box (or the party), with checkbox selection.
The Pokemon analogue of ItemStorageModel: shows the mons in the curBox box (or the party when curBox == PartyBox), with per-row checkbox state and the same bulk checked* operations (move/delete/transfer/toggle). switchBox() changes which box is shown; getBoxMon()/getPartyMon() hand a typed mon to the details screen. Pairs with a sibling model (otherModel) and a box selector. Exposed as brg.pokemonStorageModel1/2.
Definition at line 48 of file pokemonstoragemodel.h.
Columns (mapped in roleNames()).
Definition at line 67 of file pokemonstoragemodel.h.
Sentinel box index for the party.
| Enumerator | |
|---|---|
| PartyBox | |
Definition at line 83 of file pokemonstoragemodel.h.
| PokemonStorageModel::PokemonStorageModel | ( | Router * | router, |
| Storage * | storage, | ||
| PlayerPokemon * | party ) |
Definition at line 39 of file pokemonstoragemodel.cpp.
References checkStateDirty(), curBox, onReset(), pageClosing(), party, router, storage, and switchBox().
| void PokemonStorageModel::checkedDelete | ( | ) |
Delete checked mons.
Definition at line 366 of file pokemonstoragemodel.cpp.
References getChecked(), getCurBox(), party, PokemonStorageBox::pokemon, PokemonStorageBox::pokemonCount(), PokemonStorageBox::pokemonMax(), and PokemonStorageBox::pokemonRemove().
Referenced by deleteMon().
| void PokemonStorageModel::checkedMoveDown | ( | ) |
Move checked mons down one.
Definition at line 340 of file pokemonstoragemodel.cpp.
References getChecked(), getCurBox(), PokemonStorageBox::pokemon, and PokemonStorageBox::pokemonMove().
| void PokemonStorageModel::checkedMoveToBottom | ( | ) |
Move checked mons to the bottom.
Definition at line 353 of file pokemonstoragemodel.cpp.
References getChecked(), getCurBox(), PokemonStorageBox::pokemon, and PokemonStorageBox::pokemonMove().
| void PokemonStorageModel::checkedMoveToTop | ( | ) |
Move checked mons to the top.
Definition at line 324 of file pokemonstoragemodel.cpp.
References getChecked(), getCurBox(), PokemonStorageBox::pokemon, and PokemonStorageBox::pokemonMove().
| void PokemonStorageModel::checkedMoveUp | ( | ) |
Move checked mons up one.
Definition at line 332 of file pokemonstoragemodel.cpp.
References getChecked(), getCurBox(), PokemonStorageBox::pokemon, and PokemonStorageBox::pokemonMove().
| void PokemonStorageModel::checkedToggleAll | ( | ) |
Toggle all checkboxes.
Definition at line 433 of file pokemonstoragemodel.cpp.
References getCurBox(), isCheckedKey, and PokemonStorageBox::pokemon.
| void PokemonStorageModel::checkedTransfer | ( | ) |
Transfer checked mons to the paired box.
Definition at line 387 of file pokemonstoragemodel.cpp.
References PokemonParty::convertToParty(), getChecked(), getCurBox(), otherModel, party, PokemonStorageBox::pokemon, and PokemonStorageBox::relocateOne().
| void PokemonStorageModel::checkStateDirty | ( | ) |
Mark the checked-state cache stale.
Definition at line 468 of file pokemonstoragemodel.cpp.
References checkedStateDirty, and hasChecked().
Referenced by PokemonStorageModel().
| void PokemonStorageModel::clearCheckedState | ( | ) |
Uncheck everything.
Definition at line 304 of file pokemonstoragemodel.cpp.
References getCurBox(), and isCheckedKey.
Referenced by switchBox().
| void PokemonStorageModel::clearCheckedStateGone | ( | ) |
Clear checked state for removed rows.
Definition at line 313 of file pokemonstoragemodel.cpp.
References getCurBox(), isCheckedKey, and PokemonStorageBox::pokemon.
|
overridevirtual |
Row+role value.
Definition at line 117 of file pokemonstoragemodel.cpp.
References CheckedRole, DexRole, getCurBox(), getPlaceHolderData(), HpMaxRole, HpRole, IndRole, isCheckedKey, IsPartyRole, IsShinyRole, LevelRole, NameRole, NicknameRole, PlaceholderRole, PokemonStorageBox::pokemon, and StatusRole.
| void PokemonStorageModel::deleteMon | ( | int | index, |
| bool | group ) |
Delete the mon at index, or – when group – the whole checked set (the per-cell hover/checked delete button; replaces the old footer release).
Definition at line 627 of file pokemonstoragemodel.cpp.
References checkedDelete(), getCurBox(), and party.
| void PokemonStorageModel::dragReorder | ( | int | fromIndex, |
| int | toIndex, | ||
| bool | group ) |
Reorder within this box: move fromIndex (or the checked set) to toIndex.
Definition at line 511 of file pokemonstoragemodel.cpp.
References getChecked(), getCurBox(), onReset(), and PokemonStorageBox::pokemon.
| void PokemonStorageModel::dragTransfer | ( | int | fromIndex, |
| int | toIndex, | ||
| bool | group ) |
Move fromIndex (or the checked set) from this box into the paired pane's box, inserting at toIndex there.
Definition at line 553 of file pokemonstoragemodel.cpp.
References PokemonParty::convertToParty(), getChecked(), getCurBox(), otherModel, and party.
| PokemonStorageBox * PokemonStorageModel::getBox | ( | int | box | ) | const |
The box object for index box.
Definition at line 98 of file pokemonstoragemodel.cpp.
References party, PartyBox, and storage.
Referenced by getCurBox().
| PokemonBox * PokemonStorageModel::getBoxMon | ( | int | index | ) |
Typed box mon at index (for the details screen).
Definition at line 490 of file pokemonstoragemodel.cpp.
References getCurBox(), and qmlCppOwned().
| QVector< PokemonBox * > PokemonStorageModel::getChecked | ( | ) |
The currently-checked mons.
Definition at line 292 of file pokemonstoragemodel.cpp.
References getCurBox(), and isCheckedKey.
Referenced by checkedDelete(), checkedMoveDown(), checkedMoveToBottom(), checkedMoveToTop(), checkedMoveUp(), checkedTransfer(), dragReorder(), and dragTransfer().
| PokemonStorageBox * PokemonStorageModel::getCurBox | ( | ) | const |
The currently-shown box object.
Definition at line 93 of file pokemonstoragemodel.cpp.
References curBox, and getBox().
Referenced by checkedDelete(), checkedMoveDown(), checkedMoveToBottom(), checkedMoveToTop(), checkedMoveUp(), checkedToggleAll(), checkedTransfer(), clearCheckedState(), clearCheckedStateGone(), data(), deleteMon(), dragReorder(), dragTransfer(), getBoxMon(), getChecked(), getPartyMon(), hasChecked(), onInsert(), rowCount(), setData(), and switchBox().
| PokemonParty * PokemonStorageModel::getPartyMon | ( | int | index | ) |
Typed party mon at index (for the details screen).
Definition at line 501 of file pokemonstoragemodel.cpp.
References getCurBox(), PokemonStorageBox::pokemon, and qmlCppOwned().
| QVariant PokemonStorageModel::getPlaceHolderData | ( | int | role | ) | const |
The empty-slot placeholder row data.
Definition at line 211 of file pokemonstoragemodel.cpp.
References CheckedRole, DexRole, IndRole, NameRole, and PlaceholderRole.
Referenced by data().
| bool PokemonStorageModel::hasChecked | ( | ) |
Are any rows checked (live)?
Definition at line 275 of file pokemonstoragemodel.cpp.
References getCurBox(), and isCheckedKey.
Referenced by checkStateDirty().
| bool PokemonStorageModel::hasCheckedCached | ( | ) |
Cached form (backs the property).
Definition at line 287 of file pokemonstoragemodel.cpp.
References checkedStateDirty.
| void PokemonStorageModel::onBeforeRelocate | ( | PokemonBox * | item | ) |
Cleanup hook before a mon relocates away.
Definition at line 462 of file pokemonstoragemodel.cpp.
References isCheckedKey.
Referenced by switchBox().
| void PokemonStorageModel::onInsert | ( | ) |
| void PokemonStorageModel::onMove | ( | int | from, |
| int | to ) |
| void PokemonStorageModel::onRemove | ( | int | ind | ) |
React to a removal.
Definition at line 254 of file pokemonstoragemodel.cpp.
Referenced by switchBox().
| void PokemonStorageModel::onReset | ( | ) |
React to a reset.
Definition at line 268 of file pokemonstoragemodel.cpp.
Referenced by dragReorder(), PokemonStorageModel(), and switchBox().
| void PokemonStorageModel::pageClosing | ( | ) |
Hook for when the page closes.
Definition at line 479 of file pokemonstoragemodel.cpp.
Referenced by PokemonStorageModel().
|
overridevirtual |
Role -> QML name.
Definition at line 167 of file pokemonstoragemodel.cpp.
References CheckedRole, DexRole, HpMaxRole, HpRole, IndRole, IsPartyRole, IsShinyRole, LevelRole, NameRole, NicknameRole, PlaceholderRole, and StatusRole.
|
overridevirtual |
Row count of the current box.
Definition at line 106 of file pokemonstoragemodel.cpp.
References getCurBox(), and PokemonStorageBox::pokemon.
|
override |
Edit a row (e.g. checkbox).
Definition at line 187 of file pokemonstoragemodel.cpp.
References CheckedRole, getCurBox(), isCheckedKey, and PokemonStorageBox::pokemon.
| void PokemonStorageModel::switchBox | ( | int | newBox, |
| bool | force = false ) |
Show box newBox.
Definition at line 56 of file pokemonstoragemodel.cpp.
References checkedStateDirty, clearCheckedState(), curBox, getCurBox(), onBeforeRelocate(), onMove(), onRemove(), onReset(), PokemonStorageBox::pokemonInsertChange(), PokemonStorageBox::pokemonMoveChange(), PokemonStorageBox::pokemonRemoveChange(), and PokemonStorageBox::pokemonResetChange().
Referenced by PokemonStorageModel().
| bool PokemonStorageModel::checkedStateDirty = false |
Whether the checked-state cache needs refresh.
Definition at line 162 of file pokemonstoragemodel.h.
Referenced by checkStateDirty(), hasCheckedCached(), and switchBox().
| int PokemonStorageModel::curBox = PartyBox |
Definition at line 157 of file pokemonstoragemodel.h.
Referenced by getCurBox(), PokemonStorageModel(), and switchBox().
|
staticconstexpr |
QML attached-property name for the per-row checkbox.
Definition at line 64 of file pokemonstoragemodel.h.
Referenced by checkedToggleAll(), clearCheckedState(), clearCheckedStateGone(), data(), getChecked(), hasChecked(), onBeforeRelocate(), and setData().
| PokemonStorageModel* PokemonStorageModel::otherModel = nullptr |
The paired sibling model (for transfers).
Definition at line 161 of file pokemonstoragemodel.h.
Referenced by checkedTransfer(), and dragTransfer().
| PlayerPokemon* PokemonStorageModel::party = nullptr |
The party.
Definition at line 160 of file pokemonstoragemodel.h.
Referenced by checkedDelete(), checkedTransfer(), deleteMon(), dragTransfer(), getBox(), and PokemonStorageModel().
| Router* PokemonStorageModel::router = nullptr |
For page hooks.
Definition at line 158 of file pokemonstoragemodel.h.
Referenced by PokemonStorageModel().
| Storage* PokemonStorageModel::storage = nullptr |
The PC storage.
Definition at line 159 of file pokemonstoragemodel.h.
Referenced by getBox(), and PokemonStorageModel().