mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
core: add make_manually_added_dc() function
For reasons of symmetry (there is a is_manually_added_dc() function), create a make_manually_added_dc() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f687e51d4b
commit
261f07dfa4
5 changed files with 12 additions and 4 deletions
|
@ -549,8 +549,15 @@ void free_dc(struct divecomputer *dc)
|
||||||
free(dc);
|
free(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *manual_dc_name = "manually added dive";
|
||||||
bool is_manually_added_dc(const struct divecomputer *dc)
|
bool is_manually_added_dc(const struct divecomputer *dc)
|
||||||
{
|
{
|
||||||
return dc && dc->samples <= 50 &&
|
return dc && dc->samples <= 50 &&
|
||||||
same_string(dc->model, "manually added dive");
|
same_string(dc->model, manual_dc_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void make_manually_added_dc(struct divecomputer *dc)
|
||||||
|
{
|
||||||
|
free((void *)dc->model);
|
||||||
|
dc->model = strdup(manual_dc_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ extern void add_extra_data(struct divecomputer *dc, const char *key, const char
|
||||||
extern bool is_dc_planner(const struct divecomputer *dc);
|
extern bool is_dc_planner(const struct divecomputer *dc);
|
||||||
extern uint32_t calculate_string_hash(const char *str);
|
extern uint32_t calculate_string_hash(const char *str);
|
||||||
extern bool is_manually_added_dc(const struct divecomputer *dc);
|
extern bool is_manually_added_dc(const struct divecomputer *dc);
|
||||||
|
extern void make_manually_added_dc(struct divecomputer *dc);
|
||||||
|
|
||||||
/* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */
|
/* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */
|
||||||
extern int match_one_dc(const struct divecomputer *a, const struct divecomputer *b);
|
extern int match_one_dc(const struct divecomputer *a, const struct divecomputer *b);
|
||||||
|
|
|
@ -690,7 +690,7 @@ void MainWindow::on_actionAddDive_triggered()
|
||||||
d.dc.duration.seconds = 40 * 60;
|
d.dc.duration.seconds = 40 * 60;
|
||||||
d.dc.maxdepth.mm = M_OR_FT(15, 45);
|
d.dc.maxdepth.mm = M_OR_FT(15, 45);
|
||||||
d.dc.meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop
|
d.dc.meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop
|
||||||
d.dc.model = strdup("manually added dive"); // don't translate! this is stored in the XML file
|
make_manually_added_dc(&d.dc);
|
||||||
fake_dc(&d.dc);
|
fake_dc(&d.dc);
|
||||||
fixup_dive(&d);
|
fixup_dive(&d);
|
||||||
|
|
||||||
|
|
|
@ -1716,7 +1716,7 @@ int QMLManager::addDive()
|
||||||
d.dc.duration.seconds = 40 * 60;
|
d.dc.duration.seconds = 40 * 60;
|
||||||
d.dc.maxdepth.mm = M_OR_FT(15, 45);
|
d.dc.maxdepth.mm = M_OR_FT(15, 45);
|
||||||
d.dc.meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop
|
d.dc.meandepth.mm = M_OR_FT(13, 39); // this creates a resonable looking safety stop
|
||||||
d.dc.model = strdup("manually added dive"); // don't translate! this is stored in the XML file
|
make_manually_added_dc(&d.dc);
|
||||||
fake_dc(&d.dc);
|
fake_dc(&d.dc);
|
||||||
fixup_dive(&d);
|
fixup_dive(&d);
|
||||||
|
|
||||||
|
|
|
@ -868,7 +868,7 @@ static int prepare_data(int data_model, char *serial, dc_family_t dc_fam, device
|
||||||
{
|
{
|
||||||
dev_data->device = NULL;
|
dev_data->device = NULL;
|
||||||
dev_data->context = NULL;
|
dev_data->context = NULL;
|
||||||
if (!data_model){
|
if (!data_model) {
|
||||||
dev_data->model = copy_string("manually added dive");
|
dev_data->model = copy_string("manually added dive");
|
||||||
dev_data->descriptor = NULL;
|
dev_data->descriptor = NULL;
|
||||||
return DC_STATUS_NODEVICE;
|
return DC_STATUS_NODEVICE;
|
||||||
|
|
Loading…
Reference in a new issue