Skip to content

Commit

Permalink
[projection selector] apply selected projection on double click
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Dec 15, 2015
1 parent 576875e commit 84d2e95
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/gui/qgsprojectionselector.sip
Expand Up @@ -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();
};
3 changes: 3 additions & 0 deletions src/gui/qgsgenericprojectionselector.cpp
Expand Up @@ -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 )
Expand Down
36 changes: 36 additions & 0 deletions src/gui/qgsprojectionselector.cpp
Expand Up @@ -18,6 +18,7 @@
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsmessagelog.h"

//qt includes
#include <QFileInfo>
Expand Down Expand Up @@ -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." );
Expand All @@ -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<QTreeWidgetItem*> 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() )
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsprojectionselector.h
Expand Up @@ -100,7 +100,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
*/
void setOgcWmsCrsFilter( const QSet<QString>& 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 & );

Expand Down Expand Up @@ -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

0 comments on commit 84d2e95

Please sign in to comment.