Commit graph

17571 commits

Author SHA1 Message Date
Robert C. Helling
9feda56006 Remove extra argument and add a test
The compiler complained about this and it seems the
function does not need it.

Additional-test-suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13 09:42:29 +02:00
Robert C. Helling
b50d5b63ad Preserve events when editing dive in planner
The planner does not know about events except gas
changes. But if the dive comes from the log, we
should preserve the dive computer events. At least
those that happend before we started to delete
waypoints to let the planner take over.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13 09:42:29 +02:00
Robert C. Helling
1690ba7c0c Fix compiler warning about variable length field not last in struct.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13 09:42:29 +02:00
Berthold Stoeger
a537894553 profile: remove ProfileWidget2::replotEnabled
The last setter was removed in the previous commit. Let's remove this
complexity.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12 10:32:58 -07:00
Berthold Stoeger
9771c57a54 delegates: remove TankInfoDelegate::createEditor()
When creating a TankInfoDelegate editor, reploting of the profile
was disabled to avoid replotting when the user scrolls through
the tank-info list. Since the code was changed to only set the
tank-info when the editor is closed, this became unnecessary
(hopefully). Indeed the clearing of the flag was removed in a
previous commit. This means that we also have to remove the setting
of the flag. Since this is all the TankInfoDelegate::createEditor()
function was doing, we can remove the whole function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12 10:32:58 -07:00
Berthold Stoeger
563263ab4f cleanup: remove unnecessary profile update after adding new dive
MainWindow::on_actionAddDive_triggered() updated the profile after
calling Command::addDive(). However, that is redundant because the
undo-machinery does the profile reload. Remove the call.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12 09:20:17 -07:00
Berthold Stoeger
f3b817c2d5 media: invalidate correct dive when removing picture
This fixes a bug: when deleting a picture when multiple dives
were selected, possibly the wrong dive was invalidated.
Thus, the dive wouldn't have been saved to the git repository.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-11 11:12:33 -07:00
Dirk Hohndel
6d187b5f4a
Merge pull request #2643 from bstoeger/cylinder4
First steps of cylinder-editing undo
2020-04-11 11:03:05 -07:00
Dirk Hohndel
2990010ccd
Merge pull request #2742 from bstoeger/clean87
cleanup: don't keep pointer-to-picture in PictureEntry
2020-04-11 11:00:11 -07:00
Berthold Stoeger
abf9650280 cleanup: don't keep pointer-to-picture in PictureEntry
The DivePictureModel kept a pointer to picture for each entry.
Firstly, this is dangerous from a data-consistency point of view.
Secondly, the entry wasn't even used anywhere. Remove it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-11 18:50:53 +02:00
Dirk Hohndel
1c420dc64a
Merge pull request #2736 from Subsurface-divelog/removeCloudOverride
core: remove cloud certificate override
2020-04-10 17:22:06 -07:00
Dirk Hohndel
61f9c4114e
Merge pull request #2737 from Subsurface-divelog/libgitCleanup
Libgit cleanup
2020-04-10 17:19:51 -07:00
Dirk Hohndel
42c974edd7 Update CHANGELOG
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Dirk Hohndel
fe6ecb4cd8 code cleanup: once we find a match, stop checking
This isn't really a useful performance improvement, but it's still better,
IMHO, because we don't have a less specific match later on potentially change
an already executed match.

Because of our coding style the comment covering multiple cases of Pelagic dive
computers now is associated just with the first of those entries. I don't see a
way to do this differently without being in violation of our coding style, so
I'll just keep it like this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Dirk Hohndel
55bbdc2728 BLE dive computer detection
Both Shearwater Petrel and Petrel 2 identify as 'Petrel' as their BT and BLE
names. But only the Petrel 2 supports BLE, thus only the Petrel 2 shows up in
the list of known dive computers on iOS (which supports only BLE but not
BT-only). By switching this around to always pick Petrel 2 we now correctly
detect such a dive computer on iOS.

Fixes #2739

Reported-by: Rick Holcombe <wrh@nc.rr.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Dirk Hohndel
b241d09694 mobile/models: correctly reset the connection model
Qt hates empty ranges, and even for a non-empty range, this is better
implemented as a reset than a remove.

