Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
creditsdb.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// With amazing help of Quicktype!!!
18// https://app.quicktype.io
19
20#include <QObject>
21#include <QVector>
22
23#include "./db_autoport.h"
24
25class QQmlEngine;
26struct CreditDBEntry;
27
47// Singleton accessible, registered to, and protected from QML
48class DB_AUTOPORT CreditsDB : public QObject
49{
50 Q_OBJECT
51 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
52
53public:
55 static CreditsDB* inst();
56
57 // Get Properties, includes QML array helpers
58 const QVector<CreditDBEntry*> getStore() const;
59 int getStoreSize() const;
60
61 // QML Methods that can't be a property or slot because they take an argument
62 Q_INVOKABLE CreditDBEntry* getStoreAt(const int ind) const;
63
64public slots:
65 // QML accessible methods
66 void load();
67 void qmlProtect(const QQmlEngine* const engine) const;
68
69private slots:
70 void qmlRegister() const;
71
72private:
73 // Singleton Constructor
74 CreditsDB();
75
76 // Store
77 QVector<CreditDBEntry*> store;
78
79 // Allow modifications from these classes
80 friend struct CreditDBEntry;
81};
const QVector< CreditDBEntry * > getStore() const
The full entry vector.
Definition creditsdb.cpp:39
int getStoreSize() const
Entry count (backs getStoreSize).
Definition creditsdb.cpp:44
void load()
Load entries from the JSON assets.
Definition creditsdb.cpp:60
static CreditsDB * inst()
< Number of credit entries.
Definition creditsdb.cpp:33
friend struct CreditDBEntry
Lets entries populate the store during load.
Definition creditsdb.h:80
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership (anti-GC).
Definition creditsdb.cpp:78
CreditDBEntry * getStoreAt(const int ind) const
Entry at ind (for QML).
Definition creditsdb.cpp:49
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37
One credits entry – and the canonical example of the "DB entry" pattern.