Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
flydbentry.cpp
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
21
22#include <QtDebug>
23#include <QQmlEngine>
24#include <pse-common/utility.h>
25
26#include "flydbentry.h"
27#include "../mapsdb.h"
28#include "./mapdbentry.h"
29
33
34FlyDBEntry::FlyDBEntry(QJsonValue& data)
35{
37
38 // Set simple properties
39 name = data["name"].toString();
40 ind = data["ind"].toDouble();
41}
42
44{
46
47#ifdef QT_DEBUG
48 if(toMap == nullptr)
49 qCritical() << "Fly Destination: " << name << ", could not be deep linked." ;
50#endif
51
52 if(toMap != nullptr)
53 toMap->toFlyDestination = this;
54}
55
57{
58 return toMap;
59}
60
61void FlyDBEntry::qmlProtect(const QQmlEngine* const engine) const
62{
63 Utility::qmlProtectUtil(this, engine);
64}
65
67{
68 return ind;
69}
70
71QString FlyDBEntry::getName() const
72{
73 return name;
74}
75
77{
78 static bool once = false;
79 if (once) return;
80 qmlRegisterUncreatableType<FlyDBEntry>("PSE.DB.FlyDBEntry", 1, 0, "FlyDBEntry", "Can't instantiate in QML");
81 once = true;
82}
static MapsDB * inst()
< Number of maps.
Definition mapsdb.cpp:35
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition mapsdb.cpp:155
static void qmlProtectUtil(const QObject *const obj, const QQmlEngine *const engine)
Pin obj to C++ ownership so the QML engine never garbage-collects it.
Definition utility.cpp:63
int getInd() const
QString getName() const
< Destination name.
void qmlRegister() const
Register with QML.
QString name
Backing field (read via getName()).
Definition flydbentry.h:57
int ind
Backing field (read via getInd()).
Definition flydbentry.h:58
MapDBEntry * toMap
Backing field (read via getToMap()).
Definition flydbentry.h:59
MapDBEntry * getToMap() const
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
void deepLink()
Resolve the destination map.
FlyDBEntry()
Empty entry (built by FlyDB).
One map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56