Skip to content

Commit 84d2e95

Browse files
committedDec 15, 2015
[projection selector] apply selected projection on double click
1 parent 576875e commit 84d2e95

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
 

‎python/gui/qgsprojectionselector.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,7 @@ class QgsProjectionSelector : QWidget
105105
//! Notify others that the widget is now fully initialized, including deferred selection of projection
106106
//! @note added in 2.4
107107
void initialized();
108+
//! Apply projection on double click
109+
//! @note added in 2.14
110+
void projectionDoubleClicked();
108111
};

‎src/gui/qgsgenericprojectionselector.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ QgsGenericProjectionSelector::QgsGenericProjectionSelector( QWidget *parent,
3636

3737
//we will show this only when a message is set
3838
textEdit->hide();
39+
40+
//apply selected projection upon double click on item
41+
connect( projectionSelector, SIGNAL( projectionDoubleClicked() ), this, SLOT( accept() ) );
3942
}
4043

4144
void QgsGenericProjectionSelector::setMessage( QString theMessage )

‎src/gui/qgsprojectionselector.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "qgsapplication.h"
1919
#include "qgslogger.h"
2020
#include "qgscoordinatereferencesystem.h"
21+
#include "qgsmessagelog.h"
2122

2223
//qt includes
2324
#include <QFileInfo>
@@ -718,6 +719,24 @@ void QgsProjectionSelector::on_lstCoordinateSystems_currentItemChanged( QTreeWid
718719
}
719720
}
720721

722+
void QgsProjectionSelector::on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column )
723+
{
724+
Q_UNUSED( column );
725+
726+
QgsDebugMsg( "Entered." );
727+
728+
if ( !current )
729+
{
730+
QgsDebugMsg( "no current item" );
731+
return;
732+
}
733+
734+
// If the item has children, it's not an end node in the tree, and
735+
// hence is just a grouping thingy, not an actual CRS.
736+
if ( current->childCount() == 0 )
737+
emit projectionDoubleClicked();
738+
}
739+
721740
void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem * )
722741
{
723742
QgsDebugMsg( "Entered." );
@@ -735,6 +754,23 @@ void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *cu
735754
lstCoordinateSystems->setCurrentItem( nodes.first() );
736755
}
737756

757+
void QgsProjectionSelector::on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column )
758+
{
759+
Q_UNUSED( column );
760+
761+
QgsDebugMsg( "Entered." );
762+
763+
if ( !current )
764+
{
765+
QgsDebugMsg( "no current item" );
766+
return;
767+
}
768+
769+
QList<QTreeWidgetItem*> nodes = lstCoordinateSystems->findItems( current->text( QGIS_CRS_ID_COLUMN ), Qt::MatchExactly | Qt::MatchRecursive, QGIS_CRS_ID_COLUMN );
770+
if ( !nodes.isEmpty() )
771+
emit projectionDoubleClicked();
772+
}
773+
738774
void QgsProjectionSelector::hideDeprecated( QTreeWidgetItem *item )
739775
{
740776
if ( item->data( 0, Qt::UserRole ).toBool() )

‎src/gui/qgsprojectionselector.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
100100
*/
101101
void setOgcWmsCrsFilter( const QSet<QString>& crsFilter );
102102
void on_lstCoordinateSystems_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
103+
void on_lstCoordinateSystems_itemDoubleClicked( QTreeWidgetItem *current, int column );
103104
void on_lstRecent_currentItemChanged( QTreeWidgetItem *current, QTreeWidgetItem *prev );
105+
void on_lstRecent_itemDoubleClicked( QTreeWidgetItem *current, int column );
104106
void on_cbxHideDeprecated_stateChanged();
105107
void on_leSearch_textChanged( const QString & );
106108

@@ -208,6 +210,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
208210
//! Notify others that the widget is now fully initialized, including deferred selection of projection
209211
//! @note added in 2.4
210212
void initialized();
213+
//! Apply projection on double click
214+
//! @note added in 2.14
215+
void projectionDoubleClicked();
211216
};
212217

213218
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.