This fixes a crash that I have been able to create on iOS by rescanning
for devices on the download page.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Berthold Stoeger
1fd8ea9d49 cleanup: directly return from DivePictureModel::data()
Instead of assigning to a QVariant ret and returning at the end,
return directly in the various switch-cases. This makes the code
more readable, and is more idiomatic C++, as it avoids unnecessary
copies.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Berthold Stoeger
3f3869ff65 media: move picture function from dive.c to picture.c
Currently, move only those functions that do not access dive
structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Berthold Stoeger
34657f62ae cleanup: remove picture_free()
There is the free_picture() function with the same functionality.
The compiler/linker should recognize that and remove the duplicate
code, but still...

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Berthold Stoeger
aa8cadbcdd cleanup: remove dive_get_picture_count() function
The last user was removed in 5b7e4c57f7.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 10:53:03 -07:00
Dirk Hohndel
53fb533a99 cloud-storage: create consistent commit message for merges
This never made sense and I think I just forgot to complete this code
when I first worked on it. Now we can see which version of Subsurface or
Subsurface-mobile created a merge.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 09:53:24 -07:00
Berthold Stoeger
4489389a01 undo: refine pasting of cylinders
When pasting cylinders, the destination dive got a verbatim copy
of the cylinders of the source dive. This is not what users want:
for example, the start and stop pressures from the dive computer
as well as the gas mix may be overwritten.

There seems to be no perfect solution, since some times users may
want to paste the gas-mix.

Therefore, let's choose a heuristic approach for now (in the future
we might implement a UI-flag):

When copying over existing cylinders, only copy type and maximum
pressure.

When adding new cylinders (i.e. from-dive has more cylinders than
to-dive), copy everything, but reset start- and top-pressure to 0,
which represents unkown.

Moroever, in the latter case, set "manually added" to true, since
obviously this wasn't added by a dive computer.

Fixes #2676

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10 09:43:32 -07:00
Dirk Hohndel
7a238b6146 cloud-storage: simplify creation of git authorship
While having the local user information in the repo on Linux seemed
clever when we implemented it, it's inconsistent with all the other
platforms. Let's just not do that unless the user has indeed set
a global name/email pair for git.

Instead indicate if this was Subsurface or Subsurface-mobile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 17:05:44 -07:00
Dirk Hohndel
67a717dc05 cleanup: remove support for ancient versions of libgit2
We require a minimum of libgit2 0.26.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 17:05:30 -07:00
Dirk Hohndel
3828ec6097 build-system: remove references to long gone support for libgit2 < 0.23
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 17:05:24 -07:00
Dirk Hohndel
c6704f2aa6 build-system: deal with libgit2 versions 1 and later
We assumed everywhere that libgit would always have a 0.xx version number.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 17:04:52 -07:00
Dirk Hohndel
ccbd4d1916 core: remove cloud certificate override
This code stopped being useful a long time ago.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09 13:54:43 -07:00
Berthold Stoeger
3a74f65063 fulltext: don't call words.clear() in FullText::populate()
This function was not meant to be called with already existing data.
However, if it was, it cleared the words without clearing the fulltext
caches of the dives. This lead to crashes.

Be more resilient by not clearing the words: Already existing dives
are unregistered during the process of populating anyway. So this
now *should* work if new dives are added to the dive list and then
this function is called.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-08 08:08:19 -07:00
Berthold Stoeger
d9599589c7 fulltext: rename fulltext_reload() to fulltext_populate()
This function was named improperly: it was only used on freshly
loaded data. Indeed, attempts to use it to actually reload lead
to crashes.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-08 08:08:19 -07:00
Berthold Stoeger
d8b92a1852 git: don't check for git sha in parse_file()
parse_file() refused to load from a git repository if we already
had that repository and there were no changes. However, this only
checked the global divelist_changed flag, which does not track
undo-commands. Thus, after editing dives the user couldn't reload
from git.

Remove this check. It is somewhat questionable that the io layer
refuses to load from a repository anyway. Let the caller decide.
There appears to be a check_git_sha function for that purpose(?).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 07:46:27 -07:00
Berthold Stoeger
7dc04b4437 delegates: remove ComboBoxTemplate::fixTabBehavior
The comment states that Qt treats TAB as cancel when in the combobox.
However, testing shows that this use-case works without this hack.
Since it caused weird behavior (the data was set *after* the editor
was closed, leading to inconsistent state), remove it.

