Skip to content

Commit aa09c8c

Browse files
committedJun 16, 2014
Fix #10392 (ellipsoid for measurement keep getting reset)
1 parent 42d14d7 commit aa09c8c

File tree

5 files changed

+41
-25
lines changed

5 files changed

+41
-25
lines changed
 

‎python/gui/qgsprojectionselector.sip

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,7 @@ class QgsProjectionSelector : QWidget
102102
void refresh();
103103
//! Let listeners know if find has focus so they can adjust the default button
104104
void searchBoxHasFocus( bool );
105+
//! Notify others that the widget is now fully initialized, including deferred selection of projection
106+
//! @note added in 2.4
107+
void initialized();
105108
};

‎src/app/qgsprojectproperties.cpp

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
7474
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
7575
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
7676
connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) );
77+
connect( projectionSelector, SIGNAL( initialized() ), this, SLOT( projectionSelectorInitialized() ) );
7778

7879
connect( cmbEllipsoid, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateEllipsoidUI( int ) ) );
7980

@@ -123,33 +124,10 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
123124
cbxAbsolutePath->setCurrentIndex( QgsProject::instance()->readBoolEntry( "Paths", "/Absolute", true ) ? 0 : 1 );
124125

125126
// populate combo box with ellipsoids
126-
127-
QgsDebugMsg( "Setting upp ellipsoid" );
128-
127+
// selection of the ellipsoid from settings is defferred to a later point, because it would
128+
// be overridden in the meanwhile by the projection selector
129129
populateEllipsoidList();
130130

131-
// Reading ellipsoid from setttings
132-
QStringList mySplitEllipsoid = QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ).split( ':' );
133-
134-
int myIndex = 0;
135-
for ( int i = 0; i < mEllipsoidList.length(); i++ )
136-
{
137-
if ( mEllipsoidList[ i ].acronym.startsWith( mySplitEllipsoid[ 0 ] ) )
138-
{
139-
myIndex = i;
140-
break;
141-
}
142-
}
143-
144-
// Update paramaters if present.
145-
if ( mySplitEllipsoid.length() >= 3 )
146-
{
147-
mEllipsoidList[ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
148-
mEllipsoidList[ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
149-
}
150-
151-
updateEllipsoidUI( myIndex );
152-
153131

154132
int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" );
155133
spinBoxDP->setValue( dp );
@@ -1631,3 +1609,30 @@ void QgsProjectProperties::updateEllipsoidUI( int newIndex )
16311609
}
16321610
cmbEllipsoid->setCurrentIndex( mEllipsoidIndex ); // Not always necessary
16331611
}
1612+
1613+
void QgsProjectProperties::projectionSelectorInitialized()
1614+
{
1615+
QgsDebugMsg( "Setting up ellipsoid" );
1616+
1617+
// Reading ellipsoid from setttings
1618+
QStringList mySplitEllipsoid = QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ).split( ':' );
1619+
1620+
int myIndex = 0;
1621+
for ( int i = 0; i < mEllipsoidList.length(); i++ )
1622+
{
1623+
if ( mEllipsoidList[ i ].acronym.startsWith( mySplitEllipsoid[ 0 ] ) )
1624+
{
1625+
myIndex = i;
1626+
break;
1627+
}
1628+
}
1629+
1630+
// Update paramaters if present.
1631+
if ( mySplitEllipsoid.length() >= 3 )
1632+
{
1633+
mEllipsoidList[ myIndex ].semiMajor = mySplitEllipsoid[ 1 ].toDouble();
1634+
mEllipsoidList[ myIndex ].semiMinor = mySplitEllipsoid[ 2 ].toDouble();
1635+
}
1636+
1637+
updateEllipsoidUI( myIndex );
1638+
}

‎src/app/qgsprojectproperties.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
163163
*/
164164
void updateEllipsoidUI( int newIndex );
165165

166+
//! sets the right ellipsoid for measuring (from settings)
167+
void projectionSelectorInitialized();
168+
166169
signals:
167170
//! Signal used to inform listeners that the mouse display precision may have changed
168171
void displayPrecisionChanged();

‎src/gui/qgsprojectionselector.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ void QgsProjectionSelector::showEvent( QShowEvent * theEvent )
171171
// apply deferred selection
172172
applySelection();
173173

174+
emit initialized();
175+
174176
// Pass up the inheritance hierarchy
175177
QWidget::showEvent( theEvent );
176178
}

‎src/gui/qgsprojectionselector.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ class GUI_EXPORT QgsProjectionSelector : public QWidget, private Ui::QgsProjecti
205205
void refresh();
206206
//! Let listeners know if find has focus so they can adjust the default button
207207
void searchBoxHasFocus( bool );
208+
//! Notify others that the widget is now fully initialized, including deferred selection of projection
209+
//! @note added in 2.4
210+
void initialized();
208211
};
209212

210213
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.