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

List:       kde-commits
Subject:    KDE/kdeedu/marble/src
From:       Dennis Nienhüser <earthwings () gentoo ! org>
Date:       2011-01-27 20:19:17
Message-ID: 20110127201917.D3268AC8BC () svn ! kde ! org
[Download RAW message or body]

SVN commit 1217543 by nienhueser:

Use stackable windows for the routing dialog, the directions list view inside the \
routing widget, the routing profile settings dialog, the map view dialog and the \
                tracking dialog.
REVIEW: 6417

 M  +2 -2      CMakeLists.txt  
 M  +45 -50    QtMainWindow.cpp  
 M  +4 -4      QtMainWindow.h  
 A             StackableWindow.cpp   [License: LGPL]
 A             StackableWindow.h   [License: LGPL]
 M  +3 -3      lib/routing/RoutingManager.h  
 M  +1 -3      lib/routing/RoutingProfileSettingsDialog.cpp  
 M  +42 -7     lib/routing/RoutingWidget.cpp  
 M  +10 -3     lib/routing/RoutingWidget.h  
 M  +2 -2      lib/routing/RoutingWidget.ui  


--- trunk/KDE/kdeedu/marble/src/CMakeLists.txt #1217542:1217543
@@ -85,8 +85,8 @@
 )
 
 if (QTONLY)
-  set(marble_SRCS ${marble_SRCS} qtmain.cpp QtMainWindow.cpp)
-  set(marble_HDRS ${marble_HDRS} QtMainWindow.h)
+  set(marble_SRCS ${marble_SRCS} qtmain.cpp QtMainWindow.cpp StackableWindow.cpp)
+  set(marble_HDRS ${marble_HDRS} QtMainWindow.h StackableWindow.h)
 else (QTONLY)
   set(marble_SRCS ${marble_SRCS} kdemain.cpp KdeMainWindow.cpp marble_part.cpp)
   set(marble_HDRS ${marble_HDRS} KdeMainWindow.h)
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.cpp #1217542:1217543
@@ -68,6 +68,7 @@
 #include "PositionProviderPlugin.h"
 #include "PluginManager.h"
 #include "MapWizard.h"
+#include "StackableWindow.h"
 
 // For zoom buttons on Maemo
 #ifdef Q_WS_MAEMO_5
@@ -93,9 +94,9 @@
         m_downloadRegionDialog( 0 ),
         m_downloadRegionAction( 0 ),
         m_osmEditAction( 0 ),
