Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
pokemonoverviewmodel.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QObject>
18#include <QString>
19#include <QStringList>
20#include <QVector>
21#include <QCollator>
22#include <QAbstractListModel>
23
24class Storage;
26class PlayerBasics;
27
50class PokemonOverviewModel : public QAbstractListModel
51{
52 Q_OBJECT
53
56 Q_PROPERTY(QStringList columns READ columns NOTIFY columnsChanged)
57
58
59 Q_PROPERTY(int sortSelect MEMBER sortSelect NOTIFY sortSelectChanged)
61 Q_PROPERTY(QString sortLabel READ sortLabel NOTIFY sortSelectChanged)
64 Q_PROPERTY(QString sortIcon READ sortIcon NOTIFY sortSelectChanged)
65
66public:
69 NameRole = Qt::UserRole + 1,
72 };
73
83
87
88 virtual int rowCount(const QModelIndex& parent) const override;
89 virtual QVariant data(const QModelIndex& index, int role) const override;
90 virtual QHash<int, QByteArray> roleNames() const override;
91
92 QStringList columns() const;
93 QString sortLabel() const;
94 QString sortIcon() const;
95
96 Q_INVOKABLE void sortCycle();
97
98public slots:
99 void rebuild();
100
101signals:
104
105private:
108 struct Cell {
109 int count = 0;
110 QString tooltip;
111 };
112
114 struct Row {
115 QString name;
116 int dex;
117 int id;
118 QVector<Cell> cells;
119 };
120
122 Cell buildCell(PokemonStorageBox* box, int speciesId) const;
123
124 void applySort();
125
126 PokemonStorageBox* party = nullptr;
127 Storage* storage = nullptr;
128 PlayerBasics* basics = nullptr;
129
130 QVector<PokemonStorageBox*> colBoxes;
131 QStringList colLabels;
132 QVector<Row> rows;
133
134 int sortSelect = SortName;
135};
The trainer's headline values: name, ID, money, coins, badges, starter.
void sortCycle()
Advance to the next species sort order (re-sorts in place).
SortSelect
Species-column sort orders – the SAME set the Pokedex screen cycles (PokedexModel::PokemonSortSelect)...
@ SortInternal
Internal / creation (raw species id) order.
@ SortName
Alphabetical by species name.
@ SortDex
Pokedex number order.
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
protected::void columnsChanged()
OverviewRoles
Column header labels, in display order (e.g.
@ CountsRole
Per-column counts (QVariantList<int>, aligned to columns).
@ TooltipsRole
Per-column hover tooltips (QVariantList<QString>; empty when count 0).
@ NameRole
Species display name.
virtual int rowCount(const QModelIndex &parent) const override
Row count.
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
PokemonOverviewModel(PokemonStorageBox *party, Storage *storage, PlayerBasics *basics)
QStringList columns() const
void rebuild()
Re-aggregate the party + boxes (full model reset). Wired to pokemonChanged.
Holds contents of a single Pokemon storage box.
The PC: the item storage box and all 12 Pokemon boxes.
Definition storage.h:49