aboutsummaryrefslogtreecommitdiffstats
path: root/commands/command_divelist.cpp
AgeCommit message (Collapse)Author
2020-04-26cleanup: remove Command::inCommand()Gravatar Berthold Stoeger
This was used by the divelist to check wether a selection change is programmatical or user-initiated. However, since there is only one entry point for programmatical selection changes, this is not needed anymore. Remove it - this removes an inter-module dependency. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13divelist: when removing/adding a dive unregister/register fulltextGravatar Berthold Stoeger
This fixes a crash: when the undo commands removed a dive from the list, the fulltext cache was not cleared. If now the divelist is reset and then the undo-command deleted, deletion of the owned dive tries to remove it's fulltext cache, which doesn't exist anymore. For reasons of symmetry, when readding the dive, its fulltext has to be registered. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22translations: qualify tr function to get correct contextGravatar Dirk Hohndel
The way inheritance is implemented for the undo commands confuses the Qt translation tooling - with the result that the context assumed by the tools used to extract the strings doesn't match the context calculated at runtime - so all the translations for the strings in undo commands fail (including creating proper numerus forms). This change forces a consistant context tag, at the price of creating a significant delta for the source strings (the strings themselves stay the same, but the context for a lot of them changes). I am hoping that Transifex is smart enough to automagically add the correct translations for these, but I guess I won't know until I try. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-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-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: 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>
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-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-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>