Commit graph

314 commits

Author SHA1 Message Date
Berthold Stoeger
24c72cb359 Inform LocationFilterModel of added dive site name
If the user implicitly adds a dive site by editing a dive, and
a location filter is active, check the new dive site in the
location filter.

This is done by informing the LocationFilterModel of the new
dive site name prior to repopulation. The LocationFilterModel
then adds a corresponding entry and marks it as checked.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:50:40 -08:00
Berthold Stoeger
f4bcdf46aa Inform LocationFilterModel of changed dive site name
Since commit 01d961086c, the location filter
list is updated if a dive site is edited. The problem is that if the
name of a selected dive site is changed, the selection is lost.

Therefore, before repopulating, inform the location filter that a dive
site changed its name. The location filter then internally changes the
name and can properly transfer the old selection on repopulate. This is
performed via the new LocationInformationWidget::nameChanged signal,
which is connected to the new LocationFilterModel::changeName slot.

A special case to be handled is the following:
 [ ] Site 1
 [x] Site 2
and "Site 2" being renamed to "Site 1", i.e. both sites being merged.
Here, the merging is detected and "Site 1" will likewise be checked:
 [x] Site 1
 [x] Site 1
No merging is performed, as the list will be repopulated anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:50:40 -08:00
Berthold Stoeger
bf65f1e507 Fix comparison function in qt-models/divelocationmodel.cpp
The function dive_site_less_than() in qt-models/divelocationmodel.cpp
does not what it promises: it uses less-or-equal instead of less-than
comparison.

Note that, even though this may sound pedantic, this is an actual bug.
Usually, sorting functions suppose that they are provided with
strict weak ordering, which <= does *not* provide.

This is the actual reason for the crash mentioned in commit
f8a3a85210.

While touching this function, make it of static linkage, since
its usage is local to this translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:49:05 -08:00
Berthold Stoeger
d1545b27b4 Remove unused method LocationInformationModel::addDiveSite()
The call to this method was removed in commit f4c31f110f

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 23:37:01 +01:00
Berthold Stoeger
6343515fed Use equality instead of substring comparison in suits and buddy filter
This commit is a continuation of commit 739b27427c,
in which a substring comparison was replaced by equality comparison to
avoid confusing UI behavior of the filter interface.

The suit and buddy filters were plagued by the same problem, so change
their code in analogy.

Fixes #551 (in conjunction with commit dd2466f518).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 15:41:55 -08:00
Robert C. Helling
088db5e12b Hand planner variables to profile
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-25 20:13:01 +01:00
Robert C. Helling
8e21a65653 Localize global planner state
For UI responsiveness, we need to be able to run the planner in the background. This needs the
planner state to be localized (and we need to pass a pointer around).

In order to not let too many lines overrun (and to save typing in the future)
I have renamed instances of struct deco_state to ds. Yes this should have gone
to a separate commit but I accidentally commit --amend'ed it.

Computing of planner variations is temporarily disabled.

Unlock the planner when returning early

So we don't deadlock in add dive and recreational mode (which
use the planner without actually planning).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Robert C. Helling
a9ceecc2e3 Run variations calculation in background
but there are still side effects and thus it crashes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Berthold Stoeger
dd2466f518 Update filters on refreshDisplay and remember old selecttions
Update the filters if the list of dives is updated by calling
MultiFilterSortModel::instance()->myInvalidate();
This had the side effect of clearing all selections. Thus, in
the repopulate() methods of the FilterModels, check those
entries that were checked previously. Since all the filter
models use the same code, introduce a base class FilterModelBase.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 08:24:36 -08:00
Berthold Stoeger
4da6a0a732 Replace bool * array by std::vector<char> in MultiFilterInterface
This replaces a dynamically allocated array of bool by std::vector<char>.
1) This makes the code shorter and less error prone, because memory
   management has not to be done by hand.
2) It fixes a bug in the old code:
   memset(checkState, false, list.count()) is wrong, because bool is
   not guaranteed to be the same size as char!

Two notes:
1) QMap<>, QVector<>, etc. are used numerous times in the code, so
   this doesn't introduce a new C++ concept. Here, the std:: version
   is used, because there is no need for reference counting, COW
   semantics, etc.
2) std::vector<char> is used instead of std::vector<bool>, because
   the latter does a pessimization where a bitfield is used!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 08:24:36 -08:00
Berthold Stoeger
739b27427c LocationFilter: use equality instead of substring comparison
The location filter used a substring comparison, which had
the side effect that dives with the location "Test 1" were
shown when filtering for "Test 12".

Moreover, avoid a deep copy of the location list. This is
done by looping over one item less than rowCount() instead
of removing the last item. While doing this, remove an
unnecessary if-statement.

This commit partially fixes #675.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 08:24:36 -08:00
Dirk Hohndel
ba773c811f Only call autogroup when it's enabled
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-25 08:12:28 -08:00
Berthold Stoeger
24fae95070 Fix indentation
Fix an indentation issue in qt-models/diveplannermodel.cpp.
An if was indented as if it were part of an outer if.

