summaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2020-05-29cleanup: make local functions of static linkageGravatar Berthold Stoeger
A few functions in save-html.c were local but not marked as static. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-26Print correct template name on CSV exportGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-05-22cleanup: constify time_during_dive_with_offset() functionGravatar Berthold Stoeger
There is no reason to pass a non-const dive pointer as first argument. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: remove unused function get_dive_n_near()Gravatar Berthold Stoeger
The last caller was removed in 7eb422d98837b3cfb289a66fa0f3a8f78f222001. Since this is the only caller of dive_within_time_range(), remove that function as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: create common QDateTime -> timestamp conversion functionGravatar Berthold Stoeger
In analogy to the timestamp -> QDateTime conversion, create a common function. 1) For symmetry with the opposite conversion. 2) To remove numerous inconsistencies. 3) To remove use of the deprecated QDateTime::toTime_t() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: remove unused libc-structures from get_trip_date_string()Gravatar Berthold Stoeger
This must be an artifact from before using Qt's datetime functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: move timestampToDateTime() to qthelper.cppGravatar Berthold Stoeger
Move this function from maintab.cpp to qthelper.cpp. Since the functionality was used in numerous places, use the helper function there as well. This removes a number of inconsistencies. For example, sometime setTimeSpec(Qt::UTC) was called, even though the QDateTime object was already created with that time spec. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22Fix incorrect Farenheit to Kelvin formula.Gravatar Paul Buxton
Use defined function instead. Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
2020-05-22cleanup: set long and short date formats in independent branchesGravatar Berthold Stoeger
The short and long date formats where initialized in a common if-branch. However, inside the if-branch the code rechecked which of the two should be initialized. This could make sense if there was some common code between the two, but there wasn't. Therefore, make this two independent branches to avoid one nesting-level. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-17BLE: trivial updates to the GATT services listsGravatar Linus Torvalds
Add a couple of known services (Scubapro G2 and Shearwater), and update the names of others that turn out to be used for multiple dive computers. Also add another Broadcom upgrade service UUID. While at it, sort the services numerically to make it easier to see that a UUID already exists, since these service numbers do get used across multiple different devices. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-17BLE: add list of known good/bad BLE GATT servicesGravatar Linus Torvalds
We've tried to do this "automagic" service discovery, and it mostly works, but then occasionally it doesn't. Making things worse, I think different platforms end up enumerating services differently, so our "pick the first service that looks like it might be a serial service" ends up working on some platforms, but not necessarily on others. Because "first" might be different. So start a list of known good/bad services - and fall back to the old logic when you can't decide reliably. This fills in juat a few cases that I can easily check myself, and the "details" field for them may be incomplete. For example, I know Nordic Semiconductor has their vendor-specific UUIDs, and they can be found in different devices, so calling them "Nordic UART" and "Nordic Flash" services makes sense. But the "Scubapro i770R" service? It might indeed be specific to the Scubapro i770R. Or it might be a general service UUID that Pelagic uses. Or it might be the service UUID of a particular chip, and found in dive computers from other designs too (and not necessarily in all i770R's either). So this is a preliminary first stab at this, and I'm sure we'll extend the list and possibly improve on the explanations. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-16filter: properly search for tagsGravatar Berthold Stoeger
The old code used get_taglist_string() and split the resulting string at commas to get the list of tags. This was wrong for two reasons: 1) It was buggy. Every tag but the first would start with a leading space and thus not be found. 2) It was inefficient. The tag list was concatenated, just to be split again. Turn the tag list directly into a QStringList and remove whitespace for good measure. Fixes #2842. Reported-by: Hartley Horwitz <hhrwtz@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-16filter: include tags in fulltext searchGravatar Berthold Stoeger
The tags have been forgotten when implementing the fulltext search. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-15core/bt: ensure that BT/BLE addresses with name sort firstGravatar Dirk Hohndel
We don't order the list of addresses alphabetically, but we want to ensure that devices that offer us a name are listed before those that don't. This should only be relevant if the user selects the option to show all BT/BLE devices, not just recognized dive computer, because if we recognize a computer we always have the product name prepended to the address. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-15core/bt: always add bt name for devicesGravatar Dirk Hohndel
If the user asks to have all BT/BLE devices shown, we should behave consistently to the case of a recognized dive computer and always show the device name. In almost all cases the BT/BLE address (and even worse on iOS/macOS the weird uuids) are completely meaningless. If there isn't a name, don't add a leading space in order to make it easy to detect if we have an address without a name (which almost certainly isn't a dive computer, so it should be towards the end of the list of addresses - which will be handled in a later commit). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-15core/bt: match DC descriptor in lower caseGravatar Dirk Hohndel
This fixes a rather subtle bug. In btdiscovery.cpp we are detecting dive computers based on their BT name and are setting up product+vendor as the key for that lookup. QMap always uses case sensitive comparisons and a tiny inconsistency snuck into our code. libdivecomputer names for the Aqualung dive computers i200C / i300C / i550C end in an upper case C (as matches the official branding), but in btdiscovery.cpp we have those names with lower case c. And therefore didn't recognize these dive computers. Obviously this is easy to fix by fixing those three strings, but I decided that it was silly to set ourselves up for similar oversights in the future. So instead I switched the matching of the descriptor to simply be allways all lower case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14Save SAC, OTU and CNS in the XML exportGravatar Linus Torvalds
We do _not_ read them back, since they are calculated values, although I guess we could aim to do that too at some point in case we have an import from somewhere else that has these values but not the profile (or gas use) to actually calculate them. Fix test-cases that are checked by TestParse (but nothing else) to match. Requested-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.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-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-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: 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-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-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-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-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>
2020-05-03selection: create global single_selected_trip() functionGravatar Berthold Stoeger
The DiveListView had a singleSelectedTrip function that returns the selected trip if exactly one trip is selected. This could be very slow if numerous non-trip items were selected, because all the selection indices were back- translated by the proxy model. This could make selection changes very slow, because the MainTab used said function to determine whether it should show trip or dive data.. Indeed, with a 3500 dive test log, when selecting all dives in tree mode, the updating of the TabWidgets is sped up from 130 ms to 5 ms this commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03selection: introduce clear_selection() functionGravatar Berthold Stoeger
The DiveListView would touch the selection-innards directly. Let's encapsulate that. Moreover, take care to reset the trip selection when resetting the core data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03selection: add selection flag for tripsGravatar Berthold Stoeger
In analogy to dives add a selection flag for trips. The reason being that search for a selected trip can be painfully slow when we do it through Qt's proxy model. Make sure to deselect trips when they are removed from the core. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-02cleanup: remove unused function append_dive()Gravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move declaration of utc_mk* functions to new subsurface-time.h headerGravatar Berthold Stoeger
No point in slurping in all of dive.h for translation units that only want to do some time manipulation without ever touching a dive. Don't call the header "time.h", because we don't want to end up in a confusion with the system header of the same name. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: only include QString in desktop-widgets/importgps.hGravatar Berthold Stoeger
This included QFile, which is fatter and not needed here. Include QFile only in the actual translation unit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move dive_table from dive.h to divelist.hGravatar Berthold Stoeger
This allows us to decouple dive.h and divelist.h, a small step in include disentangling. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move FRACTION macro from dive.h to units.hGravatar Berthold Stoeger
There appears to be no reason to slurp in all dive.h when compiling membuffer.c. units.h might not seem like the perfect place, but it is the most fitting I found. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move DECOTIMESTEP from dive.h to planner.hGravatar Berthold Stoeger
Long-term project: reduce the size of dive.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: make enumerate_devices of external linkageGravatar Berthold Stoeger
For consistency: declare enumerate_dives as extern, since we do that for all other C-functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: make analyze_plot_info local to profile.cGravatar Berthold Stoeger
No external caller of this function exists. Moreover, turn the return type to void, as it only returned the passed-in plot_info and no caller used that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: const-ify a few functions in planner.cGravatar Berthold Stoeger
It make debugging much easier if the function signature tells you that a parameter is not altered. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01profile: for maxtime calculation include the sample after the last eventGravatar Berthold Stoeger
When plotting profiles with surface segments, there were strange artifacts. As we found out with Robert, these were due to the fact that the calculated maxtime was set to the last event which is just one second inside the surface segment. This terribly confused the profile code. For example, it didn't properly allocate samples for the surface segment. Thus, when calculating maxtime, consider the last sample beyond the last event. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>