Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
pokedexmodel.h
Go to the documentation of this file.
1
/*
2
* Copyright 2020 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 <QCollator>
18
#include <QObject>
19
#include <QString>
20
#include <QAbstractListModel>
21
#include <QVector>
22
23
class
PlayerPokedex
;
24
class
Router
;
25
27
struct
PokedexEntryData
{
28
PokedexEntryData
(QString
name
,
int
dex
,
int
id
);
29
30
QString
name
;
31
int
dex
;
32
int
id
;
33
};
34
43
class
PokedexModel
:
public
QAbstractListModel
44
{
45
Q_OBJECT
46
47
Q_PROPERTY(
int
dexSortSelect
MEMBER
dexSortSelect
NOTIFY dexSortSelectChanged)
48
49
signals:
50
void
dexSortSelectChanged();
51
52
public
:
54
enum
PokemonStarterRoles
{
55
IndRole
= Qt::UserRole + 1,
56
NameRole
,
57
StateRole
,
// 0 = None, 1 = Seen, 2 = Owned
58
};
59
61
enum
PokemonSortSelect
{
62
SortBegin
,
63
64
SortDex
,
// Pokedex Order
65
SortName
,
// Alphabetical Order
66
SortInternal
,
// Internal and Potential Creation Order
67
68
SortEnd
69
};
70
71
PokedexModel
(
PlayerPokedex
*
pokedex
,
Router
*
router
);
72
73
virtual
int
rowCount
(
const
QModelIndex& parent)
const override
;
74
virtual
QVariant
data
(
const
QModelIndex& index,
int
role)
const override
;
75
virtual
QHash<int, QByteArray>
roleNames
()
const override
;
76
77
void
dataChanged
(
int
ind);
78
79
Q_INVOKABLE
void
dexSortCycle
();
80
void
dexSort
();
81
void
dexSortName
();
82
void
dexSortNum
();
83
void
dexSortInternal
();
84
85
void
pageClosing
();
86
87
int
dexSortSelect
=
SortDex
;
88
QVector<PokedexEntryData*>
dexListCache
;
89
PlayerPokedex
*
pokedex
=
nullptr
;
90
Router
*
router
=
nullptr
;
91
92
int
dexToListIndex
(
int
ind);
93
};
PlayerPokedex
The player's Pokedex: a seen flag and an owned flag per species.
Definition
playerpokedex.h:37
PokedexModel::rowCount
virtual int rowCount(const QModelIndex &parent) const override
Row count.
Definition
pokedexmodel.cpp:63
PokedexModel::roleNames
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
Definition
pokedexmodel.cpp:103
PokedexModel::dexSortSelect
int dexSortSelect
Definition
pokedexmodel.h:87
PokedexModel::pageClosing
void pageClosing()
Hook for when the dex page closes.
Definition
pokedexmodel.cpp:195
PokedexModel::dexSortInternal
void dexSortInternal()
Sort by internal id.
Definition
pokedexmodel.cpp:185
PokedexModel::dexSort
void dexSort()
Apply the current sort.
Definition
pokedexmodel.cpp:133
PokedexModel::PokemonStarterRoles
PokemonStarterRoles
Columns (mapped in roleNames()).
Definition
pokedexmodel.h:54
PokedexModel::IndRole
@ IndRole
Definition
pokedexmodel.h:55
PokedexModel::StateRole
@ StateRole
Definition
pokedexmodel.h:57
PokedexModel::NameRole
@ NameRole
Definition
pokedexmodel.h:56
PokedexModel::dexSortCycle
void dexSortCycle()
Advance to the next sort order.
Definition
pokedexmodel.cpp:124
PokedexModel::data
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
Definition
pokedexmodel.cpp:72
PokedexModel::dexListCache
QVector< PokedexEntryData * > dexListCache
Cached, currently-sorted rows.
Definition
pokedexmodel.h:88
PokedexModel::PokemonSortSelect
PokemonSortSelect
The available sort orders (cycled by dexSortCycle()).
Definition
pokedexmodel.h:61
PokedexModel::SortName
@ SortName
Definition
pokedexmodel.h:65
PokedexModel::SortDex
@ SortDex
Definition
pokedexmodel.h:64
PokedexModel::SortInternal
@ SortInternal
Definition
pokedexmodel.h:66
PokedexModel::SortEnd
@ SortEnd
Definition
pokedexmodel.h:68
PokedexModel::SortBegin
@ SortBegin
Definition
pokedexmodel.h:62
PokedexModel::dexToListIndex
int dexToListIndex(int ind)
Row index for species ind under the current sort.
Definition
pokedexmodel.cpp:204
PokedexModel::dexSortName
void dexSortName()
Sort alphabetically.
Definition
pokedexmodel.cpp:158
PokedexModel::PokedexModel
PokedexModel(PlayerPokedex *pokedex, Router *router)
Definition
pokedexmodel.cpp:35
PokedexModel::pokedex
PlayerPokedex * pokedex
The save's dex.
Definition
pokedexmodel.h:89
PokedexModel::router
Router * router
For page open/close hooks.
Definition
pokedexmodel.h:90
PokedexModel::dataChanged
void dataChanged(int ind)
Notify that dex entry ind changed.
Definition
pokedexmodel.cpp:114
PokedexModel::dexSortNum
void dexSortNum()
Sort by dex number.
Definition
pokedexmodel.cpp:175
Router
Screen navigation for the UI – the QML StackView's controller.
Definition
router.h:74
PokedexEntryData::name
QString name
Species name.
Definition
pokedexmodel.h:30
PokedexEntryData::id
int id
Internal id.
Definition
pokedexmodel.h:32
PokedexEntryData::PokedexEntryData
PokedexEntryData(QString name, int dex, int id)
Definition
pokedexmodel.cpp:29
PokedexEntryData::dex
int dex
Pokedex number.
Definition
pokedexmodel.h:31
projects
app
src
mvc
pokedexmodel.h
Generated by
1.17.0