Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
flydb.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 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 <QHash>
20#include <QJsonValue>
21#include <QVector>
22
23#include "./db_autoport.h"
24
25class FlyDBEntry;
26class QQmlEngine;
27
37class DB_AUTOPORT FlyDB : public QObject
38{
39 Q_OBJECT
40 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
41
42public:
43 // Get Instance
44 static FlyDB* inst();
45
46 // Get Properties, includes QML array helpers
47 const QVector<FlyDBEntry*> getStore() const;
48 const QHash<QString, FlyDBEntry*> getInd() const;
49 int getStoreSize() const;
50
51 // QML Methods that can't be a property or slot because they take an argument
52 Q_INVOKABLE FlyDBEntry* getStoreAt(const int ind) const;
53 Q_INVOKABLE FlyDBEntry* getIndAt(const QString val) const;
54
55public slots:
56 void load();
57 void index();
58 void deepLink();
59 void qmlProtect(const QQmlEngine* const engine) const;
60
61private slots:
62 void qmlRegister() const;
63
64public:
65 FlyDB();
66
67 QVector<FlyDBEntry*> store;
68 QHash<QString, FlyDBEntry*> ind;
69};
FlyDBEntry * getIndAt(const QString val) const
Destination by name key (for QML).
Definition flydb.cpp:65
void deepLink()
Resolve each destination's map link.
Definition flydb.cpp:108
void index()
Build the name->entry index.
Definition flydb.cpp:92
static FlyDB * inst()
< Number of fly destinations.
Definition flydb.cpp:36
FlyDB()
(Public here, but obtain the singleton via inst().)
Definition flydb.cpp:139
int getStoreSize() const
Destination count.
Definition flydb.cpp:52
QVector< FlyDBEntry * > store
The loaded destinations.
Definition flydb.h:67
FlyDBEntry * getStoreAt(const int ind) const
Destination by store index (for QML).
Definition flydb.cpp:57
void load()
Load destinations from JSON.
Definition flydb.cpp:70
QHash< QString, FlyDBEntry * > ind
Name->entry lookup.
Definition flydb.h:68
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition flydb.cpp:122
const QHash< QString, FlyDBEntry * > getInd() const
Name->entry index.
Definition flydb.cpp:47
const QVector< FlyDBEntry * > getStore() const
All fly destinations.
Definition flydb.cpp:42
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 fly destination: its name/index and the map it flies to.
Definition flydbentry.h:37