10,863 changes: 7,274 additions & 3,589 deletions i18n/qgis_sv.ts

Large diffs are not rendered by default.

74 changes: 15 additions & 59 deletions src/app/qgsmeasuredialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,75 +230,40 @@ void QgsMeasureDialog::updateUi()

// Set tooltip to indicate how we calculate measurments
QGis::UnitType mapUnits = mTool->canvas()->mapUnits();
QString mapUnitsTxt;
switch ( mapUnits )
{
case QGis::Meters:
mapUnitsTxt = "meters";
break;
case QGis::Feet:
mapUnitsTxt = "feet";
break;
case QGis::Degrees:
mapUnitsTxt = "degrees";
break;
case QGis::UnknownUnit:
mapUnitsTxt = "-";
}
QGis::UnitType displayUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );

QString toolTip = QString( "The calculations are based on:" );
QString toolTip = tr( "The calculations are based on:" );
if ( ! mTool->canvas()->hasCrsTransformEnabled() )
{
toolTip += QString( "%1 Project CRS transformation is turned off, canvas units setting" ).arg( "<br> *" );
toolTip += QString( "is taken from project properties setting (%1)." ).arg( mapUnitsTxt );
toolTip += QString( "%1 Ellipsoidal calculation is not possible, as project CRS is undefined." ).arg( "<br> *" );
toolTip += "<br> * " + tr( "Project CRS transformation is turned off." ) + " ";
toolTip += tr( "Canvas units setting is taken from project properties setting (%1)." ).arg( QGis::tr( mapUnits ) );
toolTip += "<br> * " + tr( "Ellipsoidal calculation is not possible, as project CRS is undefined." );
}
else
{
if ( mDa.ellipsoidalEnabled() )
{
toolTip += QString( "%1 Project CRS transformation is turned on and ellipsoidal calculation is selected. " ).arg( "<br> *" );
toolTip += QString( "The coordinates are transformed to the chosen ellipsoid (%1) and the result is in meters" ).arg( mDa.ellipsoid() );
toolTip += "<br> * " + tr( "Project CRS transformation is turned on and ellipsoidal calculation is selected." ) + " ";
toolTip += "<br> * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the result is in meters" ).arg( mDa.ellipsoid() );
}
else
{
toolTip += QString( "%1 Project CRS transformation is turned on but ellipsoidal calculation is not selected. " ).arg( "<br> *" );
toolTip += QString( "The canvas units setting is taken from the project CRS (%1)." ).arg( mapUnitsTxt );
toolTip += "<br> * " + tr( "Project CRS transformation is turned on but ellipsoidal calculation is not selected." ).arg( "<br> *" );
toolTip += "<br> * " + tr( "The canvas units setting is taken from the project CRS (%1)." ).arg( QGis::tr( mapUnits ) );
}
}
if ( mapUnits == QGis::Meters && settings.value( "/qgis/measure/displayunits", "meters" ).toString() == "feet" )
{
toolTip += QString( "%1 Finally, the value is converted from meters to feet." ).arg( "<br> *" );
}
else if ( mapUnits == QGis::Feet && settings.value( "/qgis/measure/displayunits", "meters" ).toString() == "meters" )

if (( mapUnits == QGis::Meters && displayUnits == QGis::Feet ) || ( mapUnits == QGis::Feet && displayUnits == QGis::Meters ) )
{
toolTip += QString( "%1 Finally, the value is converted from feet to meters." ).arg( "<br> *" );
toolTip += "<br> * " + tr( "Finally, the value is converted from %2 to %3." ).arg( QGis::tr( mapUnits ) ).arg( QGis::tr( displayUnits ) );
}

editTotal->setToolTip( toolTip );
mTable->setToolTip( toolTip );

int decimalPlaces = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();

double dummy = 1.0;
QGis::UnitType myDisplayUnits;
// The dummy distance is ignored
convertMeasurement( dummy, myDisplayUnits, false );

