summaryrefslogtreecommitdiffstats
path: root/commands
AgeCommit message (Collapse)Author
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-17filter: update fulltext index when editing diveGravatar Berthold Stoeger
In edit commands, the fulltext might have changed and therefore we have to update the fulltext index. 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-10undo infrastructure: improve undo command textsGravatar Dirk Hohndel
For many of the commands it is fairly easy to add information that makes it easier to figure out what actually happened. That's especially true for commands operating on dives. Trip and dive site edits haven't been given these more elaborate undo texts (yet). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10core: make command texts available for C codeGravatar Dirk Hohndel
Create a C string (which the caller needs to free) with the executed commands in this session. The detour via the callback allows us to not make the corelib depend on the commands, which is nice for tests, export-html, and smtk2ssrf. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10undo infrastructure: collect the texts for the executed commandsGravatar Dirk Hohndel
This creates a single string with all the undo texts that are on the stack. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10build-system: remove pointless distinction between desktop and mobileGravatar Dirk Hohndel
It's the same sources, the same library. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10core/undo: provide access to the QUndoStackGravatar Dirk Hohndel
This is used by the mobile UI to get notifications when the undo text changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-03-09undo: implement ApplyGPSFixes undo commandGravatar Berthold Stoeger
This gets a list of dives with GPS fixes and 1) Adds new dive sites if the dive hasn't a dive site set 2) Edits the location of the dive site Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile/undo: compile undo commands and call undo command for deletion.Gravatar Berthold Stoeger
First steps towards full undo on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07debug: try to capture changes that don't invalidate git cacheGravatar Dirk Hohndel
At least in those cases where we are sending a divesChanged signal we can easily check if the cache was properly invalidated. Of course this won't help in cases where we don't notify the dive list about changes, either. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-06Cleanup: Move stringToList to core/qthelper.cppGravatar Berthold Stoeger
The same code was used in desktop and undo commands. Let's unify. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06Cleanup: use getDiveSelection() for shifting timeGravatar Berthold Stoeger
There are two cases where dive-times are shifted: in an explicit dialog and when editing the date/time of a dive. In each of these cases, the selected dives were collected manually. Instead use the getDiveSelection() function. Since this returns a std::vector, change the argument of Command::ShiftTime() to such a std::vector. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Filter: move actual filtering loop to core/divefilter.cppGravatar Berthold Stoeger
The DiveFilter class defined the showDive() function to test whether a dive should be filtered or not. This was used in DiveTripModel to loop over all dives or all dives affected by an editing action. This restricts us in how we do filtering: We can't use indexes that give us directly the result. To make the filtering more flexible, move the actual loops that do the filtering to the DiveFilter class. The undo-commands likewise called directly the showDive() function to check whether newly added dives are shown. Use the new interface here as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-19undo: don't add dive to null-tripGravatar Berthold Stoeger
In moveDiveToTrip(), the dive was first removed from its old trip and then added to the new trip. This function is also used to remove the dive from its trip (by moving it to the "null-trip" if you whish). Even in that case add_dive_to_trip() was called. The only reason why this didn't crash is that add_dive_to_trip() checks whether old and new trip are the same. This is the case when adding to the "null-trip", since the dive was removed from the trip just before. To cut a long story short, to trust on add_dive_to_trip() not crashing if moving from the null-trip to the null-trip is way to subtly. If we remove a dive from its trip, don't call add_dive_to_trip() in the first place. Reported-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09Cleanup: remove const bool parameters and return typesGravatar Berthold Stoeger
These just make no sense. Since the value is copied, it has no meaning to the caller whether the function can change the value (and vice versa for return types). 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: add empty table structuresGravatar Dirk Hohndel
It seemed to make sense to combine all three types in one commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-10code cleanup: replace use of toStdVector()Gravatar Dirk Hohndel
Frankly, I find the old API easier... Also, replace toList() with values() Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-10code cleanup: replace deprecated fromStdVector() methodGravatar Dirk Hohndel
Replacement was only introduced in Qt 5.14 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-10code cleanup: ensure all fields are initializedGravatar Dirk Hohndel
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>
2020-01-10code cleanup: initialize all elements in structureGravatar Dirk Hohndel
This seems silly. I don't like that warning and would rather disable the warning. 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-07Selection: provide convenience function for single-dive selectionGravatar Berthold Stoeger
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>
2019-12-05Translation: explicitly show no dive-count if only one dive editedGravatar Berthold Stoeger
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>
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-05Cleanup: use free_weightsystem function instead of explicit freeGravatar Berthold Stoeger
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>
2019-12-05Cleanup: introduce empty_weightsystem constantGravatar Berthold Stoeger
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>
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-04Selection: move commands/command_private.* to core/selection.*Gravatar Berthold Stoeger
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>
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-19Filter: split out filter from modelGravatar Berthold Stoeger
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>
2019-11-19Filter: move calculation of shown dives to undo commandGravatar Berthold Stoeger
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>
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>