Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
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
22class ItemStorageBox;
23
37class ItemOverviewModel : public QAbstractListModel
38{
39 Q_OBJECT
40
41public:
48
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
56public slots:
57 void rebuild();
58
59private:
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};
void rebuild()
Re-aggregate both boxes (full model reset). Wired to itemsChanged.
virtual int rowCount(const QModelIndex &parent) const override
Row count.
ItemOverviewModel(ItemStorageBox *bag, ItemStorageBox *storage)
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
OverviewRoles
Columns (mapped in roleNames()).
@ StorageCountRole
Total amount in PC storage (0 if none).
@ BagCountRole
Total amount in the bag (0 if none).
@ NameRole
Display name.
A container of Items – either the trainer's bag or a PC item box.