summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-12 12:42:10 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-12 12:42:10 (GMT)
commit1258fe101cef289b4d6b45517f27151161d00839 (patch)
treec364304b0c7885dd7387c3e121982e634a726fe6
parent3490be25a1be8465e4aa0fea8f0cef3b3850ed52 (diff)
Condense elevation information into placemark description of peaks
-rw-r--r--src/apps/marble-maps/PlacemarkDialog.qml6
-rw-r--r--src/lib/marble/declarative/Placemark.cpp19
-rw-r--r--src/lib/marble/declarative/Placemark.h6
3 files changed, 5 insertions, 26 deletions
diff --git a/src/apps/marble-maps/PlacemarkDialog.qml b/src/apps/marble-maps/PlacemarkDialog.qml
index c29df22..5cd1ab1 100644
--- a/src/apps/marble-maps/PlacemarkDialog.qml
+++ b/src/apps/marble-maps/PlacemarkDialog.qml
@@ -82,12 +82,6 @@ Item {
IconText {
width: parent.width
- visible: placemark !== null && placemark.elevation !== ""
- text: placemark === null ? "" : qsTr("Elevation: %1 m").arg(placemark.elevation)
- }
-
- IconText {
- width: parent.width
visible: text.length > 0
text: placemark === null ? "" : placemark.address
maximumLineCount: 4
diff --git a/src/lib/marble/declarative/Placemark.cpp b/src/lib/marble/declarative/Placemark.cpp
index e42d46e..1f9f0c7 100644
--- a/src/lib/marble/declarative/Placemark.cpp
+++ b/src/lib/marble/declarative/Placemark.cpp
@@ -35,7 +35,6 @@ void Placemark::setGeoDataPlacemark( const Marble::GeoDataPlacemark &placemark )
m_website = QString();
m_wikipedia = QString();
m_openingHours = QString();
- m_elevation = QString();
emit coordinatesChanged();
emit nameChanged();
emit descriptionChanged();
@@ -43,7 +42,6 @@ void Placemark::setGeoDataPlacemark( const Marble::GeoDataPlacemark &placemark )
emit websiteChanged();
emit wikipediaChanged();
emit openingHoursChanged();
- emit elevationChanged();
}
Marble::GeoDataPlacemark & Placemark::placemark()
@@ -130,6 +128,8 @@ QString Placemark::description() const
addTagDescription(m_description, QStringLiteral("recycling:waste"), "yes", tr("Waste"));
addTagDescription(m_description, QStringLiteral("recycling:white_goods"), "yes", tr("White goods"));
addTagDescription(m_description, QStringLiteral("recycling:wood"), "yes", tr("Wood"));
+ } else if (category == GeoDataPlacemark::NaturalPeak) {
+ addTagValue(m_description, QStringLiteral("ele"), tr("%1 m"));
}
}
@@ -204,17 +204,6 @@ QString Placemark::coordinates() const
return m_placemark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed();
}
-QString Placemark::elevation() const
-{
- if (!m_elevation.isEmpty()){
- return m_elevation;
- }
-
- m_elevation = m_placemark.osmData().tagValue(QStringLiteral("ele"));
-
- return m_elevation;
-}
-
void Placemark::setName(const QString & name)
{
if (m_placemark.name() == name) {
@@ -235,11 +224,11 @@ double Placemark::latitude() const
return m_placemark.coordinate().latitude(GeoDataCoordinates::Degree);
}
-void Placemark::addTagValue(QString &target, const QString &key) const
+void Placemark::addTagValue(QString &target, const QString &key, const QString &format) const
{
auto const & osmData = m_placemark.osmData();
QString const value = osmData.tagValue(key);
- QString description = value;
+ QString description = format.isEmpty() ? value : format.arg(value);
description.replace(QLatin1Char(';'), " · ");
addTagDescription(target, key, value, description);
}
diff --git a/src/lib/marble/declarative/Placemark.h b/src/lib/marble/declarative/Placemark.h
index b15476a..677f79b 100644
--- a/src/lib/marble/declarative/Placemark.h
+++ b/src/lib/marble/declarative/Placemark.h
@@ -32,7 +32,6 @@ class Placemark : public QObject
Q_PROPERTY(QString wikipedia READ wikipedia NOTIFY wikipediaChanged)
Q_PROPERTY(QString openingHours READ openingHours NOTIFY openingHoursChanged)
Q_PROPERTY(QString coordinates READ coordinates NOTIFY coordinatesChanged)
- Q_PROPERTY(QString elevation READ elevation NOTIFY elevationChanged)
Q_PROPERTY(double longitude READ longitude NOTIFY coordinatesChanged)
Q_PROPERTY(double latitude READ latitude NOTIFY coordinatesChanged)
@@ -52,7 +51,6 @@ public:
QString wikipedia() const;
QString openingHours() const;
QString coordinates() const;
- QString elevation() const;
double longitude() const;
double latitude() const;
@@ -67,10 +65,9 @@ Q_SIGNALS:
void websiteChanged();
void wikipediaChanged();
void openingHoursChanged();
- void elevationChanged();
private:
- void addTagValue(QString &target, const QString &key) const;
+ void addTagValue(QString &target, const QString &key, const QString &format=QString()) const;
void addTagDescription(QString &target, const QString &key, const QString &value, const QString &description) const;
QString addressFromOsmData() const;
QString formatStreet(const QString &street, const QString &houseNumber) const;
@@ -81,7 +78,6 @@ private:
mutable QString m_website;
mutable QString m_wikipedia;
mutable QString m_openingHours;
- mutable QString m_elevation;
};
}