7#include "MarbleLocale.h"
8#include "MarbleDebug.h"
9#include "MarbleGlobal.h"
10#include "MarbleLocale_p.h"
18MarbleLocalePrivate::MarbleLocalePrivate()
19 : m_measurementSystem(MarbleLocale::MetricSystem)
23MarbleLocalePrivate::~MarbleLocalePrivate() =
default;
25MarbleLocale::MarbleLocale()
26 : d(new MarbleLocalePrivate)
30MarbleLocale::~MarbleLocale()
35void MarbleLocale::setMeasurementSystem(MarbleLocale::MeasurementSystem measurementSystem)
37 d->m_measurementSystem = measurementSystem;
40MarbleLocale::MeasurementSystem MarbleLocale::measurementSystem()
const
42 return d->m_measurementSystem;
45void MarbleLocale::meterToTargetUnit(qreal meters, MeasurementSystem targetSystem, qreal &targetValue, MeasureUnit &targetUnit)
49 switch (targetSystem) {
51 if (targetValue > 1000.0) {
52 targetValue *= METER2KM;
53 targetUnit = Kilometer;
57 if (targetValue < 1.0 && targetValue >= 0.01) {
59 targetUnit = Centimeter;
63 if (targetValue < 0.01) {
65 targetUnit = Milimeter;
73 case ImperialSystem: {
75 qreal ftValue = targetValue * M2FT;
83 if (ftValue >= 3 && ftValue < 5280.0) {
89 if (ftValue >= 5280.0) {
90 targetValue *= METER2KM * KM2MI;
100 case NauticalSystem: {
101 targetValue *= METER2KM * KM2NM;
102 targetUnit = NauticalMile;
107 qWarning() <<
"Unknown measurement system!";
111QString MarbleLocale::unitAbbreviation(MeasureUnit unit)
137QString MarbleLocale::languageCode()
144 code = QStringLiteral(
"en");
145 }
else if (index != -1) {
146 code = lang.
left(index);
150 code = lang.
left(index);
Binds a QML item to a specific geodetic location in screen coordinates.
QString name() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString left(qsizetype n) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.