This has been deprecated for years.
The delta() member dealt with the old style mouse wheel that is associated with
a vertical scroll - so we need the y-component.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is slightly different from the previous cleanup around QFlag use as this
one is related to QtWebKit flags. But the logic is the same.
Just syntax to avoid a warning.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For multiple-choice constraints we use a bit field of type
uint64_t. This means we theoretically support up to 64 items.
Currently use at most seven.
Coverity complained (correctly) that we use the expression
"1 << x" to generate the bitfields. However 1 is a 32-bit
literal on most platforms, which makes this undefined
behavior for x >= 32. Change the integer literal to 64-bit
1ULL.
Moreover, when detecting items with an index >= 64, don't
even attempt to set the according bit, since this is
undefined behavior and the compiler is free to do as it
pleases in such a case.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If source files want to access preferences functions, they should
include pref.h themselves.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Nobody was using these return-code macros and the functions
do not exist since a long time.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These flags are not dive-related, therefore move their declaration
to the appropriate header file. Likewise, move their definition
from parse-xml.c to subsurfacehelper.c
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
unregister_dive() and delete_single_dive are defined in
divelist.c, as they take an "index" argument into the global
divelist. Therefore, move their declarations to divelist.h.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since dive.c is so huge, split out divecomputer-related functions
into divecomputer.[c|h], sample.[c|h] and extradata.[c|h].
This does not give huge compile time improvements, since
struct dive contains a struct divecomputer and therefore
dive.h has to include divecomputer.h. However, it make things
distinctly more clear.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The function
1) was misnamed: it determined the time of the first selcted dive.
2) had only one caller.
3) would crash if there was no selected dive.
Let's just fold the functionality into the caller. It's a one-liner
anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In an effort to reduce the size of dive.h and dive.c, break out
the event related functions. Moreover event-names were handled
by the profile-code, collect that also in the new source files.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was used by the DiveComputerDialog, which does not exist
anymore. The new tab uses the function in the corresponding
sorted model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Desktop does not use mark_divelist_changed() anymore - all is done
via the undo machinery. Therefore move this function (and its
counterpart unsaved_changes()) to qmlmanager.cpp.
Ultimately, it probably should be removed from there as well, but
currently I don't dare to touch all the cloud-logic!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was used to unify both methods of tracking unsaved
changes. Since desktop now only uses the undo system, it can
be replaced by a single call to "Command::setClean()".
Arguably, the UI is the wrong place to do this and the appropriate
calls should be done by the core. However, let's play it safe
for now and avoid any breaking change.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Unsaved changes are now kept track by the undo-system. No need
to test for this function when directly modifying the core
data structures.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was used to unify both methods of checking for
unsaved changes: the global unsaved_changes() flag and the
Command::clean() function of the undo-system.
However, all desktop functions are now undoable and therefore
the function is not needed and can be replaced by calls
to !Command::clean().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of modifying the device table directly, call the undo
commands. Moreover, don't keep our own copy in the mode - show
the original version. Connect to the appropriate signals.
This means that the calls from the DiveComputerManagement
dialog have to be removed, since this mode of editing is
not supported. The whole dialog will be removed in a future
commit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To implement undo-semantics, we want a longer-lived dive-computer-model
(currently, it is regenerated when the dialog is opened). Therefore, it
must be reloaded when the core data is reset. Do this like for other
models: listen to the dataReset() signal of DiveListNotifier.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The undo machinery will need a method to remove devices based
on their index instead of their name. Add it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If we want to include dive computer names in the undo system,
there should be visual feedback on undo/redo.
This would mean opening the divecomputer dialog, which would
appear quite strange. Therefore, add a tab. This is not ideal,
but consistent with the dive site tab, which probably shouldn't
be there either. In the future, the UI needs some rethinking.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add commands for deleting devices and editing device nicknames
to include the device-handling in the undo system.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Technically get_dive() could return a nullptr. The existing code made sure the
argument passed to get_dive() was one that always would result in a valid dive
pointer being returned. The new code is only slightly less efficient but allows
a static code analysis to easily see that we don't derefence NULL pointers here.
On some level this change is unnecessary. But it's also not wrong.
Fixes CID 354762
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Technically get_dive(i) could return a nullptr. But given the range for i that
can never happen. Still, the test is extremely cheap and doesn't hurt.
Fixes CID 354768
Fixes CID 354766
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way we should see the output and hopefully be able to figure
out why that silly test keeps randomly failing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The device nodes are created for all DCs, when importing the
dives. There is no point in creating only the device node for
the first DC in fixup_dive().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the specuial case of suunto, where we may add a device directly
instead of via dive->dc, add the device to the provided table.
The caller will then pass on the new device to the undo system.
This makes downloading finally really undoable (at least I
hope so). So far, the dives and dive sites were removed, but any
new device remained.
However, when setting the device-id via serial, we now have
to check both, the global and the downloaded list of devices.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In one weird case (suunto), the code in libdivecomputer.c
generates a device node directly instead of going the usual
way (setting the data in the dc-structure of the imported
dive). It is unclear to me whether that has to be that way,
as it depends on the chronological order of callbacks to
event_cb() and dive_cb().
Therefore add a device_table pointer to device_data_t
so that the downloader can add the device to this table. This
only adds the pointer, but does not yet use it in the
downloading code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>