In a total abundance of caution, make sure we don't exit the constructor
leaving fields uninitialized.
Fixes CID 351437
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently, selecting a single dive or deselecting all dives was
quite awkward: One had to pass in a single-dive vector and the
dive itself (as current dive). Provide a convenience function
that selects a single dive or deselects all dives if null is
passed in.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We relied upon the translators to remove the parenthesis in cases
like "Edited notes (%n dives)" for n = 1 dives. Dirk doesn't want
that. Therefore, do it in the C++-code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement the EditWeight undo command. Since there is common code
(storage of the old weight), this creates a common base class for
RemoveWeight and EditWeight. The model calls directly into the undo
command, which is somewhat unfortunate as it feels like a layering
violation. It's the easy thing to do for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of freeing internal data of the weightsystem structure,
call the free_weightsystem function (which has to be made extern
at first). This makes things more future-proof, should the
weightsystem struct ever be extended.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To make things more future-proof, introduce an empty_weightsystem
constant. Replace explicit aggragate initialization of empty
weightsystems by this constant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is a bit more complicated than weight adding, because the
multiple-dive case is not well defined. If multiple dives are selected,
this implementation will search for weights that are identical to the
weight deleted in the currently shown dive. The position of the weight
in the list is ignored.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Introduce an AddWeight undo command. This is modelled after the
numerous dive-edit undo commands. The redo and undo actions are
connected to the WeightModel via two new signals, weightAdded
and weightRemoved.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The file command_private.cpp had functions concerning selections
only. To make these functions accessible from outside the undo
machinery, turn it into a part of the core-library. Currently,
only C++ functions are exported. We might think about also
exporting a C interface.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Recently, undo of dive-replanning was introduced. Therefore,
it appears logical to do the same thing for editing of the
profile of manually added dives.
For now, use the same undo-command, just change the displayed
text from "replan dive" to "edit profile". Move the fixup dive
call into the undo-command.
Eventually, every action on the profile should be made undoable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Connect the UI to the underlying dive structure. Enable proper initialisation
and management of star widgets while Information tab is active. Enable undo for
the addtional star widgets.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Split out the actual filtering from the MultiFilterSortModel.
Create a DiveFilter class that does the actual filtering.
Currently, mobile and desktop have their own version of this
class, though ultimately we may want to merge them.
The idea here is that the trip-model and undo-commands have
direct access to the filter-function and thus can take care
of keeping track of the number of shown dives, etc.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The filter-model was catching dives-added / dives-deleted signals
from the models to keep track of the number of shown dives.
To simplify the data flow, do this directly in the undo-command.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the future we might want to use undo-commands for mobile as
well (even if not implementing undo).
Therefore, move the undo-command source from desktop-widgets
to their own commands top-level folder.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>