[kde-doc-english] [marble] src: Make common tasks easier/possible in the user interface.

Dennis Nienhüser earthwings at gentoo.org
Sun May 13 21:10:13 UTC 2012


Git commit 70003fa4d415f545c66d0ee13b16d18f7c4d812f by Dennis Nienhüser.
Committed on 13/05/2012 at 22:54.
Pushed by nienhueser into branch 'master'.

Make common tasks easier/possible in the user interface.

Adds buttons to open a route (from .kml), clear the current one,
reverse it, add a via point and save it.
GUI:
REVIEW: 102539
FEATURE: 285090
FEATURE: 281278
FEATURE: 278625
FIXED-IN: KDE-4.9.0

A  +-    --    src/icons/16x16/configure.png
A  +-    --    src/icons/16x16/document-open.png
A  +-    --    src/icons/16x16/document-save.png
M  +19   -33   src/lib/routing/RoutingWidget.cpp
M  +72   -16   src/lib/routing/RoutingWidget.ui
M  +3    -0    src/marble.qrc

http://commits.kde.org/marble/70003fa4d415f545c66d0ee13b16d18f7c4d812f

diff --git a/src/icons/16x16/configure.png b/src/icons/16x16/configure.png
new file mode 100644
index 0000000..5ce478b
Binary files /dev/null and b/src/icons/16x16/configure.png differ
diff --git a/src/icons/16x16/document-open.png b/src/icons/16x16/document-open.png
new file mode 100644
index 0000000..2d83b2a
Binary files /dev/null and b/src/icons/16x16/document-open.png differ
diff --git a/src/icons/16x16/document-save.png b/src/icons/16x16/document-save.png
new file mode 100644
index 0000000..8072aea
Binary files /dev/null and b/src/icons/16x16/document-save.png differ
diff --git a/src/lib/routing/RoutingWidget.cpp b/src/lib/routing/RoutingWidget.cpp
index bba13ee..a04de9f 100644
--- a/src/lib/routing/RoutingWidget.cpp
+++ b/src/lib/routing/RoutingWidget.cpp
@@ -224,7 +224,17 @@ RoutingWidget::RoutingWidget( MarbleWidget *marbleWidget, QWidget *parent ) :
     connect( d->m_ui.directionsListView, SIGNAL( activated ( QModelIndex ) ),
              this, SLOT( activateItem ( QModelIndex ) ) );
 
-    connect( d->m_ui.searchButton, SIGNAL( clicked( ) ),
+    connect( d->m_ui.openRouteButton, SIGNAL( clicked() ),
+             this, SLOT( openRoute () ) );
+    connect( d->m_ui.saveRouteButton, SIGNAL( clicked() ),
+             this, SLOT( saveRoute () ) );
+    connect( d->m_ui.addViaButton, SIGNAL( clicked() ),
+             this, SLOT( addInputWidget() ) );
+    connect( d->m_ui.reverseRouteButton, SIGNAL( clicked() ),
+             d->m_routingManager, SLOT( reverseRoute () ) );
+    connect( d->m_ui.clearRouteButton, SIGNAL( clicked() ),
+             d->m_routingManager, SLOT( clearRoute () ) );
+    connect( d->m_ui.searchButton, SIGNAL( clicked() ),
              this, SLOT( retrieveRoute () ) );
     connect( d->m_ui.showInstructionsButton, SIGNAL( clicked( bool ) ),
              this, SLOT( showDirections() ) );
@@ -432,6 +442,8 @@ void RoutingWidget::updateRouteState( RoutingManager::State state )
     if ( state == RoutingManager::Downloading ) {
         d->m_progressTimer.start();
     }
+
+    d->m_ui.saveRouteButton->setEnabled( d->m_routingManager->routingModel()->rowCount() > 0 );
 }
 
 void RoutingWidget::requestMapPosition( RoutingInputWidget *widget, bool enabled )
