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 <QtQml>
14#include <QStringListModel>
15
16namespace Marble {
17
18/**
19 * Wraps a GeoDataPlacemark for QML access
20 */
21class Placemark : public QObject
22{
24
25 Q_PROPERTY(QString name WRITE setName READ name NOTIFY nameChanged)
26 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
27 Q_PROPERTY(QString address READ address NOTIFY addressChanged)
28 Q_PROPERTY(QString website READ website NOTIFY websiteChanged)
29 Q_PROPERTY(QString wikipedia READ wikipedia NOTIFY wikipediaChanged)
30 Q_PROPERTY(QString openingHours READ openingHours NOTIFY openingHoursChanged)
31 Q_PROPERTY(QString coordinates READ coordinates NOTIFY coordinatesChanged)
32 Q_PROPERTY(QString wheelchairInfo READ wheelchairInfo NOTIFY wheelchairInfoChanged)
33 Q_PROPERTY(QString wifiAvailable READ wifiAvailable NOTIFY wifiAvailabilityChanged)
34 Q_PROPERTY(QString phone READ phone NOTIFY phoneChanged)
35 Q_PROPERTY(double longitude READ longitude NOTIFY coordinatesChanged)
36 Q_PROPERTY(double latitude READ latitude NOTIFY coordinatesChanged)
37 Q_PROPERTY(QStringList tags READ tags NOTIFY tagsChanged)
38
39 Q_PROPERTY(RouteRelationModel* routeRelationModel READ routeRelationModel CONSTANT)
40
41public:
42 /** Constructor */
43 explicit Placemark( QObject *parent = nullptr );
44
45 void setGeoDataPlacemark( const Marble::GeoDataPlacemark &placemark );
46
47 Marble::GeoDataPlacemark & placemark();
48 const Marble::GeoDataPlacemark & placemark() const;
49
50 QString name() const;
51 QString description() const;
52 QString address() const;
53 QString website() const;
54 QString wikipedia() const;
55 QString openingHours() const;
56 QString coordinates() const;
57 QString wheelchairInfo() const;
58 QString wifiAvailable() const;
59 QString phone() const;
60 double longitude() const;
61 double latitude() const;
62 const QStringList & tags() const;
63
64 RouteRelationModel* routeRelationModel();
65
66public Q_SLOTS:
67 void setName(const QString &name);
68
70 void nameChanged();
71 void coordinatesChanged();
72 void descriptionChanged();
73 void addressChanged();
74 void websiteChanged();
75 void wikipediaChanged();
76 void openingHoursChanged();
77 void wheelchairInfoChanged();
78 void wifiAvailabilityChanged();
79 void phoneChanged();
80 void tagsChanged();
81
82 void routeRelationModelChanged();
83
84private:
85 bool addTagValue(QString &target, const QString &key, const QString &format=QString(), const QString& separator = QStringLiteral(" · ")) const;
86 void addFirstTagValueOf(QString &target, const QStringList &keys) const;
87 void addTagDescription(QString &target, const QString &key, const QString &value, const QString &description) const;
88 static void append(QString &target, const QString &value);
89 QString addressFromOsmData() const;
90 static QString formatStreet(const QString &street, const QString &houseNumber);
91 void updateTags();
92 void updateRelations(const GeoDataPlacemark &placemark);
93
94 Marble::GeoDataPlacemark m_placemark;
95 mutable QString m_address; // mutable to allow lazy calculation in the getter
96 mutable QString m_description;
97 mutable QString m_website;
98 mutable QString m_wikipedia;
99 mutable QString m_openingHours;
100 mutable QString m_wheelchairInfo;
101 mutable QString m_wifiAvailable;
102 mutable QString m_phone;
103 QStringList m_tags;
104
105 RouteRelationModel m_relationModel;
106};
107
108}
109
110QML_DECLARE_TYPE(Marble::Placemark)
111
112#endif // MARBLE_DECLARATIVE_PLACEMARK_H
a class representing a point of interest on the map
Wraps a GeoDataPlacemark for QML access.
Definition Placemark.h:22
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
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.