[Marble-commits] KDE/kdeedu/marble

Dennis Nienhüser earthwings at gentoo.org
Wed Feb 2 22:09:03 CET 2011


SVN commit 1218559 by nienhueser:

Add a GeoDataCoordinates wrapper exported to QML. Use it inside Placemark (switch to GeoDataPlacemark wrapper tbd.).

 M  +4 -4      examples/qml/google-search/google-search.qml  
 M  +3 -1      src/plugins/declarative/CMakeLists.txt  
 A             src/plugins/declarative/Coordinate.cpp   [License: LGPL]
 A             src/plugins/declarative/Coordinate.h   [License: LGPL]
 M  +4 -0      src/plugins/declarative/MarbleDeclarativePlugin.cpp  
 M  +1 -1      src/plugins/declarative/MarbleDeclarativeRunnerManager.cpp  
 M  +9 -17     src/plugins/declarative/Placemark.cpp  
 M  +13 -16    src/plugins/declarative/Placemark.h  


--- trunk/KDE/kdeedu/marble/examples/qml/google-search/google-search.qml #1218558:1218559
@@ -83,8 +83,8 @@
         itemdetails.visible = false
         var result = search.searchResult()
         for( var i=0; i<result.length; ++i ) {
-          var x = map.screenX( result[i].longitude, result[i].latitude ) - 10
-          var y = map.screenY( result[i].longitude, result[i].latitude ) - 30
+          var x = map.screenX( result[i].coordinate.longitude, result[i].coordinate.latitude ) - 10
+          var y = map.screenY( result[i].coordinate.longitude, result[i].coordinate.latitude ) - 30
           if ( x > 0 && y > 0 ) {
             Search.updateResult( i, result[i].name, x, y )
           } else {
@@ -101,8 +101,8 @@
         var result = search.searchResult()
         Search.prepareResults(result.length)
         for( var i=0; i<result.length; ++i ) {
-          var x = map.screenX( result[i].longitude, result[i].latitude ) - 10
-          var y = map.screenY( result[i].longitude, result[i].latitude ) - 30
+          var x = map.screenX( result[i].coordinate.longitude, result[i].coordinate.latitude ) - 10
+          var y = map.screenY( result[i].coordinate.longitude, result[i].coordinate.latitude ) - 30
           if ( x > 0 && y > 0 ) {
             Search.createResult( i, result[i].name, x, y, mapcontainer )
           }
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/CMakeLists.txt #1218558:1218559
@@ -10,12 +10,14 @@
 INCLUDE( ${QT_USE_FILE} )
 
 set( marbleplugin_SRCS
+Coordinate.cpp
 DeclarativeMapThemeManager.cpp
 MapTheme.cpp
 MarbleDeclarativePlugin.cpp
 MarbleDeclarativeRunnerManager.cpp
 MarbleDeclarativeWidget.cpp
-Placemark.cpp )
+Placemark.cpp
+)
 
 marble_add_declarative_plugin( MarbleDeclarativePlugin ${marbleplugin_SRCS})
 qt4_automoc(${marbleplugin_SRCS})
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/MarbleDeclarativePlugin.cpp #1218558:1218559
@@ -10,6 +10,7 @@
 
 #include "MarbleDeclarativePlugin.h"
 
+#include "Coordinate.h"
 #include "MarbleDeclarativeWidget.h"
 #include "MarbleDeclarativeRunnerManager.h"
 #include "DeclarativeMapThemeManager.h"
@@ -25,6 +26,9 @@
 void MarbleDeclarativePlugin::registerTypes( const char * )
 {
     const char* uri = "org.kde.edu.marble";
+
+    qmlRegisterType<Marble::Declarative::Coordinate>( uri, 0, 11, "Coordinate" );
+
     qmlRegisterType<Marble::Declarative::MarbleWidget>( uri, 0, 11, "MarbleWidget" );
     qmlRegisterType<Marble::Declarative::MarbleRunnerManager>( uri, 0, 11, "MarbleRunnerManager" );
     qmlRegisterType<Marble::Declarative::MapThemeManager>( uri, 0, 11, "MapThemeManager" );
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/MarbleDeclarativeRunnerManager.cpp #1218558:1218559
@@ -49,7 +49,7 @@
         GeoDataCoordinates pos = qVariantValue<GeoDataCoordinates>( data );
         qreal lon = pos.longitude( GeoDataCoordinates::Degree );
         qreal lat = pos.latitude( GeoDataCoordinates::Degree );
-        result << new Placemark( name, lon, lat );
+        result << new Placemark( name, new Coordinate( lon, lat ) );
     }
 
     return result;
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/Placemark.cpp #1218558:1218559
@@ -15,10 +15,10 @@
 namespace Declarative
 {
 
-Placemark::Placemark( const QString &name, qreal lon, qreal lat, QObject *parent ) :
-    QObject( parent ), m_name( name ), m_longitude( lon ), m_latitude( lat )
+Placemark::Placemark( const QString &name, Coordinate *coordinate, QObject *parent ) :
+    QObject( parent ), m_name( name )
 {
-    // nothing to do
+    m_coordinate.setCoordinates( coordinate->coordinates() );
 }
 
 QString Placemark::name() const
@@ -29,29 +29,21 @@
 void Placemark::setName( const QString &name )
 {
     m_name = name;
+    emit nameChanged();
 }
 
-qreal Placemark::longitude() const
+Coordinate *Placemark::coordinate()
 {
-    return m_longitude;
+    return &m_coordinate;
 }
 
-void Placemark::setLongitude( qreal lon )
+void Placemark::setCoordinate( Coordinate *coordinate )
 {
-    m_longitude = lon;
+    m_coordinate.setCoordinates( coordinate->coordinates() );
+    emit coordinateChanged();
 }
 
-qreal Placemark::latitude() const
-{
-    return m_latitude;
 }
-
-void Placemark::setLatitude( qreal lat )
-{
-    m_latitude = lat;
 }
 
-}
-}
-
 #include "Placemark.moc"
--- trunk/KDE/kdeedu/marble/src/plugins/declarative/Placemark.h #1218558:1218559
@@ -11,6 +11,8 @@
 #ifndef MARBLE_DECLARATIVE_PLACEMARK_H
 #define MARBLE_DECLARATIVE_PLACEMARK_H
 
+#include "Coordinate.h"
+
 #include <QtCore/QObject>
 
 namespace Marble
@@ -27,13 +29,12 @@
 {
     Q_OBJECT
 
-    Q_PROPERTY( QString name READ name WRITE setName )
-    Q_PROPERTY( qreal longitude READ longitude WRITE setLongitude )
-    Q_PROPERTY( qreal latitude READ latitude WRITE setLatitude )
+    Q_PROPERTY( QString name READ name WRITE setName NOTIFY nameChanged )
+    Q_PROPERTY( Marble::Declarative::Coordinate* coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged )
 
 public:
     /** Constructor */
-    Placemark( const QString &name, qreal lon, qreal lat, QObject *parent = 0 );
+    Placemark( const QString &name, Coordinate *coordinate, QObject *parent = 0 );
 
     /** Provides access to the placemark name */
     QString name() const;
@@ -41,24 +42,20 @@
     /** Change the placemark's name */
     void setName( const QString &name );
 
-    /** Provides access to the longitude of the placemark */
-    qreal longitude() const;
+    /** Returns the coordinate of the place */
+    Coordinate *coordinate();
 
-    /** Change the longitude of the placemark */
-    void setLongitude( qreal lon );
+    /** Change the coordinate of the placemark */
+    void setCoordinate( Coordinate *coordinate );
 
-    /** Provides access to the latitude of the placemark */
-    qreal latitude() const;
+Q_SIGNALS:
+    void nameChanged();
+    void coordinateChanged();
 
-    /** Change the latitude of the placemark */
-    void setLatitude( qreal lat );
-
 private:
     QString m_name;
 
-    qreal m_longitude;
-
-    qreal m_latitude;
+    Coordinate m_coordinate;
 };
 
 }


More information about the Marble-commits mailing list