[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/marble/src/lib
From:       Thibaut Gridel <tgridel () free ! fr>
Date:       2010-12-26 13:55:31
Message-ID: 20101226135531.A07F2AC8AE () svn ! kde ! org
[Download RAW message or body]

SVN commit 1209329 by tgridel:

NavigationWidget: simplify centering the map widget
- no need for specific signal in the listView
- remove slots with QModelIndex as its error-prone if you don't know which model to \
                use
- call widget->centerOn directly

 M  +0 -1      FileManager.h  
 M  +0 -1      GoToDialog.cpp  
 M  +0 -1      MarbleDataFacade.h  
 M  +0 -23     MarbleMap.cpp  
 M  +0 -7      MarbleMap.h  
 M  +0 -1      MarbleModel.cpp  
 M  +0 -2      MarbleSearchListView.cpp  
 M  +0 -4      MarbleSearchListView.h  
 M  +0 -21     MarbleWidget.cpp  
 M  +0 -6      MarbleWidget.h  
 M  +14 -6     NavigationWidget.cpp  
 M  +0 -12     NavigationWidget.h  


--- trunk/KDE/kdeedu/marble/src/lib/FileManager.h #1209328:1209329
@@ -34,7 +34,6 @@
  */
 class FileManager : public QObject
 {
-    friend class MarblePlacemarkModel;
     Q_OBJECT
 
  public:
--- trunk/KDE/kdeedu/marble/src/lib/GoToDialog.cpp #1209328:1209329
@@ -15,7 +15,6 @@
 #include "GeoDataFolder.h"
 #include "PositionTracking.h"
 #include "BookmarkManager.h"
-#include "MarblePlacemarkModel.h"
 #include "routing/RoutingManager.h"
 #include "routing/RouteRequest.h"
 
--- trunk/KDE/kdeedu/marble/src/lib/MarbleDataFacade.h #1209328:1209329
@@ -39,7 +39,6 @@
 
 class MarbleModel;
 class MarbleGeoDataModel;
-class MarblePlacemarkModel;
 class GeoDataTreeModel;
 class FileViewModel;
 class MarbleDataFacadePrivate;
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1209328:1209329
@@ -50,7 +50,6 @@
 #include "MarbleDirs.h"
 #include "MarbleLocale.h"
 #include "MarbleModel.h"
-#include "MarblePlacemarkModel.h"
 #include "MeasureTool.h"
 #include "MergedLayerDecorator.h"
 #include "PlacemarkLayout.h"
@@ -752,28 +751,6 @@
     emit visibleLatLonAltBoxChanged( d->m_viewParams.viewport()->viewLatLonAltBox() \
);  }
 
-void MarbleMap::centerOn( const QModelIndex& index )
-{
-    QItemSelectionModel *selectionModel = d->m_model->placemarkSelectionModel();
-    Q_ASSERT( selectionModel );
-
-    selectionModel->clear();
-
-    if ( index.isValid() ) {
-        const GeoDataCoordinates point =
-            index.data( MarblePlacemarkModel::CoordinateRole \
                ).value<GeoDataCoordinates>();
-  
-        qreal  lon;
-        qreal  lat;
-        point.geoCoordinates( lon, lat );
-
-        centerOn( lon * RAD2DEG, lat * RAD2DEG );
-
-        selectionModel->select( index, QItemSelectionModel::SelectCurrent );
-    }
-}
-
-
 void MarbleMap::setCenterLatitude( qreal lat )
 {
     centerOn( centerLongitude(), lat );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.h #1209328:1209329
@@ -37,7 +37,6 @@
 
 // Qt
 class QAbstractItemModel;
-class QModelIndex;
 class QItemSelectionModel;
 
 namespace Marble
@@ -531,12 +530,6 @@
     void centerOn( const qreal lon, const qreal lat );
 
     /**
-     * @brief  Center the view on a point
-     * @param  index  an index for a QModel, indicating a city
-     */
-    void centerOn( const QModelIndex& index );
-
-    /**
      * @brief  Set the latitude for the center point
      * @param  lat  the new value for the latitude in degree
      */
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1209328:1209329
@@ -52,7 +52,6 @@
 #include "HttpDownloadManager.h"
 #include "MarbleDataFacade.h"
 #include "MarbleDirs.h"
-#include "MarblePlacemarkModel.h"
 #include "FileManager.h"
 #include "GeoDataTreeModel.h"
 #include "PlacemarkManager.h"
--- trunk/KDE/kdeedu/marble/src/lib/MarbleSearchListView.cpp #1209328:1209329
@@ -20,8 +20,6 @@
     : QListView( parent ),
       d( 0 )
 {
-    connect( this, SIGNAL( activated( const QModelIndex& ) ),
-             this, SIGNAL( centerOn ( const QModelIndex& ) ) );
 }
 
 
--- trunk/KDE/kdeedu/marble/src/lib/MarbleSearchListView.h #1209328:1209329
@@ -17,7 +17,6 @@
 
 #include "marble_export.h"
 
-class QModelIndex;
 class QString;
 
 namespace Marble
@@ -30,9 +29,6 @@
  public:
     explicit MarbleSearchListView(QWidget*);
 
- Q_SIGNALS:
-    void centerOn(const QModelIndex&);
-
  public Q_SLOTS:
     void  selectItem(const QString&);
     void  activate();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1209328:1209329
@@ -39,7 +39,6 @@
 #include "MarbleMap_p.h" // FIXME: remove this
 #include "MarbleModel.h"
 #include "MarblePhysics.h"
-#include "MarblePlacemarkModel.h"
 #include "MarbleWidgetInputHandler.h"
 #include "MeasureTool.h"
 #include "MergedLayerDecorator.h"
@@ -596,26 +595,6 @@
     centerOn( target, animated );
 }
 
-void MarbleWidget::centerOn( const QModelIndex& index, bool animated )
-{
-    QItemSelectionModel *selectionModel = d->m_model->placemarkSelectionModel();
-    Q_ASSERT( selectionModel );
-
-    selectionModel->clear();
-
-    if ( index.isValid() ) {
-        const GeoDataCoordinates targetPosition =
-            index.data( MarblePlacemarkModel::CoordinateRole \
                ).value<GeoDataCoordinates>();
-
-        GeoDataLookAt target = lookAt();
-        target.setLongitude( targetPosition.longitude() );
-        target.setLatitude( targetPosition.latitude() );
-        flyTo( target, animated ? Automatic : Instant );
-
-        selectionModel->select( index, QItemSelectionModel::SelectCurrent );
-    }
-}
-
 void MarbleWidget::centerOn( const GeoDataCoordinates &position, bool animated )
 {
     GeoDataLookAt target = lookAt();
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1209328:1209329
@@ -639,12 +639,6 @@
 
     /**
      * @brief  Center the view on a point
-     * @param  index  an index for a QModel, indicating a city
-     */
-    void centerOn( const QModelIndex& index, bool animated = false );
-
-    /**
-     * @brief  Center the view on a point
      * This method centers the Marble map on the point described by the latitude
      * and longitude in the GeoDataCoordinate parameter @c point. It also zooms
      * the map to be at the elevation described by the altitude. If this is
--- trunk/KDE/kdeedu/marble/src/lib/NavigationWidget.cpp #1209328:1209329
@@ -56,7 +56,7 @@
 
     d->m_navigationUi.setupUi( this );
 
-    d->m_sortproxy = new QSortFilterProxyModel( d->m_navigationUi.locationListView \
); +    d->m_sortproxy = new QSortFilterProxyModel( this );
     d->m_navigationUi.locationListView->setModel( d->m_sortproxy );
 
     connect( d->m_navigationUi.goHomeButton,     SIGNAL( clicked() ),
@@ -80,7 +80,7 @@
     connect( d->m_navigationUi.moveDownButton,   SIGNAL( clicked() ),
              this,                               SIGNAL( moveDown() ) );
 
-    connect( d->m_navigationUi.locationListView, SIGNAL( centerOn( const \
QModelIndex& ) ), +    connect( d->m_navigationUi.locationListView, SIGNAL( \
                activated( const QModelIndex& ) ),
              this,                               SLOT( mapCenterOnSignal( const \
QModelIndex& ) ) );  
     connect( d->m_navigationUi.searchLineEdit,   SIGNAL( textChanged( const QString& \
) ), @@ -126,9 +126,6 @@
     connect( this, SIGNAL( moveUp() ),    d->m_widget, SLOT( moveUp() ) );
     connect( this, SIGNAL( moveDown() ),  d->m_widget, SLOT( moveDown() ) );
 
-    connect( this,        SIGNAL( centerOn( const QModelIndex&, bool ) ),
-             d->m_widget, SLOT( centerOn( const QModelIndex&, bool ) ) );
-
     connect( d->m_widget, SIGNAL( zoomChanged( int ) ),
              this,        SLOT( changeZoom( int ) ) );
 
@@ -194,6 +191,7 @@
     d->m_sortproxy->setSortLocaleAware( true );
     d->m_sortproxy->setDynamicSortFilter( true );
     d->m_sortproxy->sort( 0 );
+    d->m_widget->placemarkSelectionModel()->clear();
     mDebug() << "NavigationWidget (sort): Time elapsed:"<< t.elapsed() << " ms";
 }
 
@@ -224,8 +222,18 @@
 
 void NavigationWidget::mapCenterOnSignal( const QModelIndex &index )
 {
-    emit centerOn( d->m_sortproxy->mapToSource( index ), true );
+    if( !index.isValid() ) {
+        return;
 }
+    GeoDataObject *object
+            = qVariantValue<GeoDataObject*>( index.model()->data(index, \
MarblePlacemarkModel::ObjectPointerRole ) ); +    if ( \
dynamic_cast<GeoDataPlacemark*>(object) ) +    {
+        GeoDataCoordinates coord = ( dynamic_cast<GeoDataPlacemark*>( object ) \
)->coordinate(); +        d->m_widget->centerOn( coord, true );
+        d->m_widget->placemarkSelectionModel()->select( d->m_sortproxy->mapToSource( \
index ), QItemSelectionModel::ClearAndSelect ); +    }
+}
 
 void NavigationWidget::adjustForAnimation()
 {
--- trunk/KDE/kdeedu/marble/src/lib/NavigationWidget.h #1209328:1209329
@@ -29,7 +29,6 @@
 class NavigationWidgetPrivate;
 
 class MarbleWidget;
-class MarblePlacemarkModel;
 
 class MARBLE_EXPORT NavigationWidget : public QWidget
 {
@@ -92,17 +91,6 @@
      */
     void moveDown();
 
-    /**
-     * @brief Signal emitted when a user selects a placemark in the search widget.
-     * @param index  the index for the chosen placemark.
-     *
-     * This signal is emitted when the user has selected a placemark
-     * in the search, e.g. by double clicking it or by pressing
-     * return.  If it is connected to the centerOn( QModelIndex&) slot
-     * in a MarbleWidget, the widget will center the view on this
-     * placemark.
-     */
-    void centerOn( const QModelIndex&, bool );
 
  public Q_SLOTS:
     /**


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic