@@ -80,34 +80,35 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
8080 // and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
8181 initOptionsBase ( false );
8282
83+ mCoordinateDisplayComboBox ->addItem ( tr ( " Decimal degrees" ), DecimalDegrees );
84+ mCoordinateDisplayComboBox ->addItem ( tr ( " Degrees, minutes" ), DegreesMinutes );
85+ mCoordinateDisplayComboBox ->addItem ( tr ( " Degrees, minutes, seconds" ), DegreesMinutesSeconds );
86+
8387 connect ( buttonBox->button ( QDialogButtonBox::Apply ), SIGNAL ( clicked () ), this , SLOT ( apply () ) );
8488 connect ( this , SIGNAL ( accepted () ), this , SLOT ( apply () ) );
85- connect ( projectionSelector, SIGNAL ( sridSelected ( QString ) ), this , SLOT ( setMapUnitsToCurrentProjection () ) );
89+ connect ( projectionSelector, SIGNAL ( sridSelected ( QString ) ), this , SLOT ( srIdUpdated () ) );
8690 connect ( projectionSelector, SIGNAL ( initialized () ), this , SLOT ( projectionSelectorInitialized () ) );
8791
8892 connect ( cmbEllipsoid, SIGNAL ( currentIndexChanged ( int ) ), this , SLOT ( updateEllipsoidUI ( int ) ) );
8993
90- connect ( radMeters, SIGNAL ( toggled ( bool ) ), btnGrpDegreeDisplay, SLOT ( setDisabled ( bool ) ) );
91- connect ( radFeet, SIGNAL ( toggled ( bool ) ), btnGrpDegreeDisplay, SLOT ( setDisabled ( bool ) ) );
92- connect ( radNMiles, SIGNAL ( toggled ( bool ) ), btnGrpDegreeDisplay, SLOT ( setDisabled ( bool ) ) );
93- connect ( radDegrees, SIGNAL ( toggled ( bool ) ), btnGrpDegreeDisplay, SLOT ( setEnabled ( bool ) ) );
94-
95- connect ( radAutomatic, SIGNAL ( toggled ( bool ) ), mPrecisionFrame , SLOT ( setDisabled ( bool ) ) );
96- connect ( radManual, SIGNAL ( toggled ( bool ) ), mPrecisionFrame , SLOT ( setEnabled ( bool ) ) );
94+ connect ( radAutomatic, SIGNAL ( toggled ( bool ) ), spinBoxDP, SLOT ( setDisabled ( bool ) ) );
95+ connect ( radAutomatic, SIGNAL ( toggled ( bool ) ), labelDP, SLOT ( setDisabled ( bool ) ) );
96+ connect ( radManual, SIGNAL ( toggled ( bool ) ), spinBoxDP, SLOT ( setEnabled ( bool ) ) );
97+ connect ( radManual, SIGNAL ( toggled ( bool ) ), labelDP, SLOT ( setEnabled ( bool ) ) );
9798
9899 QSettings settings;
99100
100101 // /////////////////////////////////////////////////////////
101102 // Properties stored in map canvas's QgsMapRenderer
102103 // these ones are propagated to QgsProject by a signal
103104
104- QGis::UnitType myUnit = mMapCanvas ->mapSettings ().mapUnits ();
105- setMapUnits ( myUnit );
106-
107105 // we need to initialize it, since the on_cbxProjectionEnabled_toggled()
108106 // slot triggered by setChecked() might use it.
109107 mProjectSrsId = mMapCanvas ->mapSettings ().destinationCrs ().srsid ();
110108
109+ QgsCoordinateReferenceSystem srs ( mProjectSrsId , QgsCoordinateReferenceSystem::InternalCrsId );
110+ updateGuiForMapUnits ( srs.mapUnits () );
111+
111112 QgsDebugMsg ( " Read project CRSID: " + QString::number ( mProjectSrsId ) );
112113 projectionSelector->setSelectedCrsId ( mProjectSrsId );
113114
@@ -127,13 +128,17 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
127128 if ( automaticPrecision )
128129 {
129130 radAutomatic->setChecked ( true );
130- mPrecisionFrame ->setEnabled ( false );
131+ spinBoxDP->setEnabled ( false );
132+ labelDP->setEnabled ( false );
131133 }
132134 else
133135 {
134136 radManual->setChecked ( true );
135- mPrecisionFrame ->setEnabled ( true );
137+ spinBoxDP->setEnabled ( true );
138+ labelDP->setEnabled ( true );
136139 }
140+ int dp = QgsProject::instance ()->readNumEntry ( " PositionPrecision" , " /DecimalPlaces" );
141+ spinBoxDP->setValue ( dp );
137142
138143 cbxAbsolutePath->setCurrentIndex ( QgsProject::instance ()->readBoolEntry ( " Paths" , " /Absolute" , true ) ? 0 : 1 );
139144
@@ -142,17 +147,15 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
142147 // be overridden in the meanwhile by the projection selector
143148 populateEllipsoidList ();
144149
145-
146- int dp = QgsProject::instance ()->readNumEntry ( " PositionPrecision" , " /DecimalPlaces" );
147- spinBoxDP->setValue ( dp );
148-
149150 QString format = QgsProject::instance ()->readEntry ( " PositionPrecision" , " /DegreeFormat" , " D" );
150- if ( format == " DM" )
151- radDM->setChecked ( true );
151+ if ( format == " MU" && mCoordinateDisplayComboBox ->findData ( MapUnits ) >= 0 )
152+ mCoordinateDisplayComboBox ->setCurrentIndex ( mCoordinateDisplayComboBox ->findData ( MapUnits ) );
153+ else if ( format == " DM" )
154+ mCoordinateDisplayComboBox ->setCurrentIndex ( mCoordinateDisplayComboBox ->findData ( DegreesMinutes ) );
152155 else if ( format == " DMS" )
153- radDMS-> setChecked ( true );
156+ mCoordinateDisplayComboBox -> setCurrentIndex ( mCoordinateDisplayComboBox -> findData ( DegreesMinutesSeconds ) );
154157 else
155- radD-> setChecked ( true );
158+ mCoordinateDisplayComboBox -> setCurrentIndex ( mCoordinateDisplayComboBox -> findData ( DecimalDegrees ) );
156159
157160 // get the color selections and set the button color accordingly
158161 int myRedInt = QgsProject::instance ()->readNumEntry ( " Gui" , " /SelectionColorRedPart" , 255 );
@@ -692,11 +695,6 @@ void QgsProjectProperties::setMapUnits( QGis::UnitType unit )
692695 unit = QGis::Meters;
693696 }
694697
695- radMeters->setChecked ( unit == QGis::Meters );
696- radFeet->setChecked ( unit == QGis::Feet );
697- radNMiles->setChecked ( unit == QGis::NauticalMiles );
698- radDegrees->setChecked ( unit == QGis::Degrees );
699-
700698 mMapCanvas ->setMapUnits ( unit );
701699}
702700
@@ -714,28 +712,6 @@ void QgsProjectProperties::title( QString const & title )
714712// when user clicks apply button
715713void QgsProjectProperties::apply ()
716714{
717- // Set the map units
718- // Note. Qt 3.2.3 and greater have a function selectedId() that
719- // can be used instead of the two part technique here
720- QGis::UnitType mapUnit;
721- if ( radDegrees->isChecked () )
722- {
723- mapUnit = QGis::Degrees;
724- }
725- else if ( radFeet->isChecked () )
726- {
727- mapUnit = QGis::Feet;
728- }
729- else if ( radNMiles->isChecked () )
730- {
731- mapUnit = QGis::NauticalMiles;
732- }
733- else
734- {
735- mapUnit = QGis::Meters;
736- }
737-
738- mMapCanvas ->setMapUnits ( mapUnit );
739715 mMapCanvas ->setCrsTransformEnabled ( cbxProjectionEnabled->isChecked () );
740716
741717 mMapCanvas ->enableMapTileRendering ( mMapTileRenderingCheckBox ->isChecked () );
@@ -781,8 +757,24 @@ void QgsProjectProperties::apply()
781757 // can be used instead of the two part technique here
782758 QgsProject::instance ()->writeEntry ( " PositionPrecision" , " /Automatic" , radAutomatic->isChecked () );
783759 QgsProject::instance ()->writeEntry ( " PositionPrecision" , " /DecimalPlaces" , spinBoxDP->value () );
784- QgsProject::instance ()->writeEntry ( " PositionPrecision" , " /DegreeFormat" ,
785- QString ( radDM->isChecked () ? " DM" : radDMS->isChecked () ? " DMS" : " D" ) );
760+ QString degreeFormat;
761+ switch ( static_cast < CoordinateFormat >( mCoordinateDisplayComboBox ->itemData ( mCoordinateDisplayComboBox ->currentIndex () ).toInt () ) )
762+ {
763+ case DegreesMinutes:
764+ degreeFormat = " DM" ;
765+ break ;
766+ case DegreesMinutesSeconds:
767+ degreeFormat = " DMS" ;
768+ break ;
769+ case MapUnits:
770+ degreeFormat = " MU" ;
771+ break ;
772+ case DecimalDegrees:
773+ default :
774+ degreeFormat = " D" ;
775+ break ;
776+ }
777+ QgsProject::instance ()->writeEntry ( " PositionPrecision" , " /DegreeFormat" , degreeFormat );
786778
787779 // Announce that we may have a new display precision setting
788780 emit displayPrecisionChanged ();
@@ -1148,7 +1140,6 @@ void QgsProjectProperties::showProjectionsTab()
11481140void QgsProjectProperties::on_cbxProjectionEnabled_toggled ( bool onFlyEnabled )
11491141{
11501142 QString measureOnFlyState = tr ( " Measure tool (CRS transformation: %1)" );
1151- QString unitsOnFlyState = tr ( " Canvas units (CRS transformation: %1)" );
11521143 if ( !onFlyEnabled )
11531144 {
11541145 // reset projection to default
@@ -1169,20 +1160,10 @@ void QgsProjectProperties::on_cbxProjectionEnabled_toggled( bool onFlyEnabled )
11691160 mProjectSrsId = mLayerSrsId ;
11701161 projectionSelector->setSelectedCrsId ( mLayerSrsId );
11711162
1172- QgsCoordinateReferenceSystem srs ( mLayerSrsId , QgsCoordinateReferenceSystem::InternalCrsId );
1173- // set radio button to crs map unit type
1174- QGis::UnitType units = srs.mapUnits ();
1175-
1176- radMeters->setChecked ( units == QGis::Meters );
1177- radFeet->setChecked ( units == QGis::Feet );
1178- radNMiles->setChecked ( units == QGis::NauticalMiles );
1179- radDegrees->setChecked ( units == QGis::Degrees );
1180-
11811163 // unset ellipsoid
11821164 mEllipsoidIndex = 0 ;
11831165
11841166 btnGrpMeasureEllipsoid->setTitle ( measureOnFlyState.arg ( tr ( " OFF" ) ) );
1185- btnGrpMapUnits->setTitle ( unitsOnFlyState.arg ( tr ( " OFF" ) ) );
11861167 }
11871168 else
11881169 {
@@ -1193,14 +1174,12 @@ void QgsProjectProperties::on_cbxProjectionEnabled_toggled( bool onFlyEnabled )
11931174 projectionSelector->setSelectedCrsId ( mProjectSrsId );
11941175
11951176 btnGrpMeasureEllipsoid->setTitle ( measureOnFlyState.arg ( tr ( " ON" ) ) );
1196- btnGrpMapUnits->setTitle ( unitsOnFlyState.arg ( tr ( " ON" ) ) );
11971177 }
11981178
1199- setMapUnitsToCurrentProjection ();
1179+ srIdUpdated ();
12001180
12011181 // Enable/Disable selector and update tool-tip
12021182 updateEllipsoidUI ( mEllipsoidIndex ); // maybe already done by setMapUnitsToCurrentProjection
1203-
12041183}
12051184
12061185void QgsProjectProperties::cbxWFSPubliedStateChanged ( int aIdx )
@@ -1237,7 +1216,33 @@ void QgsProjectProperties::cbxWCSPubliedStateChanged( int aIdx )
12371216 }
12381217}
12391218
1240- void QgsProjectProperties::setMapUnitsToCurrentProjection ()
1219+ void QgsProjectProperties::updateGuiForMapUnits ( QGis::UnitType units )
1220+ {
1221+ int idx = mCoordinateDisplayComboBox ->findData ( MapUnits );
1222+ if ( units == QGis::Degrees )
1223+ {
1224+ // remove map units option from coordinate display combo
1225+ if ( idx >= 0 )
1226+ {
1227+ mCoordinateDisplayComboBox ->removeItem ( idx );
1228+ }
1229+ }
1230+ else
1231+ {
1232+ // make sure map units option is shown in coordinate display combo
1233+ QString mapUnitString = tr ( " Map units (%1)" ).arg ( QGis::tr ( units ) );
1234+ if ( idx < 0 )
1235+ {
1236+ mCoordinateDisplayComboBox ->insertItem ( 0 , mapUnitString, MapUnits );
1237+ }
1238+ else
1239+ {
1240+ mCoordinateDisplayComboBox ->setItemText ( idx, mapUnitString );
1241+ }
1242+ }
1243+ }
1244+
1245+ void QgsProjectProperties::srIdUpdated ()
12411246{
12421247 long myCRSID = projectionSelector->selectedCrsId ();
12431248 if ( !isProjected () || !myCRSID )
@@ -1247,10 +1252,7 @@ void QgsProjectProperties::setMapUnitsToCurrentProjection()
12471252 // set radio button to crs map unit type
12481253 QGis::UnitType units = srs.mapUnits ();
12491254
1250- radMeters->setChecked ( units == QGis::Meters );
1251- radFeet->setChecked ( units == QGis::Feet );
1252- radNMiles->setChecked ( units == QGis::NauticalMiles );
1253- radDegrees->setChecked ( units == QGis::Degrees );
1255+ updateGuiForMapUnits ( units );
12541256
12551257 // attempt to reset the projection ellipsoid according to the srs
12561258 int myIndex = 0 ;
0 commit comments