[projection selector] apply selected projection on double click

This commit is contained in:
nirvn 2015-12-14 11:25:35 +07:00
parent 576875e998
commit 84d2e954bc
4 changed files with 47 additions and 0 deletions

View File

@ -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();
};

View File

@ -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 )

View File

@ -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() )

View File

@ -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 & );
@ -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