Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
23
struct
SpeciesSelectEntry
{
24
SpeciesSelectEntry
(QString
name
,
int
ind
);
25
26
QString
name
;
27
int
ind
;
28
};
29
41
class
SpeciesSelectModel
:
public
QAbstractListModel
42
{
43
Q_OBJECT
44
45
public
:
47
enum
ItemRoles
{
48
IndRole
= Qt::UserRole + 1,
49
NameRole
,
50
};
51
52
SpeciesSelectModel
();
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
};
SpeciesSelectModel::data
virtual QVariant data(const QModelIndex &index, int role) const override
Value for a row + role.
Definition
speciesselectmodel.cpp:97
SpeciesSelectModel::rowCount
virtual int rowCount(const QModelIndex &parent) const override
Number of species rows.
Definition
speciesselectmodel.cpp:88
SpeciesSelectModel::speciesListCache
QVector< SpeciesSelectEntry * > speciesListCache
Cached picker rows.
Definition
speciesselectmodel.h:58
SpeciesSelectModel::SpeciesSelectModel
SpeciesSelectModel()
Build the cache from the species DB.
Definition
speciesselectmodel.cpp:33
SpeciesSelectModel::speciesToListIndex
int speciesToListIndex(int ind)
Row index for species ind (for combo highlighting).
Definition
speciesselectmodel.cpp:132
SpeciesSelectModel::roleNames
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name map.
Definition
speciesselectmodel.cpp:122
SpeciesSelectModel::ItemRoles
ItemRoles
Picker columns (mapped to names in roleNames()).
Definition
speciesselectmodel.h:47
SpeciesSelectModel::IndRole
@ IndRole
Definition
speciesselectmodel.h:48
SpeciesSelectModel::NameRole
@ NameRole
Definition
speciesselectmodel.h:49
SpeciesSelectEntry::name
QString name
Display name.
Definition
speciesselectmodel.h:26
SpeciesSelectEntry::ind
int ind
Species index.
Definition
speciesselectmodel.h:27
SpeciesSelectEntry::SpeciesSelectEntry
SpeciesSelectEntry(QString name, int ind)
Definition
speciesselectmodel.cpp:28
projects
app
src
mvc
speciesselectmodel.h
Generated by
1.17.0