summaryrefslogtreecommitdiffstats
path: root/commands/command_edit.h
AgeCommit message (Collapse)Author
2020-04-07undo: more fine-grained editing of cylinderGravatar Berthold Stoeger
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-07undo: store all cylinders in EditCylinderBaseGravatar Berthold Stoeger
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-07undo: be more flexible about which cylinders to editGravatar Berthold Stoeger
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-07undo: remove only "non-protected" cylindersGravatar Berthold Stoeger
The undo-code must take care not to remove used cylinders. To do so, extend the constructor of EditCylinderBase, which collects the cylinders and dives to edit, by the "nonProtectedOnly" boolean argument. If true, only those cylinders for wich "is_cylinder_prot" returns false will be added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: add cylinder undo commands by copy & pasteGravatar Berthold Stoeger
Do a simple copy & paste followed by a simple search & replace to generate cylinder undo commands from weight undo commands. Obviously, this is still missing the necessary code to keep the dive-data consistent after cylinder editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04undo/mobile: keep track of dive sitesGravatar Berthold Stoeger
When editing the dive site of a dive, the dive-table of the corresponding dive site was not properly updated by the undo commands. Try to get this right. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31undo: autogenerate string get() and data() functions using a templateGravatar Berthold Stoeger
Do this in analogy to other types. However, here we have to convert from / to QString. We could do this in an even more general way by using two templat parameters: one for the Qt type, one for the core type and define conversion functions. However, let's not do this for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31undo: autogenerate trivial set() and data() functions by a templateGravatar Berthold Stoeger
Some dive-editing undo commands have trivial setter and getter functions: they simply read and write a struct dive member. Autogenerate these in a template to which we pass a pointer to member as template argument. For the invalid-flag we have to turn the edit command from int to bool, since that is how the flag is store in the dive struct. Sadly, quite a number of the setters do funky things and we cannot autogenerate them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-31undo: generate fieldId() virtual functions by templatesGravatar Berthold Stoeger
Most edit commands derive from a common base class EditBase, which declares a fieldId() virtual function that has to be defined by the child classes. This is tedious. For some reason the C++ makers refuse to allow "virtual member constants". To make the code somewhat less verbose, create these functions by a template. Of course, we could introduce the template parameter directly in the EditBase class. However, that would mean that the code in this base class is generated for every single undo command. I'm not sure we want that. This should als make it somewhat less tedious to create new edit commands by copy & paste. We could do the same for the fieldName. However, that is more complicated for two reasons: 1) For historic reasons(?) C++ doesn't allow for string literals as template parameters. Therefore, arrays-of-string would have to be defined, which is not very nice. 2) We would have to make sure that these strings are recognized by Qt's translation machinery and use the QT_TRANSLATE_NOOP macro, which makes the whole thing even less attractive. Maybe later. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20Undo: implement invalidate-dive commandGravatar Berthold Stoeger
Connect command to context menu. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-17undo: remove EditNumber commandGravatar Berthold Stoeger
Number editing works via the RenumberDives command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-11Grammar: replaces 'indexes' by 'indices'Gravatar Robert C. Helling
Grammar-nazi ran git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g' to prevent future wincing when reading the source code. Unfortunatly, Qt itself is infected as in QModelIndexList QItemSelection::indexes() const Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-10mobile/undo: create EditDive commandGravatar Berthold Stoeger
Command that just swaps two dives. This is rather complex, as for example a dive site might be created. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04Cleanup: lower-case filenames in core/subsurface-qt/Gravatar Berthold Stoeger
We tend to use lower-case filenames. Let's do it for these files as well. Simple search & replace. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-10code cleanup: remove unused member variableGravatar Dirk Hohndel
It was initialized, but never referenced. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-06core: read and write the user-specified salinityGravatar willemferguson
Both XML and git storage are added. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-05Undo: make weight editing undoableGravatar Berthold Stoeger
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>
2019-12-05Undo: make weight-deletion an undoable actionGravatar Berthold Stoeger
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>
2019-12-05Undo: make adding of weights an undoable actionGravatar Berthold Stoeger
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>
2019-12-03Undo: make profile-editing undoableGravatar Berthold Stoeger
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>
2019-12-03Desktop: add additional star widgets to Information tabGravatar willemferguson
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>
2019-11-14Refactoring: move undo commands to top levelGravatar Berthold Stoeger
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>