From 84d2e954bce8c56ea81e7a03eef5fd8fb588ddbd Mon Sep 17 00:00:00 2001 From: nirvn Date: Mon, 14 Dec 2015 11:25:35 +0700 Subject: [PATCH 1/2] [projection selector] apply selected projection on double click --- python/gui/qgsprojectionselector.sip | 3 ++ src/gui/qgsgenericprojectionselector.cpp | 3 ++ src/gui/qgsprojectionselector.cpp | 36 ++++++++++++++++++++++++ src/gui/qgsprojectionselector.h | 5 ++++ 4 files changed, 47 insertions(+) diff --git a/python/gui/qgsprojectionselector.sip b/python/gui/qgsprojectionselector.sip index 5316e0ae969e..451f995b420e 100644 --- a/python/gui/qgsprojectionselector.sip +++ b/python/gui/qgsprojectionselector.sip @@ -105,4 +105,7 @@ class QgsProjectionSelector : QWidget //! Notify others that the widget is now fully initialized, including deferred selection of projection //! @note added in 2.4 void initialized(); + //! Apply projection on double click + //! @note added in 2.14 + void projectionDoubleClicked(); }; diff --git a/src/gui/qgsgenericprojectionselector.cpp b/src/gui/qgsgenericprojectionselector.cpp index 5d777b06c48f..69a5be921378 100644 --- a/src/gui/qgsgenericprojectionselector.cpp +++ b/src/gui/qgsgenericprojectionselector.cpp @@ -36,6 +36,9 @@ QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent, //we will show this only when a message is set textEdit->hide(); + + //apply selected projection upon double click on item + connect( projectionSelector, SIGNAL( projectionDoubleClicked() ), this, SLOT( accept() ) ); } void QgsGenericProjectionSelector::setMessage( QString theMessage ) diff --git a/src/gui/qgsprojectionselector.cpp b/src/gui/qgsprojectionselector.cpp index 95485f23bd51..7cdae47db6d0 100644 --- a/src/gui/qgsprojectionselector.cpp +++ b/src/gui/qgsprojectionselector.cpp @@ -18,6 +18,7 @@ #include "qgsapplication.h" #include "qgslogger.h" #include "qgscoordinatereferencesystem.h" +#include "qgsmessagelog.h" //qt includes #include @@ -718,6 +719,24 @@ void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWid } } +void QgsProjectionSelector::on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column ) +{ + Q_UNUSED( column ); + + QgsDebugMsg( "Entered." ); + + if ( !current ) + { + QgsDebugMsg( "no current item" ); + return; + } + + // If the item has children, it's not an end node in the tree, and + // hence is just a grouping thingy, not an actual CRS. + if ( current->childCount() == 0 ) + emit projectionDoubleClicked(); +} + void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * ) { QgsDebugMsg( "Entered." ); @@ -735,6 +754,23 @@ void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *cu lstCoordinateSystems->setCurrentItem( nodes.first() ); } +void QgsProjectionSelector::on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column ) +{ + Q_UNUSED( column ); + + QgsDebugMsg( "Entered." ); + + if ( !current ) + { + QgsDebugMsg( "no current item" ); + return; + } + + QList nodes = lstCoordinateSystems->findItems( current->text( QGIS_CRS_ID_COLUMN ), Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN ); + if ( !nodes.isEmpty() ) + emit projectionDoubleClicked(); +} + void QgsProjectionSelector::hideDeprecated( QTreeWidgetItem *item ) { if ( item->data( 0, Qt::UserRole ).toBool() ) diff --git a/src/gui/qgsprojectionselector.h b/src/gui/qgsprojectionselector.h index 10d62327d278..dab1f65b6695 100644 --- a/src/gui/qgsprojectionselector.h +++ b/src/gui/qgsprojectionselector.h @@ -100,7 +100,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti */ void setOgcWmsCrsFilter( const QSet& crsFilter ); void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev ); + void on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column ); void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev ); + void on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column ); void on_cbxHideDeprecated_stateChanged(); void on_leSearch_textChanged( const QString & ); @@ -208,6 +210,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti //! Notify others that the widget is now fully initialized, including deferred selection of projection //! @note added in 2.4 void initialized(); + //! Apply projection on double click + //! @note added in 2.14 + void projectionDoubleClicked(); }; #endif From 8a40dda2e56235cae9636657f8e3dd12910cce2d Mon Sep 17 00:00:00 2001 From: nirvn Date: Tue, 15 Dec 2015 10:19:47 +0700 Subject: [PATCH 2/2] fix sip coverage test failure --- src/gui/qgsprojectionselector.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/qgsprojectionselector.h b/src/gui/qgsprojectionselector.h index dab1f65b6695..1aae402f645c 100644 --- a/src/gui/qgsprojectionselector.h +++ b/src/gui/qgsprojectionselector.h @@ -100,9 +100,7 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti */ void setOgcWmsCrsFilter( const QSet& crsFilter ); void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev ); - void on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column ); void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev ); - void on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column ); void on_cbxHideDeprecated_stateChanged(); void on_leSearch_textChanged( const QString & ); @@ -194,9 +192,13 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti //! Most recently used projections (trimmed at 25 entries) QStringList mRecentProjections; - //! hide deprecated CRSes + //! Hide deprecated CRSes void hideDeprecated( QTreeWidgetItem *item ); + //! Apply projection on double click + void on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column ); + void on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column ); + private slots: //! get list of authorities QStringList authorities();