-        m_mapViewDialog( 0 ),
-        m_routingDialog( 0 ),
-        m_trackingDialog( 0 ),
+        m_mapViewWindow( 0 ),
+        m_routingWindow( 0 ),
+        m_trackingWindow( 0 ),
         m_routingWidget( 0 )
 {
 #ifdef Q_WS_MAEMO_5
@@ -1260,25 +1261,19 @@
 
 void MainWindow::showMapViewDialog()
 {
-    if( !m_mapViewDialog ) {
-        m_mapViewDialog = new QDialog( this );
-        m_mapViewDialog->setWindowTitle( tr( "Map View - Marble" ) );
-        MapViewWidget *mapViewWidget = new MapViewWidget( m_mapViewDialog );
+    if( !m_mapViewWindow ) {
+        m_mapViewWindow = new StackableWindow( this );
+        m_mapViewWindow->setWindowTitle( tr( "Map View - Marble" ) );
+
+        MapViewWidget *mapViewWidget = new MapViewWidget( m_mapViewWindow );
         mapViewWidget->setMarbleWidget( m_controlView->marbleWidget() );
 
-        QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok, \
                Qt::Vertical, m_mapViewDialog );
-        connect(buttonBox, SIGNAL( accepted() ), m_mapViewDialog, SLOT( accept() ) \
                );
-
-        QHBoxLayout* layout = new QHBoxLayout;
-        layout->addWidget( mapViewWidget );
-        layout->addWidget( buttonBox );
-        m_mapViewDialog->setLayout( layout );
-        m_mapViewDialog->resize( 640, 420 );
+        m_mapViewWindow->setCentralWidget( mapViewWidget );
     }
 
-    m_mapViewDialog->show();
-    m_mapViewDialog->raise();
-    m_mapViewDialog->activateWindow();
+    m_mapViewWindow->show();
+    m_mapViewWindow->raise();
+    m_mapViewWindow->activateWindow();
 }
 
 void MainWindow::showLegendTab( bool enabled )
@@ -1294,53 +1289,53 @@
 
 void MainWindow::showRoutingDialog()
 {
-    if( !m_routingDialog ) {
-        m_routingDialog = new QDialog( this );
-        m_routingDialog->setWindowTitle( tr( "Routing - Marble" ) );
-        m_routingWidget = new RoutingWidget( m_controlView->marbleWidget(), \
m_routingDialog ); +    if( !m_routingWindow ) {
+        m_routingWindow = new StackableWindow( this );
+        m_routingWindow->setWindowTitle( tr( "Routing - Marble" ) );
+
+        m_routingWidget = new RoutingWidget( m_controlView->marbleWidget(), \
m_routingWindow );  m_routingWidget->setWorkOffline( m_workOfflineAct->isChecked() );
-        m_routingWidget->setOpenFileButtonVisible( true );
+        m_routingWidget->setShowDirectionsButtonVisible( true );
 
-        QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok, \
                Qt::Vertical, m_routingDialog );
-        connect(buttonBox, SIGNAL( accepted() ), m_routingDialog, SLOT( accept() ) \
                );
-
         QScrollArea* scrollArea = new QScrollArea;
-        m_routingWidget->setMinimumWidth( 560 );
+        m_routingWidget->setMinimumWidth( 760 );
         scrollArea->setWidget( m_routingWidget );
 
-        QHBoxLayout* layout = new QHBoxLayout;
-        layout->addWidget( scrollArea );
-        layout->addWidget( buttonBox );
-        m_routingDialog->setLayout( layout );
-        m_routingDialog->resize( 640, 420 );
+        QAction *openAction = new QAction( tr( "Open Route..." ), this );
+        connect( openAction, SIGNAL( triggered() ), m_routingWidget, SLOT( \
openRoute() ) ); +        m_routingWindow->menuBar()->addAction( openAction );
+
+        QAction* saveAction = new QAction( tr( "Save Route..." ), this );
+        connect( saveAction, SIGNAL( triggered() ), m_routingWidget, SLOT( \
saveRoute() ) ); +        m_routingWindow->menuBar()->addAction( saveAction );
+
+        QAction* reverseAction = new QAction( tr( "Reverse Route" ), this );
+        RoutingManager * const manager = \
m_controlView->marbleWidget()->model()->routingManager(); +        connect( \
reverseAction, SIGNAL( triggered() ), manager, SLOT( reverseRoute() ) ); +        \
m_routingWindow->menuBar()->addAction( reverseAction ); +
+        m_routingWindow->setCentralWidget( scrollArea );
     }
 
-    m_routingDialog->show();
-    m_routingDialog->raise();
-    m_routingDialog->activateWindow();
+    m_routingWindow->show();
+    m_routingWindow->raise();
+    m_routingWindow->activateWindow();
 }
 
 void MainWindow::showTrackingDialog()
 {
-    if( !m_trackingDialog ) {
-        m_trackingDialog = new QDialog( this );
-        m_trackingDialog->setWindowTitle( tr( "Tracking - Marble" ) );
-        CurrentLocationWidget *trackingWidget = new CurrentLocationWidget( \
m_trackingDialog ); +    if( !m_trackingWindow ) {
+        m_trackingWindow = new StackableWindow( this );
+        m_trackingWindow->setWindowTitle( tr( "Tracking - Marble" ) );
+        CurrentLocationWidget *trackingWidget = new CurrentLocationWidget( \
m_trackingWindow );  trackingWidget->setMarbleWidget( m_controlView->marbleWidget() \
);  
-        QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok, \
                Qt::Vertical, m_trackingDialog );
-        connect(buttonBox, SIGNAL( accepted() ), m_trackingDialog, SLOT( accept() ) \
                );
-
-        QHBoxLayout* layout = new QHBoxLayout;
-        layout->addWidget( trackingWidget );
-        layout->addWidget( buttonBox );
-        m_trackingDialog->setLayout( layout );
-        m_trackingDialog->resize( 640, 420 );
+        m_trackingWindow->setCentralWidget( trackingWidget );
     }
 
-    m_trackingDialog->show();
-    m_trackingDialog->raise();
-    m_trackingDialog->activateWindow();
+    m_trackingWindow->show();
+    m_trackingWindow->raise();
+    m_trackingWindow->activateWindow();
 }
 
 void MainWindow::updateMapEditButtonVisibility( const QString &mapTheme )
--- trunk/KDE/kdeedu/marble/src/QtMainWindow.h #1217542:1217543
@@ -18,7 +18,6 @@
 #include <QtCore/QDateTime>
 #include "ControlView.h"
 
-
 class QAction;
 class QLabel;
 class QMenu;
@@ -34,6 +33,7 @@
 class DownloadRegionDialog;
 class RoutingWidget;
 class MapWizard;
+class StackableWindow;
 
 class MainWindow : public QMainWindow
 {
@@ -207,9 +207,9 @@
     QAction *m_toggleRoutingTabAction;
     QAction *m_showTrackingDialogAction;
 
-    QDialog *m_mapViewDialog;
-    QDialog *m_routingDialog;
-    QDialog *m_trackingDialog;
+    StackableWindow *m_mapViewWindow;
+    StackableWindow *m_routingWindow;
+    StackableWindow *m_trackingWindow;
 
     RoutingWidget *m_routingWidget;
 };
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingManager.h #1217542:1217543
@@ -78,9 +78,6 @@
       */
     void retrieveRoute( RouteRequest *route );
 
-    /** Reverse the previously requested route, i.e. swap start and destination (and \
                via points, if any) */
-    void reverseRoute();
-
     /**
       * Toggle offline mode. In offline mode, new routes cannot be downloaded
       */
@@ -123,6 +120,9 @@
     void loadRoute( const QString &filename );
 
 public Q_SLOTS:
+    /** Reverse the previously requested route, i.e. swap start and destination (and \
via points, if any) */ +    void reverseRoute();
+
     /** Update the route */
     void updateRoute();
 
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingProfileSettingsDialog.cpp \
#1217542:1217543 @@ -33,9 +33,7 @@
     if ( smallScreen ) {
       setMinimumHeight( 480 );
       m_ui->services->setMinimumWidth( 280 );
-      m_ui->gridLayout->removeWidget( m_ui->buttonBox );
-      m_ui->buttonBox->setOrientation( Qt::Vertical );
-      m_ui->gridLayout->addWidget( m_ui->buttonBox, 1, 1 );
+      m_ui->buttonBox->hide();
     }
 
     QList<RunnerPlugin*> allPlugins = pluginManager->runnerPlugins();
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.cpp #1217542:1217543
@@ -228,8 +228,8 @@
 
     connect( d->m_ui.searchButton, SIGNAL( clicked( ) ),
              this, SLOT( retrieveRoute () ) );
-    connect( d->m_ui.openButton, SIGNAL( clicked( bool ) ),
-             this, SLOT( openRouteFile() ) );
+    connect( d->m_ui.showInstructionsButton, SIGNAL( clicked( bool ) ),
+             this, SLOT( showDirections() ) );
     connect( d->m_ui.optionsLabel, SIGNAL( linkActivated( QString ) ),
              this, SLOT( configureProfile() ) );
     connect( d->m_ui.routeComboBox, SIGNAL( currentIndexChanged( int ) ),
@@ -244,8 +244,17 @@
         addInputWidget();
     }
     //d->m_ui.descriptionLabel->setVisible( false );
-    setOpenFileButtonVisible( false );
+    setShowDirectionsButtonVisible( false );
+
+    if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
+        d->m_ui.directionsListView->setVisible( false );
+#ifdef Q_WS_MAEMO_5
+        d->m_ui.directionsListView->setAttribute( Qt::WA_Maemo5StackedWindow );
+        d->m_ui.directionsListView->setWindowFlags( Qt::Window );
+        d->m_ui.directionsListView->setWindowTitle( tr( "Directions - Marble" ) );
+#endif // Q_WS_MAEMO_5
 }
