mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Import: Move the Import of .FIT Files to 'Import log files'
Move the import of .FIT files into the 'Import log files' menu item, where most people will be looking for it. This also naturally opens a file selection dialog, which is more intuitive than having to select this in the dive computer import dialog. Also fix a bug affecting file imports if the log files contain coordinates - the dive log needs to be set in the import data structure. And refactor the file dialog file filters to make it more natural to add more entries. Requires https://github.com/subsurface/libdc/pull/72 to work. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
feb70907e5
commit
5889c1a3f8
12 changed files with 77 additions and 72 deletions
|
@ -14,22 +14,25 @@
|
|||
#include "libdivecomputer.h"
|
||||
|
||||
// As supplied by Divesoft
|
||||
static const char divesoft_liberty_serial_prefix[] = "7026";
|
||||
static const char divesoft_freedom_serial_prefix[] = "7044";
|
||||
static const char divesoft_freedom_plus_serial_prefix[] = "7273";
|
||||
static constexpr std::string_view divesoft_liberty_serial_prefix = "7026";
|
||||
static constexpr std::string_view divesoft_freedom_serial_prefix = "7044";
|
||||
static constexpr std::string_view divesoft_freedom_plus_serial_prefix = "7273";
|
||||
|
||||
// From libdivecomputer
|
||||
static const int divesoft_liberty_model = 10;
|
||||
static const int divesoft_freedom_model = 19;
|
||||
static constexpr int divesoft_liberty_model = 10;
|
||||
static constexpr int divesoft_freedom_model = 19;
|
||||
|
||||
int divesoft_import(const std::unique_ptr<std::vector<unsigned char>> &buffer, struct divelog *log)
|
||||
int divesoft_import(const std::string &buffer, struct divelog *log)
|
||||
{
|
||||
std::string model_identifier = buffer.substr(52, 4);
|
||||
int model = 0;
|
||||
if (strncmp((char *)(buffer->data() + 52), divesoft_liberty_serial_prefix, 4) == 0)
|
||||
if (model_identifier == divesoft_liberty_serial_prefix)
|
||||
model = divesoft_liberty_model;
|
||||
else if (strncmp((char *)(buffer->data() + 52), divesoft_freedom_serial_prefix, 4) == 0 || strncmp((char *)(buffer->data() + 52), divesoft_freedom_plus_serial_prefix, 4) == 0)
|
||||
else if (model_identifier == divesoft_freedom_serial_prefix || model_identifier == divesoft_freedom_plus_serial_prefix)
|
||||
model = divesoft_freedom_model;
|
||||
|
||||
device_data_t devdata;
|
||||
devdata.log = log;
|
||||
int ret = prepare_device_descriptor(model, DC_FAMILY_DIVESOFT_FREEDOM, devdata);
|
||||
if (ret == 0)
|
||||
return report_error("%s", translate("gettextFromC", "Unknown DC"));
|
||||
|
@ -38,7 +41,7 @@ int divesoft_import(const std::unique_ptr<std::vector<unsigned char>> &buffer, s
|
|||
d->dcs[0].model = devdata.vendor + " " + devdata.model + " (Imported from file)";
|
||||
|
||||
// Parse the dive data
|
||||
dc_status_t rc = libdc_buffer_parser(d.get(), &devdata, buffer->data(), buffer->size());
|
||||
dc_status_t rc = libdc_buffer_parser(d.get(), &devdata, (const unsigned char *)buffer.data(), buffer.size());
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return report_error(translate("gettextFromC", "Error - %s - parsing dive %d"), errmsg(rc), d->number);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue