Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
30
FlyDBEntry::FlyDBEntry
() {
31
qmlRegister
();
32
}
33
34
FlyDBEntry::FlyDBEntry
(QJsonValue& data)
35
{
36
qmlRegister
();
37
38
// Set simple properties
39
name
= data[
"name"
].toString();
40
ind
= data[
"ind"
].toDouble();
41
}
42
43
void
FlyDBEntry::deepLink
()
44
{
45
toMap
=
MapsDB::inst
()->
getIndAt
(
name
);
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
56
MapDBEntry
*
FlyDBEntry::getToMap
()
const
57
{
58
return
toMap
;
59
}
60
61
void
FlyDBEntry::qmlProtect
(
const
QQmlEngine*
const
engine)
const
62
{
63
Utility::qmlProtectUtil
(
this
, engine);
64
}
65
66
int
FlyDBEntry::getInd
()
const
67
{
68
return
ind
;
69
}
70
71
QString
FlyDBEntry::getName
()
const
72
{
73
return
name
;
74
}
75
76
void
FlyDBEntry::qmlRegister
()
const
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
}
MapsDB::inst
static MapsDB * inst()
< Number of maps.
Definition
mapsdb.cpp:35
MapsDB::getIndAt
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition
mapsdb.cpp:155
Utility::qmlProtectUtil
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
flydbentry.h
mapdbentry.h
mapsdb.h
FlyDBEntry::getInd
int getInd() const
Definition
flydbentry.cpp:66
FlyDBEntry::getName
QString getName() const
< Destination name.
Definition
flydbentry.cpp:71
FlyDBEntry::qmlRegister
void qmlRegister() const
Register with QML.
Definition
flydbentry.cpp:76
FlyDBEntry::name
QString name
Backing field (read via getName()).
Definition
flydbentry.h:57
FlyDBEntry::ind
int ind
Backing field (read via getInd()).
Definition
flydbentry.h:58
FlyDBEntry::toMap
MapDBEntry * toMap
Backing field (read via getToMap()).
Definition
flydbentry.h:59
FlyDBEntry::getToMap
MapDBEntry * getToMap() const
Definition
flydbentry.cpp:56
FlyDBEntry::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
flydbentry.cpp:61
FlyDBEntry::deepLink
void deepLink()
Resolve the destination map.
Definition
flydbentry.cpp:43
FlyDBEntry::FlyDBEntry
FlyDBEntry()
Empty entry (built by FlyDB).
Definition
flydbentry.cpp:30
MapDBEntry
One map's complete static definition – the root of the MapDBEntry family.
Definition
mapdbentry.h:56
utility.h
projects
db
src
pse-db
entries
flydbentry.cpp
Generated by
1.17.0