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:
Berthold Stoeger 2022-10-21 00:39:30 +02:00 committed by Dirk Hohndel
parent 9ced3a3a4d
commit f687e51d4b
7 changed files with 15 additions and 8 deletions

View file

@ -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