+}
 
 RoutingWidget::~RoutingWidget()
 {
@@ -329,7 +338,11 @@
         d->m_widget->centerOn( GeoDataLatLonBox::fromLineString( placemarks ) );
         //d->m_ui.descriptionLabel->setVisible( false );
     }
+
+    if ( MarbleGlobal::getInstance()->profiles() & MarbleGlobal::SmallScreen ) {
+        d->m_ui.directionsListView->setVisible( true );
 }
+}
 
 void RoutingWidget::centerOnInputWidget( RoutingInputWidget *widget )
 {
@@ -464,7 +477,12 @@
 {
     int index = d->m_ui.routingProfileComboBox->currentIndex();
     if ( index != -1 ) {
-        RoutingProfileSettingsDialog dialog( d->m_widget->model()->pluginManager(), \
d->m_routingManager->profilesModel(), d->m_widget ); +        \
RoutingProfileSettingsDialog dialog( d->m_widget->model()->pluginManager(), \
d->m_routingManager->profilesModel(), this ); +#ifdef Q_WS_MAEMO_5
+        dialog.setAttribute( Qt::WA_Maemo5StackedWindow );
+        dialog.setWindowFlags( Qt::Window );
+        dialog.setWindowTitle( tr( "Routing Profile - Marble" ) );
+#endif // Q_WS_MAEMO_5
         dialog.editProfile( d->m_ui.routingProfileComboBox->currentIndex() );
         d->m_routeRequest->setRoutingProfile( \
d->m_routingManager->profilesModel()->profiles().at( index ) );  }
@@ -541,12 +559,12 @@
     d->m_ui.searchButton->setIcon( QIcon() );
 }
 
-void RoutingWidget::setOpenFileButtonVisible( bool visible )
+void RoutingWidget::setShowDirectionsButtonVisible( bool visible )
 {
-    d->m_ui.openButton->setVisible( visible );
+    d->m_ui.showInstructionsButton->setVisible( visible );
 }
 
-void RoutingWidget::openRouteFile()
+void RoutingWidget::openRoute()
 {
     QString const file = QFileDialog::getOpenFileName( this, tr( "Open Route" ),
                             QString(), tr("KML Files (*.kml)") );
@@ -571,6 +589,23 @@
     }
 }
 
