aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget/profilewidget2.cpp
AgeCommit message (Collapse)Author
2018-05-21profile-widget: 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: 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-21profile-widget: profilewidget2.cpp, silence unused parameterGravatar jan Iversen
Add Q_UNUSED for not used parameter Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-17Dive pictures: Don't plot pictures twice when changing current diveGravatar Berthold Stoeger
In MainWindow::current_dive_changed() first plotDive() is called, which replots all the pictures by calling plotPictures(). This is pointess, because it plots the pictures of the previous dive. Then, updateDiveInfo() is called, which resets the dive pictures and automatically replots them. Thus, switching between dives both with hundreds of pictures is way slower than necessary. Switching the plotDive() and updateDiveInfo() calls doesn't work. The reason is not 100% clear, but it doesn't make sense to plot pictures of the new dive as long as the profile still shows the old dive anyway. As a quick-fix, add a flag to plotDive(), which tells the function to clear the pictures list instead of redrawing it. Ultimately, plotDive() should probably be split in two functions. One for the callers who update the pictures themselves and one for the others. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-14Place divemode changes in submenu of context menuGravatar Robert C. Helling
Also unify the repeated code in slots. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Show divemode swith options only for rebreather divesGravatar Willem Ferguson
The dive profile context menu gets rather long with three additional divome switches that can be selected. This is now changed so that the additional options are only shown when in CCR or in PSCR divemode. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Create divemode switches using profile context menuGravatar Willem Ferguson
Allow the manual creation of divemode switch events using the profile context menu. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
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-07Fix CCR setpoint display bugGravatar Willem Ferguson
1) The connection for the display of CCR-setpoint o2SetpointGasItem was erroneous, being connected to partialpressuregasSettings. It is now correctly connected to technicalDetailsSettings. 2) The colour of the setpoint graph is changed from PO2_ALERT (red) to an orange colour in order to show setpoint in red only when it exceeds 1.6. This emphasises the visibility of red parts of the gas pressure graphs whenever gas limits are exceeed. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
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-05-03Profile: Fix crash on addition of dive to fresh logbookGravatar Berthold Stoeger
If there is no current dive, the macro current_dc returns NULL. This led to a null-pointer dereference. Reported-by: Martin Měřinský <mermar@centrum.cz> 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-09Profile: On dataChanged() only update pictures that actually changedGravatar Berthold Stoeger
Only update those pictures of the DivePictureModel that actually changed. This will be useful once pictures are loaded incrementally. To do so, replace the pictures array by an array with stable ids. Before this commit, not-shown pictures are left out of the pictures array, which makes the mapping from DivePictureModel-ids to the picture array index non-trivial. Replace the QList<DivePictureItem *> by a std::vector<std::unique_ptr<DivePictureItem>> to ease memory management. Sadly, owing to COW semantics, QVector is incompatible with QScopedPointer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-19Profile heartrate: Nicer min/max values and tic distanceGravatar Stefan Fuchs
Correct a bug in finding the minimum heartrate. Use the minimum and maximum heartrate value to set min/max and tic distance for the heartrate axis in the profile. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
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-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-01-31profile: replot handles while planningGravatar Jan Mulder
The settingsChanged() function of the profile widget tries to be clever and tries to prevent not needed replots of the profile. I'm not sure this is very relevant in the first place as change of settings are almost instantly, with or without replot. It appears that replot is always executed when there are calculated ceilings visible. But without calculated ceilings a replot is "optimized out". This does, however, introduce dangling divehandles in PLAN/EDIT and ADD mode of the profile, when any setting that influences the y-axis is changed. The fix is trivial. Just force a replot in the PLAN/EDIT and ADD modes. Fixes: #1070 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-24profile: fix weird disappearance of cylinder pressure lineGravatar Jan Mulder
The reason for this issue, and fix for this is very similar to commit b4d37e8ee. Just set both recalculate flags on a mouse release event, so that the cylinder pressure line is recalculated. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-21Show ICD events data in infoboxGravatar Robert C. Helling
If a gas switch violates our ICD criteria, show this in the info box. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-12profile: fix garbled profiles after visiting the plannerGravatar Jan Mulder
See mentioned GitHub issue for the full issue, and images. The reason for this weird behavior is the existence of 2 flags in the profile code: shouldCalculateMaxTime and shouldCalculateMaxDepth. When exactly following the use case and test data as attached to the GitHub issue (a very short dive, shorter than most of the dives in the logbook), the shouldCalculateMaxTime flag never got back to its true status, causing the the time scale not to adapt to other dives when just clicking (or selecting) them from the dive list. The problem is fixed here by also setting the shouldCalculateMaxTime flag on manipulating wayppoints in the dive plan. Fixes: #1039 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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>
2018-01-10Un-tie plannner model from profile on mobileGravatar Jan Mulder
Do not pull in the DivePlannerPointsModel::instance as this is not used in the called function. We (currently) do not support deco computations on mobile, so trying to pull in any deco state from the planner is futile anyway. With this uncoupling, 6 more model files are not needed in mobile any more. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10Typo: Threshould -> ThresholdGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Typo: indice -> indexGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Replace CREATE_PP_GAS macro by member function in profilewidget2.cppGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Remove two arguments from ProfileWidget2::setupItem()Gravatar Berthold Stoeger
1) hAxis was always set to timeAxis 2) model was always set to dataModel Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Replace ADD_ACTION macro by member function in profilewidget2.cppGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Replace HIDE_ALL macro by template function in profilewidget2.cppGravatar Berthold Stoeger
This is easier to read and debug. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Remove unnecessary deletes in destructor of ProfileWidget2Gravatar Berthold Stoeger
All the deleted items were added to the scene, which takes "ownership" (a remarkably fuzzy concept in Qt) of these objects. In principle, deleting these items is a bug - even though it is handled gracefully. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Unused code: remove ProfileWidget2::isAddOrPlanner()Gravatar Jan Mulder
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-18Implement different zoom levels for dive photos tabGravatar Berthold Stoeger
This implements different zoom levels for the dive photos tab as suggested by Stefan Fuchs <sfuchs@gmx.de> in #898. The zoom level can be changed using a slider or CTRL+mousewheel. Zoom levels range from a third of the standard thumbnail size to thrice the standard thumbnail size. Thumbnails are cached in maximum resolution and scaled down on the fly. Because the profile widget took its pictures from the photo list model, an extra picture copy with a fixed size had to be introduced. The UI is still a bit crude. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-15divepicturemodel: Reset start and end row for displayed_dive correctlyGravatar Stefan Fuchs
Correct way of using indices for rowDDstart and rowDDend. Reset rowDDstart and rowDDend at beginning of updating dive pictures. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13Fine tune the position of pictures in the profileGravatar Stefan Fuchs
Start a new column a little bit earlier otherwise it will get difficult to fit a high number of pictures. Don't put more than ~16 pictures in one column. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13Dive pictures show pictures of all selected divesGravatar Stefan Fuchs
In the dive picture tab show pictures of all selected dive. But at the same moment take care that in the profile only pictures from displayed_dive are displayed. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01Prevent redundant replanningGravatar Robert C. Helling
Planning dives is heavy on CPU, so better be sure we only do it when needed. In particular, when moving around dive points, we only want a new plan once per move and not three times (triggered at various points in the chain of events). This should significantly improve planner snappiness. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01Control growth of time axisGravatar Robert C. Helling
While dragging waypoints around, don't grow the time axis according to dive duration (including deco stops) as this can explode too easly resulting in an effectively unresponsive planner. Rather grow it only (slowly) when a dive handler is moved to the right 10% of the profile. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-30Use better aliases for icons.Gravatar Martin Měřinský
Icon aliases were complete mess. Some icons had alias some didn't. Named with underscores vs. hyphens vs. camelCase. Lower vs. upper case. "ICON" prefix vs. suffix vs. nothing. With vs. without filename suffix. Some didn't make sence. Eg. mapwidget-marker-gray (I can see, it's grey, but what does it represent?) Some were duplicated, eg warning vs. warning-icon. Some were name after widget, which is wrong. Do not reinvent wheel. Use widely used naming scheme close to Freedesktop Icon Naming Specification. This will enable usage of common icons from current set in the future. Thus Subsurface will fit nicely to GUI. This changes icon aliases to one, easy grep-able style. Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29Revert "Use consistent aliases for all icons."Gravatar Dirk Hohndel
This reverts commit 92e9c6606f6ef3ad16d2e31f9f9a8f5fa14f2c1a.
2017-11-29Use consistent aliases for all icons.Gravatar Martin Měřinský
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase. With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs. prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some icons didn't have alias at all. This changes all icon aliases to one, easy grep-able style which complies to Freedesktop Icon Naming Specification (Guidelines). Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-25Fix toggling of partial pressure graphsGravatar Berthold Stoeger
When toggling the display of the partial pressure graph, the graph was either not shown correctly or unnecessary ticks were left in the graph. Calling the settingsChanged() method of the profileYAxis object solves the problem by initializing the ticks according to the selected graphs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25In strings change tank to cylinderGravatar Stefan Fuchs
Change the word "tank" to "cylinder" or "cyl." in two occurences. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25Hand planner variables to profileGravatar Robert C. Helling
Pass the planner state struct to the profile computation so it can use deco_time and first ceiling to display VPM-B ceiling. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-23Fix obscure display bug in profile widget, where heat map wasn't shownGravatar Berthold Stoeger
Fixes an obscure bug, which happened under very specific circumstances. Precodition: fresh program start and neither of the partial pressure graphs, nor the heat maps are shown. User clicks on heat map icon. Bug: The heat map is not shown at the bottom of the graph. The fix consists in replacing two percentageAxis->setLine() calls by precentageAxis->animateChangeLine() calls. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-18Prevent signed/unsigned comparison warningGravatar Berthold Stoeger
Change an unsigned integer to a signed integer in profilewidget2.cpp, because commit 1f8506c changed the definition of duration_t from unsigned to signed. Since this value represents the number of seconds since a dive started, there is no possible chance of overflow problems. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-26desktop UI: no longer attempt to manually show error notificationsGravatar Dirk Hohndel
report_error() now does this automatically. So all these odd places in which we tried to make sure that we show errors are no longer needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20Translate dc text in profile also if string has suffix for > 1 DCGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>