[Marble-commits] branches/KDE/4.3/kdeedu/marble/src/lib

Bastian Holst bastianholst at gmx.de
Sun Jul 26 18:14:58 CEST 2009


SVN commit 1002631 by bholst:

You won't have to reimplement all functions if you want to implement a DataPlugin for Marble

 M  +9 -0      AbstractDataPluginItem.cpp  
 M  +2 -2      AbstractDataPluginItem.h  
 M  +4 -0      AbstractDataPluginModel.cpp  
 M  +1 -1      AbstractDataPluginModel.h  
 M  +17 -1     MarbleWidgetInputHandler.cpp  


--- branches/KDE/4.3/kdeedu/marble/src/lib/AbstractDataPluginItem.cpp #1002630:1002631
@@ -80,6 +80,15 @@
     d->m_addedAngularResolution = resolution;
 }
 
+QAction *AbstractDataPluginItem::action() {
+    return 0;
+}
+
+void AbstractDataPluginItem::addDownloadedFile( const QString& url, const QString& type ) {
+    Q_UNUSED( url )
+    Q_UNUSED( type )
+}
+
 } // Marble namespace
 
 #include "AbstractDataPluginItem.moc"
--- branches/KDE/4.3/kdeedu/marble/src/lib/AbstractDataPluginItem.h #1002630:1002631
@@ -51,13 +51,13 @@
     qreal addedAngularResolution() const;
     void setAddedAngularResolution( qreal resolution );
     
-    virtual QAction *action() = 0;
+    virtual QAction *action();
     
     virtual QString itemType() const = 0;
      
     virtual bool initialized() = 0;
     
-    virtual void addDownloadedFile( const QString& url, const QString& type ) = 0;
+    virtual void addDownloadedFile( const QString& url, const QString& type );
     
     virtual void paint( GeoPainter *painter, ViewportParams *viewport,
                         const QString& renderPos, GeoSceneLayer * layer = 0 ) = 0;
--- branches/KDE/4.3/kdeedu/marble/src/lib/AbstractDataPluginModel.cpp #1002630:1002631
@@ -223,6 +223,10 @@
     return itemsAt;
 }
 
+void AbstractDataPluginModel::parseFile( const QByteArray& file ) {
+    Q_UNUSED( file );
+}
+
 void AbstractDataPluginModel::downloadItemData( const QUrl& url,
                                                 const QString& type,
                                                 AbstractDataPluginItem *item )
--- branches/KDE/4.3/kdeedu/marble/src/lib/AbstractDataPluginModel.h #1002630:1002631
@@ -82,7 +82,7 @@
      * starts additionally needed downloads.
      * This method has to be implemented in a subclass.
      **/
-    virtual void parseFile( const QByteArray& file ) = 0;
+    virtual void parseFile( const QByteArray& file );
         
     /**
      * Downloads the file from @p url. @p item -> addDownloadedFile() will be called when the
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1002630:1002631
@@ -26,6 +26,7 @@
 #include "ViewParams.h"
 #include "ViewportParams.h"
 #include "AbstractFloatItem.h"
+#include "AbstractDataPluginItem.h"
 #include "MeasureTool.h"
 #include "MarbleWidgetPopupMenu.h"
 
@@ -398,8 +399,23 @@
         // Adjusting Cursor shape
 
         QPoint mousePosition( event->x(), event->y() );
+        
+        // Find out if there are data items and if one has defined an action
+        QList<AbstractDataPluginItem *> dataItems
+                = m_widget->model()->whichItemAt( mousePosition );
+        bool dataAction = false;
+        for ( QList<AbstractDataPluginItem *>::iterator it = dataItems.begin();
+              it != dataItems.end();
+              ++it )
+        {
+            if ( (*it)->action() ) {
+                dataAction = true;
+                break;
+            }
+        }
+        
         if ( ( m_widget->model()->whichFeatureAt( mousePosition ).size() == 0 )
-             && ( m_widget->model()->whichItemAt( mousePosition ).size() == 0 ) )
+             && ( !dataAction ) )
         {
             if ( !m_leftpressed )
                 arrowcur [1][1] = QCursor(Qt::OpenHandCursor);


More information about the Marble-commits mailing list