Marble

Placemark.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org>
4//
5
6#ifndef MARBLE_DECLARATIVE_PLACEMARK_H
7#define MARBLE_DECLARATIVE_PLACEMARK_H
8
9#include "GeoDataPlacemark.h"
10#include "RouteRelationModel.h"
11
12#include <QObject>
13#include <QStringListModel>
14#include <QUrl>
15#include <qqmlregistration.h>
16
17namespace Marble
18{
19
20/**
21 * Wraps a GeoDataPlacemark for QML access
22 */
23class Placemark : public QObject
24{
26 QML_ELEMENT
27
28 Q_PROPERTY(QString name WRITE setName READ name NOTIFY nameChanged)
29 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
30 Q_PROPERTY(QString address READ address NOTIFY addressChanged)
31 Q_PROPERTY(QString website READ website NOTIFY websiteChanged)
32 Q_PROPERTY(QString wikipedia READ wikipedia NOTIFY wikipediaChanged)
33 Q_PROPERTY(QString openingHours READ openingHours NOTIFY openingHoursChanged)
34 Q_PROPERTY(QString coordinates READ coordinates NOTIFY coordinatesChanged)
35 Q_PROPERTY(QString wheelchairInfo READ wheelchairInfo NOTIFY wheelchairInfoChanged)
36 Q_PROPERTY(QString wifiAvailable READ wifiAvailable NOTIFY wifiAvailabilityChanged)
37 Q_PROPERTY(QString phone READ phone NOTIFY phoneChanged)
38 Q_PROPERTY(double longitude READ longitude NOTIFY coordinatesChanged)
39 Q_PROPERTY(double latitude READ latitude NOTIFY coordinatesChanged)
40 Q_PROPERTY(QStringList tags READ tags NOTIFY tagsChanged)
41
42 Q_PROPERTY(RouteRelationModel *routeRelationModel READ routeRelationModel CONSTANT)
43
44public:
45 /** Constructor */
46 explicit Placemark(QObject *parent = nullptr);
47
48 void setGeoDataPlacemark(const Marble::GeoDataPlacemark &placemark);
49
50 Marble::GeoDataPlacemark &placemark();
51 const Marble::GeoDataPlacemark &placemark() const;
52
53 QString name() const;
54 QString description() const;
55 QString address() const;
56 QString website() const;
57 QString wikipedia() const;
58 QString openingHours() const;
59 QString coordinates() const;
60 QString wheelchairInfo() const;
61 QString wifiAvailable() const;
62 QString phone() const;
63 double longitude() const;
64 double latitude() const;
65 const QStringList &tags() const;
66
67 RouteRelationModel *routeRelationModel();
68
69public Q_SLOTS:
70 void setName(const QString &name);
71
73 void nameChanged();
74 void coordinatesChanged();
75 void descriptionChanged();
76 void addressChanged();
77 void websiteChanged();
78 void wikipediaChanged();
79 void openingHoursChanged();
80 void wheelchairInfoChanged();
81 void wifiAvailabilityChanged();
82 void phoneChanged();
83 void tagsChanged();
84
85 void routeRelationModelChanged();
86
87private:
88 bool addTagValue(QString &target, const QString &key, const QString &format = QString(), const QString &separator = QStringLiteral(" · ")) const;
89 void addFirstTagValueOf(QString &target, const QStringList &keys) const;
90 void addTagDescription(QString &target, const QString &key, const QString &value, const QString &description) const;
91 static void append(QString &target, const QString &value);
92 QString addressFromOsmData() const;
93 static QString formatStreet(const QString &street, const QString &houseNumber);
94 void updateTags();
95 void updateRelations(const GeoDataPlacemark &placemark);
96
97 Marble::GeoDataPlacemark m_placemark;
98 mutable QString m_address; // mutable to allow lazy calculation in the getter
99 mutable QString m_description;
100 mutable QString m_website;
101 mutable QString m_wikipedia;
102 mutable QString m_openingHours;
103 mutable QString m_wheelchairInfo;
104 mutable QString m_wifiAvailable;
105 mutable QString m_phone;
106 QStringList m_tags;
107
108 RouteRelationModel m_relationModel;
109};
110
111}
112
113#endif // MARBLE_DECLARATIVE_PLACEMARK_H
a class representing a point of interest on the map
Wraps a GeoDataPlacemark for QML access.
Definition Placemark.h:24
Placemark(QObject *parent=nullptr)
Constructor.
Definition Placemark.cpp:20
Binds a QML item to a specific geodetic location in screen coordinates.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.