Skip to content
Permalink
Browse files

Merge pull request #2580 from nirvn/projection_selector_dbl_click_v5

[projection selector] apply selected projection on double click
  • Loading branch information
NathanW2 committed Dec 15, 2015
2 parents 576875e + 8a40dda commit 34ccc345cc9e0a57b15c9c8a8afff4e5df207abd
@@ -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();
};
@@ -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 )
@@ -18,6 +18,7 @@
#include "qgsapplication.h"
#include "qgslogger.h"
#include "qgscoordinatereferencesystem.h"
#include "qgsmessagelog.h"

//qt includes
#include <QFileInfo>
@@ -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<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() )
@@ -192,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();
@@ -208,6 +212,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 34ccc34

Please sign in to comment.
You can’t perform that action at this time.