Note: this overrides the previous commit, which is therefore redundant
from a history point of view. However, I'll leave the previous commit
in so that if something turns out to break, we can figure out which
of the two changes it was.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
e5c4dee7f6 delegates: call fixTabBehavior *before* closing the editor
fixTabBehavior() set the editor text *after* closing the editor.
This left us in an inconsistent state where we thought that the
editor is active. By reversing two connects, this problem is resolved.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
4d5f25ccf4 cleanup: remove conditional compilation in cylindermodel.cpp
Parts of the code were not compiled on mobile, because they used
the undo-command infrastructure. However, since mobile now also
compiles that, we might as well remove the conditional compilation.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
e2f77f9238 undo: call invalidate_dive_cache() when editing cylinders
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
f9e246fed2 cleanup: make static fields local to ComboBoxDelegate
All combobox-delegates shared a number of static status fields.
In a quest to make the code more reentrant, move that to the
actual object. The fields have to be defined as mutable, since
they are set in const member functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
be7365755e cleanup: remove TankInfoDelegate::reenableReplot
Update of the profile is now done by the undo-commands. If the
planner needs this, it is probably better to connect directly
to the model, not the delegate.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
39bc6e3bdd cleanup: remove unneeded includes from TabDiveEquipment.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
63414fc823 undo: show multiple dive warning when editing equipment
When editing cylinders or weights directly in the table widgets,
no warning was shown if multiple dives were affected. To solve this,
emit signals from the respective models and catch them in dive
equipment tab. Not very nice, but it works for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
2eeb5f4fc2 undo: more fine-grained editing of cylinder
Don't overwrite the full cylinder when editing a single field.
Implement three "modes": editing of type, pressure and gasmix.

Don't consider individual fields, because some of them are
related. E.g. you can change the gasmix by setting the MOD.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
4e8a838f74 undo: store all cylinders in EditCylinderBase
We stored only one cylinder in EditCylinderBase, which is the
base class of RemoveCylinder and EditCylinder. This turns out
to be too crude: when removing the "same" cylinder from
multiple dives, there are some "hidden variables" such as
bestmix_o2 or manually_added, which might actually be different.
We don't want to overwrite those on undo of delete.
Moreover, the cylinder edit is way too crude at the moment,
as it overwrites the whole cylinder even when the user edited
only a single field. To enable a more refined edit, we have
to store each changed cylinder.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
5b65776e43 cleanup: remove same_cylinder
The last user was uses a more general function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
79d117b5bc undo: be more flexible about which cylinders to edit
Currently we use the same_cylinder() function to determine
which cylinders should be edited in a multi-dive edit. Make
this more flexible by introducing a flag-set, such that
the undo-command can select which cylinders are considered
as equal:
	- same type
	- same pressure
	- same gas mix
	- same size

Currently both undo commands use same type, pressure and
gas so that the behavior stays unchanged.

The future goal is to split the cylinder-edit undo command
into different commands so that when, for example, editing
the type only the type is considered by not the gas mix.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
20e7064658 desktop/tabwidgets: replace editMode by boolean
There was only one editMode left (MANUALLY_ADDED_DIVE).
Therefore replace by a flag. This makes the code more consistent,
because the conditions "editMode != NONE" and "editMode ==
MANUALLY_ADDED_DIVE) actually meant the same thing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
3b9913d828 desktop/tabwidgets: replace IGNORE_MODE by flag
The editMode was set to IGNORE_MODE when programatically setting
fields so that we can ignore changed-signals.

That seems to be orthogonal to whether we are in edit mode
and indeed when setting IGNORE_MODE the edit mode was
saved and restored.

Therefore, replace the IGNORE_MODE by an independent ignoreInput
flag.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
e8beeb6767 desktop: properly initialize activeText of model-delegates
For reasons that I don't understand, we keep track of the
current combo-box text for our model-delegates. However,
that text was not initialized when the editor was generated,
leading to a UI bug in the cylinder and weight widgets:
Activate a field, click somewhere else -> either the empty
string or the previous string was set.

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
bbd3f0dd6d cylinders: use preferences modpO2 preferences value
Use the user-editable MOD-pO2 preferences value when creating
a default cylinder. It is not clear to me, when that even has
a consequence, but it looks like the right thing to do.

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
4ae87da58c undo: reload dive on removal of gas-switch
If a gas-switch is removed we have to perform the same action
as if a gas-switch is added: fixup the dive and signal the
changed cylinder and stats.

Adapt the RemoveEvent command accordingly. Copy the code of
the AddGasSwitch command and simplify for the fact that
only ony cylinder can be affected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
e39063f6df undo: switch to affected dive on undo/redo of event-changes
Select and make current the affected dive. And also switch
to the divecomputer that was affected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
48b4dc9c84 cleanup: remove commented-out evn_foreach() function
Apparently this was used to hide events in pre-Qt times. However,
that has already been reimplemented in different ways. Let's remove
that commented-out code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00
Berthold Stoeger
7081674b67 cleanup: remove remove_event() function
No user left.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07 00:13:35 +02:00