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

Dennis Nienhüser earthwings at gentoo.org
Mon Nov 8 20:38:58 CET 2010


SVN commit 1194343 by nienhueser:

Remove the guidance mode toggle button from the routing widget. The same functionality is available in the routing float item.
Add an "Open File..." button, visible in the routing dialog (maemo), that can be used to open a route (kml format).

 M  +1 -0      QtMainWindow.cpp  
 M  +6 -2      lib/routing/AlternativeRoutesModel.cpp  
 M  +3 -0      lib/routing/AlternativeRoutesModel.h  
 M  +4 -0      lib/routing/RoutingInputWidget.cpp  
 M  +9 -0      lib/routing/RoutingManager.cpp  
 M  +5 -0      lib/routing/RoutingManager.h  
 M  +16 -4     lib/routing/RoutingWidget.cpp  
 M  +6 -3      lib/routing/RoutingWidget.h  
 M  +11 -11    lib/routing/RoutingWidget.ui  


--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1194342:1194343
@@ -1239,6 +1239,7 @@
         m_routingDialog->setWindowTitle( tr( "Routing - Marble" ) );
         m_routingWidget = new RoutingWidget( m_controlView->marbleWidget(), m_routingDialog );
         m_routingWidget->setWorkOffline( m_workOfflineAct->isChecked() );
+        m_routingWidget->setOpenFileButtonVisible( true );
 
         QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok, Qt::Vertical, m_routingDialog );
         connect(buttonBox, SIGNAL( accepted() ), m_routingDialog, SLOT( accept() ) );
--- trunk/KDE/kdeedu/marble/src/lib/routing/AlternativeRoutesModel.cpp #1194342:1194343
@@ -327,9 +327,8 @@
 
 void AlternativeRoutesModel::newRequest( RouteRequest * )
 {
-    d->m_routes.clear();
     d->m_responseTime.start();
-    reset();
+    clear();
 }
 
 void AlternativeRoutesModel::addRestrainedRoutes()
@@ -448,6 +447,11 @@
     return result;
 }
 
+void AlternativeRoutesModel::clear()
+{
+    d->m_routes.clear();
+    reset();
+}
 
 } // namespace Marble
 
--- trunk/KDE/kdeedu/marble/src/lib/routing/AlternativeRoutesModel.h #1194342:1194343
@@ -76,6 +76,9 @@
 
     void setCurrentRoute( int index );
 
+    /** Remove all alternative routes from the model */
+    void clear();
+
     GeoDataDocument* currentRoute();
 
     /** Returns the waypoints contained in the route as a linestring */
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.cpp #1194342:1194343
@@ -295,8 +295,12 @@
 
 GeoDataCoordinates RoutingInputWidget::targetPosition() const
 {
+    if ( d->m_index < d->m_route->size() ) {
     return d->m_route->at( d->m_index );
+    } else {
+        return GeoDataCoordinates();
 }
+}
 
 void RoutingInputWidget::findPlacemarks()
 {
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.cpp #1194342:1194343
@@ -178,6 +178,10 @@
                 }
                 m_routeRequest->setName( m_routeRequest->size()-1, placemarks[i]->name() );
             }
+
+            for ( int i=placemarks.size(); i<m_routeRequest->size(); ++i ) {
+                m_routeRequest->remove( i );
+            }
         } else {
             mDebug() << "Expected a GeoDataDocument, didn't get one though";
         }
@@ -302,6 +306,11 @@
     d->saveRoute( filename );
 }
 
