Skip to content

Commit

Permalink
Merge pull request #2580 from nirvn/projection_selector_dbl_click_v5
Browse files Browse the repository at this point in the history
[projection selector] apply selected projection on double click
  • Loading branch information
NathanW2 committed Dec 15, 2015
2 parents 576875e + 8a40dda commit 34ccc34
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/gui/qgsprojectionselector.sip
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
9 changes: 8 additions & 1 deletion src/gui/qgsprojectionselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.