Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
speciesselectmodel.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 <QObject>
18#include <QString>
19#include <QAbstractListModel>
20#include <QVector>
21
24 SpeciesSelectEntry(QString name, int ind);
25
26 QString name;
27 int ind;
28};
29
41class SpeciesSelectModel : public QAbstractListModel
42{
43 Q_OBJECT
44
45public:
47 enum ItemRoles {
48 IndRole = Qt::UserRole + 1,
50 };
51
53
54 virtual int rowCount(const QModelIndex& parent) const override;
55 virtual QVariant data(const QModelIndex& index, int role) const override;
56 virtual QHash<int, QByteArray> roleNames() const override;
57
58 QVector<SpeciesSelectEntry*> speciesListCache;
59
60 Q_INVOKABLE int speciesToListIndex(int ind);
61};
virtual QVariant data(const QModelIndex &index, int role) const override
Value for a row + role.
virtual int rowCount(const QModelIndex &parent) const override
Number of species rows.
QVector< SpeciesSelectEntry * > speciesListCache
Cached picker rows.
SpeciesSelectModel()
Build the cache from the species DB.
int speciesToListIndex(int ind)
Row index for species ind (for combo highlighting).
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name map.
ItemRoles
Picker columns (mapped to names in roleNames()).
QString name
Display name.
int ind
Species index.
SpeciesSelectEntry(QString name, int ind)