+void RoutingManager::loadRoute( const QString &filename )
+{
+    d->loadRoute( filename );
+}
+
 void RoutingManager::readSettings()
 {
     d->loadRoute( d->stateFile() );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.h #1194342:1194343
@@ -117,6 +117,11 @@
       */
     void saveRoute( const QString &filename ) const;
 
+    /**
+      * Opens the given filename (kml format) and loads the route contained in it
+      */
+    void loadRoute( const QString &filename );
+
 public Q_SLOTS:
     /** Update the route */
     void updateRoute();
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.cpp #1194342:1194343
@@ -31,6 +31,7 @@
 #include <QtGui/QSortFilterProxyModel>
 #include <QtGui/QComboBox>
 #include <QtGui/QPainter>
+#include <QtGui/QFileDialog>
 
 #include "ui_RoutingWidget.h"
 
@@ -232,8 +233,8 @@
 
     connect( d->m_ui.searchButton, SIGNAL( clicked( ) ),
              this, SLOT( retrieveRoute () ) );
-    connect( d->m_ui.guideButton, SIGNAL( clicked( bool ) ),
-             this, SLOT( setGuidanceModeEnabled( bool ) ) );
+    connect( d->m_ui.openButton, SIGNAL( clicked( bool ) ),
+             this, SLOT( openRouteFile() ) );
     connect( d->m_ui.optionsLabel, SIGNAL( linkActivated( QString ) ),
              this, SLOT( configureProfile() ) );
     connect( d->m_ui.routeComboBox, SIGNAL( currentIndexChanged( int ) ),
@@ -248,6 +249,7 @@
         addInputWidget();
     }
     //d->m_ui.descriptionLabel->setVisible( false );
+    setOpenFileButtonVisible( false );
 }
 
 RoutingWidget::~RoutingWidget()
@@ -544,11 +546,21 @@
     }
 }
 
-void RoutingWidget::setGuidanceModeEnabled( bool enabled )
+void RoutingWidget::setOpenFileButtonVisible( bool visible )
 {
-    d->m_routingManager->setGuidanceModeEnabled( enabled );
+    d->m_ui.openButton->setVisible( visible );
 }
 
+void RoutingWidget::openRouteFile()
+{
+    QString const file = QFileDialog::getOpenFileName( this, tr( "Open Route" ),
+                            QString(), tr("KML Files (*.kml)") );
+    if ( !file.isEmpty() ) {
+        d->m_routingManager->alternativeRoutesModel()->clear();
+        d->m_routingManager->loadRoute( file );
+    }
+}
+
 void RoutingWidget::selectFirstProfile()
 {
     int count = d->m_routingManager->profilesModel()->rowCount();
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.h #1194342:1194343
@@ -52,6 +52,9 @@
       */
     void setWorkOffline( bool offline );
 
+    /** Show or hide the "open file..." button. Default is false (not visible) */
+    void setOpenFileButtonVisible( bool visible );
+
 private Q_SLOTS:
     /** Retrieve route directions */
     void retrieveRoute();
@@ -107,12 +110,12 @@
     /** Toggle visibility of alternative routes */
     void updateAlternativeRoutes();
 
-    /** Toggle turn by turn navigation mode */
-    void setGuidanceModeEnabled( bool enabled );
-
     /** Select the first routing profile if none is selected yet */
     void selectFirstProfile();
 
+    /** Ask the user for a kml file to open */
+    void openRouteFile();
+
 private:
     RoutingWidgetPrivate *const d;
 };
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.ui #1194342:1194343
@@ -63,7 +63,7 @@
         <string>Show or hide routing options</string>
        </property>
        <property name="text">
-        <string>&lt;a href="http://edu.kde.org"&gt;Configure&lt;/a&gt;</string>
+        <string>&lt;a href=&quot;http://edu.kde.org&quot;&gt;Configure&lt;/a&gt;</string>
        </property>
        <property name="textFormat">
         <enum>Qt::RichText</enum>
@@ -82,16 +82,6 @@
       </widget>
      </item>
      <item>
-      <widget class="QPushButton" name="guideButton">
-       <property name="text">
-        <string>Guidance Mode</string>
-       </property>
-       <property name="checkable">
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
       <spacer name="horizontalSpacer_2">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
@@ -104,6 +94,16 @@
        </property>
       </spacer>
      </item>
+     <item>
+      <widget class="QPushButton" name="openButton">
+       <property name="text">
+        <string>Open File...</string>
+       </property>
+       <property name="checkable">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>


More information about the Marble-commits mailing list