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

Dennis Nienhüser earthwings at gentoo.org
Wed Nov 10 22:03:59 CET 2010


SVN commit 1195332 by nienhueser:

QMenus are hard to operate on Maemo and the drop down one in the routing input widget has a dynamic size (due to the bookmarks) that complicates it further. Use the GoTo dialog instead to select routing targets. This removes the map based actions (center here, select from map), which however are accessible from the map directly.

 M  +19 -12    GoToDialog.cpp  
 M  +4 -2      GoToDialog.h  
 M  +4 -1      MarbleWidgetPopupMenu.cpp  
 M  +22 -1     routing/RoutingInputWidget.cpp  
 M  +2 -0      routing/RoutingInputWidget.h  


--- trunk/KDE/kdeedu/marble/src/lib/GoToDialog.cpp #1195331:1195332
@@ -59,11 +59,15 @@
 class GoToDialogPrivate
 {
 public:
+    GoToDialog* m_parent;
+
     MarbleWidget* m_marbleWidget;
 
-    GoToDialogPrivate( MarbleWidget* marbleWidget );
+    GeoDataLookAt m_lookAt;
 
-    void goTo( const QModelIndex &index );
+    GoToDialogPrivate( GoToDialog* parent, MarbleWidget* marbleWidget );
+
+    void saveSelection( const QModelIndex &index );
 };
 
 TargetModel::TargetModel( MarbleWidget* marbleWidget, QObject * parent ) :
@@ -219,22 +223,27 @@
     return QVariant();
 }
 
-GoToDialogPrivate::GoToDialogPrivate( MarbleWidget* marbleWidget ) :
-    m_marbleWidget( marbleWidget )
+GoToDialogPrivate::GoToDialogPrivate( GoToDialog* parent, MarbleWidget* marbleWidget ) :
+    m_parent( parent), m_marbleWidget( marbleWidget )
 {
     // nothing to do
 }
 
+void GoToDialogPrivate::saveSelection( const QModelIndex &index )
+{
+    QVariant data = index.data( GeoDataLookAtRole );
+    m_lookAt = qVariantValue<GeoDataLookAt>( data );
+    m_parent->accept();
+}
+
 GoToDialog::GoToDialog( MarbleWidget* marbleWidget, QWidget * parent, Qt::WindowFlags flags ) :
-    QDialog( parent, flags ), d( new GoToDialogPrivate( marbleWidget ) )
+    QDialog( parent, flags ), d( new GoToDialogPrivate( this, marbleWidget ) )
 {
     setupUi( this );
 
     bookmarkListView->setModel( new TargetModel( marbleWidget ) );
     connect( bookmarkListView, SIGNAL( activated( QModelIndex ) ),
-             this, SLOT( goTo ( QModelIndex ) ) );
-    connect( bookmarkListView, SIGNAL( activated( QModelIndex ) ),
-             this, SLOT( accept() ) );
+             this, SLOT( saveSelection ( QModelIndex ) ) );
 }
 
 GoToDialog::~GoToDialog()
@@ -242,11 +251,9 @@
     delete d;
 }
 
-void GoToDialogPrivate::goTo( const QModelIndex &index )
+GeoDataLookAt GoToDialog::lookAt() const
 {
-    QVariant data = index.data( GeoDataLookAtRole );
-    GeoDataLookAt lookat = qVariantValue<GeoDataLookAt>( data );
-    m_marbleWidget->flyTo( lookat );
+    return d->m_lookAt;
 }
 
 }
--- trunk/KDE/kdeedu/marble/src/lib/GoToDialog.h #1195331:1195332
@@ -12,7 +12,7 @@
 #define MARBLE_GOTODIALOG_H
 
 #include "marble_export.h"
-#include "GeoDataCoordinates.h"
+#include "GeoDataLookAt.h"
 
 #include <QtGui/QDialog>
 
@@ -40,8 +40,10 @@
 
     ~GoToDialog();
 
-    Q_PRIVATE_SLOT( d, void goTo( const QModelIndex &index ) )
+    GeoDataLookAt lookAt() const;
 
