Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
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
23class PlayerPokedex;
24class Router;
25
28 PokedexEntryData(QString name, int dex, int id);
29
30 QString name;
31 int dex;
32 int id;
33};
34
43class PokedexModel : public QAbstractListModel
44{
45 Q_OBJECT
46
47 Q_PROPERTY(int dexSortSelect MEMBER dexSortSelect NOTIFY dexSortSelectChanged)
48
49signals:
50 void dexSortSelectChanged();
51
52public:
55 IndRole = Qt::UserRole + 1,
57 StateRole, // 0 = None, 1 = Seen, 2 = Owned
58 };
59
63
64 SortDex, // Pokedex Order
65 SortName, // Alphabetical Order
66 SortInternal, // Internal and Potential Creation Order
67
69 };
70
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
88 QVector<PokedexEntryData*> dexListCache;
90 Router* router = nullptr;
91
92 int dexToListIndex(int ind);
93};
The player's Pokedex: a seen flag and an owned flag per species.
virtual int rowCount(const QModelIndex &parent) const override
Row count.
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
void pageClosing()
Hook for when the dex page closes.
void dexSortInternal()
Sort by internal id.
void dexSort()
Apply the current sort.
PokemonStarterRoles
Columns (mapped in roleNames()).
void dexSortCycle()
Advance to the next sort order.
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
QVector< PokedexEntryData * > dexListCache
Cached, currently-sorted rows.
PokemonSortSelect
The available sort orders (cycled by dexSortCycle()).
int dexToListIndex(int ind)
Row index for species ind under the current sort.
void dexSortName()
Sort alphabetically.
PokedexModel(PlayerPokedex *pokedex, Router *router)
PlayerPokedex * pokedex
The save's dex.
Router * router
For page open/close hooks.
void dataChanged(int ind)
Notify that dex entry ind changed.
void dexSortNum()
Sort by dex number.
Screen navigation for the UI – the QML StackView's controller.
Definition router.h:74
QString name
Species name.
int id
Internal id.
PokedexEntryData(QString name, int dex, int id)
int dex
Pokedex number.