Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
itemoverviewmodel.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 <QVector>
20
#include <QAbstractListModel>
21
22
class
ItemStorageBox
;
23
37
class
ItemOverviewModel
:
public
QAbstractListModel
38
{
39
Q_OBJECT
40
41
public
:
43
enum
OverviewRoles
{
44
NameRole
= Qt::UserRole + 1,
45
BagCountRole
,
46
StorageCountRole
,
47
};
48
50
ItemOverviewModel
(
ItemStorageBox
* bag,
ItemStorageBox
* storage);
51
52
virtual
int
rowCount
(
const
QModelIndex& parent)
const override
;
53
virtual
QVariant
data
(
const
QModelIndex& index,
int
role)
const override
;
54
virtual
QHash<int, QByteArray>
roleNames
()
const override
;
55
56
public
slots:
57
void
rebuild
();
58
59
private
:
61
struct
Row {
62
QString name;
63
int
bag;
64
int
storage;
65
};
66
67
ItemStorageBox* bag =
nullptr
;
68
ItemStorageBox* storage =
nullptr
;
69
QVector<Row> rows;
70
};
ItemOverviewModel::rebuild
void rebuild()
Re-aggregate both boxes (full model reset). Wired to itemsChanged.
Definition
itemoverviewmodel.cpp:75
ItemOverviewModel::rowCount
virtual int rowCount(const QModelIndex &parent) const override
Row count.
Definition
itemoverviewmodel.cpp:43
ItemOverviewModel::ItemOverviewModel
ItemOverviewModel(ItemStorageBox *bag, ItemStorageBox *storage)
Definition
itemoverviewmodel.cpp:32
ItemOverviewModel::data
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
Definition
itemoverviewmodel.cpp:49
ItemOverviewModel::roleNames
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
Definition
itemoverviewmodel.cpp:66
ItemOverviewModel::OverviewRoles
OverviewRoles
Columns (mapped in roleNames()).
Definition
itemoverviewmodel.h:43
ItemOverviewModel::StorageCountRole
@ StorageCountRole
Total amount in PC storage (0 if none).
Definition
itemoverviewmodel.h:46
ItemOverviewModel::BagCountRole
@ BagCountRole
Total amount in the bag (0 if none).
Definition
itemoverviewmodel.h:45
ItemOverviewModel::NameRole
@ NameRole
Display name.
Definition
itemoverviewmodel.h:44
ItemStorageBox
A container of Items – either the trainer's bag or a PC item box.
Definition
itemstoragebox.h:36
projects
app
src
mvc
itemoverviewmodel.h
Generated by
1.17.0