aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-05-07cleanup: remove clearing of displayed_dive in MainTab constructorGravatar Berthold Stoeger
Clearing displayed_dive here makes no sense for two reasons: 1) This is only called on startup, when displayed_dive is not yet initialized. 2) The tab-widgets don't use displayed_dive anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07desktop: use current_dive to save subtitlesGravatar Berthold Stoeger
The old code used displayed_dive. However, virtually all the displayed data is now derived from current_dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07desktop: use current_dive instead of displayed_dive on equipment tabGravatar Berthold Stoeger
Since the displayed data is extracted from current_dive it makes no sense to query displayed_dive for the dive mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07desktop: update tab info only if current_dive is setGravatar Berthold Stoeger
If current_dive was not set, the code would clear the tabs right after updating the data. We might just as well set the data only if current_dive is set. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07statistics tab: use current_dive to decide whether user is freedivingGravatar Berthold Stoeger
This used the displayed_dive object. However, we now use current_dive to designate the currently displayed dive. Thus, use this instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07DiveComponentSelection: use current_dive instead of displayed_diveGravatar Berthold Stoeger
This should have been converted a long time ago. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07cleanup: generalize ExtraDataModel to display data of any dcGravatar Berthold Stoeger
The goal here is to remove a dependency on displayed_dive. While doing so, make the model more general and display any dc. Pass in the dc of the current dive instead of displayed dive, since all other tabs are already converted to show data of the current dive. The QStrings are cached since we generate them anyway, so we may just keep them. Thus, there is no danger of the dc becoming invalid. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07cleanup: return directly in ExtraDataModel::data()Gravatar Berthold Stoeger
Instead of assigning to a ret variable and returning at the end of the function, return directly from the various switch branches. This is more idiomatic and consistent with the other models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07cleanup: use begin/endResetModel in ExtraDataModelGravatar Berthold Stoeger
As we do in most other models, use begin/endResetModel() to reset the model. This is distinctly less errorprone than the add/removeRows() version as we don't have to check for empty ranges, etc. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07desktop: don't update models in MainWindow::refreshDisplay()Gravatar Berthold Stoeger
The models should now properly reset themselves if data in the core changes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07cleanup: invert control-flow when resetting the core structuresGravatar Berthold Stoeger
To reset the core data structures, the mobile and desktop UIs were calling into the dive-list models, which then reset the core data structures, themselves and the unrelated locationinformation model. The UI code then reset various other things, such as the TankInformation model or the map. . This was unsatisfying from a control-flow perspective, as the models should display the core data, not act on it. Moreover, this meant lots of intricate intermodule-dependencies. Thus, straighten up the control flow: give the C core the possibility to send a "all data reset" event. And do that in those functions that reset the core data structures. Let each module react to this event by itself. This removes inter-module dependencies. For example, the MainWindow now doesn't have to reset the TankInfoModel or the MapWidget. Then, to reset the core data structures, let the UI code simply directly call the respective core functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06profile: clear pictures when displaying empty diveGravatar Berthold Stoeger
Since the profile does not listen to DivePictureModel resets anymore, the pictures weren't cleared when clearing the canvas. Do this explicitly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06dive list: update dive list entry if pictures changedGravatar Berthold Stoeger
We show an icon whether there are pictures and whether they are before or after the dive. Thus, the list models must emit the proper signals when the pictures of a dive change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06undo: make adding of pictures undoableGravatar Berthold Stoeger
This one is a bit hairy, because two things might happen if the picture has a geo location: - A dive gets a newly generated dive site set. - The dive site of a dive is edited. Therefore the undo command has to store keep track of that. Oh my. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06core: move picture-related function from dive.c to picture.cGravatar Berthold Stoeger
Move the two functions create_picture() and picture_check_valid_time() from dive.c to picture.c. This might be somewhat questionable, as these functions are not purely picture related, but check the nearest selected dives, etc. However, dive.c is so huge, that slimming it down can't hurt. Moreover, getting the nearest selected dive is more divelist- than dive functionality anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: move addition of pictures out of create_picture()Gravatar Berthold Stoeger
If we want to make addition of pictures undoable, then create_picture() must not add directly to the dive. Instead, return the dive to which the picture should be added and let the caller perform the addition. This means that the picture-test has to be adapted. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06core: remove new_picture_for_dive() function in dive.cGravatar Berthold Stoeger
We can do the same with get_picture_idx(). Yes, it is a bit more unwieldy. However a full reimplementation seems not worth it. We could make this a one-liner helper function though. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06undo: make picture (media) deletion undoableGravatar Berthold Stoeger
The code is rather complex. Firstly, we have different representations of pictures throughout the code. Secondly, this tries to do add the pictures in batches to the divepicture model and that is always rather tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: turn DivePictureModel::pictures into std::vectorGravatar Berthold Stoeger
QVector doesn't have a function to insert a range of pictures, which we will need for undo of image adding/deletion. Moreover, std::vector gives us stronger guarantees. For example, if capacity is large enough, it guarantees that there will be no reallocation and thus iterators stay valid. I have not found such a guarantee in the Qt docs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: add small C++ helper describing a picture structGravatar Berthold Stoeger
By using a std::string instead of a C-string, memory management becomes so much simpler! This class will be used for keeping track of deleted/added pictures in the undo system. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06Cleanup: remove DivePictureThumbnailThreadGravatar Berthold Stoeger
An empty class that was not used anywhere. This allows us to remove a few include files as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: remove unused local variableGravatar Berthold Stoeger
TabDivePhotos::saveSubtitles() had an unused local variable. Clearly a copy&paste oversight. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: put photo-view in row-selection modeGravatar Berthold Stoeger
It makes no sense to have the view in item-selection mode, since each picture represents a row. Thus we can remove a few lines of code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: store dive instead of dive-id in DivePictureModelGravatar Berthold Stoeger
dive-pointers are stable and the dive picture model is reset if a selected dive is removed, so there is no risk in keeping pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: don't send dive-id in drag&drop eventGravatar Berthold Stoeger
The profile-widget doesn't use that information anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06undo: implement undo of setting a picture time by drag&dropGravatar Berthold Stoeger
Even though the functionality is seemingly trivial, this is a bit invasive, as the code has to be split into two distinct parts: 1) Post undo command 2) React to changes to the divelist Don't compile that code on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: create sort_picture_table function via macroGravatar Berthold Stoeger
This needs a slight change to the macro, because here we sort by value type. Yes, from a C-programming point of view this is horrible, however a decent compiler should just inline everything and not pass around value types. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06core: add get_picture_idx() functionGravatar Berthold Stoeger
A function that gets the index of a picture in a picture table given its filename. Since we are going to identify pictures by their filename, we will need this function in the undo code. Use the function in the remove_picture() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06cleanup: don't call updateDivePictures in MainWindowGravatar Berthold Stoeger
That is already properly done by the photo-tabwidget, which displays the pictures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: use table instead of linked list for mediaGravatar Berthold Stoeger
For consistency with equipment, use our table macros for pictures. Generally tables (arrays) are preferred over linked lists, because they allow random access. This is mostly copy & paste of the equipment code. Sadly, our table macros are quite messy and need some revamping. Therefore, the resulting code is likewise somewhat messy. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06core: make picture.h compatible with C++Gravatar Berthold Stoeger
The "extern C {" guards were missing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06cleanup: move copy_cylinders from dive.c to equipment.cGravatar Berthold Stoeger
Since this doesn't touch struct dive, dive.c is not an appropriate place for this function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06cleanup: make remove_from_*_table equipment functions staticGravatar Berthold Stoeger
These functions were not used outside their translation unit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06pictures: turn QString into std::string for filenamesGravatar Berthold Stoeger
For undo of picture manipulation, it will be crucial that the model and the core have the same order of pictures. The first sort criterion will be time, the second filename in the case that two pictures have, for whatever reason, the same timestamp. However in the core we us C-strings and thus sort byte-wise using strcmp. In the Qt-part we use QStrings, which sort according to unicode encoding. To enable consistent sorting, change the Qt-part to std::string, which uses a C-style 0-terminated string as its backing store. One might argue that in general filenames should use system-encoding and therefore use std::string instead of QString. However, a broader conversion to std::string turned out to be very painful, since Qt is (deliberately?) difficult to use with std::string. Notable all the file-manipulation functions don't take std::string by default. Thus, this commit only converts the internal data of DivePictureModel, but continues to use QString for the Qt-facing interface. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06desktop: avoid spurious undo commands for date/time editingGravatar Berthold Stoeger
The date and time fields of the main tab posted undo events for every date/timeChanged signal. Thus, when changing the day of the month to e.g. 21, this would result in two date change events: one to the 2nd and one to the 21st. This is very irritating. Instead listen to editingFinished() events, which thankfully exist for these widgets. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06desktop: update statistics tab when cylinders changedGravatar Berthold Stoeger
The cylinder-based statistics where not updated when an undo command edited cylinder data. Do so. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06desktop: update information tab when cylinders changeGravatar Berthold Stoeger
The SAC rate, etc were only updated when switching between dives. They should always be updated when an undo command changes (adds, edits, removes) the cylinders of a dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06models: emit dive changed signal when cylinders editedGravatar Berthold Stoeger
To display changed SAC values it is necessary that the models emit changed signals when cylinders are edited. An alternative might be that the undo commands emit dive-changed signals themselves. Fixes #2814. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06undo: update cylinder related info when editing cylinder dataGravatar Berthold Stoeger
We have to call update_cylinder_related_info() when adding / editing / removing cylinders. This could be done in a common base class of the commands. For simplicity, let's call the function in the respective undo()/redo() functions. Partially fixes #2814. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-05documentation: remove two remaining references to the surveyGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05documentation: revert switch to asciidoctorGravatar Dirk Hohndel
While this worked well on Mac, it creates odd errors on Linux. This doesn't seem worth spending too much effort on - so let's just go back to asciidoc. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05documentation: fix makefileGravatar Dirk Hohndel
This one was my fault, not Willems (since I edited his commit). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-05documentation/mobile-manual: create a merged v3 manualGravatar Willem Ferguson
Unintentionally two versions of the mobile manual were created. This brings all of Willem's changes into the version for Subsurface-mobile v3, and restores the last version of the v2 mobile manual. This commit was manually created from a pull request that was signed off by Willem, given that he wrote most of the text I am copying that SOB into this commit and will assign authorship to him. To avoid further confusion, we now have a v2 and a v3 manual, explicitly named. The corresponding .html.git files were also updated (reflecting our switch to asciidoctor). Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-06cleanup: move the inertgas enum from qthelper.hpp to deco.cGravatar Berthold Stoeger
There are no outside users. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06planner: remove Bühlmann factor cacheGravatar Berthold Stoeger
The Bühlmann factors were cached in a thread-safe hashmap. It seemed somewhat dubious that entering a critical section and doing a hash-lookup would be significantly faster than a simple exp() call. Indeed, in a very cache friendly test (16 entries, tight loop) calling the factor() function 32 000 000 times from a different translation units we get: - with cache: 604 ms - without cache: 266 ms Therefore, remove the cache. Given that 32 000 000 calls take only 266 ms, it appears not sensible to try to optimize this function anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-05cleanup: capitalize use dcGravatar Monty Taylor
It was suggested in a review of a previous patchset that we should capitalize the use of "use dc" to "Use DC" - but if we were going to do that we should do it everywhere, not just in the one place. This is the followup to do that. Signed-off-by: Monty Taylor <mordred@inaugust.com>
2020-05-05Changelog for variations checkboxGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-05Explanatory comment in testprofile.cppGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-05cleanup: Change Salty to BrackishGravatar Monty Taylor
In the code, the difference between SALTYWATER and SALTWATER is hard to see. More importantly, in the UI - Brackish is the word for water that has more salt that freshwater but less salt that seawater. The docs already use the word to clarify what is meant.
2020-05-05Grantlee: Add salinity and water type to grantlee variablesGravatar Monty Taylor
These can be useful in a printed divelog, especially if the log entry is also showing weight and exposure suit. Signed-off-by: Monty Taylor <mordred@inaugust.com>