Commit graph

121 commits

Author SHA1 Message Date
Berthold Stoeger
9293268027 Dive picture: fix toggling of picture-visibility
In a recent commit, the profile widget was changed to reuse
DivePictureItems. This made toggling of picture-visibility
disfunctional, because the visibility was set in the constructor.
Only on change of dive would the setting take effect.

Therefore, move the setting of the visibility up to the
ProfileWidget2::plotPictures() call. This is more consistent
anyway, since at this level pixmap and fileUrl are set.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04 10:28:08 -07:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
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-06-04 08:50:10 -07:00
jan Iversen
3963e44404 desktop: use QElapsedTimer to measure time
QElapsedTimer is the preferred timer for measuring time
so lets use it.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-29 12:48:32 -07:00
Robert C. Helling
7c6e5ed5db Distinguish between user and internal divemode names
The former should be translated but not those that
go to xml/git.

... and fix capitalization of pSCR.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
jan Iversen
86ab5a91f7 profile-widget: set printmode but allow events for ssrf-mobile
Reactivate printMode true for ssrf-mobile to avoid font problems,
do not discard events if ssrf-mobile (even though printMode is true)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 12:04:14 -07:00
jan Iversen
065af62f59 profile-widget: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
Berthold Stoeger
f47f2773fd Dive pictures: don't repopulate DivePictureModel on deletion
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-21 22:17:28 +03:00
Berthold Stoeger
fbe1144eaf Dive pictures: use modelReset signal when reseting picture list
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-21 22:17:28 +03:00
jan Iversen
158be64883 profile-widget: profilewidget2.cpp, silence unused parameter
Add Q_UNUSED for not used parameter

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 07:31:16 -07:00
Berthold Stoeger
45395fd466 Dive pictures: Don't plot pictures twice when changing current dive
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-17 07:24:54 -07:00
Robert C. Helling
969dfee9ec Rename enum dive_comp_type to divemode_t
...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-14 23:47:00 +03:00
Robert C. Helling
6b0ecb012d Place divemode changes in submenu of context menu
Also unify the repeated code in slots.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Willem Ferguson
718f9811b7 Show divemode swith options only for rebreather dives
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-14 23:47:00 +03:00
Willem Ferguson
e46cb2f800 Create divemode switches using profile context menu
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-14 23:47:00 +03:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Berthold Stoeger
c71a5d7413 Dive pictures: Don't update all pictures on drag & drop to profile
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-13 13:52:35 -07:00
Willem Ferguson
70bb4c145b Fix CCR setpoint display bug
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-07 13:56:23 +02:00
Berthold Stoeger
920ff15f71 Planner: don't return static data in fake_dc()
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-07 13:11:53 +03:00
Berthold Stoeger
fb84b11854 Profile: Fix crash on addition of dive to fresh logbook
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-05-03 02:14:03 +03:00
Willem Ferguson
81a812539c Plot OC-pO2 graph for SCR dives
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-28 20:11:22 +03:00
Berthold Stoeger
f1830cd44e Profile: On dataChanged() only update pictures that actually changed
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-04-09 07:50:21 -07:00
Stefan Fuchs
b38eb45b29 Profile heartrate: Nicer min/max values and tic distance
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-19 15:44:02 -07:00
Berthold Stoeger
b72cc1f317 Cleanup: consistently use qPrintable()
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-14 13:55:36 +02:00
Berthold Stoeger
5c248d91cd Coding-style: remove superfluous parentheses
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-17 19:38:52 -08:00
Jan Mulder
20dc6a31f4 profile: replot handles while planning
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-31 14:48:31 +01:00
Jan Mulder
36cfab46bd profile: fix weird disappearance of cylinder pressure line
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-24 16:19:19 +01:00
Robert C. Helling
7b508e41cd Show ICD events data in infobox
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-21 15:24:46 +01:00
Jan Mulder
b4d37e8eeb profile: fix garbled profiles after visiting the planner
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-12 10:26:05 -08:00
Berthold Stoeger
e85ecdd925 Introduce helper function empty_string()
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-11 06:07:13 +01:00
Jan Mulder
34bc4fc0af Pictures tied to profile are not supported on mobile
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-10 21:28:02 +01:00
Jan Mulder
9c01315d31 Un-tie plannner model from profile on mobile
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-10 21:28:02 +01:00
Berthold Stoeger
14e6c132c8 Typo: Threshould -> Threshold
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10 21:25:02 +01:00
Berthold Stoeger
85ac3106e6 Typo: indice -> index
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10 21:25:02 +01:00
Berthold Stoeger
d9ac716162 Replace CREATE_PP_GAS macro by member function in profilewidget2.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10 21:25:02 +01:00
Berthold Stoeger
05974d17c9 Remove two arguments from ProfileWidget2::setupItem()
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-10 21:25:02 +01:00
Berthold Stoeger
769c64fe5e Replace ADD_ACTION macro by member function in profilewidget2.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10 21:25:02 +01:00
Berthold Stoeger
3d8b0e6d3f Replace HIDE_ALL macro by template function in profilewidget2.cpp
This is easier to read and debug.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10 21:25:02 +01:00
Berthold Stoeger
6cf06fb61d Remove unnecessary deletes in destructor of ProfileWidget2
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-10 21:25:02 +01:00
Jan Mulder
1892e2af21 Unused code: remove ProfileWidget2::isAddOrPlanner()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Berthold Stoeger
05a1626c7e Implement different zoom levels for dive photos tab
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-18 12:07:10 -08:00
Stefan Fuchs
2890be9256 divepicturemodel: Reset start and end row for displayed_dive correctly
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-15 09:11:28 -08:00
Stefan Fuchs
7bc77947f6 Fine tune the position of pictures in the profile
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-13 05:48:20 -08:00
Stefan Fuchs
5b7e4c57f7 Dive pictures show pictures of all selected dives
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-13 05:48:20 -08:00
Robert C. Helling
4d605ce51f Prevent redundant replanning
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-01 15:47:51 -08:00
Robert C. Helling
e06b507230 Control growth of time axis
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-12-01 15:47:51 -08:00
Martin Měřinský
8ef87e618a Use better aliases for icons.
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-30 23:14:46 -08:00
Dirk Hohndel
2747056889 Revert "Use consistent aliases for all icons."
This reverts commit 92e9c6606f.
2017-11-29 14:05:07 -08:00
Martin Měřinský
92e9c6606f Use consistent aliases for all icons.
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-29 11:46:35 +01:00
Berthold Stoeger
82898a837d Fix toggling of partial pressure graphs
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-25 15:42:44 -08:00
Stefan Fuchs
5da6362679 In strings change tank to cylinder
Change the word "tank" to "cylinder" or "cyl." in two occurences.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:41:28 -08:00