aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-05-14mobile/models: add access to tags stringGravatar Dirk Hohndel
We already allow filtering by tags, but don't even show them on mobile. That seems rather inconsistent. First step is to make the tags available to the QML layer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14mobile/dive-details: less whitespace at the topGravatar Dirk Hohndel
This always seemed odd - the location looked like it sat 'low' on the screen. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14mobile/dive-details: use our labels to create denser displayGravatar Dirk Hohndel
This makes better use of the screen real estate, without (IMHO) seeming too crowded. This is a tough balance to strike. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14mobile: reduce vertical white space around labelsGravatar Dirk Hohndel
Our labels all seem to have a lot of empty vertical space around them. Try to be a bit more conservative with space. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14mobile: add smaller, vertically dense template labelGravatar Dirk Hohndel
By default single line text has too much white space around it. This smaller, denser label works well to more efficiently use screen real estate, I think. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-12Remove 'string marker after running out of strings' warningGravatar Linus Torvalds
This warning is unnecessarily scary - we had a problem with parsing multiple strings on the same line, but it should be all solved, and while it does mean that people may have old incorrect git save files with empty strings, scaring users about it isn't going to help. And with the warning removed, we can just remove the whole test for an empty string, because the normal code sequence handles that case just fine. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-09add Berthold to the list of explicitly mentioned developersGravatar Dirk Hohndel
Number 3 overall committer with currently 9% of total commits and 27% of all commits in the last three years. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-08desktop: hide/unhide tags if dive site was editedGravatar Berthold Stoeger
The tags of the dive site were shown/hidden when changing the current dive. Thus the following could happen: 1) User changes to dive with no tags. Tags are hidden. 2) User add image, which creates GPS tag 3) Tag is updated but not shown. Fix this by showing/hiding tags when they are calculated not when switching the dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-08media: give newly created dive sites a nameGravatar Berthold Stoeger
When adding a picture with GPS information, a dive site was added if the dive didn't have any. The dive site had the empty string as name, leading to a confusing UI experience. We could catch the empty string at numerous places and replace it by some dummy string. This commit goes the distinctly less invasive route and adds the dive site with the "unnamed dive site" string (translated to the user language) as name. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07Update to latest libdivecomputerGravatar Dirk Hohndel
This switches us to the DS9 branch. Yeah, that's what came after Next Generation. Anyway, this is a clean rebase on top of current upstream libdivecomputer master, which makes for a much cleaner history. Also merges updatream updates from Jef Driesen: - work around Pelagic BLE oddity (Oceanic Pro Plus X and Aqualung i770R) - OSTC3 firmware update improvements Use a more robust command to write flash memory Read and cache the firmware version information Add an extra delay after writing to the flash memory Add an extra delay after erasing a flash memory page Send the service init command one byte at a time Fix some typos in the comments Ignore excess bytes in the BLE version packet Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07cleanup: free tab-widgets when exiting the applicationGravatar Berthold Stoeger
This is completely irrelevant, however out of principle, let's free the tab-widgets at the end of the application. To do so, use Qt's object hierarchy. I'm not a fan of this kind of memory management, but it is how it is. Moreover, remove the explicit constructor of MainTab, since it doesn't differ from the default constructor anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>