Added OpenStreetMaps license text feature
authorKaj Wallin <kaj.wallin@ixonos.com>
Wed, 5 May 2010 12:36:01 +0000 (15:36 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Wed, 5 May 2010 12:36:01 +0000 (15:36 +0300)
Reviewed by: J. Laitinen

doc/test_cases/functionality-tests.doc
src/map/mapcommon.h
src/map/mapview.cpp
src/map/mapview.h
src/ui/mapviewscreen.cpp
src/ui/mapviewscreen.h

index 6a709cc..18563aa 100644 (file)
Binary files a/doc/test_cases/functionality-tests.doc and b/doc/test_cases/functionality-tests.doc differ
index 01fa61d..a8fc860 100644 (file)
@@ -68,6 +68,8 @@ const qreal DEFAULT_LATITUDE = 65.0000;  ///< Default latitude value
 
 const int GRID_PADDING = 1;  ///< Grid padding used in tile grid calculation
 
+const QString OSM_LICENSE = QString::fromUtf8("© OpenStreetMap contributors, CC-BY-SA");
+
 /**
 * @var UNDEFINED
 * @brief Value to be used when zoom level, tile numbers or position are not defined
index 50c4f13..351e714 100644 (file)
@@ -104,6 +104,7 @@ void MapView::resizeEvent(QResizeEvent *event)
     qDebug() << __PRETTY_FUNCTION__ << "Resize:" << event->size();
 
     emit viewResized(event->size());
+    emit viewResizedNewSize(viewport()->width(), viewport()->height());
     emit viewContentChanged(mapToScene(viewport()->x(), viewport()->y()).toPoint());
 }
 
index 23b7def..128543e 100644 (file)
@@ -153,6 +153,15 @@ signals:
     */
     void viewContentChanged(QPoint viewTopLeft);
 
+    /**
+    * @brief Signal for drawing OSM license
+    *
+    * Signal is emitted when view is resized.
+    * @param width Viewport width
+    * @param height Viewport height
+    */
+    void viewResizedNewSize(int width, int height);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
index a4fe962..fc54e3f 100644 (file)
@@ -40,6 +40,9 @@ MapViewScreen::MapViewScreen(QWidget *parent)
     connect(mapView, SIGNAL(viewContentChanged(QPoint)),
             mapEngine, SLOT(alignImmovableItems(QPoint)));
     connect(mapView, SIGNAL(viewZoomFinished()), mapEngine, SLOT(viewZoomFinished()));
+    connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
+            this, SLOT(drawOsmLicense(int, int)));
+
 
     QHBoxLayout *mapViewLayout = new QHBoxLayout;
     //DEBUG
@@ -59,11 +62,15 @@ MapViewScreen::MapViewScreen(QWidget *parent)
 //    connect(zoomIn, SIGNAL(clicked()), mapEngine, SLOT(zoomIn()));
 //    connect(zoomOut, SIGNAL(clicked()), mapEngine, SLOT(zoomOut()));
     //DEBUG
-    QLabel *OsmLicense = new QLabel("© OpenStreetMap contributors, CC-BY-SA",this);
-    OsmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
-    OsmLicense->resize(OsmLicense->fontMetrics().width("© OpenStreetMap contributors, CC-BY-SA"),
-                       OsmLicense->fontMetrics().height());
-    mapView->stackUnder(OsmLicense);
+
+    osmLicense = new QLabel(this);
+    osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
+    osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
+    osmLicense->setText("<font color='black'>"+OSM_LICENSE+"</font>");
+    osmLicense->setFont(QFont("Nokia Sans", 9));
+    osmLicense->resize(osmLicense->fontMetrics().width(OSM_LICENSE),
+                       osmLicense->fontMetrics().height());
+    mapView->stackUnder(osmLicense);
 
     mapViewLayout->addWidget(mapView);
     setLayout(mapViewLayout);
@@ -96,3 +103,10 @@ void MapViewScreen::friendsLocationsReady(QList<User *> &friendsList)
     qDebug() << __PRETTY_FUNCTION__;
     mapEngine->receiveFriendLocations(friendsList);
 }
+
+void MapViewScreen::drawOsmLicense(int width, int height)
+{
+    qDebug() << __PRETTY_FUNCTION__ << width << "x" << height;
+    osmLicense->move(width-osmLicense->fontMetrics().width(OSM_LICENSE),
+                     height-osmLicense->fontMetrics().height());
+}
index ccea38b..c52b04e 100644 (file)
@@ -67,12 +67,21 @@ private slots:
     */
     void friendsLocationsReady(QList<User *> &friendsList);
 
+    /**
+    * @brief Slot for drawing the Open Street Map license text
+    *
+    * @param width Width of the viewport
+    * @param height Height of the viewport
+    */
+    void drawOsmLicense(int width, int height);
+
 /*******************************************************************************
  * DATA MEMBERS
  ******************************************************************************/
 private:
     MapEngine *mapEngine; ///< MapEngine
     //DEBUG
+    QLabel *osmLicense; ///< Label for Open Street Map license
     QPushButton *zoomIn; ///< Debug button for zooming in
     QPushButton *zoomOut; ///< Debug button for zooming out
     QLineEdit latLine; ///< Debug input field for latitude