aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_edit.h
AgeCommit message (Collapse)Author
2019-11-14Undo: don't delete dive sites when pasting divesGravatar Berthold Stoeger
We used to only keep sites with dives around. This changed when implementing the dive site tab. The paste-dive code was written using the old semantics and thus, when overwriting dive sites, it deleted unused dive sites. To make things consistent, remove that code. It would be very weird when dive sites are deleted by pasting, but not by setting a different dive site manually. Bonus: no more dependencies on desktop-includes in the undo code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Core: remove MAX_CYLINDERS restrictionGravatar Berthold Stoeger
Instead of using fixed size arrays, use a new cylinder_table structure. The code copies the weightsystem code, but is significantly more complex because cylinders are such an integral part of the core. Two functions to access the cylinders were added: get_cylinder() and get_or_create_cylinder() The former does a simple array access and supposes that the cylinder exists. The latter is used by the parser(s) and if a cylinder with the given id does not exist, cylinders up to that id are generated. One point will make C programmers cringe: the cylinder structure is passed by value. This is due to the way the table-macros work. A refactoring of the table macros is planned. It has to be noted that the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit architecture, so passing on the stack is probably not even significantly slower than passing as reference. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Undo: Make PasteState cylinders list dynamically allocatedGravatar Berthold Stoeger
Instead of using a sub-array, use a std::vector<>. This is a necessary step in removing the MAX_CYLINDERS restriction. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-10-26Undo: implement ReplanDive commandGravatar Berthold Stoeger
Implement an undo command that overwrites the dive-computers and cylinders of the current dive with a given dive. This will be used when replanning a dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-19Undo: make editing of dive number undoableGravatar Berthold Stoeger
When pressing F2 in the dive list, the number can be edited. Make this action undoable by implementing a EditNumber command. This command is differs from the other undo commands, as not the currently selected dives are changed. This means that the EditCommand needs an alternative constructor taking a single dive. This constructor was implemented in the base class so that all edit commands can now be called with a single dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-18Core: dynamically resize weight tableGravatar Berthold Stoeger
Replace the fixed-size weightsystem table by a dynamically relocated table. Reuse the table-macros used in other parts of the code. The table stores weightsystem entries, not pointers to weightsystems. Thus, ownership of the description string is taken when adding a weightsystem. An extra function adds a cloned weightsystem at the end of the table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-06-15Undo: return number of changed dives from undo commandsGravatar Berthold Stoeger
To enable a "multiple dives edited" message, return the number of edited dives from dive edit undo commands. Since there are two kinds of these commands, viz. normal fields and tag fields, and the former use templates, create a common base class that can return the number of dives. Yes, the class hierarchy is getting scarily deep! At least, this gives a tiny bit of code-reuse. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-15Convert the atmospheric pressure in the Information Tab to an editable fieldGravatar willemferguson
The Information tab shows the atmospheric pressure. Make this value editable and also ensure that changes to it are undo-able. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2019-04-12Cleanup: remove EDIT_TEXT and EDIT_VALUE macros in maintab.cppGravatar Berthold Stoeger
These functions are now performed by the edit commands and the macros have no users. Remove them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: select dives on undo of editing commandsGravatar Berthold Stoeger
Save selected dives when generating an edit-command. Restore the selection and current dive in undo()/redo(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: move dive-list logic into edit commandsGravatar Berthold Stoeger
The edit-commands were called with a list of selected dives and the original value. Move the creation of the list and extraction of the original value into the edit-commmands. This removes the "current is last" rule and allows for more flexibility. Since the depth- and duration editing applies only to the current dive and not all selected dives, add a parameter to the edit-commands controlling whether only the current or all selected dives are edited. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of depth and duration editingGravatar Berthold Stoeger
This was a bit different from the other editing commands: 1) Only the current dive is edited not all selected dives. Therefore, create a function that turns the current dive into a one-element list. 2) The profile has to be replot. Here, likewise, create a function to do that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of divemaster editingGravatar Berthold Stoeger
This is mostly a trivial copy of the buddies code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of buddy editingGravatar Berthold Stoeger
This was mostly trivial by reusing the code for tag-editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of tag editingGravatar Berthold Stoeger
The code follows the other edit-commands, but uses its own base class, because it is distinctly different. Editing the tag field does not simply mean setting the tag for all dives, but rather adding and removing individual tags. This class will be reused for editing of dive buddies and masters. Modify the tag widget thus that it sends an editingFinished() signal when it goes out of focus. The editingFinished() signal was prevented by hooking into the return, enter and tab key-events. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site editingGravatar Berthold Stoeger
This one is a bit more tricky. There are two modes: set dive site and set newly created dive site. This is realized using an OO model with derived classed. Quite convoluted - but it seems to work. Moreover, editing a dive site is not simply setting a value, but the list of dives in a dive site has to be kept up to date. Finally, we have to inform the dive site list of the changed number of dives. Therefore add a new signal diveSiteDivesChanged. To send only one signal per dive site, hook into the undo() and redo() functions and call the functions of the base class there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of air and water temperature editingGravatar Berthold Stoeger
Mostly trivial. Since now on editing the field is re-set, the validation function becomes unnecessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of rating and visibility ratingGravatar Berthold Stoeger
This was rather trivial and modeled after the previous edit UndoCommands. Since this is the first time we're editing integers a new constructor instantiation had to be added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of suit editingGravatar Berthold Stoeger
This one was trivially modelled after notes editing. Only difference: the textChanged() signal was replaced by the editingFinished() signal so that we're not generating undo-commands on every key-press. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive mode editingGravatar Berthold Stoeger
Add a new UndoCommand for dive mode editing. This one is a bit special, as the mode is associated with a dive computer (DC), not a dive. Thus the edit command has an additional parameter, viz. the index of the DC. This does not fit properly to the EditBase class, as this class isn't aware of additional parameters and therefore this parameter is not sent via signals. At the moment this doesn't matter. In any case, the semantics of editing are weird and therefore let's do the simple thing (derive from EditBase) and let's see what the future brings. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: update notes field if changed by undo commandsGravatar Berthold Stoeger
To keep the UI in a consistent state, update the notes field if it is changed by an undo command. To that purpose, add a new signal to diveListNotifier with a list of dives and a field-id as payload. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement rudimentary undo of dive-notes editingGravatar Berthold Stoeger
Implement a first rudimentary dive-editing command. The main code resides in a base class Command::Edit, which calls virtual functions to read / set the fields and extract the field name. Implement an example: editing of dive notes. This dose not yet update the UI on undo / redo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>