@@ -230,75 +230,40 @@ void QgsMeasureDialog::updateUi()
230
230
231
231
// Set tooltip to indicate how we calculate measurments
232
232
QGis::UnitType mapUnits = mTool ->canvas ()->mapUnits ();
233
- QString mapUnitsTxt;
234
- switch ( mapUnits )
235
- {
236
- case QGis::Meters:
237
- mapUnitsTxt = " meters" ;
238
- break ;
239
- case QGis::Feet:
240
- mapUnitsTxt = " feet" ;
241
- break ;
242
- case QGis::Degrees:
243
- mapUnitsTxt = " degrees" ;
244
- break ;
245
- case QGis::UnknownUnit:
246
- mapUnitsTxt = " -" ;
247
- }
233
+ QGis::UnitType displayUnits = QGis::fromLiteral ( settings.value ( " /qgis/measure/displayunits" , QGis::toLiteral ( QGis::Meters ) ).toString () );
248
234
249
- QString toolTip = QString ( " The calculations are based on:" );
235
+ QString toolTip = tr ( " The calculations are based on:" );
250
236
if ( ! mTool ->canvas ()->hasCrsTransformEnabled () )
251
237
{
252
- toolTip += QString ( " %1 Project CRS transformation is turned off, canvas units setting " ). arg ( " <br> * " ) ;
253
- toolTip += QString ( " is taken from project properties setting (%1)." ).arg ( mapUnitsTxt );
254
- toolTip += QString ( " %1 Ellipsoidal calculation is not possible, as project CRS is undefined." ). arg ( " <br> * " );
238
+ toolTip += " <br> * " + tr ( " Project CRS transformation is turned off. " ) + " " ;
239
+ toolTip += tr ( " Canvas units setting is taken from project properties setting (%1)." ).arg ( QGis::tr ( mapUnits ) );
240
+ toolTip += " <br> * " + tr ( " Ellipsoidal calculation is not possible, as project CRS is undefined." );
255
241
}
256
242
else
257
243
{
258
244
if ( mDa .ellipsoidalEnabled () )
259
245
{
260
- toolTip += QString ( " %1 Project CRS transformation is turned on and ellipsoidal calculation is selected. " ). arg ( " <br> * " ) ;
261
- toolTip += QString ( " The coordinates are transformed to the chosen ellipsoid (%1) and the result is in meters" ).arg ( mDa .ellipsoid () );
246
+ toolTip += " <br> * " + tr ( " Project CRS transformation is turned on and ellipsoidal calculation is selected." ) + " " ;
247
+ toolTip += " <br> * " + tr ( " The coordinates are transformed to the chosen ellipsoid (%1), and the result is in meters" ).arg ( mDa .ellipsoid () );
262
248
}
263
249
else
264
250
{
265
- toolTip += QString ( " %1 Project CRS transformation is turned on but ellipsoidal calculation is not selected. " ).arg ( " <br> *" );
266
- toolTip += QString ( " The canvas units setting is taken from the project CRS (%1)." ).arg ( mapUnitsTxt );
251
+ toolTip += " <br> * " + tr ( " Project CRS transformation is turned on but ellipsoidal calculation is not selected." ).arg ( " <br> *" );
252
+ toolTip += " <br> * " + tr ( " The canvas units setting is taken from the project CRS (%1)." ).arg ( QGis::tr ( mapUnits ) );
267
253
}
268
254
}
269
- if ( mapUnits == QGis::Meters && settings.value ( " /qgis/measure/displayunits" , " meters" ).toString () == " feet" )
270
- {
271
- toolTip += QString ( " %1 Finally, the value is converted from meters to feet." ).arg ( " <br> *" );
272
- }
273
- else if ( mapUnits == QGis::Feet && settings.value ( " /qgis/measure/displayunits" , " meters" ).toString () == " meters" )
255
+
256
+ if (( mapUnits == QGis::Meters && displayUnits == QGis::Feet ) || ( mapUnits == QGis::Feet && displayUnits == QGis::Meters ) )
274
257
{
275
- toolTip += QString ( " %1 Finally, the value is converted from feet to meters ." ).arg ( " <br> * " );
258
+ toolTip += " <br> * " + tr ( " Finally, the value is converted from %2 to %3 ." ).arg ( QGis::tr ( mapUnits ) ). arg ( QGis::tr ( displayUnits ) );
276
259
}
277
260
278
261
editTotal->setToolTip ( toolTip );
279
262
mTable ->setToolTip ( toolTip );
280
263
281
264
int decimalPlaces = settings.value ( " /qgis/measure/decimalplaces" , " 3" ).toInt ();
282
265
283
- double dummy = 1.0 ;
284
- QGis::UnitType myDisplayUnits;
285
- // The dummy distance is ignored
286
- convertMeasurement ( dummy, myDisplayUnits, false );
287
-
288
- switch ( myDisplayUnits )
289
- {
290
- case QGis::Meters:
291
- mTable ->setHeaderLabels ( QStringList ( tr ( " Segments (in meters)" ) ) );
292
- break ;
293
- case QGis::Feet:
294
- mTable ->setHeaderLabels ( QStringList ( tr ( " Segments (in feet)" ) ) );
295
- break ;
296
- case QGis::Degrees:
297
- mTable ->setHeaderLabels ( QStringList ( tr ( " Segments (in degrees)" ) ) );
298
- break ;
299
- case QGis::UnknownUnit:
300
- mTable ->setHeaderLabels ( QStringList ( tr ( " Segments" ) ) );
301
- }
266
+ mTable ->setHeaderLabels ( QStringList ( tr ( " Segments [%1]" ).arg ( QGis::tr ( displayUnits ) ) ) );
302
267
303
268
if ( mMeasureArea )
304
269
{
@@ -322,18 +287,9 @@ void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, b
322
287
323
288
// Get the units for display
324
289
QSettings settings;
325
- QString myDisplayUnitsTxt = settings.value ( " /qgis/measure/displayunits" , " meters" ).toString ();
326
- QgsDebugMsg ( QString ( " Preferred display units are %1" ).arg ( myDisplayUnitsTxt ) );
290
+ QGis::UnitType displayUnits = QGis::fromLiteral ( settings.value ( " /qgis/measure/displayunits" , QGis::toLiteral ( QGis::Meters ) ).toString () );
327
291
328
- QGis::UnitType displayUnits;
329
- if ( myDisplayUnitsTxt == " feet" )
330
- {
331
- displayUnits = QGis::Feet;
332
- }
333
- else
334
- {
335
- displayUnits = QGis::Meters;
336
- }
292
+ QgsDebugMsg ( QString ( " Preferred display units are %1" ).arg ( QGis::toLiteral ( displayUnits ) ) );
337
293
338
294
mDa .convertMeasurement ( measure, myUnits, displayUnits, isArea );
339
295
u = myUnits;
0 commit comments