The pre-existing tissue load going into a dive can change if the start
time of a dive changes. Therefore we need to recalculate the ceiling when
editing start time (or date) of a dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While the existing code worked fine for editing that start date or time of
dives downloaded from a dive computer or imported from some other source,
for manually entered dives this did not work and the date or time was
always reset to the original time once the changes were saved.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds a maxcnsText widget under infoTab and populates it.
Note that I manually edited maintab.ui to display CNS and OTU
next to each other and right after gas data.
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we can't edit the trip date, we need to remember to
re-enable it after we disable it.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was an interesting bug. When adding a dive that would end up in the
middle of the dive list, the newest dive in the dive list would end up
marked in the dive structure as selected - even though it wasn't
visualized as selected by Qt. Bad things happen if the user then made
changes to that dive without selecting something else first, for example
by either editing the dive or doing things to it like removing it from or
adding it to a trip. The same operation would also be applied to the
newest dive in the dive list.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use the same logic as we do for newly added dives.
As a side effect this patch appears to fix the issues with getting the
newly planned dive selected.
Fixes#692
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should correctly set all the values and puts us in edit mode.
Testing so far looks good for both single dive and multiple dives selected
(i.e., you can paste into multiple dives).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the GPS coordinates for a dive were incorrect for some reason and the
user wanted to clear them in order to then re-download / apply GPS
information from the Subsurface webservice, prior to this patch we would
always match the location name and re-populate the GPS coordinates, making
it impossible to clear a GPS location without also changing the location
name.
This patch fixes this - but if you have multiple dives with the incorrect
name / GPS location pair, the next edit to a dive that had the GPS
coordinates cleared will re-populate the GPS coordinates (at that point
Subsurface can no longer tell that this was intentional).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far we only did it when we added a dive or modified a manually added
dive. But the reality is that an edit of any dive could cause changes that
require the dive list to be reloaded.
Fixes#698
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Select the picture, press delete, profit.
[Dirk Hohndel: removed the stray hunk that snuck into this patch]
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The gas use logic in the dive statistics page is confused.
The SAC case had a special case for "unknown", but only for
the first gas. Other gases had the normal empty case.
Also, the logic was really odd - if you had gases that weren't used (or
pressures not known) intermixed with gases you *did* have pressure for,
the statistics got really confused.
The list of gases showed all gases that we know about during the dive,
but then the gas use and SAC-rate lists wouldn't necessarily match,
because the loops that computed those stopped after the first gas that
didn't have any pressure change.
To make things worse, the first cylinder was special-cased again, so it
all lined up for the single-cylinder case.
This makes all the cylinders act the same way, leaving unknown gas use
(and thus SAC) just empty for that gas.
It also fixes the SAC calculation case where we don't have real samples,
and the profile is a fake profile - possibly with gas changes in between
the fake points. We now make the SAC calculations match what we show -
which is admittedly not at all necessarily what the dive was, but at
least we're consistent.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we have no data about the gas consumption it makes no sense to show a
SAC of 0. Instead we should show either "unknown" or nothing.
Fixes#693
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The only time we want the close button is when showing an error at the
bottom of the main window.
In the other cases (maintab, globe) we need to explicitly hide it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some of the toolbox icons will trigger a recalculation of the dive,
triggering then a replot, that will copy the dive to the displayed_dive
again, but in the case of a edit this would discard the edition (
that would still be shown on the UI ) leaving the dive in an
unconsistent state.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fixes the problem I pointed out im my comment to #667 and hopefully also
the original problem although I cannot confirm since i cannot reproduce the
problem in the first place.
See #677
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is yet another unintended side effect of the UI restructure changes.
I stared at this code for so long - I can't believe I kept missing this.
Fixes#668
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reusing the displayed_dive for this caused all kind of odd problems that
were hard to reproduce, because the behavior depended on what was in the
corresponding fields of the current_dive. Worse: the GPS location handling
prevented us from reliably removing the location of a trip.
The solution isn't ideal and certainly isn't elegant. Maybe we simply
shouldn't reuse the widget here. But I think what I have now works - I
tried hard to make it break again and couldn't.
Fixes#659
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I know I tested this - no idea how I missed this.
Anyway, this was of course utterly bogus. Whenever we get a time from a
time_t into a Qt Date or Time datastructure, we need to adjust it by the
timezone offset as otherwise Qt will assume it's in local time and
helpfully change it to the wrong values for us.
See #655
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes the screen repopulate itself after a dive change only
one time instead of the old 4. we were repopulateing when we
removed the actual selection to reset the old selection previously
stored, sigh.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The text we generate for the diveplan has a table inside, and
we must use HTML only for the dive plan. so I treat all text
as HTML, look for a table item, if it doesn't have, I treat
it as Simple text and set it on the notes. Works and makes
linus loves me again.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Calculating the timezoneoffset for the current date really makes no sense
whatsoever when displaying a time that isn't "now".
Fixes#605
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we had a trip selected, we ignored that and simply called
the DiveAdd functions, but the mainTab code that deal with selections
to show one or more dives or trips asked how many trips were selected
to the DiveList, and since a trip was selected things go kabum.
Fixes#606
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We save an HTML table-based plan, so we need to get the text as html,
not plaintext.
Fixes#634
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- set application-wide locale from preferences
- use custom date format for display
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
updateDive() cannot reset the changed status - this is called while the
dive is edited. Instead this status is reset when the user either accepts
or rejects the changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We keep getting this wrong. First you check all selected dives that are
not the current dive, make sure the equipment was the same before the edit
and then apply the changes. Then, when you are done with ALL of them, then
you change the current dive. Otherwise you cannot compare to the 'before'
state anymore.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Q_FOREACH will expand and already creates a copy of the
contained container, so this is just a waste of cpu cycles
and also increases a tiny bit the memory consumption.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For consitency in the UI
There are plenty more of these to find, and once in a while
"Temperature" looks more apropriate, like in a title, but most
of the time "temp." works best.
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Introduce on_location_editingFinished() and move the GPS coordinates
completion logic there. This simplifies acceptChanges(), but replaces
the clever code for multidive completion by something a little more
straightforward.
Note the call to on_location_editingFinished() from acceptChanges();
without it, completion only happens *after* the dive has been saved.
[Dirk Hohndel: trivial merge, minor changes for consistency]
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I don't think this is the right approach, but it makes things work. The
reason that it was not working before it's because upon save we are not
copying the edited dive against the displayed dive for some reason, and I
didn't find the place that should deal with that.
This fixes one of the various issues around tags, but others remain.
Fixes#587
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Very good patch, lots of removed lines. :)
Only try to add the tags when user accepts, discards the
test to see if the tags were changed or not, delete the
old list and copy the new one always.
only bug that's appearing now: taglist is still empty after save
we need to reselect the dive to make it appear, fixing that
on the next patch.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The way that we work with tags is a bit weird, we have a global
tag_list pointer and every dive copy the tags from there. the problem
is that the tags_changed() function looks at those two places ( the
global and the dive-local lists ) to see if something was changed,
but we shouldn't add anything at the global taglist untill a tag
is really added, so that function is bogus.
The correct way to check if something changed is to check all the
strings in tags against the strings in the QLineEdit and see if they
are the same, then we can add things to the tag_list.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Move the gpsHasChanged() call on selected dive when coordinates have
changed *before* autofilling, otherwise it erases the autofilled values.
Also update displayed_dive when autofilling, otherwise values are stored
but not displayed immediately after saving.
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was way too complicated because we used to edit a "live" dive that
was on the dive list. All we really need to do is systematically make
sure that all the widgets are in the correct state.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Recreational divers, especially ones diving with air, do not need to be
shown that their gas can be mixed with 0 liters of O2 and He. And
similarly Nitrox diver does not need to know about 0 liters of He.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we were trying to get rid of the tracked gas pressures that
were added when using the plan infrastructure to create a dive. Now that
this isn't the case anymore we can stop doing that which magically makes
setting start and end pressure while adding a dive work as expected.
Fixes#582Fixes#553
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add commented out options to subsurface.pro that enable debuging the planner.
Remove obsolete comment.
Clean up the selection tracking.
Force the re-sort of the divelist inside the reload instead of explicitly
calling it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Prior to commit 95cb4e, when a new dive was added with the same location
name as a previous dive, the GPS coordinates for that new dive would be
automatically set to that of the matching previous dive.
This restores this feature, by duplicating code further down
qt-ui/maintab.cpp that handles the case where multiple dives are
modified at once.
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This gets rid of the stagingDive and stops the constant adding and
removing of dives from the divelist (that was an INSANE design,
seriously).
When adding or planning a dive all work is now done in the dedicated
displayed_dive.
Add dive mostly works - when the user clicks save the dive is added to the
dive list and selected.
Plan dive is mostly untested. It passed trivial "start planner, save"
testing so it's not entirely broken, but I'm sure there's more work to be
done there.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With this patch a simple click into the main tab does not start editing
mode. Only once a value is modified do we show the message box and disable
the other widgets.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of comparing the dive structures (which doesn't work since the
strings are actually copies), track if the user made changes.
Cylinders and weights still need to be compared as they are handled in
different widgets.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>