summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanjiban Bairagya <sanjiban22393@gmail.com>2016-07-24 13:24:43 (GMT)
committerSanjiban Bairagya <sanjiban@magicpin.in>2016-07-24 13:25:05 (GMT)
commit4213c996dba39106b6b0b05208c362efb2846f2e (patch)
treeecac09db6ffc62dffb4c33c665b01b01a4b2e103
parent0f61ad6bd9c22cf92288b6cda3e926f4db35d7b7 (diff)
Make a special dedicated popup for OpenStreetMap data in the Desktop version
-rw-r--r--src/lib/marble/MarbleMap.cpp5
-rw-r--r--src/lib/marble/MarbleMap.h3
-rw-r--r--src/lib/marble/MarbleWidget.cpp6
-rw-r--r--src/lib/marble/MarbleWidget.h3
-rw-r--r--src/lib/marble/MarbleWidgetPopupMenu.cpp163
-rw-r--r--src/lib/marble/libmarble.qrc1
-rw-r--r--src/lib/marble/webpopup/osm.html67
7 files changed, 232 insertions, 16 deletions
diff --git a/src/lib/marble/MarbleMap.cpp b/src/lib/marble/MarbleMap.cpp
index 0df7dd3..b7bfd50 100644
--- a/src/lib/marble/MarbleMap.cpp
+++ b/src/lib/marble/MarbleMap.cpp
@@ -1382,6 +1382,11 @@ TextureLayer *MarbleMap::textureLayer() const
return &d->m_textureLayer;
}
+const StyleBuilder* MarbleMap::styleBuilder() const
+{
+ return &d->m_styleBuilder;
+}
+
}
#include "moc_MarbleMap.cpp"
diff --git a/src/lib/marble/MarbleMap.h b/src/lib/marble/MarbleMap.h
index 8efb997..da62d66 100644
--- a/src/lib/marble/MarbleMap.h
+++ b/src/lib/marble/MarbleMap.h
@@ -54,6 +54,7 @@ class AbstractFloatItem;
class TextureLayer;
class TileCoordsPyramid;
class GeoSceneTextureTileDataset;
+class StyleBuilder;
/**
* @short A class that can paint a view of the earth.
@@ -420,6 +421,8 @@ class MARBLE_EXPORT MarbleMap : public QObject
RenderState renderState() const;
+ const StyleBuilder* styleBuilder() const;
+
public Q_SLOTS:
/**
diff --git a/src/lib/marble/MarbleWidget.cpp b/src/lib/marble/MarbleWidget.cpp
index 5e21bb6..f108103 100644
--- a/src/lib/marble/MarbleWidget.cpp
+++ b/src/lib/marble/MarbleWidget.cpp
@@ -44,6 +44,7 @@
#include "ViewportParams.h"
#include "routing/RoutingLayer.h"
#include "MarbleAbstractPresenter.h"
+#include "StyleBuilder.h"
namespace Marble
{
@@ -1189,6 +1190,11 @@ PopupLayer *MarbleWidget::popupLayer()
return d->m_mapInfoDialog;
}
+const StyleBuilder* MarbleWidget::styleBuilder() const
+{
+ return d->m_map.styleBuilder();
+}
+
}
#include "moc_MarbleWidget.cpp"
diff --git a/src/lib/marble/MarbleWidget.h b/src/lib/marble/MarbleWidget.h
index 5efa243..007d71e 100644
--- a/src/lib/marble/MarbleWidget.h
+++ b/src/lib/marble/MarbleWidget.h
@@ -55,6 +55,7 @@ class TileCoordsPyramid;
class TileCreator;
class ViewportParams;
class PopupLayer;
+class StyleBuilder;
/**
* @short A widget class that displays a view of the earth.
@@ -247,6 +248,8 @@ class MARBLE_EXPORT MarbleWidget : public QWidget
PopupLayer* popupLayer();
+ const StyleBuilder* styleBuilder() const;
+
/**
* @brief Get the Projection used for the map
* @return @c Spherical a Globe
diff --git a/src/lib/marble/MarbleWidgetPopupMenu.cpp b/src/lib/marble/MarbleWidgetPopupMenu.cpp
index d668097..a51844d 100644
--- a/src/lib/marble/MarbleWidgetPopupMenu.cpp
+++ b/src/lib/marble/MarbleWidgetPopupMenu.cpp
@@ -26,6 +26,7 @@
#include "GeoDataPlacemark.h"
#include "GeoDataSnippet.h"
#include "GeoDataStyle.h"
+#include "GeoDataIconStyle.h"
#include "GeoDataTypes.h"
#include "GeoDataPhotoOverlay.h"
#include "GeoSceneDocument.h"
@@ -41,6 +42,8 @@
#include "BookmarkManager.h"
#include "ReverseGeocodingRunnerManager.h"
#include "TemplateDocument.h"
+#include "OsmPlacemarkData.h"
+#include "StyleBuilder.h"
// Qt
#include <QApplication>
@@ -57,8 +60,8 @@ namespace Marble {
class Q_DECL_HIDDEN MarbleWidgetPopupMenu::Private {
public:
- const MarbleModel *const m_model;
- MarbleWidget *const m_widget;
+ const MarbleModel *const m_model;
+ MarbleWidget *const m_widget;
QVector<const GeoDataFeature*> m_featurelist;
QList<AbstractDataPluginItem *> m_itemList;
@@ -70,9 +73,9 @@ public:
QAction *m_directionsFromHereAction;
QAction *m_directionsToHereAction;
- QAction *const m_copyCoordinateAction;
+ QAction *const m_copyCoordinateAction;
- QAction *m_rmbExtensionPoint;
+ QAction *m_rmbExtensionPoint;
ReverseGeocodingRunnerManager m_runnerManager;
@@ -90,6 +93,7 @@ public:
GeoDataCoordinates mouseCoordinates( QAction* dataContainer ) const;
static QString filterEmptyShortDescription( const QString &description );
+ void setupDialogOsm( PopupLayer *popup, const GeoDataPlacemark* placemark );
void setupDialogSatellite( const GeoDataPlacemark *placemark );
static void setupDialogCity( PopupLayer *popup, const GeoDataPlacemark *placemark );
static void setupDialogNation( PopupLayer *popup, const GeoDataPlacemark *placemark );
@@ -174,6 +178,135 @@ QString MarbleWidgetPopupMenu::Private::filterEmptyShortDescription(const QStrin
return description;
}
+void MarbleWidgetPopupMenu::Private::setupDialogOsm( PopupLayer *popup, const GeoDataPlacemark *placemark )
+{
+ const GeoDataCoordinates location = placemark->coordinate();
+ popup->setCoordinates(location, Qt::AlignRight | Qt::AlignVCenter);
+
+ QFile descriptionFile(":/marble/webpopup/osm.html");
+ if (!descriptionFile.open(QIODevice::ReadOnly)) {
+ return;
+ }
+
+ QString description = descriptionFile.readAll();
+ OsmPlacemarkData data = placemark->osmData();
+ if (!data.containsTagKey("addr:street") && !data.containsTagKey("addr:housenumber")){
+ description = description.replace("<br> %postcode%", "%postcode%");
+ }
+ TemplateDocument doc(description);
+
+ if (data.containsTagKey("name")){
+ doc["name"] = data.tagValue("name");
+ } else {
+ doc["name"] = "";
+ }
+
+ if (data.containsTagKey("shop")){
+ QString shop = data.tagValue("shop");
+ shop[0] = shop[0].toUpper();
+ doc["amenity"] = "Shop - " + shop;
+ } else if (data.containsTagKey("amenity")){
+ QString amenity = data.tagValue("amenity");
+ amenity[0] = amenity[0].toUpper();
+ doc["amenity"] = amenity;
+ } else {
+ doc["amenityVisibility"] = "none";
+ }
+
+ if (data.containsTagKey("cuisine")){
+ QString cuisine = data.tagValue("cuisine");
+ cuisine[0] = cuisine[0].toUpper();
+ doc["cuisine"] = cuisine;
+ } else {
+ doc["cuisineVisibility"] = "none";
+ }
+
+ if (data.containsTagKey("opening_hours")){
+ doc["openinghours"] = data.tagValue("opening_hours");
+ } else {
+ doc["openinghoursVisibility"] = "none";
+ }
+
+ bool hasAddressData = false;
+ foreach(const QString &tag, QStringList() << "addr:street" << "addr:housenumber" << "addr:postcode" << "addr:city") {
+ if (data.containsTagKey(tag)){
+ hasAddressData = true;
+ break;
+ }
+ }
+
+ bool hasWebsiteData = false;
+ foreach(const QString &tag, QStringList() << "website" << "contact:website" << "facebook" << "contact:facebook" << "url") {
+ if (data.containsTagKey(tag)){
+ hasWebsiteData = true;
+ break;
+ }
+ }
+
+ bool hasPhoneData = data.containsTagKey("phone");
+
+ bool hasContactsData = hasAddressData || hasPhoneData || hasWebsiteData;
+
+ if (hasContactsData){
+ if (hasAddressData){
+ foreach (const QString tag, QStringList() << "addr:street" << "addr:housenumber" << "addr:postcode" << "addr:city") {
+ if (data.containsTagKey(tag)){
+ doc[tag.split("addr:")[1]] = data.tagValue(tag);
+ } else {
+ doc[tag.split("addr:")[1]] = "";
+ }
+ }
+ } else {
+ doc["addressVisibility"] = "none";
+ }
+
+ if (hasPhoneData){
+ doc["phone"] = data.tagValue("phone");
+ } else {
+ doc["phoneVisibility"] = "none";
+ }
+
+ if (hasWebsiteData){
+ foreach(const QString tag, QStringList() << "website" << "contact:website" << "facebook" << "contact:facebook" << "url") {
+ if (data.containsTagKey(tag)){
+ doc["website"] = data.tagValue(tag);
+ break;
+ }
+ }
+ } else {
+ doc["websiteVisibility"] = "none";
+ }
+ } else {
+ doc["contactVisibility"] = "none";
+ }
+
+ if (data.containsTagKey("wheelchair") || data.containsTagKey("internet_access") || data.containsTagKey("smoking")){
+ if (data.containsTagKey("wheelchair")){
+ doc["wheelchair"] = data.tagValue("wheelchair");
+ } else {
+ doc["wheelchairVisibility"] = "none";
+ }
+
+ if (data.containsTagKey("internet_access")){
+ doc["internetaccess"] = data.tagValue("internet_access");
+ } else {
+ doc["internetVisibility"] = "none";
+ }
+
+ if (data.containsTagKey("smoking")){
+ doc["smoking"] = data.tagValue("smoking");
+ } else {
+ doc["smokingVisibility"] = "none";
+ }
+ } else {
+ doc["facilitiesVisibility"] = "none";
+ }
+
+ const QString flagPath = m_widget->styleBuilder()->createStyle(StyleParameters(placemark))->iconStyle().iconPath();
+ doc["flag"] = flagPath;
+ popup->setContent(doc.finalText());
+}
+
void MarbleWidgetPopupMenu::Private::setupDialogSatellite( const GeoDataPlacemark *placemark )
{
PopupLayer *const popup = m_widget->popupLayer();
@@ -479,6 +612,24 @@ void MarbleWidgetPopupMenu::slotInfoDialog()
bool isCity = false;
bool isNation = false;
+ OsmPlacemarkData data = placemark->osmData();
+
+ bool hasOsmData = false;
+
+ QStringList recognizedTags;
+ recognizedTags << "name" << "amenity" << "cuisine" << "opening_hours";
+ recognizedTags << "addr:street" << "addr:housenumber" << "addr:postcode";
+ recognizedTags << "addr:city" << "phone" << "wheelchair" << "internet_access";
+ recognizedTags << "smoking" << "website" << "contact:website" << "facebook";
+ recognizedTags << "contact:facebook" << "url";
+
+ foreach(const QString &tag, recognizedTags) {
+ if (data.containsTagKey(tag)) {
+ hasOsmData = true;
+ break;
+ }
+ }
+
if ( placemark ) {
isSatellite = (placemark->visualCategory() == GeoDataFeature::Satellite);
isCity = (placemark->visualCategory() >= GeoDataFeature::SmallCity &&
@@ -494,7 +645,9 @@ void MarbleWidgetPopupMenu::slotInfoDialog()
popup->setSize(QSizeF(400, 400));
- if (isSatellite) {
+ if (hasOsmData){
+ d->setupDialogOsm( popup, placemark );
+ } else if (isSatellite) {
d->setupDialogSatellite( placemark );
} else if (isCity) {
Private::setupDialogCity( popup, placemark );
diff --git a/src/lib/marble/libmarble.qrc b/src/lib/marble/libmarble.qrc
index 3abebdc..bb56407 100644
--- a/src/lib/marble/libmarble.qrc
+++ b/src/lib/marble/libmarble.qrc
@@ -98,6 +98,7 @@
<file alias="nation.html">webpopup/nation.html</file>
<file alias="skyplace.html">webpopup/skyplace.html</file>
<file alias="photooverlay.html">webpopup/photooverlay.html</file>
+ <file alias="osm.html">webpopup/osm.html</file>
</qresource>
<qresource prefix="/htmlfeatures">
<file alias="files/bootstrap.min.css">htmlfeatures/bootstrap.min.css</file>
diff --git a/src/lib/marble/webpopup/osm.html b/src/lib/marble/webpopup/osm.html
index 84a331b..cfa3773 100644
--- a/src/lib/marble/webpopup/osm.html
+++ b/src/lib/marble/webpopup/osm.html
@@ -6,11 +6,56 @@
<link rel="stylesheet" media="print, embossed" href="qrc:/marble/webpopup/placesprint.css"></head>
<style>
.flag {
- background-image:url('file://%amenity%');
+ background-image:url('file://%flag%');
+}
+
+h2.osmamenity {
+ display: %amenityVisibility%
+}
+
+h3.osmcuisine {
+ display: %cuisineVisibility%
+}
+
+p.openinghours {
+ display: %openinghoursVisibility%
+}
+
+table.contact {
+ display: %contactVisibility%
+}
+
+tr.address {
+ display: %addressVisibility%
+}
+
+tr.phone {
+ display: %phoneVisibility%
+}
+
+tr.website {
+ display: %websiteVisibility%
+}
+
+table.facilities {
+ display: %facilitiesVisibility%
+}
+
+tr.wheelchair {
+ display: %wheelchairVisibility%
+}
+
+tr.internet {
+ display: %internetVisibility%
+}
+
+tr.smoking {
+ display: %smokingVisibility%
}
</style>
+
<body>
-<div class="osmname"><h1>%name%</h1></div>
+<div class="flag"><h1>%name%</h1></div>
<h2 class="osmamenity">%amenity%</h2>
@@ -18,34 +63,34 @@
<p class="openinghours">Opening Hours: %openinghours%</p>
-<table>
+<table class="contact">
<tr class="blue">
<td colspan="2">Contact</td>
</tr>
-<tr>
+<tr class="address">
<td>Address:</td><td>%street% %housenumber% <br> %postcode% %city%</td>
</tr>
-<tr>
+<tr class="phone">
<td>Phone:</td><td>%phone%</td>
</tr>
-<tr>
- <td>Website:</td><td>%website% m</td>
+<tr class="website">
+ <td>Website:</td><td><a href="%website%">%website%</a></td>
</tr>
</table>
<br>
-<table>
+<table class="facilities">
<tr class="blue">
<td colspan="2">Popular Facilities</td>
</tr>
-<tr>
+<tr class="wheelchair">
<td>Wheelchair access</td><td>%wheelchair%</td>
</tr>
-<tr>
+<tr class="internet">
<td>Internet</td><td>%internetaccess%</td>
</tr>
-<tr>
+<tr class="smoking">
<td>Smoking</td><td>%smoking%</td>
</tr>
</table>