summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-07-23 13:19:49 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-07-23 14:10:40 (GMT)
commit70200bbeb53f7620e4138171e89e3ca34fd819c6 (patch)
tree4c406ca667b9e1f9026a256b9da4784a028612e4
parent47b59f9f029eabb60342a166f6621b8c040abda0 (diff)
Enable selection of buildings
-rw-r--r--src/apps/marble-maps/PlacemarkDialog.qml2
-rw-r--r--src/lib/marble/declarative/Bookmarks.cpp20
-rw-r--r--src/lib/marble/declarative/Bookmarks.h2
-rw-r--r--src/lib/marble/declarative/MarbleQuickItem.cpp5
-rw-r--r--src/lib/marble/declarative/Placemark.cpp5
-rw-r--r--src/lib/marble/declarative/Placemark.h1
6 files changed, 24 insertions, 11 deletions
diff --git a/src/apps/marble-maps/PlacemarkDialog.qml b/src/apps/marble-maps/PlacemarkDialog.qml
index d601408..4c50463 100644
--- a/src/apps/marble-maps/PlacemarkDialog.qml
+++ b/src/apps/marble-maps/PlacemarkDialog.qml
@@ -156,7 +156,7 @@ Item {
if (bookmarkButton.bookmark) {
bookmarks.removeBookmark(root.placemark.longitude, root.placemark.latitude)
} else {
- bookmarks.addBookmark(root.placemark.longitude, root.placemark.latitude, root.placemark.name, "Default")
+ bookmarks.addBookmark(root.placemark, "Default")
}
bookmarkButton.bookmark = !bookmarkButton.bookmark
}
diff --git a/src/lib/marble/declarative/Bookmarks.cpp b/src/lib/marble/declarative/Bookmarks.cpp
index 819cbbe..80340f4 100644
--- a/src/lib/marble/declarative/Bookmarks.cpp
+++ b/src/lib/marble/declarative/Bookmarks.cpp
@@ -23,6 +23,7 @@
#include "GeoDataExtendedData.h"
#include "GeoDataTreeModel.h"
#include "kdescendantsproxymodel.h"
+#include "osm/OsmPlacemarkData.h"
#include <QSortFilterProxyModel>
@@ -86,7 +87,7 @@ Placemark *Bookmarks::placemark(int row)
return placemark;
}
-void Bookmarks::addBookmark( qreal longitude, qreal latitude, const QString &name, const QString &folderName )
+void Bookmarks::addBookmark(Placemark *placemark, const QString &folderName )
{
if ( !m_marbleQuickItem || !m_marbleQuickItem->model()->bookmarkManager() ) {
return;
@@ -115,13 +116,16 @@ void Bookmarks::addBookmark( qreal longitude, qreal latitude, const QString &nam
Q_ASSERT( target );
}
- Marble::GeoDataPlacemark placemark;
- Marble::GeoDataCoordinates coordinate( longitude, latitude, 0.0, Marble::GeoDataCoordinates::Degree );
- placemark.setCoordinate( coordinate );
- placemark.setName( name );
- placemark.extendedData().addValue( Marble::GeoDataData( "isBookmark", true ) );
-
- manager->addBookmark( target, placemark );
+ Marble::GeoDataPlacemark bookmark = placemark->placemark();
+ if (bookmark.name().isEmpty()) {
+ bookmark.setName(placemark->address());
+ }
+ if (bookmark.name().isEmpty()) {
+ bookmark.setName(bookmark.coordinate().toString(GeoDataCoordinates::Decimal).trimmed());
+ }
+ bookmark.clearOsmData();
+ bookmark.setCoordinate(bookmark.coordinate()); // replace non-point geometries with their center
+ manager->addBookmark( target, bookmark );
}
void Bookmarks::removeBookmark( qreal longitude, qreal latitude )
diff --git a/src/lib/marble/declarative/Bookmarks.h b/src/lib/marble/declarative/Bookmarks.h
index da9f8e7..ef5c63c 100644
--- a/src/lib/marble/declarative/Bookmarks.h
+++ b/src/lib/marble/declarative/Bookmarks.h
@@ -62,7 +62,7 @@ public:
Q_INVOKABLE Placemark* placemark(int index);
public Q_SLOTS:
- void addBookmark( qreal longitude, qreal latitude, const QString &name, const QString &folder );
+ void addBookmark(Placemark *placemark, const QString &folder );
void removeBookmark( qreal longitude, qreal latitude );
void updateBookmarkDocument();
diff --git a/src/lib/marble/declarative/MarbleQuickItem.cpp b/src/lib/marble/declarative/MarbleQuickItem.cpp
index 4666702..df0e918 100644
--- a/src/lib/marble/declarative/MarbleQuickItem.cpp
+++ b/src/lib/marble/declarative/MarbleQuickItem.cpp
@@ -569,7 +569,10 @@ namespace Marble
void MarbleQuickItem::selectPlacemarkAt(int x, int y)
{
- auto const features = d->m_map.whichFeatureAt(QPoint(x, y));
+ auto features = d->m_map.whichFeatureAt(QPoint(x, y));
+ if (features.empty()) {
+ features = d->m_map.whichBuildingAt(QPoint(x, y));
+ }
QVector<GeoDataPlacemark const *> placemarks;
foreach(auto feature, features) {
if (feature->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
diff --git a/src/lib/marble/declarative/Placemark.cpp b/src/lib/marble/declarative/Placemark.cpp
index 4e56129..d5e67d2 100644
--- a/src/lib/marble/declarative/Placemark.cpp
+++ b/src/lib/marble/declarative/Placemark.cpp
@@ -53,6 +53,11 @@ Marble::GeoDataPlacemark & Placemark::placemark()
return m_placemark;
}
+const GeoDataPlacemark &Placemark::placemark() const
+{
+ return m_placemark;
+}
+
QString Placemark::name() const
{
return m_placemark.name();
diff --git a/src/lib/marble/declarative/Placemark.h b/src/lib/marble/declarative/Placemark.h
index 3a40a3f..cfd8ed5 100644
--- a/src/lib/marble/declarative/Placemark.h
+++ b/src/lib/marble/declarative/Placemark.h
@@ -46,6 +46,7 @@ public:
void setGeoDataPlacemark( const Marble::GeoDataPlacemark &placemark );
Marble::GeoDataPlacemark & placemark();
+ const Marble::GeoDataPlacemark & placemark() const;
QString name() const;
QString description() const;