Commit b818f557 authored by Volker Krause's avatar Volker Krause
Browse files

Add properties to Platform for direct access from QML

parent 3f7d89de
......@@ -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", {});
......
......@@ -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;
QByteArray m_ifopt;
QString 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;
}
QByteArray Platform::ifopt() const
QString Platform::ifopt() const
{
return d->m_ifopt;
}
void Platform::setIfopt(const QByteArray &ifopt)
void Platform::setIfopt(const QString &ifopt)
{
d.detach();
d->m_ifopt = ifopt;
......
......@@ -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 */
QByteArray ifopt() const;
void setIfopt(const QByteArray &ifopt);
QString ifopt() const;
void setIfopt(const QString &ifopt);
/** Names of public transport lines stopping at this platform. */
QStringList lines() const;
......
......@@ -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));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment