core/settings:: remove string functions for units

Remove string version of unit_system, duration_units, length, pressure,
temperature, vertical_speed_time, and volume, including tests and make signals
strongly typed in C++

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
jan Iversen 2020-01-07 14:31:49 +01:00 committed by Dirk Hohndel
parent 13b2b9f19c
commit 6e06550631
6 changed files with 60 additions and 183 deletions

View file

@ -34,14 +34,14 @@ void TestQPrefUnits::test_struct_get()
prefs.units.weight = units::KG;
QCOMPARE(tst->coordinates_traditional(), true);
QCOMPARE(tst->duration_units(), QStringLiteral("mixed"));
QCOMPARE(tst->length(), QStringLiteral("meters"));
QCOMPARE(tst->pressure(), QStringLiteral("bar"));
QCOMPARE(tst->duration_units(), units::MIXED);
QCOMPARE(tst->length(), units::METERS);
QCOMPARE(tst->pressure(), units::BAR);
QCOMPARE(tst->show_units_table(), true);
QCOMPARE(tst->temperature(), QStringLiteral("celcius"));
QCOMPARE(tst->vertical_speed_time(), QStringLiteral("seconds"));
QCOMPARE(tst->volume(), QStringLiteral("liter"));
QCOMPARE(tst->weight(), QStringLiteral("kg"));
QCOMPARE(tst->temperature(), units::CELSIUS);
QCOMPARE(tst->vertical_speed_time(), units::SECONDS);
QCOMPARE(tst->volume(), units::LITER);
QCOMPARE(tst->weight(), units::KG);
}
void TestQPrefUnits::test_set_struct()
@ -159,9 +159,9 @@ void TestQPrefUnits::test_multiple()
auto tst = qPrefUnits::instance();
QCOMPARE(tst->length(), qPrefUnits::length());
QCOMPARE(tst->length(), QStringLiteral("meters"));
QCOMPARE(tst->length(), units::METERS);
QCOMPARE(tst->pressure(), qPrefUnits::pressure());
QCOMPARE(tst->pressure(), QStringLiteral("bar"));
QCOMPARE(tst->pressure(), units::BAR);
}
void TestQPrefUnits::test_unit_system()
@ -170,22 +170,22 @@ void TestQPrefUnits::test_unit_system()
auto tst = qPrefUnits::instance();
tst->set_unit_system("metric");
tst->set_unit_system(METRIC);
QCOMPARE(prefs.unit_system, METRIC);
QCOMPARE(tst->unit_system(), QStringLiteral("metric"));
tst->set_unit_system("imperial");
QCOMPARE(tst->unit_system(), METRIC);
tst->set_unit_system(IMPERIAL);
QCOMPARE(prefs.unit_system, IMPERIAL);
QCOMPARE(tst->unit_system(), QStringLiteral("imperial"));
tst->set_unit_system("personalized");
QCOMPARE(tst->unit_system(), IMPERIAL);
tst->set_unit_system(PERSONALIZE);
QCOMPARE(prefs.unit_system, PERSONALIZE);
QCOMPARE(tst->unit_system(), QStringLiteral("personalized"));
QCOMPARE(tst->unit_system(), PERSONALIZE);
prefs.unit_system = METRIC;
QCOMPARE(tst->unit_system(), QStringLiteral("metric"));
QCOMPARE(tst->unit_system(), METRIC);
prefs.unit_system = IMPERIAL;
QCOMPARE(tst->unit_system(), QStringLiteral("imperial"));
QCOMPARE(tst->unit_system(), IMPERIAL);
prefs.unit_system = PERSONALIZE;
QCOMPARE(tst->unit_system(), QStringLiteral("personalized"));
QCOMPARE(tst->unit_system(), PERSONALIZE);
}
#define TEST(METHOD, VALUE) \
@ -203,17 +203,19 @@ void TestQPrefUnits::test_oldPreferences()
units->set_volume(units::LITER);
units->set_temperature(units::CELSIUS);
units->set_weight(units::KG);
units->set_unit_system(QStringLiteral("metric"));
units->set_unit_system(METRIC);
units->set_coordinates_traditional(false);
units->set_vertical_speed_time(units::SECONDS);
TEST(units->length(), QStringLiteral("meters"));
TEST(units->pressure(), QStringLiteral("bar"));
TEST(units->volume(), QStringLiteral("liter"));
TEST(units->temperature(), QStringLiteral("celcius"));
TEST(units->weight(), QStringLiteral("kg"));
TEST(units->vertical_speed_time(), QStringLiteral("seconds"));
TEST(units->unit_system(), QStringLiteral("metric"));
TEST(units->length(), units::METERS);
TEST(units->pressure(), units::BAR);
TEST(units->volume(), units::LITER);
TEST(units->temperature(), units::CELSIUS);
TEST(units->weight(), units::KG);
TEST(units->vertical_speed_time(), units::SECONDS);
TEST(units->unit_system(), METRIC);
TEST(units->vertical_speed_time(), units::SECONDS);
TEST(units->unit_system(), METRIC);
TEST(units->coordinates_traditional(), false);
units->set_length(units::FEET);
@ -222,16 +224,14 @@ void TestQPrefUnits::test_oldPreferences()
units->set_temperature(units::FAHRENHEIT);
units->set_weight(units::LBS);
units->set_vertical_speed_time(units::MINUTES);
units->set_unit_system(QStringLiteral("fake-metric-system"));
units->set_coordinates_traditional(true);
TEST(units->length(), QStringLiteral("feet"));
TEST(units->pressure(), QStringLiteral("psi"));
TEST(units->volume(), QStringLiteral("cuft"));
TEST(units->temperature(), QStringLiteral("fahrenheit"));
TEST(units->weight(), QStringLiteral("lbs"));
TEST(units->vertical_speed_time(), QStringLiteral("minutes"));
TEST(units->unit_system(), QStringLiteral("personalized"));
TEST(units->length(), units::FEET);
TEST(units->pressure(), units::PSI);
TEST(units->volume(), units::CUFT);
TEST(units->temperature(), units::FAHRENHEIT);
TEST(units->weight(), units::LBS);
TEST(units->vertical_speed_time(), units::MINUTES);
TEST(units->coordinates_traditional(), true);
}