Correct indentation confirmed by Stefan Fuchs <sfuchs@gmx.de>.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-19 00:21:45 +01:00
Lubomir I. Ivanov
746874a78e map-widget: allow real-time updates of edited markers
This patch allows updating the location of map markers
while editing a dive site and updating the text in the
LocationInformationWidget in real-time.

Currently it is only possible to see the marker changes by
clicking 'Apply'.

The modification required the following changes:
- add the MapWidget::updateCurrentDiveSiteCoordinatesToMap() slot
and call it each time the GPS text updates
- separate the updateCurrentDiveSiteCoordinates(FromMap/ToMap) logic
by having the FromMap/ToMap suffix to method names
- make MapWidgetHelper::updateCurrentDiveSiteCoordinatesToMap()
call a new MapLocationModel::updateMapLocationCoordinates()
method, which updates selected location coordinates and the model
- add MapLocation::setCoordinateNoEmit() that does not emit
a signal when updating a coordinate

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-09 12:40:25 -08:00
Stefan Fuchs
2bfcc5554f Tidy up code for cylinder remove decision in cylindermodel.cpp
Replace currentMode() != ...:NOTHING with equivalent in_planner()

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-30 21:45:56 +01:00
Dirk Hohndel
9ef9c3efc0 Respect autogroup in Subsurface-mobile
After we download new dives we need to try to autogroup them.
In Subsurface this is done when we refresh the dive list. Here
we might be better off doing it right after processing the new
dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-23 15:15:17 -04:00
Stefan Fuchs
96d2e57843 When removing a cylinder completely fill the mapping table
When deleting a cylinder the mapping was not filled with all
necessary values. Values for cylinders before deleted cylinder were
missing.

Plus do the endRemoveRows at the right time.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-21 15:33:57 -04:00
Dirk Hohndel
27c49fe3ad Silence random warnings
None of these seem to point to actual issues, so let's quiet them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20 17:25:18 -04:00
Stefan Fuchs
748bb90a73 Update dive planner points cylinder names also when cyl is added
Amendment to c29456f0bb

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-20 07:55:18 -04:00
Stefan Fuchs
93e2bda070 Do cylinder renumber for dive data points only when in planner mode
Amendment to 73d2ab8099

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-20 07:55:18 -04:00
Stefan Fuchs
27a8fd51ed Planner: Autom. move first datapoint gas to first gaslist position p2
This is a amendment to 24bd5a8dce

Move the cylinder also to first position if first planner datapoint
cylinder change because a row is added or deleted to the dive datapoints.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 23:20:44 +02:00
Stefan Fuchs
4158a4c7de init_deco correctly identify previous dives and report overlapping dives
When changing the date/time of a dive in the planner the dive may end
up in a totaly new position in respect to date/time of other dives in
dive list table. It can be moved to the past or the future before or after
other existing dives. It also could overlap with an existing dive.

This change enables identification of a new "virtual" dive list position
and based on this starts looking for previous dives.
Then it (as before the change) does init the deco calculation with any
applicable previous dive and surface interval.
If some of these applicable dives overlap it returns a neg. surface time
which is then used in the planner notes to prohibit display of results.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 23:19:13 +02:00
Robert C. Helling
432110ac8f Find current gasmix for heatmap
To compute the heatmap value, we need the current gasmix but
the current cylinderindex is no longer available.

Fixes #562

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-18 06:34:15 -04:00
Stefan Fuchs
bfe52f6689 Correctly name member function gasChange of DivePlannerPointsModel
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
24bd5a8dce Planner: Autom. move first datapoint gas to first gaslist position
In the planner it is best practise to start the dive with the first
gas in the gaslist. Otherwise one would get a gaschange event at the
very beginning of a dive.
This change implements the following feature:
Automatically move a gas to position 0 in the gaslist if the user selects
this gas for the first dive data point.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
73d2ab8099 Update diveplannerpoints cylinderidx when deleting a cylinder
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
c29456f0bb Used gas in dive planner points: Support for multiple cyl with same gas
In the planner if one adds two or more cylinders with the same gasmix
(e.g. back gas and bottom stage 18/45) the drop down and data in the
used gas column of the planner points table will be filled with a more
verbose string mentioning also the cyl number and the cyl type
description.
Makes it easier in such a case to select the right cylinder.

Introduces also a helper function which tells you if there is another
cylinder with the same gasmix as the provided cylinder.
This also has an option if it should consider unused cylinders or not.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
8fd1c72f04 Removing cylinders in planner: Be more restrictive
Be even more restrictive regarding which cylinders can be removed from
the cylinder table in the planner.
Only if a cyliner is not used in the planned part of the dive
it can be removed.
It doesn't matter if there is another cylinder with same gasmix.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
78cda85444 Display units in dive list table based on prefs option
Add a preferences option which enables or disables display of units in the
main dive liste table.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-09 11:49:29 +03:00
Stefan Fuchs
cf409b59ba Planner settings ascend and descende rate: Wire up UI elements correctly
Wire up the UI elements (QSpinBoxes) for ascend rates (4x) and descend rate
(1x) correctly so that the profile and calculation is updated immediately
after the value is changed (e.g. increased/decresed by 1) by clicking
the QSpinBox arrows.
Until now one had to click into the profile or change another planner
preference first before the change became effective.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-04 08:41:10 +02:00
Lubomir I. Ivanov
e3118d915c divelist: prevent a crash for missing column width
The `static int defaultWidth[]` definition in divelistview.cpp
could potentially end up missing an element which can later result
in out-of-bounds access when iterating through the list of
columns and updating their widths.

