|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
Editable list model for an item box (the bag or a PC item box). More...
#include <itemstoragemodel.h>
Public Types | |
| enum | BagItemRoles { IdRole = Qt::UserRole + 1 , CountRole , CheckedRole , PlaceholderRole } |
| Columns (mapped in roleNames()). More... | |
Public Member Functions | |
| ItemStorageModel (ItemStorageBox *items, 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. | |
| 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's data. | |
| void | onMove (int from, int to) |
| React to a box move. | |
| void | onRemove (int ind) |
| React to a box removal. | |
| void | onInsert () |
| React to a box insert. | |
| void | onReset () |
| React to a box reset. | |
| bool | hasChecked () |
| Are any rows checked (live)? | |
| bool | hasCheckedCached () |
| Cached form (backs the property). | |
| QVector< Item * > | getChecked () |
| The currently-checked items. | |
| void | onBeforeRelocate (Item *item) |
| Cleanup hook before an item relocates away. | |
| void | checkStateDirty () |
| Mark the checked-state cache stale. | |
| void | pageClosing () |
| Hook for when the page closes. | |
| 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 box, inserting at toIndex there. | |
| void | deleteItem (int index, bool group) |
Delete the item at index, or – when group – the whole checked set (the per-row hover/checked delete button; replaces the old footer delete). | |
| void | clearCheckedState () |
| Uncheck everything. | |
| void | clearCheckedStateGone () |
| Clear checked state for removed rows. | |
| void | checkedMoveToTop () |
| Move checked rows to the top. | |
| void | checkedMoveUp () |
| Move checked rows up one. | |
| void | checkedMoveDown () |
| Move checked rows down one. | |
| void | checkedMoveToBottom () |
| Move checked rows to the bottom. | |
| void | checkedDelete () |
| Delete checked rows. | |
| void | checkedTransfer () |
| Transfer checked rows to the paired box. | |
| void | checkedToggleAll () |
| Toggle all checkboxes. | |
Public Attributes | |
| ItemStorageBox * | items = nullptr |
| The wrapped item box. | |
| Router * | router |
| For page hooks. | |
| ItemStorageModel * | otherModel = nullptr |
| The paired sibling model (for cross-pane 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 an item box (the bag or a PC item box).
Wraps an ItemStorageBox (see CreditsModel for the base convention) as an editable model: rows can be reordered/removed/inserted, and each row carries a checkbox state (a QML attached property, isCheckedKey). The checked* slots act on the checked rows in bulk – move up/down/top/bottom, delete, transfer (to the paired box), toggle-all. hasChecked drives "any selected" UI. Exposed as brg.bagItemsModel / brg.pcItemsModel.
Definition at line 38 of file itemstoragemodel.h.
Columns (mapped in roleNames()).
| Enumerator | |
|---|---|
| IdRole | |
| CountRole | |
| CheckedRole | |
| PlaceholderRole | |
Definition at line 54 of file itemstoragemodel.h.
| ItemStorageModel::ItemStorageModel | ( | ItemStorageBox * | items, |
| Router * | router ) |
| items | the box; |
| router | for page hooks. |
Definition at line 32 of file itemstoragemodel.cpp.
References checkStateDirty(), ItemStorageBox::itemInsertChange(), ItemStorageBox::itemMoveChange(), ItemStorageBox::itemRemoveChange(), items, ItemStorageBox::itemsResetChange(), onBeforeRelocate(), onMove(), onRemove(), onReset(), pageClosing(), and router.
| void ItemStorageModel::checkedDelete | ( | ) |
Delete checked rows.
Definition at line 299 of file itemstoragemodel.cpp.
References getChecked(), and items.
Referenced by deleteItem().
| void ItemStorageModel::checkedMoveDown | ( | ) |
Move checked rows down one.
Definition at line 273 of file itemstoragemodel.cpp.
References getChecked(), and items.
| void ItemStorageModel::checkedMoveToBottom | ( | ) |
Move checked rows to the bottom.
Definition at line 286 of file itemstoragemodel.cpp.
References getChecked(), and items.
| void ItemStorageModel::checkedMoveToTop | ( | ) |
Move checked rows to the top.
Definition at line 257 of file itemstoragemodel.cpp.
References getChecked(), and items.
| void ItemStorageModel::checkedMoveUp | ( | ) |
Move checked rows up one.
Definition at line 265 of file itemstoragemodel.cpp.
References getChecked(), and items.
| void ItemStorageModel::checkedToggleAll | ( | ) |
Toggle all checkboxes.
Definition at line 317 of file itemstoragemodel.cpp.
References isCheckedKey, and items.
| void ItemStorageModel::checkedTransfer | ( | ) |
Transfer checked rows to the paired box.
Definition at line 307 of file itemstoragemodel.cpp.
References getChecked(), and items.
| void ItemStorageModel::checkStateDirty | ( | ) |
Mark the checked-state cache stale.
Definition at line 352 of file itemstoragemodel.cpp.
References checkedStateDirty, and hasChecked().
Referenced by ItemStorageModel().
| void ItemStorageModel::clearCheckedState | ( | ) |
Uncheck everything.
Definition at line 237 of file itemstoragemodel.cpp.
References isCheckedKey, and items.
Referenced by pageClosing().
| void ItemStorageModel::clearCheckedStateGone | ( | ) |
Clear checked state for removed rows.
Definition at line 246 of file itemstoragemodel.cpp.
References isCheckedKey, and items.
|
overridevirtual |
Row+role value.
Definition at line 68 of file itemstoragemodel.cpp.
References CheckedRole, CountRole, getPlaceHolderData(), IdRole, isCheckedKey, items, and PlaceholderRole.
| void ItemStorageModel::deleteItem | ( | int | index, |
| bool | group ) |
Delete the item at index, or – when group – the whole checked set (the per-row hover/checked delete button; replaces the old footer delete).
Definition at line 505 of file itemstoragemodel.cpp.
References checkedDelete(), and items.
| void ItemStorageModel::dragReorder | ( | int | fromIndex, |
| int | toIndex, | ||
| bool | group ) |
Reorder within this box: move fromIndex (or the checked set) to toIndex.
Definition at line 369 of file itemstoragemodel.cpp.
References getChecked(), items, and onReset().
| void ItemStorageModel::dragTransfer | ( | int | fromIndex, |
| int | toIndex, | ||
| bool | group ) |
Move fromIndex (or the checked set) from this box into the paired box, inserting at toIndex there.
Definition at line 410 of file itemstoragemodel.cpp.
References Item::amount, getChecked(), items, otherModel, and Item::setAmount().
| QVector< Item * > ItemStorageModel::getChecked | ( | ) |
The currently-checked items.
Definition at line 225 of file itemstoragemodel.cpp.
References isCheckedKey, and items.
Referenced by checkedDelete(), checkedMoveDown(), checkedMoveToBottom(), checkedMoveToTop(), checkedMoveUp(), checkedTransfer(), dragReorder(), and dragTransfer().
| QVariant ItemStorageModel::getPlaceHolderData | ( | int | role | ) | const |
The "empty slot" placeholder row's data.
Definition at line 146 of file itemstoragemodel.cpp.
References CheckedRole, CountRole, IdRole, and PlaceholderRole.
Referenced by data().
| bool ItemStorageModel::hasChecked | ( | ) |
Are any rows checked (live)?
Definition at line 208 of file itemstoragemodel.cpp.
References isCheckedKey, and items.
Referenced by checkStateDirty().
| bool ItemStorageModel::hasCheckedCached | ( | ) |
Cached form (backs the property).
Definition at line 220 of file itemstoragemodel.cpp.
References checkedStateDirty.
| void ItemStorageModel::onBeforeRelocate | ( | Item * | item | ) |
Cleanup hook before an item relocates away.
Definition at line 346 of file itemstoragemodel.cpp.
References isCheckedKey.
Referenced by ItemStorageModel().
| void ItemStorageModel::onInsert | ( | ) |
| void ItemStorageModel::onMove | ( | int | from, |
| int | to ) |
React to a box move.
Definition at line 168 of file itemstoragemodel.cpp.
Referenced by ItemStorageModel().
| void ItemStorageModel::onRemove | ( | int | ind | ) |
React to a box removal.
Definition at line 187 of file itemstoragemodel.cpp.
Referenced by ItemStorageModel().
| void ItemStorageModel::onReset | ( | ) |
React to a box reset.
Definition at line 201 of file itemstoragemodel.cpp.
Referenced by dragReorder(), and ItemStorageModel().
| void ItemStorageModel::pageClosing | ( | ) |
Hook for when the page closes.
Definition at line 363 of file itemstoragemodel.cpp.
References checkedStateDirty, and clearCheckedState().
Referenced by ItemStorageModel().
|
overridevirtual |
Role -> QML name.
Definition at line 100 of file itemstoragemodel.cpp.
References CheckedRole, CountRole, IdRole, and PlaceholderRole.
|
overridevirtual |
|
override |
Edit a row (e.g. checkbox).
Definition at line 112 of file itemstoragemodel.cpp.
References CheckedRole, CountRole, IdRole, isCheckedKey, and items.
| bool ItemStorageModel::checkedStateDirty = false |
Whether the checked-state cache needs refresh.
Definition at line 124 of file itemstoragemodel.h.
Referenced by checkStateDirty(), hasCheckedCached(), and pageClosing().
|
staticconstexpr |
QML attached-property name for the per-row checkbox.
Definition at line 51 of file itemstoragemodel.h.
Referenced by checkedToggleAll(), clearCheckedState(), clearCheckedStateGone(), data(), getChecked(), hasChecked(), onBeforeRelocate(), and setData().
| ItemStorageBox* ItemStorageModel::items = nullptr |
The wrapped item box.
Definition at line 121 of file itemstoragemodel.h.
Referenced by checkedDelete(), checkedMoveDown(), checkedMoveToBottom(), checkedMoveToTop(), checkedMoveUp(), checkedToggleAll(), checkedTransfer(), clearCheckedState(), clearCheckedStateGone(), data(), deleteItem(), dragReorder(), dragTransfer(), getChecked(), hasChecked(), ItemStorageModel(), onInsert(), rowCount(), and setData().
| ItemStorageModel* ItemStorageModel::otherModel = nullptr |
The paired sibling model (for cross-pane transfers).
Definition at line 123 of file itemstoragemodel.h.
Referenced by dragTransfer().
| Router* ItemStorageModel::router |
For page hooks.
Definition at line 122 of file itemstoragemodel.h.
Referenced by ItemStorageModel().