mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
core: don't consider dives with many samples as manually added
This causes UI confusion. Notably we go into edit mode and reduce the number of samples, leading to loss of information. If someone really manually adds a dive with more than 50 samples, they should still be able to explicitly open the dive in the planner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9ced3a3a4d
commit
f687e51d4b
7 changed files with 15 additions and 8 deletions
|
@ -2333,8 +2333,8 @@ static int likely_same_dive(const struct dive *a, const struct dive *b)
|
|||
int match, fuzz = 20 * 60;
|
||||
|
||||
/* don't merge manually added dives with anything */
|
||||
if (same_string(a->dc.model, "manually added dive") ||
|
||||
same_string(b->dc.model, "manually added dive"))
|
||||
if (is_manually_added_dc(&a->dc) ||
|
||||
is_manually_added_dc(&b->dc))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
|
|
|
@ -548,3 +548,9 @@ void free_dc(struct divecomputer *dc)
|
|||
free_dc_contents(dc);
|
||||
free(dc);
|
||||
}
|
||||
|
||||
bool is_manually_added_dc(const struct divecomputer *dc)
|
||||
{
|
||||
return dc && dc->samples <= 50 &&
|
||||
same_string(dc->model, "manually added dive");
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ extern void remove_event_from_dc(struct divecomputer *dc, struct event *event);
|
|||
extern void add_extra_data(struct divecomputer *dc, const char *key, const char *value);
|
||||
extern bool is_dc_planner(const struct divecomputer *dc);
|
||||
extern uint32_t calculate_string_hash(const char *str);
|
||||
extern bool is_manually_added_dc(const struct divecomputer *dc);
|
||||
|
||||
/* 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);
|
||||
|
|
|
@ -192,7 +192,7 @@ void ProfileWidget::plotCurrentDive()
|
|||
if (current_dive && !editedDive &&
|
||||
DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING) {
|
||||
struct divecomputer *dc = get_dive_dc(current_dive, dc_number);
|
||||
if (dc && same_string(dc->model, "manually added dive") && dc->samples)
|
||||
if (dc && is_manually_added_dc(dc) && dc->samples)
|
||||
editDive();
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ void TabDiveInformation::updateData()
|
|||
}
|
||||
|
||||
int salinity_value;
|
||||
manualDive = same_string(current_dive->dc.model, "manually added dive");
|
||||
manualDive = is_manually_added_dc(¤t_dive->dc);
|
||||
updateWaterTypeWidget();
|
||||
updateProfile();
|
||||
updateWhen();
|
||||
|
|
|
@ -251,7 +251,7 @@ void TabDiveNotes::updateData()
|
|||
ui.LocationLabel->setText(tr("Location"));
|
||||
ui.NotesLabel->setText(tr("Notes"));
|
||||
ui.tagWidget->setText(get_taglist_string(current_dive->tag_list));
|
||||
bool isManual = same_string(current_dive->dc.model, "manually added dive");
|
||||
bool isManual = is_manually_added_dc(¤t_dive->dc);
|
||||
ui.depth->setVisible(isManual);
|
||||
ui.depthLabel->setVisible(isManual);
|
||||
ui.duration->setVisible(isManual);
|
||||
|
|
|
@ -1127,7 +1127,7 @@ bool QMLManager::checkDuration(struct dive *d, QString duration)
|
|||
m = m6.captured(1).toInt();
|
||||
}
|
||||
d->dc.duration.seconds = d->duration.seconds = h * 3600 + m * 60 + s;
|
||||
if (same_string(d->dc.model, "manually added dive"))
|
||||
if (is_manually_added_dc(&d->dc))
|
||||
free_samples(&d->dc);
|
||||
else
|
||||
appendTextToLog("Cannot change the duration on a dive that wasn't manually added");
|
||||
|
@ -1145,7 +1145,7 @@ bool QMLManager::checkDepth(dive *d, QString depth)
|
|||
// the depth <= 500m
|
||||
if (0 <= depthValue && depthValue <= 500000) {
|
||||
d->maxdepth.mm = depthValue;
|
||||
if (same_string(d->dc.model, "manually added dive")) {
|
||||
if (is_manually_added_dc(&d->dc)) {
|
||||
d->dc.maxdepth.mm = d->maxdepth.mm;
|
||||
free_samples(&d->dc);
|
||||
}
|
||||
|
@ -1351,7 +1351,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
|
|||
if (diveChanged) {
|
||||
if (d->maxdepth.mm == d->dc.maxdepth.mm &&
|
||||
d->maxdepth.mm > 0 &&
|
||||
same_string(d->dc.model, "manually added dive") &&
|
||||
is_manually_added_dc(&d->dc) &&
|
||||
d->dc.samples == 0) {
|
||||
// so we have depth > 0, a manually added dive and no samples
|
||||
// let's create an actual profile so the desktop version can work it
|
||||
|
|
Loading…
Reference in a new issue