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

Read-only "where are my items" overview for the Bag screen's View All pane. More...

#include <itemoverviewmodel.h>

Inheritance diagram for ItemOverviewModel:
Collaboration diagram for ItemOverviewModel:

Public Types

enum  OverviewRoles { NameRole = Qt::UserRole + 1 , BagCountRole , StorageCountRole }
 Columns (mapped in roleNames()). More...

Public Member Functions

 ItemOverviewModel (ItemStorageBox *bag, ItemStorageBox *storage)
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 rebuild ()
 Re-aggregate both boxes (full model reset). Wired to itemsChanged.

Detailed Description

Read-only "where are my items" overview for the Bag screen's View All pane.

Aggregates the player's two item boxes (bag + PC storage) into one alphabetized table: each distinct item the save holds becomes a row carrying its display name plus the total amount in the bag and the total amount in storage (summed across any duplicate rows – the editor supports same-item duplicates). Rows with a zero total on BOTH sides are dropped; a side that's zero is surfaced as 0 so the view can hide just that number. Rebuilds (full reset) whenever either box changes, so the pane stays live while the user edits. Exposed as brg.itemOverviewModel.

See also
ItemStorageBox, ItemStorageModel (the editable per-box model).

Definition at line 37 of file itemoverviewmodel.h.

Member Enumeration Documentation

◆ OverviewRoles

Columns (mapped in roleNames()).

Enumerator
NameRole 

Display name.

BagCountRole 

Total amount in the bag (0 if none).

StorageCountRole 

Total amount in PC storage (0 if none).

Definition at line 43 of file itemoverviewmodel.h.

Constructor & Destructor Documentation

◆ ItemOverviewModel()

ItemOverviewModel::ItemOverviewModel ( ItemStorageBox * bag,
ItemStorageBox * storage )
Parameters
bagthe player's bag box;
storagethe PC item box.

Definition at line 32 of file itemoverviewmodel.cpp.

References ItemStorageBox::itemsChanged(), and rebuild().

Member Function Documentation

◆ data()

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

Row+role value.

Definition at line 49 of file itemoverviewmodel.cpp.

References BagCountRole, NameRole, and StorageCountRole.

◆ rebuild()

void ItemOverviewModel::rebuild ( )

Re-aggregate both boxes (full model reset). Wired to itemsChanged.

Definition at line 75 of file itemoverviewmodel.cpp.

References ItemStorageBox::items.

Referenced by ItemOverviewModel().

◆ roleNames()

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

Role -> QML name.

Definition at line 66 of file itemoverviewmodel.cpp.

References BagCountRole, NameRole, and StorageCountRole.

◆ rowCount()

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

Row count.

Definition at line 43 of file itemoverviewmodel.cpp.


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