+void RoutingWidget::showDirections()
+{
+    d->m_ui.directionsListView->setVisible( true );
+}
+
+void RoutingWidget::saveRoute()
+{
+    QString const fileName = QFileDialog::getSaveFileName( this,
+                       tr( "Save Route" ), // krazy:exclude=qclasses
+                       QDir::homePath(),
+                       tr( "KML files (*.kml)" ) );
+
+    if ( !fileName.isEmpty() ) {
+        d->m_routingManager->saveRoute( fileName );
+    }
+}
+
 } // namespace Marble
 
 #include "RoutingWidget.moc"
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.h #1217542:1217543
@@ -53,8 +53,15 @@
     void setWorkOffline( bool offline );
 
     /** Show or hide the "open file..." button. Default is false (not visible) */
-    void setOpenFileButtonVisible( bool visible );
+    void setShowDirectionsButtonVisible( bool visible );
 
+public Q_SLOTS:
+    /** Ask the user for a kml file to open */
+    void openRoute();
+
+    /** Ask the user for a kml file to save the current route to */
+    void saveRoute();
+
 private Q_SLOTS:
     /** Retrieve route directions */
     void retrieveRoute();
@@ -113,8 +120,8 @@
     /** Select the first routing profile if none is selected yet */
     void selectFirstProfile();
 
-    /** Ask the user for a kml file to open */
-    void openRouteFile();
+    /** Show the directions ListView */
+    void showDirections();
 
     /** Update the route request with the given profile */
     void setRoutingProfile( int index );
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingWidget.ui #1217542:1217543
@@ -98,9 +98,9 @@
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="openButton">
+      <widget class="QPushButton" name="showInstructionsButton">
        <property name="text">
-        <string>Open...</string>
+        <string>Show Directions</string>
        </property>
        <property name="checkable">
         <bool>false</bool>


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

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