aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models
AgeCommit message (Collapse)Author
2018-06-24Copy divemode to ReplanGravatar Robert C. Helling
this needs copying the divemode from the dive to the plan. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-20equipment: sanitize 'ws_info' loop limitsGravatar Lubomir I. Ivanov
Instead of a constant or a macro for the maximum number of 'ws_info' elements the 100 literal was used. Define MAX_WS_INFO in dive.h and use it everywhere. Also clamp loops that iterate `ws_info' to MAX_WS_INFO. Prevents potential out-of-bounds reading, similarly to the previous commit about 'tank_info'. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-20equipment: sanitize 'tank_info' loop limitsGravatar Lubomir I. Ivanov
In a number of places the global 'tank_info' array is being iterated based on a 'tank_info[idx].name != NULL' condition. This is dangerous because if the user has added a lot of tanks, such loops can reach 'tank_info[MAX_TANK_INFO]'. This is an out of bounds read and if the 'name' pointer there happens to be non-NULL, passing that address to a peace of code that tries to read it (like strlen()) would either SIGSEGV or have undefined behavior. Clamp all loops that iterate 'tank_info' to MAX_TANK_INFO. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-18Change from gettextFromC::instance()->tr() to gettextFromC::tr();Gravatar Stefan Fuchs
Code cleanup. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18Use correct "tr" call for translating dive mode namesGravatar Stefan Fuchs
Correctly use gettextFromC::instance()->tr(); instead of a simple tr(); to translate the dive mode names. This goes on top of 0bc9edf855caf95e2d58ccaf704ceeda079e06f1 and finally makes the whole thing work. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Dive computers: turn QMultiMap into sorted vectorGravatar Berthold Stoeger
The list of known dive computers was stored in a multi-map indexed by the device name. Turn this into a sorted QVector. Thus, no map-to-list conversion is needed in the device editing dialog, which distinctly simplifies the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17Fix an error around translation of dive modes in the UIGravatar Stefan Fuchs
This fixes an mistake introduced in 3d1072f8862e4c329dc2678df52a24137b8d4704 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21qt-models: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21Dive pictures: don't repopulate DivePictureModel on deletionGravatar Berthold Stoeger
On deletion of a single or multiple pictures, the whole DivePictureModel was repopulated, which was clearly visible in the UI, owing to the reconstructing of all images in the profile plot. To avoid this vexing behavior, implement proper deletion routines in DivePictureModel and ProfileWidget2. Since this needs sensible erase() semantics the QList<PictureEntry> member of DivePictureModel was replaced by a QVector. A QVector should be the default anyway, unless there are very specific reasons to use a QList (which actually is a deque, not a classical linked list). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21Dive pictures: change removePicture() interfaceGravatar Berthold Stoeger
The function removePicture() had a flag "last", which would indicate that the called had finished removing pictures. Only then would the model be recalculated. This is a strange interface and, matter of fact, the caller was buggy: if the last picture to be removed didn't have a proper url, removePicture() was never called with "last" being set. Change the interface to take a list of pictures to be deleted. This will allow us to make picture deletion smarter in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21Dive pictures: use modelReset signal when reseting picture listGravatar Berthold Stoeger
In the old code a combination of removeRows()/insertRows() was used to signal a model reset. Replace this by a single, modelReset signal. This saves a call to plotPictures() and will allow us to be smarter in the future, when removing pictures. Reset-model and remove-items are semantically different. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-18mobile: add "Copy log to clipboard" buttonGravatar jan Iversen
on iOS it is practically impossible to copy the App log to e.g. a mail! in iOS 11 the log file is stored within the subsurface container and you first need to copy (actually using the clipboard) out from there to the "normal" document shared space, before it can be used. At least iOS users (and I believe Android users) are not really used to work with files, so the process is not easy to document in an understandable way. The alternative is to provide a button, which simply puts the log on the general clipboard, allowing it to be pasted in a multitud of applications. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Planner: Add combo box for dive mode selectionGravatar Robert C. Helling
I am not really sure what I am doing here but I copied code from the gas selection. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Rename enum dive_comp_type to divemode_tGravatar Robert C. Helling
...as the usuage is not anymore about a computer but a momentary dive mode. Rename the end indicator as well. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Add planner infra structure for bailoutGravatar Robert C. Helling
Add a divemode column to the planner model and a corresponding field to struct divepoint and fill it in the corresponding functions. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Core: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-13Dive pictures: Don't update all pictures on drag & drop to profileGravatar Berthold Stoeger
In the old code, we used to reload the whole picture list on drag & drop to the profile. Instead, only update the drag&dropped picture and repaint the profile-pictures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Move thumbnail-size to Thumbnailer classGravatar Berthold Stoeger
The size of the to-be-created thumbnails was passed from DivePictureModel to Thumbnailer. This became more and more bothersome, because the size had to be stored with the request. Calling from Thumbnailer into DivePictureModel was not an option, since this is not linked to all tests. Therefore, move these functions to the Thumbnailer class. Since the maximum thumbnail size is now known to the thumbnailer, the dummy and failure images can be precalculated, which makes switching between dives faster. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Update pictures when thumbnails are readyGravatar Berthold Stoeger
Connect the thumbnailer signal to the dive picture model slot. This needs some code-reshuffling in the dive picture model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Introduce thumbnailer classGravatar Berthold Stoeger
Create a new class, which performs all thumbnailing code. This is mostly code reshuffling. Thumbnails are extracted either from a cache or thumbnail calculation is started in a worker thread. Since getHashedImage() is called from a worker thread it makes no sense to call subfunctions in yet another worker thread. Remove these calls. In contrast to the previous code, on error the background thread produces a failure image, but it is not yet shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: replace picture struct by QStringGravatar Berthold Stoeger
In imagedownloader.cpp the only thing we need from the picture struct is the filename. Therefore, use QStrings instead of the picture struct. This simplifies memory management. Remove the clone_picture() function, which is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: turn SHashedImage class into getHashedImage() functionGravatar Berthold Stoeger
SHashedImage was a subclass of QImage, which fetched the image according to the filename hashes. Turn this into a function, as this is much more idiomatic and flexible. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: save thumbnails to individual filesGravatar Berthold Stoeger
The old code loaded all thumbnails into memory at once. This does not scale to logs with thousands of pictures. Therefore, save the pictures to individual files and only load the currently needed pictures. Currently, this will make changing switching between dives slower, because the thumbnails are loaded from disk. In the future, it is planned to do this in a background thread without blocking the user interface. A notable difference to the old code: Thumbnails are now indexed by the image-hash (i.e. the content of the raw image) and not by the filename of the image. Thus, different paths to the same image should only be saved once. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Scale thumbnails on demandGravatar Berthold Stoeger
To potentially conserve memory, don't keep copies of scaled thumbnails. Scale the thumbnails on demand. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-11Corrected file name "weigthsysteminfomodel" to "weightsysteminfomodel"Gravatar Oliver Schwaneberg
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-07Planner: don't return static data in fake_dc()Gravatar Berthold Stoeger
fake_dc() used to return a statically allocated dc with statically allocated samples. This is of course a questionable practice in the light of multi-threading / resource ownership. Once these problems were recognized, the parameter "alloc" was added. If set to true, the function would still return a statically allocated dc, but heap-allocated samples, which could then be copied in a different dc. All in all an ownership nightmare and a recipie for disaster. The returned static dc was only used as a pointer to the samples anyway. There are four callers of fake_dc() and they all have access to a dc-structure without samples. Therefore, change the semantics of fake_dc() to fill out the passed in dc. If the caller does not care about the samples, it can simply reset the sample number to zero after work. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-28Plot OC-pO2 graph for SCR divesGravatar Willem Ferguson
This commit allows plotting the OC-equivalent pO2 graph for PSCR dives. This happens in both the cases where there is no external O2-monitoring AND when there is external pO2 monitoring. The calculations are only done for PSCR dives and is achieved as follows: 1) Within plot-info create a pressure-t called OC_pO2 in profile.h and populate this variable with the open-circuit pO2 values in profile.c. 2) Create a new partialPressureGasItem ocpo2GasItem in profilewidget2.h and, in profilewidget2.cpp, initialise it to read the plot-info OC_pO2 values and enable its display by using the setVisible method. The diveplotdatamodel was also touched in order to achieve this. 3) Create a pref button that controls the display of OC-pO2 for SCR dives 4) Change the colour of the OC-pO2 grpah to orange 5) Change the connection of the crr_OC_pO2 signal to be appropriate 6) rename the OC_pO2 attribute to scr_OC-pO2 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-13iOS: log messagesGravatar Dirk Hohndel
So far we only wrote messages to subsurface.log on Android (since we couldn't figure out how to make that file user accessible on iOS). Now that that's fixed, we also need to actually write to the file in the first place. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-09Change taglist_get_tagstring to support 'unlimited' tag list sizeGravatar Jeremie Guichard
Previous taglist_get_tagstring signature/implementation did not allow handling of cases where inputted buffer could not contain all tags. New implementation allocates buffer based on pre-computed size allowing to insert all tags in the returned string. Added get_taglist_string in qthelper to handle conversion to QString Added TestTagList with tests for taglist_get_tagstring Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-04Add "Tags" column in Desktop app's dive list viewGravatar Jeremie Guichard
Add DiveItem::displayTags helper method to return Tags as a QString New Tags column is by default inserted before "Photos" column by default disabled Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-01Debug: sprinkle debug messages in thumbnailing codeGravatar Berthold Stoeger
To ease trouble-shooting of the picture thumbnailer add a number of debug- and info-messages. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-22cmake: move maplocationmodel to generic modelsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-14Cleanup: introduce copy_qstring() functionGravatar Berthold Stoeger
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common occurrences that they seem worthy of a short helper-function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-11cmake: update CMake to build the map components on mobileGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-05Cleanup: Remove superfluous QString constructions in divetripmodel.cppGravatar Stefan Fuchs
Remove superfluous QString constructions in a couple of simple functions in divetripmodel.cpp Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-05Use correct numeric format based on selected locale (Qt domain part)Gravatar Stefan Fuchs
This changes the numeric format of many values printed to the UI to reflect the correct numeric format of the selected locale: - dot or comma as decimal separator - comma or dot as thousands separator In the Qt domain the `L` flag is used case specific mostly in qthelper.cpp. Then the helper functions get_xxx_string() are used more consistently. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-27Updated strategy for removing cylindersGravatar Stefan Fuchs
Change the strategy when to allow cylinder removal from a dive: - Not remove when cylinder has gas switch events, in any other cases allow removal - Remove this whole "cylinder with same gas" thing being a criteria for cylinder removal When removing a cylinder which has corresponding pressure info in samples, also remove this pressure info from the samples. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24Use temperature_t for temperatures in struct stats_tGravatar Stefan Fuchs
Use struct temperature_t for temperatures in struct stats_t and use get_temperature_string() when printing these temperatures for statistics and HTML export. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-17Coding-style: remove superfluous parenthesesGravatar Berthold Stoeger
Mostly replace "return (expression);" by "return expression;" and one case of "function((parameter))" by "function(parameter)". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Bugfix in plannermodel for very short dive durationsGravatar Oliver Schwaneberg
When adding a dive manually, you might clear the "duration" field and fill in your value by hand. Unfortunately, commit #1052 produced a bug that practically limited the dive duration to 6 minutes once the field was cleared. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-31mobile cleanup: restyle construction of locationlistGravatar Jan Mulder
See also e6e1473e6. The construction of the locationlist was not the same as the 3 previous lists, and it needs the inclusion of a new model file (divelocationmodel.cpp) in the mobile app. In addition, as the mobile app is mainly interested in a simple stringList (model) to populate a HintsText field (or maybe later a combobox), this stringlist is added to the model, to easy interfacing with QML. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (1)Gravatar Jan Mulder
This is the first of a set of commits that are (very) similar. It appeared that a number of more or less static lists, which are constructed by a loop over all dives in the logbook, were executed when changing focus to a next dive. For example, the in this commit addressed list of used dive suits. What was wrong was that the suitList was linked to a dive. There is only a need to construct the list of used suits when data is changed (and obviously, once on startup of the app). Further, it appeared that a lot of code was duplicated and that we can use (in this case) the same code from the desktop completionmodels.cpp. Basically, this commit involves the following changes: - include completionmodels.cpp in mobile and desktop (so move it from the desktop only category to the generic category). - remove double code from DiveObjectHelper.cpp - Do not differentiate in the init phase and the normal refresh of the list - the per dive logic is now only the getting of a previously constructed list (in init or update of the divelist). There are no visible changes in the UI, other than a better performance when scrolling over dive details. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-26Initialise cylinder start pressure with working pressureGravatar Robert C. Helling
In the planner, this is the natural assumption. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-19Improve profile display in plannerGravatar Willem Ferguson
This patch allows the planner to save the last manually-entered dive planner point of a dive plan. When the plan has been saved and re-opened for edit, the time of the last-entered dive planner point is used to ensure that dive planning continues from the same point in the profile as was when the original dive plan was saved. Mechanism: 1) In dive.h, create a new dc attribute dc->last_manual_time with data type of duration_t. 2) In diveplanner.c, ensure that the last manually-entered dive planner point is saved in dc->last_manual_time. 3) In save-xml.c, create a new XML attribute for the <divecomputer> element, named last-manual-time. For dive plans, the element would now look like: <divecomputer model='planned dive' last-manual-time='31:17 min'> 4) In parse-xml.c, insert code that recognises the last-manual-time XML attribute, reads the time value and assigns this time to dc->last_manual_time. 5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive, insert code that sets the appropriate boolean value to dp->entered by comparing newtime (i.e. time of dp) with dc->last_manual_time. 6) Diveplannermodel.cpp also accepts profile data from normal dives in the dive log, whether hand-entered or loaded from dive computer. It looks like the reduction of dive points for dives with >100 points continues to work ok. The result is that when a dive plan is saved with manually entered points up to e.g. 10 minutes into the dive, it can be re-opened for edit in the dive planner and the planner re-creates the plan with manually entered points up to 10 minutes. The rest of the points are "soft" points, shaped by the deco calculations of the planner. Improvements: Improve code for profile display in dive planner This responds to #1052. Change load-git.c and save-git.c so that the last-manual-time is also saved in the git-format dive log. Several stylistic changes in text for consistent C source code. Improvement of dive planner profile display: Do some simplification of my alterations to diveplannermodel.cpp Two small style changes in planner.c and diveplannermodel.cpp as requested ny @neolit123 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-11Use helper function empty_string() instead of manual checksGravatar Berthold Stoeger
For code consistency, substitute boolean expressions: s && *s -> !empty_string(s) s && s[0] -> !empty_string(s) !s || !*s -> empty_string(s) !s || !s[0] -> empty_string(s) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Introduce helper function empty_string()Gravatar Berthold Stoeger
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Pictures tied to profile are not supported on mobileGravatar Jan Mulder
Move divepicturemodel.cpp to the desktop only category and deal with the (limited) fallout. We, currently, do not support dive pictures tied to the profile on mobile, so there is no use including this code. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>