Add a couple of methods in DiveTripModel for setting and getting
the widths and use those. The default values are now pre-set in a
QVector in the DiveTripModel() constructor.

Throw warnings if out-of-bounds columns are requested.

Reported-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-03 15:43:03 -07:00
Tomaz Canabrava
d5ab03ef4e [Divesite] Hook qt model for country
See #144

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 09:52:58 -07:00
Stefan Fuchs
7713c7e607 Use helper function dive_endtime() where apropriate
Calculating dive.when + dive.duration doesn't always give the correct
endtime of a dive especially when a dive has surface interval(s) in
the middle.
Using the helper function dive_endtime() fixes this issue.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-01 23:55:37 +03:00
Robert C. Helling
5b080bedde Remove option to apply GFlow at maxdepth
This option should have never been there. This is not how
gradient factors are supposed to work. It would only trick
users to use the wrong value..

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Robert C. Helling
a6f186279f Add a checkbox to turn off plan variations
... as those come with a performance penalty

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Robert C. Helling
58b7c6f8ef Don't comput plan variations when not in the planner
Fixes #565

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-16 08:36:59 -07:00
Robert C. Helling
aed5b7d267 Show variations in Runtime string
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
2832141d2c Compute variations of plans
Print out partial derivatives of stop times with respect to
variation of depth and duratin of last manual segment.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
e6545a7b0f Store a table of deco stops in planner
... in addition to struct diveplan which combines all kinds
of information

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
82aac4efff Make plan take dive and decotimestep as arguments
...rather than use a global variable and a macro.

This should be a no-op in preparation to allow planning
several versions of a dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Linus Torvalds
2fa66f7ab1 Tweak the "display_unused_tanks" preferences logic
This is really unrelated to my recent "multiple gas pressures" work, but
the test case from Gaetan Bisson showed that the logic for which
cylinders to show in the equipment tab was less than optimal.

We basically used to show only cylinders that were actively used, unless
you had the "display_unused_tanks" preference option set.  That comes
from some dive computers reporting a *lot* of cylinders that the diver
really doesn't even have with him on the dive.  And showing those extra
dummy cylinders gets pretty annoying after a time, which is why we
default to not showing unused tanks.

However, in Gaetan's case, he had a total of four cylinders on the dive:
the O2 and diluent bottle for the rebreather dive, and then bailout
bottles (both air and deco).  And while the bailout bottles weren't
actually used, Gaetan had actually filled in all the pressure details
etc for them, and so you'd really expect them to show up.  These were
*not* just some extraneous default cylinder filled in by an over-eager
dive computer.

But because the bailout wasn't used, the manual pressures at the end
were the same as at the beginning, and the "unused cylinder" logic
triggered anyway.

So tweak the logic a bit, and say that you show cylinder equipment not
only if it has been used on the dive, but also if it has any pressure
information for it.

So the o nly cylinders we don't show are the ones that really have no
interesting information at all, except for possibly the cylinder tank
type itself (which is exactly what the over-eager dive computer case
might fill in, usually in the form of a default cylinder type).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-30 21:28:38 -07:00
Dirk Hohndel
dff6c001d7 Map: mark function as override
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28 22:03:22 -07:00
Dirk Hohndel
c59cdd6efd Switch new files to unix line endings
I thought we had this automated, but Lubomirs commits introduced a few
files with dos line endings. This is purely a change of line endings, no
other changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28 22:01:36 -07:00
Lubomir I. Ivanov
69f8fc3c5b map: whitespace cleanup in QML and C++ files
- remove ";"s
- remove {} where not needed or move them to the same line

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
f6e269c07a maplocationmodel: fix getMapLocationForUuid()
This method did not return NULL properly if a MapLocation does
not exists in the list.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
0955a5b36a maplocationmodel: use READ method selectedUuid
Also emit the selectedUuidChanged signal.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
2dea6f5146 maplocation: add helpers for coordinate and uuid
getRole() returns a QVariant and the cast is a small overhead.
Using these helpers will reduce the overhead.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
be0d513324 maplocationmodel: add the "namer" property
The MapLocation QObject now has a QString property "name", which is
translating the dive_site->name member.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
e79eac3335 maplocationmodel: fix some public / private declarations
Make the m_* variables private.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
5ea702199b maplocationmodel: make setSelectedUuid() accept "fromClick" flag
The idea of this flag is to be able to only to emit the
selectedLocationChanged() signal when the user clicked on the map
(fromClick == true).

MapWidgetHelper::selectedLocationChanged() listens for this signal
and only then it will select nearby dives based on a "small-cicle".

If "fromClick" is false, it's the backend or the dive list that
updated the selection and MapWidgetHelper::selectedLocationChanged()
should no be called.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00