aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2019-12-05Undo: make adding of weights an undoable actionGravatar Berthold Stoeger
Introduce an AddWeight undo command. This is modelled after the numerous dive-edit undo commands. The redo and undo actions are connected to the WeightModel via two new signals, weightAdded and weightRemoved. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-05core: add dive_site export for mobile in ExportfuncsGravatar jan Iversen
DiveFilter is not available in Mobile, so another solution is needed. Use "for_each_dive_site" to loop over dive sites instead. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-04Selection: move selection of "first" dive to coreGravatar Berthold Stoeger
The DiveListView has a function to select the first dive. Move this to the core to be able to call it from all parts (not only desktop) of the code. Currently, this has a (small?) UI regression: when filtering dives and no selected dive is visible anymore, the old code would select the first dive in the list. The new code selects the newest dive, which might not be the first if some sort-criterion is active. To revert to the old behavior, it will be necessary to move the sorting function likewise to the core. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04Cleanup: remove superfluous includes from core/divelist.cGravatar Berthold Stoeger
Most of these haven't been used in a long time. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04Selection: move selection functions from divelist.c to selection.cGravatar Berthold Stoeger
Since we now have a selection.c translation unit, put the selection- related functions there. 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-12-03core: add shared export functions (copy from desktop-widgets)Gravatar jan Iversen
desktop-widgets/divelogexportdialog.* contains both the desktop dialog as well as the "real" export functions. Create a class to be shared between desktop and mobile Copy the export functions 1-1 from divelogexportdialog.* of course changing class names. saveProfile is highly dependent on the UI, so the implementaion will be done in each UI directory (desktop-widgets, mobile-widgets). Remark this commit just add the copied functions, in order to secure nothing is broken. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-03Desktop: add export to htmlGravatar willemferguson
Add the export of environmental parameters in star widgets to .html format. The dive rating is always shown both in the condensed as well as in the expanded view. The other five environmental variables are only shown in the expanded view. Only those star widgets with a rating are shown: if a star widget has not been rated in the UI, then it is assumed unrated and is not indicated in the expanded view. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-03Desktop: add additional star widgets to Information tabGravatar willemferguson
Provide file I/O for those star widgets that are enabled. The values of the widgets can be stored to and read from either xml or git. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-03Desktop: add additional star widgets to Information tabGravatar willemferguson
Connect the UI to the underlying dive structure. Enable proper initialisation and management of star widgets while Information tab is active. Enable undo for the addtional star widgets. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-03Desktop: handle environmental states in Information tabGravatar willemferguson
Create a preference setting on the General Settings page. The setting is saved with the other preferences. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-28Add current GF to infoboxGravatar Robert C. Helling
As per request from users on scubaforum.com, this adds the current gradient factor to the deco information of the infobox. Up to now, this information was only graphically represented in the pressure bar graph and the heatmap. This gives a numerical value. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-26core: add --testqml flag to mobileExecutableGravatar jan Iversen
Add flag to subsurface_mobile (only when compiling for desktop) to allow using qml files from disk instead of resources. This allows testing qml changes with just restarting subsurface_mobile. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-11-22Core: don't prevent some OSTC models from being recognizedGravatar Dirk Hohndel
The code seemed to do something really reasonable by picking one of the supported OSTC versions - except that the one it picked didn't support BT/BLE and therefore our logic of recognizing dive computers on iOS failed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-20Translations: try to be smarter when picking the right localeGravatar Dirk Hohndel
I was reminded to do this when a user in French speaking Switzerland reasonably suggested that fr_FR would be a much better fallback than en_US in their situation. Fixes: #2388 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-19Dive list: update selection after clearing modelGravatar Berthold Stoeger
When clearing the model the selection is cleared. Send the according signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19Filter: move recalculation of filter from FilterModel to TripModelGravatar Berthold Stoeger
The way this was accessed via Qt's model semantics was horrible. This gives arguably more readable code, since we don't have to shoehorn things through QVariants. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19Filter: move num_shown logic from model to coreGravatar Berthold Stoeger
Since the number of shown dives is stored in the core, let's also keep it updated there. 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-19Filter: move number of shown dives to coreGravatar Berthold Stoeger
We mark hidden/shown dives in the core but store the number of shown dives in the MultiFilterSortModel. Move this datum to the core for improved locality. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16Check if all required bytes were readGravatar Robert C. Helling
Fixes CID 350077 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16Don't acces null dive computerGravatar Robert C. Helling
Fixes CID 350111 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16Use the actual error numberGravatar Robert C. Helling
According to the man page, fopen and fclose return the error number in the global variable errno. Fixes CID 350115 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16Initialize cylider field properlyGravatar Robert C. Helling
This fixes another thing Coverty found. I am not 100% sure I understand the semantics of cylinder_t.manually_added but looking at other instance I guess true is the correct value for a cylinder from a csv file for a Poseidon rebreather. Fixes CID 350734 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16Don't access uninitialized deco_structureGravatar Robert C. Helling
Coverty found that in the export functions, we initialize the planner deco state with NULL and then possibly later access its content. This makes sure, we don't do that. Let's see if this makes Coverty happy or I missed somehting else. Fixes CID 350736 Fixes CID 350735 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-11-16Cleanup: move clearing of current_dive into clear_dive_file_data()Gravatar Berthold Stoeger
It makes no sense to have a non-NULL current_dive once all dives have been deleted. Therefore, clear current_dive implicitly in clear_dive_file_data() and don't depend on the caller performing this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-16Core: set gas use to zero if no values are givenGravatar Berthold Stoeger
In get_gas_used() the use was left uninitialized if there are neither user- nor computer-supplied values. This gives random SACs in the UI. Initialize to 0. Fixes #2376. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-12Profile: fix pressure scaleGravatar Berthold Stoeger
The determination of minimum pressure in calculate_max_limits_new() in profile.c was wrong for a long time. Since the loop went over all cylinders (even unused ones), the minimum pressure was always zero. Since we loop only over used cylinders, the minimum pressure was initialized to the lowest starting pressure of any cylinder. If there were no events with pressure change, the minimum pressure stayed unchanged, resulting in a funky scaling. Instead, let's initialize the minimum pressure to the lowest ending pressure. Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Parser: set timestamp to zero if parsing failedGravatar Berthold Stoeger
When parsing of a timestamp failed (shouldn't happen) set the timestamp to zero. This should give less unpredictable results and silence a compiler warning. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cylinders: access cylinders with get_cylinder()Gravatar Berthold Stoeger
Instead of accessing the cylinder table directly, use the get_cylinder() function. This gives less unwieldy expressions. But more importantly, the function does bound checking. This is crucial for now as the code hasn't be properly audited since the change to arbitrarily sized cylinder tables. Accesses of invalid cylinder indexes may lead to silent data-corruption that is sometimes not even noticed by valgrind. Returning NULL instead of an invalid pointer will make debugging much easier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Mobile: optimize cylinderList() functionGravatar Berthold Stoeger
The cylinderList() function collects all cylinder descriptions. Instead of adding all cylinders, then sort, then removed duplicates, keep a sorted list and only add non-existing elements. Find existing elements by a binary search. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Desktop: support no-cylinders in dive information tabGravatar Berthold Stoeger
The tab was crashing if there were no cylinders because 1) per_cylinder_mean_depth() would access non-existing cylinders. 2) TabDiveInformation::updateProfile() would access a non-existing mean. Fix both of these crash conditions by checking whether the dive actually has cylinders. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cleanup: replace unsigned by signed parameter in two helper functionsGravatar Berthold Stoeger
In getFormattedWeight() and getFormattedCylinder(), the indexes were passed as unsigned ints. This makes no sense as the only callers were using signed ints. Change the parameters to signed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cleanup: return cylinder from add_empty_cylinder()Gravatar Berthold Stoeger
As a convenience, return the cylinder from add_empty_cylinder() to spare the caller from the nasty expression to fetch the last cylinder. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cleanup: return cylinder from cylinder_start() in parserGravatar Berthold Stoeger
Most callers of this function accessed the newly generated cylinder immediately after calling this function. Thus, for convenience, return the added cylinder. This avoids a number of verbose expressions. On the flip side, cylinder_start() now has to be cast to function returning void in a the "nesting" function table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Core: remove MAX_CYLINDERS restrictionGravatar Berthold Stoeger
Instead of using fixed size arrays, use a new cylinder_table structure. The code copies the weightsystem code, but is significantly more complex because cylinders are such an integral part of the core. Two functions to access the cylinders were added: get_cylinder() and get_or_create_cylinder() The former does a simple array access and supposes that the cylinder exists. The latter is used by the parser(s) and if a cylinder with the given id does not exist, cylinders up to that id are generated. One point will make C programmers cringe: the cylinder structure is passed by value. This is due to the way the table-macros work. A refactoring of the table macros is planned. It has to be noted that the size of a cylinder_t is 64 bytes, i.e. 8 long words on a 64-bit architecture, so passing on the stack is probably not even significantly slower than passing as reference. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cleanup: move copy_cylinder_types() from dive.c to equipment.cGravatar Berthold Stoeger
Thus, future callers will not have to include the monster dive.h include if they just want to copy cylinders. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Core: create copy_cylinder_type() functionGravatar Berthold Stoeger
Move the loop body of copy_cylinder_types() into its own function. When using variable sized arrays, this loop will have to treat two cases (overwrite cylinder and add new cylinder), so that makes things more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Core: dynamically allocate cylinder maps in merge_cylinders()Gravatar Berthold Stoeger
merge_cylinders() used three bitmaps to identify cylinders used in the first and second dive and matched cylinders. Even though nobody will use more than 32 (or 64!) cylinders, replace these with dynamically allocated bool-arrays for consistency with the rest of the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Core: dynamically allocate gases arrayGravatar Berthold Stoeger
When calculating per-cylinder mean depths, bitfields were used to keep track of "used" and "known" cylinders. Even though no sane person will use more than 32 cylinders, turn this into dynamically allocated arrays of bool for consistency with the rest of the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: dynamically allocate gases arrayGravatar Berthold Stoeger
To calculate sac rates, an array of used gases for every point on the profile was used. This was implemented using unsigned int bitfields. While nobody sane will ever use 32 or even 64 cylinders, for consistency with the rest of the code, also change this to use dynamically allocated arrays. But allocate only once per shown profile, not once per sample. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: dynamically allocate plot pressure dataGravatar Berthold Stoeger
All accesses to the pressure data were converted to use functions. Therefore it is now rather trivial to dynamically allocate the pressure array and just change the functions. The only thing to take care of is the idiosyncratic memory management. Make sure to free and copy the buffer in the appropriate places. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: use pressure data functions in save_profiles_bufferGravatar Berthold Stoeger
The save_profiles_buffer() function was accessing the pressure data directly. Instead, use the already existing funcions to make transition to dynamically allocated pressure data more seamless. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: use pressure data functions in fill_missing_tank_pressuresGravatar Berthold Stoeger
The pressure data was directly accessed in fill_missing_tank_pressures(). Use the already existing functions so that the structures can be adapted easily. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: turn INSERT_ENTRY macro into helper functionGravatar Berthold Stoeger
The only apparent reason that this was a macro is that it automatically increased the "index" and "entry" counts. But incrementing these explicitly seems reasonable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: pass index instead of pointer to set_plot_pressure_dataGravatar Berthold Stoeger
Another plot-pressure-related function whose argument is converted to an index. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: switch pressure-accessing functions to indexesGravatar Berthold Stoeger
Continue with replacing pointers to struct plot_data entries by indexes. Thus the pressure data can be kept in its own array and can by dynamically sized. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Profile: change get_plot_pressure to take index instead of pointerGravatar Berthold Stoeger
The goal here is to make it possible to detach the pressure related data from the plot_info structure. Thus, the pressure related data can be allocated independently depending on the number of cylinders per dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cylinders: dynamically allocate cylinder arraysGravatar Berthold Stoeger
Dynamically allocate cylinder arrays in C code. This is a tiny step in removing the MAX_CYLINDERS limitation. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>