aboutsummaryrefslogtreecommitdiffstats
path: root/core/divecomputer.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@gmail.com>2016-08-10 18:10:15 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-08-27 11:40:44 -0700
commitdb8e8957abc8b8dc407a94835e686f649c9643a6 (patch)
tree5c21bd7e9a4174704e1c53752146c1229464b2bc /core/divecomputer.cpp
parentb264c3e36704c83a6c9353fe5eac3dc0eb3c9a80 (diff)
downloadsubsurface-db8e8957abc8b8dc407a94835e686f649c9643a6.tar.gz
Settings update: Add "Dive Computer" settings to SettingsObjectWrapper
For some reason, the dive computer settings weren't in the settings prefs. This moves it, makes the boilerplate on Settings ObjectWrapper and make things compile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/divecomputer.cpp')
-rw-r--r--core/divecomputer.cpp59
1 files changed, 5 insertions, 54 deletions
diff --git a/core/divecomputer.cpp b/core/divecomputer.cpp
index e4081e1cd..5a79f3981 100644
--- a/core/divecomputer.cpp
+++ b/core/divecomputer.cpp
@@ -1,12 +1,9 @@
#include "divecomputer.h"
#include "dive.h"
+#include "subsurface-qt/SettingsObjectWrapper.h"
#include <QSettings>
-const char *default_dive_computer_vendor;
-const char *default_dive_computer_product;
-const char *default_dive_computer_device;
-int default_dive_computer_download_mode;
DiveComputerList dcList;
DiveComputerList::DiveComputerList()
@@ -144,60 +141,14 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *
extern "C" int is_default_dive_computer(const char *vendor, const char *product)
{
- return default_dive_computer_vendor && !strcmp(vendor, default_dive_computer_vendor) &&
- default_dive_computer_product && !strcmp(product, default_dive_computer_product);
+ auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
+ return dc->dc_vendor() == vendor && dc->dc_product() == product;
}
extern "C" int is_default_dive_computer_device(const char *name)
{
- return default_dive_computer_device && !strcmp(name, default_dive_computer_device);
-}
-
-void set_default_dive_computer(const char *vendor, const char *product)
-{
- QSettings s;
-
- if (!vendor || !*vendor)
- return;
- if (!product || !*product)
- return;
- if (is_default_dive_computer(vendor, product))
- return;
-
- free((void *)default_dive_computer_vendor);
- free((void *)default_dive_computer_product);
- default_dive_computer_vendor = strdup(vendor);
- default_dive_computer_product = strdup(product);
- s.beginGroup("DiveComputer");
- s.setValue("dive_computer_vendor", vendor);
- s.setValue("dive_computer_product", product);
- s.endGroup();
-}
-
-void set_default_dive_computer_device(const char *name)
-{
- QSettings s;
-
- if (!name || !*name)
- return;
- if (is_default_dive_computer_device(name))
- return;
-
- free((void *)default_dive_computer_device);
- default_dive_computer_device = strdup(name);
- s.beginGroup("DiveComputer");
- s.setValue("dive_computer_device", name);
- s.endGroup();
-}
-
-void set_default_dive_computer_download_mode(int download_mode)
-{
- QSettings s;
-
- default_dive_computer_download_mode = download_mode;
- s.beginGroup("DiveComputer");
- s.setValue("dive_computer_download_mode", download_mode);
- s.endGroup();
+ auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
+ return dc->dc_device() == name;
}
extern "C" void set_dc_nickname(struct dive *dive)