aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2019-04-15make sure to clear dives on dive split failureGravatar Linus Torvalds
The dive splitting code returns an error code when splitting fails, but it turns out that the C++ UI code doesn't actually look at the error code, and instead expected the resulting dives to be NULL if an error happened and the split didn't succeed for whatever reason. Which is kind of lazy of it, but we might as well clear the resulting dives and make the UI code happy. This should fix the problem that Celia Marlowe reported on the Subsurface google groups forum. Reported-by: Celia Marlowe Acked-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Fixes: 145f70aab5 ("Undo: implement split-out of dive computer") Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-15FTDI support: ignore case when comparing magic device nameGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-15Cleanup: remove completers from MainTab objectGravatar Berthold Stoeger
This struct is used to store the completers during construction of the object. But it is never accessed afterwards. Therefore, remove it from the object and remove the structure definition from the header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15Cleanup: Move dive-equipment tab into own translation unitsGravatar Berthold Stoeger
Most tabs in the dive-information widget have there own translation units and ui-files. Only the equipment tab was married with the main tab. Move it out to get more reasonably sized translation units and some isolation. Currently, this needs ugly hacks when entering / checking for edit mode: Access to MainTab is via the MainWindow. And vice/versa, when accessing the DiveEquipmentTab from the MainTab, the former is hardcoded as the first item of an array. These hacks will soon be removed though, when making equipment editing undoable. The tabs will then be independent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15Cleanup: Remove MainTab::getEditMode() functionGravatar Berthold Stoeger
The only caller of said function used to check whether MainTab is in edit mode. For this case there is already a function - use that instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15Core: turn add_single_dive() to append_dive()Gravatar Berthold Stoeger
The only external caller of add_single_dive() used it to append a dive to the global dive list. Rename the function accordingly and remove the index parameter. The internal caller can use the local insert_dive() function, which doesn't consider selection. That shouldn't be a problem, as the caller is doing import. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15Undo: don't store insertion index in undo commandGravatar Berthold Stoeger
When adding dives in an undo command, the index is saved in the command. This seemed logical at first, because why calculate the index more than once? But actually it made the code rather subtle and brittle when multiple dives were added. Moreover, this is a pointless optimization, as it doesn't optimize the common case (only one execution). Remove this for now and calculate the index on every execution. If it ever turns out to be a bottle neck, it will be much more effective to turn the linear search of the index into a binary search. A further sensible optimization would be inserting in batches. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-15Cleanup: free dive table in trips and dive sitesGravatar Berthold Stoeger
Trips and dive sites were changed to use dive tables instead of linked lists. But the memory used for the tables wasn't freed. Do this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-13Update CHANGELOGGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-04-14Desktop: remove edit-check in tag-widget completerGravatar Berthold Stoeger
The tag-widget was only showing the completer if we were in edit mode. The edit mode does not exist anymore - therefore remove the check. Hopefully this has no unintended consequences, like the completer not disappearing when it should. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-13Add export option to export dive sites.Gravatar Doug Junkins
Selecting "Selected dives" exports the dive sites for the selected dives. Selecting "All dives" exports all dive sites. XML format is the subsection of the divelog XML that describes the sites headed with a <divesites> section like: <divesites program='subsurface' version='3'> </divesites> Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-04-14Desktop: destroy maintab before destructing mainwindowGravatar Berthold Stoeger
Apparently, in some Qt-versions the destructor of the base class calls hide on child-objects (according to Qt's object hierarchy). This is obviously called after the derived class has been destructed. In a concrete case, the base class of the destructed MainWindow would hide the TabDiveSite object. That would reset the filtering if a dive site was selected, which would indirectly access the MainWindow, which is already partially destroyed. Therefore, destroy the MainTab before destroying the MainWindow. Do this by keeping it as a std::unique_ptr subobject. Thus, it will be destroyed before the MainWindow and remove itself from Qt's object hierarchy. Reported-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-13Desktop: put dive site table in "row selection mode"Gravatar Berthold Stoeger
This feels more natural than selecting a single cell. Still, the "delete" cell is not visibly selected, which give a strange impression. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-13Desktop: update dive site list on file-closeGravatar Berthold Stoeger
The model was not reset on file close, leading to weird effects. New dive sites would be added at the end of a table full of empty entries. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-13Dive sites: dont't disable all tabs when creating new dive siteGravatar Berthold Stoeger
The dive tabs are disabled, when no dive is shown. The dive site tab is implemented as a dive tab, which is of course conceptually wrong. Moreover it has the nasty side effect that when adding an empty dive site, no dives are shown and the tab is disabled, leading to a UI dead lock. Therefore, disable all tabs but the dive site tab. The proper fix will be a refactoring of the UI. Reported-by: Doug Junkins <junkins@foghead.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: show dives at selected dive sitesGravatar Berthold Stoeger
When in dive site tab and some dive sites are selected, show only dives at those sites. Simply read the selection and pass it to the filter. Start and stop filtering when switching to and from the tab, respectively. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Filter: allow filtering multiple dive sitesGravatar Berthold Stoeger
In the edit-dive-site tab the filter is switched to a particular mode where only dives at that site are shown. If we want to reuse this for the dive-site tab the mode has to be extended to allow for multiple dive sites. This is trivially done by replacing a pointer by a vector of pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Filter: call update title directly in filter modelGravatar Berthold Stoeger
Instead of sending a signal when counts change, catching them in the filter widget and update the window title there, directly update the window title in the model. This removes a signal/slot pair. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: fix merging testsGravatar Berthold Stoeger
The handling of dive site merging changed and therefore the tests have to be adapted. 1) Dive sites are recognized as identical based on their name. Therefore, give the dive sites that should be merged the same name. 2) The dive site id of the first imported dive is kept. Thus, merge and reverse merge produce two different output files. Create a second file reflecting that fact. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: make UUID generation deterministicGravatar Berthold Stoeger
Instead of using a random UUID, use an SHA1 hash of name, description and notes (if defined). This is necessary for testing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: replace QString("") by QString()Gravatar Berthold Stoeger
That should be more effective. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Map: reload map when editing dive site of a diveGravatar Berthold Stoeger
Editing the dive site of a dive may make a dive site appear (first dive of that site) or disappear (the last dive of that site was removed). Therefore, we have to reload the dive site markers on editing the site of a dive. This should be made smarter by only reloading the markers if the dive site status actually changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove redundant checks for null dive siteGravatar Berthold Stoeger
The dive_site_has_gps_location() function already checks for the null dive site. Remove redundant checks. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Map: Use proper location for flag when editing dive siteGravatar Berthold Stoeger
When the dive site was not on the map because it had no dives, entering dive site edit mode would place the map at the center of the map, not at the location of the dive site. Use the location of the dive site unless it has no location. In that case use the map center. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: on save remove focus from active fieldsGravatar Berthold Stoeger
The editing of a dive field is only performed when focus is removed from the field. On pressing CTRL-s, the changes in the currently active field were therefore not saved. Remove the focus from all fields to trigger an edit command yand thus ensure that all changes are saved. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Remove check for whether a site is used before saving it.Gravatar Doug Junkins
Signed-off-by: Doug Junkins <junkins@foghead.com>
2019-04-12Undo: use QUndoStack::isClean() to determine unsaved changesGravatar Berthold Stoeger
Properly implement the unsaved-changes flag(s). Since we currently have two kinds of changes, there are two flags: 1) dive_list_changed in divelist.c marks non-undoable changes. This flag is only cleared on save or load. 2) QUndoStack::isClean() is used to determine the state of undoable changes. Every time the user returns to the state where they saved, this flag is cleared. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Desktop: read tab-items from current_dive, not displayed_diveGravatar Berthold Stoeger
The whole edit logic moved from displayed_dive to current_dive and it became more and more tedious to keep these in sync. Therefore, simply always display current_dive. The only exceptions are the equipment tab and the planner, as these are not yet integrated in the undo system. Once this is done, displayed_dive can be removed. Moreover, remove the clear parameter from updateDiveInfo(). Instead simply clear of there is no current_dive set. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: inform maintab if dive site changedGravatar Berthold Stoeger
If a dive site was edited, the location field should be updated. Do this by hooking into the diveSiteChanged signal of DiveListNotifier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: remove ADD mode from main tabGravatar Berthold Stoeger
Instead of letting the user edit the fields before adding a dive, simply add an empty dive. Thus, the ADD mode of the main tab can be removed. Constructing a new dive with default-depth and making sure that the dive is displayed correctly is very subtle. This all needs to be detangled in due course. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add proximity field to dive site listGravatar Berthold Stoeger
Merging dive sites is currently only possible if dive sites are at the exact same position. Introduce a field where the user can enter a distance up to which all dive sites should be listed. These can then be merged. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: add fulltext filterGravatar Berthold Stoeger
In the dive site tab, add a fulltext filter. The UI is only a mock up. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: update filter flag when dives changeGravatar Berthold Stoeger
The filter code is strange: it actually only checks the dive->hidden_by_filter flag. Thus, before propagating the dive changed signal, this flag has to be updated. Do this in the DiveTripModel. Ultimately, this should be refactored. Moreover, if the filter-flag changed notify the frontend of a changed trip so that the trip is hidden / unhidden. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: update dive list if trip changedGravatar Berthold Stoeger
In tree-mode, the trip locations are displayed. Update the corresponding entries if the trip changed, by hooking into the tripChanged() signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: switch to edited tripGravatar Berthold Stoeger
If fields in a trip are edited, select that trip, which will display the trip in the notes-box. This is realized by hooking into the tripChanged signal in the dive-list. A layering-violation, perhaps? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: move temperature update from MainTab to EditWaterTempGravatar Berthold Stoeger
The code in maintab is not called anymore (unless cylinders or weightsystems are changed). Move the code to the command that edits water temperature. This should be audited as it is unclear weather this is necessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove field-coloring code in MainTabGravatar Berthold Stoeger
Since all fields on the maintab are now directly edited, there is no point in marking fields as changed. Remove unused functions MainTab::markChangedWidget() and MainTab::resetPalette(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive trip editingGravatar Berthold Stoeger
This is copying the dive editing code. It uses an OO design with virtual functions for getting and setting the values. It doesn't use templates though, as both fields of strig type. This feels a bit over-engineered, but it is 1) consistent with the dive edit code and 2) the number / types of dive trip fields might increase. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: update cylinder and weight models on pasteGravatar Berthold Stoeger
When pasting (or undoing paste) the cylinders or weights may change. Send the appropriate signals and update the models accordingly. Currently, this means copying from current dive to displayed dive, but hopefully we can get rid of "displayed_dive" in the not so distant future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Coding style: remove Java-style function definitionGravatar Berthold Stoeger
Remove a few cases of void fun() { ... } While touching these functions, fix a few other whitespace coding style violations. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-12Core: introduce taglist_copy() functionGravatar Berthold Stoeger
Taglists were only copied in dive.c using the STRUCTURED_LIST_COPY macro. Export that functionality in a function. This will be needed for undo of dive-pasting. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: remove MainTab::*TaggedStrings() functionsGravatar Berthold Stoeger
Moving the tagged-string edit functions into the undo-system made the MainTab::saveTaggedStrings() and MainTab::diffTaggedStrings() functions unnecessary. 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 selection function into command_private.cpp fileGravatar Berthold Stoeger
Undo of editing should probably also restore the old selection and current dive. Therefore, move the functions that set and restore the selection and the current dive from the command_divelist.cpp into the command_private.cpp translation unit. 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: update dive list after edit commandGravatar Berthold Stoeger
The dive list was not updated automatically when an edit command was executed. There was already a signal to do that, viz. divesChanged(). But that signal worked by-trip and didn't have a dive-field specifier. The edit-commands used the divesEdited() signal that isn't by-trip but has a dive-field specifier. Unify these two signals to be by-trip and with dive-field specifier. This needs common code to generate the by-trip list that is moved to a command_private.h header. Since there might now be multiple signals (one per trip) actually check in the main-tab whether the current trip is affected to avoid multiple update of fields. This has the positive(?) effect of not doing any update if the current dive isn't changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove MainTab::acceptingEditGravatar Berthold Stoeger
The acceptingEdit field was used to ignore edit-signals in MainTab::acceptEdit(). But an equivalent mechanism already exists: setting editMode to IGNORE. For consistency, replace the former by the latter. acceptEdit() resets the editMode in all cases anyway. 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>