@@ -503,32 +515,11 @@ void RoutingWidget::updateAlternativeRoutes()
 {
     if ( d->m_ui.routeComboBox->count() == 1) {
         // Parts of the route may lie outside the route trip points
-        GeoDataLineString bbox;
-        for ( int i = 0; i < d->m_routingManager->routingModel()->rowCount(); ++i ) {
-            QModelIndex index = d->m_routingManager->routingModel()->index( i, 0 );
-            QVariant pos = index.data( MarblePlacemarkModel::CoordinateRole );
-            if ( !pos.isNull() ) {
-                bbox << qVariantValue<GeoDataCoordinates>( pos );
-            }
-        }
-
-        if ( bbox.size() > 1 ) {
-//            qreal distance = d->m_routingManager->routingModel()->totalDistance();
-//            unsigned int days = d->m_routingManager->routingModel()->duration().days;
-//            QTime time = d->m_routingManager->routingModel()->duration().time;
-//            QString timeString = time.toString( Qt::DefaultLocaleShortDate );
-//            if ( days ) {
-//                QString label = tr( "Estimated travel time: %1 days, %2 (%3 km)", 0, days );
-//                d->m_ui.descriptionLabel->setText( label.arg( days ).arg( timeString ).arg( distance, 0, 'f', 1 ) );
-//            } else {
-//                QString label = tr( "Estimated travel time: %1 (%2 km)" );
-//                d->m_ui.descriptionLabel->setText( label.arg( timeString ).arg( distance, 0, 'f', 1 ) );
-//            }
-//            d->m_ui.descriptionLabel->setVisible( true );
-
+        GeoDataLatLonBox const bbox = d->m_routingManager->routingModel()->route().bounds();
+        if ( !bbox.isEmpty() ) {
             if ( d->m_zoomRouteAfterDownload ) {
                 d->m_zoomRouteAfterDownload = false;
-                d->m_widget->centerOn( GeoDataLatLonBox::fromLineString( bbox ) );
+                d->m_widget->centerOn( bbox );
             }
         }
     }
@@ -544,6 +535,7 @@ void RoutingWidget::updateAlternativeRoutes()
     QString const results = tr( "%n routes found", "", d->m_ui.routeComboBox->count() );
     d->m_ui.resultLabel->setText( results );
     d->m_ui.resultLabel->setVisible( true );
+    d->m_ui.saveRouteButton->setEnabled( d->m_routingManager->routingModel()->rowCount() > 0 );
 }
 
 void RoutingWidget::setShowDirectionsButtonVisible( bool visible )
@@ -557,15 +549,9 @@ void RoutingWidget::openRoute()
                             d->m_routingManager->lastOpenPath(), tr("KML Files (*.kml)") );
     if ( !file.isEmpty() ) {
         d->m_routingManager->setLastOpenPath( QFileInfo( file ).absolutePath() );
-        d->m_routingManager->alternativeRoutesModel()->clear();
+        d->m_zoomRouteAfterDownload = true;
         d->m_routingManager->loadRoute( file );
-        GeoDataDocument* route = d->m_routingManager->alternativeRoutesModel()->route( 0 );
-        if ( route ) {
-            GeoDataLineString* waypoints = d->m_routingManager->alternativeRoutesModel()->waypoints( route );
-            if ( waypoints ) {
-                d->m_widget->centerOn( waypoints->latLonAltBox() );
-            }
-        }
+        updateAlternativeRoutes();
     }
 }
 
diff --git a/src/lib/routing/RoutingWidget.ui b/src/lib/routing/RoutingWidget.ui
index 7d0620c..0cf837e 100644
--- a/src/lib/routing/RoutingWidget.ui
+++ b/src/lib/routing/RoutingWidget.ui
@@ -6,23 +6,47 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>282</width>
-    <height>319</height>
+    <width>245</width>
+    <height>414</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="routingLayout">
-   <property name="sizeConstraint">
-    <enum>QLayout::SetMinAndMaxSize</enum>
-   </property>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <widget class="QPushButton" name="addViaButton">
+       <property name="text">
+        <string>Add Via</string>
+       </property>
+       <property name="checkable">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="reverseRouteButton">
+       <property name="text">
+        <string>Reverse</string>
+       </property>
+       <property name="checkable">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
      <item>
-      <widget class="QLabel" name="preferenceLabel">
+      <widget class="QPushButton" name="clearRouteButton">
        <property name="text">
-        <string>Profile</string>
+        <string>Clear</string>
+       </property>
+       <property name="checkable">
+        <bool>false</bool>
        </property>
       </widget>
      </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QComboBox" name="routingProfileComboBox">
        <item>
@@ -61,9 +85,13 @@
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="configureButton">
+      <widget class="QToolButton" name="configureButton">
        <property name="text">
-        <string>Configure</string>
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../marble.qrc">
+         <normaloff>:/icons/16x16/configure.png</normaloff>:/icons/16x16/configure.png</iconset>
        </property>
       </widget>
      </item>
@@ -130,14 +158,42 @@
     </widget>
    </item>
    <item>
-    <widget class="QComboBox" name="routeComboBox">
-     <property name="toolTip">
-      <string>Choose alternative routes</string>
-     </property>
-    </widget>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <widget class="QComboBox" name="routeComboBox">
+       <property name="toolTip">
+        <string>Choose alternative routes</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QToolButton" name="openRouteButton">
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../marble.qrc">
+         <normaloff>:/icons/16x16/document-open.png</normaloff>:/icons/16x16/document-open.png</iconset>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QToolButton" name="saveRouteButton">
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset resource="../../marble.qrc">
+         <normaloff>:/icons/16x16/document-save.png</normaloff>:/icons/16x16/document-save.png</iconset>
+       </property>
+      </widget>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>
- <resources/>
+ <resources>
+  <include location="../../marble.qrc"/>
+ </resources>
  <connections/>
 </ui>
diff --git a/src/marble.qrc b/src/marble.qrc
index 089f627..ac7da95 100644
--- a/src/marble.qrc
+++ b/src/marble.qrc
@@ -50,8 +50,11 @@
     <file>icons/crosshairs.png</file>
     <file>icons/elevationprofile.png</file>
     <file>icons/16x16/task-accepted.png</file>
+    <file>icons/16x16/document-open.png</file>
+    <file>icons/16x16/document-save.png</file>
     <file>icons/16x16/task-attention.png</file>
     <file>icons/16x16/edit-find.png</file>
+    <file>icons/16x16/configure.png</file>
     <file>icons/16x16/edit-clear-locationbar-ltr.png</file>
     <file>icons/16x16/edit-clear-locationbar-rtl.png</file>
     <file>icons/22x22/edit-clear-locationbar-ltr.png</file>


More information about the kde-doc-english mailing list