core/settings: change bestmixend to int, to allow qml to work

depth_t is a good struct in C, but bad in QML.

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-09-08 16:44:51 +02:00 committed by Dirk Hohndel
parent c0b78d69d9
commit a037578015
5 changed files with 14 additions and 21 deletions

View file

@ -54,7 +54,7 @@ HANDLE_PREFERENCE_INT(DivePlanner, "ascrate50", ascrate50);
HANDLE_PREFERENCE_INT(DivePlanner, "ascrate75", ascrate75);
HANDLE_PREFERENCE_STRUCT(DivePlanner, depth_t, "bestmixend", bestmixend, mm);
HANDLE_PREFERENCE_STRUCT(DivePlanner, "bestmixend", bestmixend, mm);
HANDLE_PREFERENCE_INT(DivePlanner, "bottompo2", bottompo2);

View file

@ -11,7 +11,7 @@ class qPrefDivePlanner : public QObject {
Q_PROPERTY(int ascratestops READ ascratestops WRITE set_ascratestops NOTIFY ascratestopsChanged);
Q_PROPERTY(int ascrate50 READ ascrate50 WRITE set_ascrate50 NOTIFY ascrate50Changed);
Q_PROPERTY(int ascrate75 READ ascrate75 WRITE set_ascrate75 NOTIFY ascrate75Changed);
Q_PROPERTY(depth_t bestmixend READ bestmixend WRITE set_bestmixend NOTIFY bestmixendChanged);
Q_PROPERTY(int bestmixend READ bestmixend WRITE set_bestmixend NOTIFY bestmixendChanged);
Q_PROPERTY(int bottompo2 READ bottompo2 WRITE set_bottompo2 NOTIFY bottompo2Changed);
Q_PROPERTY(int bottomsac READ bottomsac WRITE set_bottomsac NOTIFY bottomsacChanged);
Q_PROPERTY(int decopo2 READ decopo2 WRITE set_decopo2 NOTIFY decopo2Changed);
@ -47,7 +47,7 @@ public:
static int ascratestops() { return prefs.ascratestops; }
static int ascrate50() { return prefs.ascrate50; }
static int ascrate75() { return prefs.ascrate75; }
static depth_t bestmixend() { return prefs.bestmixend; }
static int bestmixend() { return prefs.bestmixend.mm; }
static int bottompo2() { return prefs.bottompo2; }
static int bottomsac() { return prefs.bottomsac; }
static int decopo2() { return prefs.decopo2; }
@ -74,7 +74,7 @@ public slots:
static void set_ascratestops(int value);
static void set_ascrate50(int value);
static void set_ascrate75(int value);
static void set_bestmixend(depth_t value);
static void set_bestmixend(int value);
static void set_bottompo2(int value);
static void set_bottomsac(int value);
static void set_decopo2(int value);
@ -101,7 +101,7 @@ signals:
void ascratestopsChanged(int value);
void ascrate50Changed(int value);
void ascrate75Changed(int value);
void bestmixendChanged(depth_t value);
void bestmixendChanged(int value);
void bottompo2Changed(int value);
void bottomsacChanged(int value);
void decopo2Changed(int value);

View file

@ -62,7 +62,7 @@ void qPrefGeneral::set_default_file_behavior(enum def_file_behavior value)
prefs.default_file_behavior = value;
}
disk_default_file_behavior(true);
emit qPrefGeneral::instance()->default_file_behaviorChanged(value);
emit instance()->default_file_behaviorChanged(value);
}
}
void qPrefGeneral::disk_default_file_behavior(bool doSync)

View file

@ -647,7 +647,7 @@ void PlannerSettingsWidget::setDecoPo2(double po2)
void PlannerSettingsWidget::setBestmixEND(int depth)
{
qPrefDivePlanner::instance()->set_bestmixend(units_to_depth(depth));
qPrefDivePlanner::instance()->set_bestmixend(units_to_depth(depth).mm);
}
void PlannerSettingsWidget::setBackgasBreaks(bool dobreaks)

View file

@ -50,7 +50,7 @@ void TestQPrefDivePlanner::test_struct_get()
QCOMPARE(tst->ascratestops(), prefs.ascratestops);
QCOMPARE(tst->ascrate50(), prefs.ascrate50);
QCOMPARE(tst->ascrate75(), prefs.ascrate75);
QCOMPARE(tst->bestmixend().mm, prefs.bestmixend.mm);
QCOMPARE(tst->bestmixend(), prefs.bestmixend.mm);
QCOMPARE(tst->bottompo2(), prefs.bottompo2);
QCOMPARE(tst->bottomsac(), prefs.bottomsac);
QCOMPARE(tst->decopo2(), prefs.decopo2);
@ -83,9 +83,7 @@ void TestQPrefDivePlanner::test_set_struct()
tst->set_ascratestops(21);
tst->set_ascrate50(22);
tst->set_ascrate75(23);
depth_t x;
x.mm = 21;
tst->set_bestmixend(x);
tst->set_bestmixend(21);
tst->set_bottompo2(24);
tst->set_bottomsac(25);
tst->set_decopo2(26);
@ -144,9 +142,7 @@ void TestQPrefDivePlanner::test_set_load_struct()
tst->set_ascratestops(21);
tst->set_ascrate50(22);
tst->set_ascrate75(23);
depth_t x;
x.mm = 41;
tst->set_bestmixend(x);
tst->set_bestmixend(41);
tst->set_bottompo2(24);
tst->set_bottomsac(25);
tst->set_decopo2(26);
@ -335,7 +331,6 @@ void TestQPrefDivePlanner::test_multiple()
void TestQPrefDivePlanner::test_oldPreferences()
{
auto planner = qPrefDivePlanner::instance();
depth_t x;
planner->set_last_stop(true);
planner->set_verbatim_plan(true);
@ -354,8 +349,7 @@ void TestQPrefDivePlanner::test_oldPreferences()
planner->set_descrate(5);
planner->set_bottompo2(6);
planner->set_decopo2(7);
x.mm = 8;
planner->set_bestmixend(x);
planner->set_bestmixend(8);
planner->set_reserve_gas(9);
planner->set_min_switch_duration(10);
planner->set_bottomsac(11);
@ -380,7 +374,7 @@ void TestQPrefDivePlanner::test_oldPreferences()
TEST(planner->descrate(), 5);
TEST(planner->bottompo2(), 6);
TEST(planner->decopo2(), 7);
TEST(planner->bestmixend().mm, 8);
TEST(planner->bestmixend(), 8);
TEST(planner->reserve_gas(), 9);
TEST(planner->min_switch_duration(), 10);
TEST(planner->bottomsac(), 11);
@ -405,8 +399,7 @@ void TestQPrefDivePlanner::test_oldPreferences()
planner->set_descrate(15);
planner->set_bottompo2(16);
planner->set_decopo2(17);
x.mm = 18;
planner->set_bestmixend(x);
planner->set_bestmixend(18);
planner->set_reserve_gas(19);
planner->set_min_switch_duration(110);
planner->set_bottomsac(111);
@ -431,7 +424,7 @@ void TestQPrefDivePlanner::test_oldPreferences()
TEST(planner->descrate(), 15);
TEST(planner->bottompo2(), 16);
TEST(planner->decopo2(), 17);
TEST(planner->bestmixend().mm, 18);
TEST(planner->bestmixend(), 18);
TEST(planner->reserve_gas(), 19);
TEST(planner->min_switch_duration(), 110);
TEST(planner->bottomsac(), 111);