Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
24
class
Storage
;
25
class
PokemonStorageBox
;
26
class
PlayerBasics
;
27
50
class
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
66
public
:
68
enum
OverviewRoles
{
69
NameRole
= Qt::UserRole + 1,
70
CountsRole
,
71
TooltipsRole
,
72
};
73
76
enum
SortSelect
{
77
SortBegin
,
78
SortDex
,
79
SortName
,
80
SortInternal
,
81
SortEnd
82
};
83
86
PokemonOverviewModel
(
PokemonStorageBox
* party,
Storage
* storage,
PlayerBasics
* basics);
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
98
public
slots:
99
void
rebuild
();
100
101
signals:
102
void
columnsChanged
();
103
void
sortSelectChanged
();
104
105
private
:
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
};
PlayerBasics
The trainer's headline values: name, ID, money, coins, badges, starter.
Definition
playerbasics.h:67
PokemonOverviewModel::sortSelectChanged
void sortSelectChanged()
PokemonOverviewModel::sortCycle
void sortCycle()
Advance to the next species sort order (re-sorts in place).
Definition
pokemonoverviewmodel.cpp:280
PokemonOverviewModel::sortIcon
QString sortIcon() const
Definition
pokemonoverviewmodel.cpp:305
PokemonOverviewModel::sortLabel
QString sortLabel() const
Definition
pokemonoverviewmodel.cpp:295
PokemonOverviewModel::SortSelect
SortSelect
Species-column sort orders – the SAME set the Pokedex screen cycles (PokedexModel::PokemonSortSelect)...
Definition
pokemonoverviewmodel.h:76
PokemonOverviewModel::SortInternal
@ SortInternal
Internal / creation (raw species id) order.
Definition
pokemonoverviewmodel.h:80
PokemonOverviewModel::SortEnd
@ SortEnd
Definition
pokemonoverviewmodel.h:81
PokemonOverviewModel::SortBegin
@ SortBegin
Definition
pokemonoverviewmodel.h:77
PokemonOverviewModel::SortName
@ SortName
Alphabetical by species name.
Definition
pokemonoverviewmodel.h:79
PokemonOverviewModel::SortDex
@ SortDex
Pokedex number order.
Definition
pokemonoverviewmodel.h:78
PokemonOverviewModel::roleNames
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
Definition
pokemonoverviewmodel.cpp:113
PokemonOverviewModel::columnsChanged
protected::void columnsChanged()
PokemonOverviewModel::OverviewRoles
OverviewRoles
Column header labels, in display order (e.g.
Definition
pokemonoverviewmodel.h:68
PokemonOverviewModel::CountsRole
@ CountsRole
Per-column counts (QVariantList<int>, aligned to columns).
Definition
pokemonoverviewmodel.h:70
PokemonOverviewModel::TooltipsRole
@ TooltipsRole
Per-column hover tooltips (QVariantList<QString>; empty when count 0).
Definition
pokemonoverviewmodel.h:71
PokemonOverviewModel::NameRole
@ NameRole
Species display name.
Definition
pokemonoverviewmodel.h:69
PokemonOverviewModel::rowCount
virtual int rowCount(const QModelIndex &parent) const override
Row count.
Definition
pokemonoverviewmodel.cpp:73
PokemonOverviewModel::data
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
Definition
pokemonoverviewmodel.cpp:84
PokemonOverviewModel::PokemonOverviewModel
PokemonOverviewModel(PokemonStorageBox *party, Storage *storage, PlayerBasics *basics)
Definition
pokemonoverviewmodel.cpp:50
PokemonOverviewModel::columns
QStringList columns() const
Definition
pokemonoverviewmodel.cpp:79
PokemonOverviewModel::rebuild
void rebuild()
Re-aggregate the party + boxes (full model reset). Wired to pokemonChanged.
Definition
pokemonoverviewmodel.cpp:194
PokemonStorageBox
Holds contents of a single Pokemon storage box.
Definition
pokemonstoragebox.h:49
Storage
The PC: the item storage box and all 12 Pokemon boxes.
Definition
storage.h:49
projects
app
src
mvc
pokemonoverviewmodel.h
Generated by
1.17.0