switch ( myDisplayUnits )
{
case QGis::Meters:
mTable->setHeaderLabels( QStringList( tr( "Segments (in meters)" ) ) );
break;
case QGis::Feet:
mTable->setHeaderLabels( QStringList( tr( "Segments (in feet)" ) ) );
break;
case QGis::Degrees:
mTable->setHeaderLabels( QStringList( tr( "Segments (in degrees)" ) ) );
break;
case QGis::UnknownUnit:
mTable->setHeaderLabels( QStringList( tr( "Segments" ) ) );
}
mTable->setHeaderLabels( QStringList( tr( "Segments [%1]" ).arg( QGis::tr( displayUnits ) ) ) );

if ( mMeasureArea )
{
Expand All @@ -322,18 +287,9 @@ void QgsMeasureDialog::convertMeasurement( double &measure, QGis::UnitType &u, b

// Get the units for display
QSettings settings;
QString myDisplayUnitsTxt = settings.value( "/qgis/measure/displayunits", "meters" ).toString();
QgsDebugMsg( QString( "Preferred display units are %1" ).arg( myDisplayUnitsTxt ) );
QGis::UnitType displayUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );

QGis::UnitType displayUnits;
if ( myDisplayUnitsTxt == "feet" )
{
displayUnits = QGis::Feet;
}
else
{
displayUnits = QGis::Meters;
}
QgsDebugMsg( QString( "Preferred display units are %1" ).arg( QGis::toLiteral( displayUnits ) ) );

mDa.convertMeasurement( measure, myUnits, displayUnits, isArea );
u = myUnits;
Expand Down
31 changes: 18 additions & 13 deletions src/core/qgis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef QGSVERSION
#include "qgsversion.h"
#endif

#include <QCoreApplication>
#include "qgsconfig.h"

#include <ogr_api.h>
Expand Down Expand Up @@ -74,28 +74,33 @@ const double QGis::DEFAULT_IDENTIFY_RADIUS = 0.5;
// Order must match enum indices
const char* QGis::qgisUnitTypes[] =
{
"meters",
"feet",
"degrees",
"<unknown>",
"degrees",
"degrees",
"degrees"
QT_TRANSLATE_NOOP( "QGis::UnitType", "meters" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "feet" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "<unknown>" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" ),
QT_TRANSLATE_NOOP( "QGis::UnitType", "degrees" )
};

QGis::UnitType QGis::fromString( QString unitTxt, QGis::UnitType defaultType )
QGis::UnitType QGis::fromLiteral( QString literal, QGis::UnitType defaultType )
{
for ( int i = 0; i < sizeof( qgisUnitTypes ); i++ )
for ( unsigned int i = 0; i < sizeof( qgisUnitTypes ); i++ )
{
if ( unitTxt == qgisUnitTypes[ i ] )
if ( literal == qgisUnitTypes[ i ] )
{
return static_cast<UnitType>( i );
}
}
return defaultType;
}

QString QGis::toString( QGis::UnitType unit )
QString QGis::toLiteral( QGis::UnitType unit )
{
return QString( qgisUnitTypes[ static_cast<int>( unit )] );
}

QString QGis::tr( QGis::UnitType unit )
{
return QString( qgisUnitTypes[ static_cast<int>( unit ) ] );
return QCoreApplication::translate( "QGis::UnitType", qPrintable( toLiteral( unit ) ) );
}
11 changes: 8 additions & 3 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <QEvent>
#include <QString>
#include <QMetaType>
#include <cfloat>
#include <cmath>
#include <qnumeric.h>
Expand Down Expand Up @@ -95,9 +96,13 @@ class CORE_EXPORT QGis
DegreesMinutesSeconds = 2, // was 4
DegreesDecimalMinutes = 2, // was 5
};
// Converters for the above type
static QString toString( QGis::UnitType unit );
static UnitType fromString( QString unitTxt, QGis::UnitType defaultType = UnknownUnit );

// Provides the canonical name of the type value
static QString toLiteral( QGis::UnitType unit );
// Converts from the canonical name to the type value
static UnitType fromLiteral( QString literal, QGis::UnitType defaultType = UnknownUnit );
// Provides translated version of the type value
static QString tr( QGis::UnitType unit );

//! User defined event types
enum UserEvent
Expand Down