summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-08-27 10:16:20 (GMT)
committerBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-08-27 10:39:03 (GMT)
commit98a8173678a6f1dd8c63315584e9d1c7d60e5de8 (patch)
tree68c91aa39de29125b0799cce44a248762e311910
parentbc13e500f7a12d14e6d5300591964882e1d53a9b (diff)
return OsmPlacemarkData rather than suitable tag
By returning OsmPlacemarkData, the full power of OsmPresetLibrary::determineVisualCategory() can be used to determine the visual category of the placemark.
-rw-r--r--src/lib/marble/EditPlacemarkDialog.cpp8
-rw-r--r--src/lib/marble/osm/OsmTagEditorWidget.cpp16
-rw-r--r--src/lib/marble/osm/OsmTagEditorWidget.h18
-rw-r--r--src/plugins/render/annotate/EditPolygonDialog.cpp6
-rw-r--r--src/plugins/render/annotate/EditPolylineDialog.cpp6
5 files changed, 22 insertions, 32 deletions
diff --git a/src/lib/marble/EditPlacemarkDialog.cpp b/src/lib/marble/EditPlacemarkDialog.cpp
index b9c0478..997fdf9 100644
--- a/src/lib/marble/EditPlacemarkDialog.cpp
+++ b/src/lib/marble/EditPlacemarkDialog.cpp
@@ -340,11 +340,11 @@ void EditPlacemarkDialog::updateTextAnnotation()
d->m_placemark->setStyle( newStyle );
}
else {
- const OsmTagEditorWidget::OsmTag suitableTag = d->m_osmTagEditorWidget->suitableTag();
- if (suitableTag != OsmTagEditorWidget::OsmTag()) {
- GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::osmVisualCategory( suitableTag );
- d->m_placemark->setVisualCategory( category );
+ const OsmPlacemarkData osmData = d->m_osmTagEditorWidget->placemarkData();
+ const GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::determineVisualCategory(osmData);
+ if (category != GeoDataFeature::None) {
d->m_placemark->setStyle(GeoDataStyle::Ptr());
+ d->m_placemark->setVisualCategory( category );
}
}
diff --git a/src/lib/marble/osm/OsmTagEditorWidget.cpp b/src/lib/marble/osm/OsmTagEditorWidget.cpp
index 05b77b5..d5a7e56 100644
--- a/src/lib/marble/osm/OsmTagEditorWidget.cpp
+++ b/src/lib/marble/osm/OsmTagEditorWidget.cpp
@@ -72,22 +72,16 @@ void OsmTagEditorWidget::update()
emit placemarkChanged( d->m_placemark );
}
-OsmTagEditorWidget::OsmTag OsmTagEditorWidget::suitableTag() const
+OsmPlacemarkData OsmTagEditorWidget::placemarkData() const
{
- /*
- * The most suitable tag is the first tag in the list for which the OsmPresetLibrary
- * has an assigned visual category ( a QMap entry )
- * Maybe there's a better option.
- */
+ OsmPlacemarkData osmData;
+
for (int index = 0; index < d->m_currentTagsList->topLevelItemCount(); ++index) {
const QTreeWidgetItem *item = d->m_currentTagsList->topLevelItem( index );
- const auto tag = OsmTag(item->text(0), item->text(1));
- if (OsmPresetLibrary::osmVisualCategory(tag) != GeoDataFeature::None) {
- return tag;
- }
+ osmData.addTag(item->text(0), item->text(1));
}
- return OsmTag();
+ return osmData;
}
void OsmTagEditorWidget::addSelectedTag()
diff --git a/src/lib/marble/osm/OsmTagEditorWidget.h b/src/lib/marble/osm/OsmTagEditorWidget.h
index 5136600..27fcca6 100644
--- a/src/lib/marble/osm/OsmTagEditorWidget.h
+++ b/src/lib/marble/osm/OsmTagEditorWidget.h
@@ -12,11 +12,10 @@
#define MARBLE_OSMTAGEDITORWIDGET_H
#include <QWidget>
-
-#include "MarbleGlobal.h"
#include "marble_export.h"
-#include <QPair>
+#include "MarbleGlobal.h"
+#include "OsmPlacemarkData.h"
class QTreeWidgetItem;
@@ -32,11 +31,14 @@ class MARBLE_EXPORT OsmTagEditorWidget : public QWidget
Q_OBJECT
public:
- typedef QPair<QString, QString> OsmTag;
-
explicit OsmTagEditorWidget( GeoDataPlacemark *placemark, QWidget *parent = 0 );
~OsmTagEditorWidget();
+ /**
+ * @brief returns the current tag set for the placemark
+ */
+ OsmPlacemarkData placemarkData() const;
+
public Q_SLOTS:
void update();
void addSelectedTag();
@@ -44,12 +46,6 @@ public Q_SLOTS:
void handleDoubleClick( QTreeWidgetItem *item, int column );
void handleItemChanged( QTreeWidgetItem *item, int column );
- /**
- * @brief suitableTag returns the tag that fits best to represent the Visual Category
- * of the placemark ( chosen from the current list of tags )
- */
- OsmTag suitableTag() const;
-
Q_SIGNALS:
void placemarkChanged( GeoDataFeature *);
diff --git a/src/plugins/render/annotate/EditPolygonDialog.cpp b/src/plugins/render/annotate/EditPolygonDialog.cpp
index 4305fc7..8e77b7f 100644
--- a/src/plugins/render/annotate/EditPolygonDialog.cpp
+++ b/src/plugins/render/annotate/EditPolygonDialog.cpp
@@ -255,9 +255,9 @@ void EditPolygonDialog::updatePolygon()
// If there is not custom style initialized( default #polyline url is used ) and there is a osmTag-based style
// available, set it
- const OsmTagEditorWidget::OsmTag suitableTag = d->m_osmTagEditorWidget->suitableTag();
- if (d->m_placemark->styleUrl() == QLatin1String("#polygon") && suitableTag != OsmTagEditorWidget::OsmTag()) {
- GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::osmVisualCategory( suitableTag );
+ const OsmPlacemarkData osmData = d->m_osmTagEditorWidget->placemarkData();
+ const GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::determineVisualCategory(osmData);
+ if (d->m_placemark->styleUrl() == QLatin1String("#polygon") && category != GeoDataFeature::None) {
d->m_placemark->setStyle( GeoDataStyle::Ptr() ); // first clear style so style gets set by setVisualCategory()
d->m_placemark->setVisualCategory( category );
}
diff --git a/src/plugins/render/annotate/EditPolylineDialog.cpp b/src/plugins/render/annotate/EditPolylineDialog.cpp
index 4820795..fe58b80 100644
--- a/src/plugins/render/annotate/EditPolylineDialog.cpp
+++ b/src/plugins/render/annotate/EditPolylineDialog.cpp
@@ -219,9 +219,9 @@ void EditPolylineDialog::updatePolyline()
// If there is no custom style initialized( default #polyline url is used ) and there is a osmTag-based style
// available, set it
- const OsmTagEditorWidget::OsmTag suitableTag = d->m_osmTagEditorWidget->suitableTag();
- if (d->m_placemark->styleUrl() == QLatin1String("#polyline") && suitableTag != OsmTagEditorWidget::OsmTag()) {
- GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::osmVisualCategory( suitableTag );
+ const OsmPlacemarkData osmData = d->m_osmTagEditorWidget->placemarkData();
+ const GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::determineVisualCategory(osmData);
+ if (d->m_placemark->styleUrl() == QLatin1String("#polyline") && category != GeoDataFeature::None) {
d->m_placemark->setStyle( GeoDataStyle::Ptr() ); // first clear style so style gets set by setVisualCategory()
d->m_placemark->setVisualCategory( category );
}