Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
KOSMIndoorMap
Commits
b818f557
Commit
b818f557
authored
Nov 09, 2021
by
Volker Krause
Browse files
Add properties to Platform for direct access from QML
parent
3f7d89de
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/map-quick/kosmindoormapquickplugin.cpp
View file @
b818f557
...
...
@@ -23,6 +23,7 @@ void KOSMIndoorMapQuickPlugin::registerTypes(const char *uri)
Q_UNUSED
(
uri
);
qRegisterMetaType
<
OSMAddress
>
();
qRegisterMetaType
<
OSMElement
>
();
qRegisterMetaType
<
Platform
>
();
qRegisterMetaType
<
Platform
::
Mode
>
();
qmlRegisterUncreatableType
<
MapData
>
(
"org.kde.kosmindoormap"
,
1
,
0
,
"MapData"
,
{});
...
...
src/map/content/platform.cpp
View file @
b818f557
...
...
@@ -76,7 +76,7 @@ public:
Platform
::
Mode
m_mode
=
Platform
::
Rail
;
// TODO should eventually be "Unknown"
int
m_level
=
std
::
numeric_limits
<
int
>::
min
();
// INT_MIN indicates not set, needed for merging
std
::
vector
<
PlatformSection
>
m_sections
;
Q
ByteArray
m_ifopt
;
Q
String
m_ifopt
;
QStringList
m_lines
;
static
void
appendSection
(
std
::
vector
<
PlatformSection
>
&
sections
,
const
Platform
&
p
,
PlatformSection
&&
sec
,
std
::
vector
<
const
OSM
::
Node
*>
&
edgePath
,
const
OSM
::
DataSet
&
dataSet
);
...
...
@@ -210,12 +210,12 @@ void Platform::setMode(Platform::Mode mode)
d
->
m_mode
=
mode
;
}
Q
ByteArray
Platform
::
ifopt
()
const
Q
String
Platform
::
ifopt
()
const
{
return
d
->
m_ifopt
;
}
void
Platform
::
setIfopt
(
const
Q
ByteArray
&
ifopt
)
void
Platform
::
setIfopt
(
const
Q
String
&
ifopt
)
{
d
.
detach
();
d
->
m_ifopt
=
ifopt
;
...
...
src/map/content/platform.h
View file @
b818f557
...
...
@@ -55,6 +55,9 @@ class PlatformPrivate;
/** A railway platform/track. */
class
KOSMINDOORMAP_EXPORT
Platform
{
Q_GADGET
Q_PROPERTY
(
QString
name
READ
name
WRITE
setName
)
Q_PROPERTY
(
Mode
mode
READ
mode
WRITE
setMode
)
Q_PROPERTY
(
QString
ifopt
READ
ifopt
WRITE
setIfopt
)
public:
explicit
Platform
();
Platform
(
const
Platform
&
);
...
...
@@ -116,8 +119,8 @@ public:
void
setMode
(
Mode
mode
);
/** IFOPT identifier */
Q
ByteArray
ifopt
()
const
;
void
setIfopt
(
const
Q
ByteArray
&
ifopt
);
Q
String
ifopt
()
const
;
void
setIfopt
(
const
Q
String
&
ifopt
);
/** Names of public transport lines stopping at this platform. */
QStringList
lines
()
const
;
...
...
src/map/content/platformfinder.cpp
View file @
b818f557
...
...
@@ -80,7 +80,7 @@ std::vector<Platform> PlatformFinder::find(const MapData &data)
platform
.
setMode
(
modeForElement
(
e
));
platform
.
setSections
(
sectionsForPath
(
e
.
outerPath
(
m_data
.
dataSet
()),
names
[
i
]));
if
(
ifopts
.
size
()
==
names
.
size
())
{
platform
.
setIfopt
(
ifopts
[
i
]);
platform
.
setIfopt
(
QString
::
fromUtf8
(
ifopts
[
i
])
)
;
}
// we delay merging of platforms, as those without track names would
// otherwise cobble together two distinct edges when merged to early
...
...
@@ -93,7 +93,7 @@ std::vector<Platform> PlatformFinder::find(const MapData &data)
platform
.
setName
(
QString
::
fromUtf8
(
e
.
tagValue
(
"local_ref"
,
"ref"
)));
platform
.
setLevel
(
levelForPlatform
((
*
it
).
first
,
e
));
platform
.
setSections
(
sectionsForPath
(
e
.
outerPath
(
m_data
.
dataSet
()),
platform
.
name
()));
platform
.
setIfopt
(
e
.
tagValue
(
"ref:IFOPT"
));
platform
.
setIfopt
(
QString
::
fromUtf8
(
e
.
tagValue
(
"ref:IFOPT"
))
)
;
addPlatform
(
std
::
move
(
platform
));
}
else
if
(
!
railway
.
isEmpty
()
&&
e
.
type
()
==
OSM
::
Type
::
Way
&&
railway
!=
"disused"
)
{
...
...
@@ -113,7 +113,7 @@ std::vector<Platform> PlatformFinder::find(const MapData &data)
platform
.
setLevel
(
levelForPlatform
((
*
it
).
first
,
e
));
platform
.
setName
(
Platform
::
preferredName
(
QString
::
fromUtf8
(
platform
.
stopPoint
().
tagValue
(
"local_ref"
,
"ref"
,
"name"
)),
nameFromTrack
(
e
)));
platform
.
setMode
(
modeForElement
(
OSM
::
Element
(
&
node
)));
platform
.
setIfopt
(
platform
.
stopPoint
().
tagValue
(
"ref:IFOPT"
));
platform
.
setIfopt
(
QString
::
fromUtf8
(
platform
.
stopPoint
().
tagValue
(
"ref:IFOPT"
))
)
;
if
(
platform
.
mode
()
==
Platform
::
Unknown
)
{
platform
.
setMode
(
modeForElement
(
e
));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment