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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
...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>
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>
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>
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>
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>
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>