Skip to content

Commit 8f938dd

Browse files
committedMar 31, 2014
Merge pull request #1267 from mwa/fix_8298_crs_select
Fix #8298 ignored first selection in projection selector
2 parents 528d70f + abc7b9b commit 8f938dd

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed
 

‎src/app/qgsprojectproperties.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ void QgsProjectProperties::apply()
602602
if ( srs.mapUnits() != QGis::UnknownUnit )
603603
mMapCanvas->setMapUnits( srs.mapUnits() );
604604
}
605+
606+
if ( cbxProjectionEnabled->isChecked() )
607+
{
608+
// mark selected projection for push to front
609+
projectionSelector->pushProjectionToFront();
610+
}
605611
}
606612

607613
// Set the project title

‎src/gui/qgsprojectionselector.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,17 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
3232
, mUserProjListDone( false )
3333
, mRecentProjListDone( false )
3434
, mSearchColumn( NONE )
35-
, mSkipFirstRecent( true )
35+
, mPushProjectionToFront( false )
3636
{
3737
Q_UNUSED( name );
3838
setupUi( this );
3939

40+
if ( qobject_cast<QDialog*>( parent ) )
41+
{
42+
// mark selected projection for push to front if parent dialog is accepted
43+
connect( parent, SIGNAL( accepted() ), this, SLOT( pushProjectionToFront() ) );
44+
}
45+
4046
// Get the full path name to the sqlite3 spatial reference database.
4147
mSrsDatabaseFileName = QgsApplication::srsDbFilePath();
4248

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

95101
QgsProjectionSelector::~QgsProjectionSelector()
96102
{
103+
if ( !mPushProjectionToFront )
104+
{
105+
return;
106+
}
107+
97108
// Push current projection to front, only if set
98109
long crsId = selectedCrsId();
99110
if ( crsId == 0 )
@@ -750,12 +761,6 @@ void QgsProjectionSelector::on_lstRecent_currentItemChanged( QTreeWidgetItem *cu
750761
{
751762
QgsDebugMsg( "Entered." );
752763

753-
if ( mSkipFirstRecent )
754-
{
755-
mSkipFirstRecent = false;
756-
return;
757-
}
758-
759764
if ( !current )
760765
{
761766
QgsDebugMsg( "no current item" );
@@ -862,6 +867,13 @@ void QgsProjectionSelector::on_leSearch_textChanged( const QString & theFilterTx
862867
}
863868

864869

870+
void QgsProjectionSelector::pushProjectionToFront()
871+
{
872+
// set flag to push selected projection to front in destructor
873+
mPushProjectionToFront = true;
874+
}
875+
876+
865877
long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
866878
{
867879
long srsId = 0;

‎src/gui/qgsprojectionselector.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
104104
void on_cbxHideDeprecated_stateChanged();
105105
void on_leSearch_textChanged( const QString & );
106106

107+
//! mark selected projection for push to front
108+
void pushProjectionToFront();
109+
107110
protected:
108111
/** Used to ensure the projection list view is actually populated */
109112
void showEvent( QShowEvent * theEvent );
@@ -181,7 +184,7 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
181184
int mSearchColumn;
182185
QString mSearchValue;
183186

184-
bool mSkipFirstRecent;
187+
bool mPushProjectionToFront;
185188

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

0 commit comments

Comments
 (0)
Please sign in to comment.