Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #8298 ignored first selection of recently used CRS in projection …
…selector
  • Loading branch information
mwa committed Mar 26, 2014
1 parent 19da71c commit abc7b9b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -602,6 +602,12 @@ void QgsProjectProperties::apply()
if ( srs.mapUnits() != QGis::UnknownUnit )
mMapCanvas->setMapUnits( srs.mapUnits() );
}

if ( cbxProjectionEnabled->isChecked() )
{
// mark selected projection for push to front
projectionSelector->pushProjectionToFront();
}
}

// Set the project title
Expand Down
26 changes: 19 additions & 7 deletions src/gui/qgsprojectionselector.cpp
Expand Up @@ -32,11 +32,17 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
, mUserProjListDone( false )
, mRecentProjListDone( false )
, mSearchColumn( NONE )
, mSkipFirstRecent( true )
, mPushProjectionToFront( false )
{
Q_UNUSED( name );
setupUi( this );

if ( qobject_cast<QDialog*>( parent ) )
{
// mark selected projection for push to front if parent dialog is accepted
connect( parent, SIGNAL( accepted() ), this, SLOT( pushProjectionToFront() ) );
}

// Get the full path name to the sqlite3 spatial reference database.
mSrsDatabaseFileName = QgsApplication::srsDbFilePath();

Expand Down Expand Up @@ -94,6 +100,11 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,

QgsProjectionSelector::~QgsProjectionSelector()
{
if ( !mPushProjectionToFront )
{
return;
}

// Push current projection to front, only if set
long crsId = selectedCrsId();
if ( crsId == 0 )
Expand Down Expand Up @@ -750,12 +761,6 @@ void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *cu
{
QgsDebugMsg( "Entered." );

if ( mSkipFirstRecent )
{
mSkipFirstRecent = false;
return;
}

if ( !current )
{
QgsDebugMsg( "no current item" );
Expand Down Expand Up @@ -862,6 +867,13 @@ void QgsProjectionSelector::on_leSearch_textChanged( const QString & theFilterTx
}


void QgsProjectionSelector::pushProjectionToFront()
{
// set flag to push selected projection to front in destructor
mPushProjectionToFront = true;
}


long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
{
long srsId = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/gui/qgsprojectionselector.h
Expand Up @@ -104,6 +104,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
void on_cbxHideDeprecated_stateChanged();
void on_leSearch_textChanged( const QString & );

//! mark selected projection for push to front
void pushProjectionToFront();

protected:
/** Used to ensure the projection list view is actually populated */
void showEvent( QShowEvent * theEvent );
Expand Down Expand Up @@ -181,7 +184,7 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
int mSearchColumn;
QString mSearchValue;

bool mSkipFirstRecent;
bool mPushProjectionToFront;

//! The set of OGC WMS CRSs that want to be applied to this widget
QSet<QString> mCrsFilter;
Expand Down

0 comments on commit abc7b9b

Please sign in to comment.