+    Q_PRIVATE_SLOT( d, void saveSelection( const QModelIndex &index ) )
+
 private:
     GoToDialogPrivate * const d;
 };
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetPopupMenu.cpp #1195331:1195332
@@ -340,7 +340,10 @@
 void MarbleWidgetPopupMenu::openGoToDialog()
 {
     QPointer<GoToDialog> dialog = new GoToDialog( m_widget, m_widget );
-    dialog->exec();
+    if ( dialog->exec() == QDialog::Accepted ) {
+        GeoDataLookAt lookAt = dialog->lookAt();
+        m_widget->flyTo( lookAt );
+    }
     delete dialog;
 }
 
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.cpp #1195331:1195332
@@ -22,6 +22,7 @@
 #include "GeoDataFolder.h"
 #include "PositionTracking.h"
 #include "RoutingLineEdit.h"
+#include "GoToDialog.h"
 
 #include <QtCore/QTimer>
 #include <QtCore/QUrl>
@@ -231,11 +232,12 @@
         layout->addWidget( d->m_lineEdit );
         d->m_menuButton->setArrowType( Qt::DownArrow );
         layout->addWidget( d->m_menuButton );
+        connect( d->m_menuButton, SIGNAL( clicked() ), this, SLOT( openTargetSelectionDialog() ) );
     } else {
+        d->m_menuButton->setMenu( d->createMenu( this ) );
         layout->addWidget( d->m_menuButton );
         layout->addWidget( d->m_lineEdit );
     }
-    d->m_menuButton->setMenu( d->createMenu( this ) );
 
     connect( d->m_marbleModel->bookmarkManager(), SIGNAL( bookmarksChanged() ),
              this, SLOT( reloadBookmarks() ) );
@@ -367,8 +369,10 @@
 
 void RoutingInputWidget::abortMapInputRequest()
 {
+    if ( d->m_mapInput ) {
     d->m_mapInput->setChecked( false );
 }
+}
 
 void RoutingInputWidget::setIndex( int index )
 {
@@ -415,8 +419,10 @@
 
 void RoutingInputWidget::reloadBookmarks()
 {
+    if ( d->m_bookmarkAction ) {
     d->m_bookmarkAction->setMenu( d->createBookmarkMenu( this ) );
 }
+}
 
 void RoutingInputWidget::setHomePosition()
 {
@@ -430,8 +436,10 @@
 
 void RoutingInputWidget::updateCurrentLocationButton( PositionProviderStatus status )
 {
+    if ( d->m_currentLocationAction ) {
     d->m_currentLocationAction->setEnabled( status == PositionProviderStatusAvailable );
 }
+}
 
 void RoutingInputWidget::setCurrentLocation()
 {
@@ -441,8 +449,10 @@
 
 void RoutingInputWidget::updateCenterButton( bool hasPosition )
 {
+    if ( d->m_centerAction ) {
     d->m_centerAction->setEnabled( hasPosition );
 }
+}
 
 void RoutingInputWidget::setBookmarkPosition( QAction* bookmark )
 {
@@ -452,6 +462,17 @@
     }
 }
 
+void RoutingInputWidget::openTargetSelectionDialog()
+{
+    QPointer<GoToDialog> dialog = new GoToDialog( d->m_marbleWidget, this );
+    dialog->setWindowTitle( tr( "Choose Placemark" ) );
+    if ( dialog->exec() == QDialog::Accepted ) {
+        GeoDataLookAt lookAt = dialog->lookAt();
+        setTargetPosition( lookAt.coordinates() );
+    }
+    delete dialog;
+}
+
 } // namespace Marble
 
 #include "RoutingInputWidget.moc"
--- trunk/KDE/kdeedu/marble/src/lib/routing/RoutingInputWidget.h #1195331:1195332
@@ -164,6 +164,8 @@
 
     void setBookmarkPosition( QAction* bookmark );
 
+    void openTargetSelectionDialog();
+
 private:
     RoutingInputWidgetPrivate *const d;
 };


More information about the Marble-commits mailing list