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

Bastian Holst bastianholst at gmx.de
Sun Jul 26 18:27:41 CEST 2009


SVN commit 1002636 by bholst:

Forwardport: 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  


--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginItem.cpp #1002635:1002636
@@ -82,6 +82,15 @@
     return false;
 }
 
+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"
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginItem.h #1002635:1002636
@@ -62,7 +62,7 @@
     /**
      * Returns the action of this specific item.
      */
-    virtual QAction *action() = 0;
+    virtual QAction *action();
     
     /**
      * Returns the type of this specific item.
@@ -71,7 +71,7 @@
 
     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;
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginModel.cpp #1002635:1002636
@@ -226,6 +226,10 @@
     return itemsAt;
 }
 
+void AbstractDataPluginModel::parseFile( const QByteArray& file ) {
+    Q_UNUSED( file );
+}
+
 void AbstractDataPluginModel::downloadItemData( const QUrl& url,
                                                 const QString& type,
                                                 AbstractDataPluginItem *item )
--- trunk/KDE/kdeedu/marble/src/lib/AbstractDataPluginModel.h #1002635:1002636
@@ -89,7 +89,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
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1002635:1002636
@@ -26,6 +26,7 @@
 #include "ViewParams.h"
 #include "ViewportParams.h"
 #include "AbstractFloatItem.h"
+#include "AbstractDataPluginItem.h"
 #include "MeasureTool.h"
 #include "MarbleWidgetPopupMenu.h"
 
@@ -411,8 +412,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