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

Dennis Nienhüser earthwings at gentoo.org
Mon May 10 20:49:30 CEST 2010


SVN commit 1125135 by nienhueser:

Use a progress indicator in the Get Directions button to indicate when a route is being downloaded in the background.
CCBUG: 237122

 M  +24 -2     RoutingWidget.cpp  
 M  +3 -0      RoutingWidget.h  


--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.cpp #1125134:1125135
@@ -24,8 +24,10 @@
 #include "RoutingProxyModel.h"
 
 #include <QtCore/QTime>
+#include <QtCore/QTimer>
 #include <QtGui/QFileDialog>
 #include <QtGui/QSortFilterProxyModel>
+#include <QtGui/QMovie>
 
 #include "ui_RoutingWidget.h"
 
@@ -57,6 +59,10 @@
 
     bool m_workOffline;
 
+    QMovie m_progress;
+
+    QTimer m_progressTimer;
+
     /** Constructor */
     RoutingWidgetPrivate();
 
@@ -81,9 +87,9 @@
         m_widget( 0 ), m_routingManager( 0 ), m_routingLayer( 0 ),
         m_activeInput( 0 ), m_inputRequest( 0 ), m_routingProxyModel( 0 ),
         m_routeSkeleton( 0 ), m_zoomRouteAfterDownload( false ),
-        m_workOffline( false )
+        m_workOffline( false ), m_progress( ":/data/bitmaps/progress.mng" )
 {
-    // nothing to do
+    m_progressTimer.setInterval( 100 );
 }
 
 void RoutingWidgetPrivate::adjustInputWidgets()
@@ -159,6 +165,8 @@
              this, SLOT( insertInputWidget( int ) ) );
     connect( d->m_routeSkeleton, SIGNAL( positionRemoved( int ) ),
              this, SLOT( removeInputWidget( int ) ) );
+    connect( &d->m_progressTimer, SIGNAL( timeout() ),
+             this, SLOT( updateProgress() ) );
 
     d->m_routingProxyModel = new RoutingProxyModel( this );
     d->m_routingProxyModel->setSourceModel( d->m_routingManager->routingModel() );
@@ -402,7 +410,14 @@
     }
 
     d->m_routingLayer->setRouteDirty( state == RoutingManager::Downloading );
+
+    if ( state == RoutingManager::Downloading ) {
+        d->m_progressTimer.start();
+    } else {
+        d->m_progressTimer.stop();
+        d->m_ui.searchButton->setIcon( QIcon() );
 }
+}
 
 void RoutingWidget::requestMapPosition( RoutingInputWidget *widget, bool enabled )
 {
@@ -475,6 +490,13 @@
     d->m_routingManager->setWorkOffline( offline );
 }
 
+void RoutingWidget::updateProgress()
+{
+    d->m_progress.jumpToNextFrame();
+    QPixmap frame = d->m_progress.currentPixmap();
+    d->m_ui.searchButton->setIcon( frame );
+}
+
 } // namespace Marble
 
 #include "RoutingWidget.moc"
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.h #1125134:1125135
@@ -100,6 +100,9 @@
     /** Export route to a file */
     void exportRoute();
 
+    /** Progress animation update */
+    void updateProgress();
+
 private:
     RoutingWidgetPrivate *const d;
 };


More information about the Marble-commits mailing list