Commit eb02a737 authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Other routing items (source, destination, via points) are more confusing than...

Other routing items (source, destination, via points) are more confusing than useful when selecting routing targets, so disable them in the dialog invoked by RoutingInputWidgets.

svn path=/trunk/KDE/kdeedu/marble/; revision=1196401
parent 0895af12
......@@ -38,6 +38,8 @@ public:
virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
void setShowRoutingItems( bool show );
private:
QVariant currentLocationData ( int role ) const;
......@@ -54,6 +56,8 @@ private:
QVector<GeoDataPlacemark*> m_bookmarks;
bool m_hasCurrentLocation;
bool m_showRoutingItems;
};
class GoToDialogPrivate
......@@ -65,6 +69,8 @@ public:
GeoDataLookAt m_lookAt;
TargetModel* m_targetModel;
GoToDialogPrivate( GoToDialog* parent, MarbleWidget* marbleWidget );
void saveSelection( const QModelIndex &index );
......@@ -72,7 +78,8 @@ public:
TargetModel::TargetModel( MarbleWidget* marbleWidget, QObject * parent ) :
QAbstractListModel( parent ),
m_marbleWidget( marbleWidget ), m_hasCurrentLocation( false )
m_marbleWidget( marbleWidget ), m_hasCurrentLocation( false ),
m_showRoutingItems( true )
{
BookmarkManager* manager = marbleWidget->model()->bookmarkManager();
foreach( GeoDataFolder * folder, manager->folders() ) {
......@@ -91,6 +98,10 @@ TargetModel::TargetModel( MarbleWidget* marbleWidget, QObject * parent ) :
QVector<GeoDataPlacemark> TargetModel::viaPoints() const
{
if ( !m_showRoutingItems ) {
return QVector<GeoDataPlacemark>();
}
RouteRequest* request = m_marbleWidget->model()->routingManager()->routeRequest();
QVector<GeoDataPlacemark> result;
for ( int i = 0; i < request->size(); ++i ) {
......@@ -223,8 +234,14 @@ QVariant TargetModel::data ( const QModelIndex & index, int role ) const
return QVariant();
}
void TargetModel::setShowRoutingItems( bool show )
{
m_showRoutingItems = show;
reset();
}
GoToDialogPrivate::GoToDialogPrivate( GoToDialog* parent, MarbleWidget* marbleWidget ) :
m_parent( parent), m_marbleWidget( marbleWidget )
m_parent( parent), m_marbleWidget( marbleWidget ), m_targetModel( 0 )
{
// nothing to do
}
......@@ -241,7 +258,8 @@ GoToDialog::GoToDialog( MarbleWidget* marbleWidget, QWidget * parent, Qt::Window
{
setupUi( this );
bookmarkListView->setModel( new TargetModel( marbleWidget ) );
d->m_targetModel = new TargetModel( marbleWidget, this );
bookmarkListView->setModel( d->m_targetModel );
connect( bookmarkListView, SIGNAL( activated( QModelIndex ) ),
this, SLOT( saveSelection ( QModelIndex ) ) );
}
......@@ -256,6 +274,11 @@ GeoDataLookAt GoToDialog::lookAt() const
return d->m_lookAt;
}
void GoToDialog::setShowRoutingItems( bool show )
{
d->m_targetModel->setShowRoutingItems( show );
}
}
#include "GoToDialog.moc"
......@@ -40,6 +40,13 @@ public:
~GoToDialog();
/** Toggle whether routing items (source, destination and via points) are visible */
void setShowRoutingItems( bool show );
/**
* Returns the position of the item selected by the user, or a default
* constructed GeoDataLookAt if the dialog was cancelled by the user
*/
GeoDataLookAt lookAt() const;
Q_PRIVATE_SLOT( d, void saveSelection( const QModelIndex &index ) )
......
......@@ -466,6 +466,7 @@ void RoutingInputWidget::openTargetSelectionDialog()
{
QPointer<GoToDialog> dialog = new GoToDialog( d->m_marbleWidget, this );
dialog->setWindowTitle( tr( "Choose Placemark" ) );
dialog->setShowRoutingItems( false );
if ( dialog->exec() == QDialog::Accepted ) {
GeoDataLookAt lookAt = dialog->lookAt();
setTargetPosition( lookAt.coordinates() );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment