Commit graph

333 commits

Author SHA1 Message Date
Dirk Hohndel
71d21c375c Recalculate the decompression if the date / time of a dive changes
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>
2014-10-20 17:40:11 -07:00
Dirk Hohndel
e1db94ea0c Correctly edit dive date/time when editing manually entered dives
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>
2014-10-20 17:34:53 -07:00
Gaetan Bisson
ae6b0468b1 Report CNS in dive info tab
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>
2014-09-18 06:16:44 -07:00
Tomaz Canabrava
214bd0ed6e Re-enable the edition of the Date after editing a trip.
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>
2014-08-23 08:10:47 -07:00
Dirk Hohndel
4a04fc2a1b Fix selection logic when manually adding a dive
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>
2014-08-21 17:58:15 -07:00
Dirk Hohndel
0f1381f160 Planner: assign a dive number if the right number seems obvious
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>
2014-08-18 14:12:05 -05:00
Dirk Hohndel
29f50c6aee Cut'n'paste for dive data: implement paste side
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>
2014-08-17 11:58:11 -06:00
Dirk Hohndel
c58d136d33 Dive edit: allow the user to explicitly clear a GPS location
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>
2014-08-16 07:09:11 -06:00
Dirk Hohndel
ee77398eb8 Reload the dive list after accepting changes
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>
2014-08-07 10:23:08 -07:00
Tomaz Canabrava
68af9f0afb Delete pictures from the Widget by pressing delete
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>
2014-08-06 18:32:28 -07:00
Linus Torvalds
3aaf8b1f5a Make gas use statistics be coherent and more complete
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>
2014-08-06 09:14:34 -07:00
Dirk Hohndel
74e7b8e879 Don't show a SAC of 0.0l/min (or cuft/min)
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>
2014-08-06 07:39:19 -07:00
Tomaz Canabrava
f9d38100c4 Hide Depth Column
We were showing everything, always.

Fixes #639

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05 14:42:56 -07:00
Dirk Hohndel
78fee70450 Correctly remove the Close button from most message widgets
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>
2014-08-04 22:45:17 -07:00
Tomaz Canabrava
e95fa6c6dc Disable the Toolbox when in edit mode.
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>
2014-08-04 09:48:35 -07:00
Robert C. Helling
1508f95775 Update pictures when entering/exiting planner
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>
2014-08-02 15:13:51 -07:00
Dirk Hohndel
13d922aef7 Keep edited profile after editing a manually added dive
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>
2014-07-31 14:41:30 -07:00
Dirk Hohndel
1a978a0345 Maintab: fix trip location / notes editing
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>
2014-07-30 08:52:11 -07:00
Dirk Hohndel
d262886a2d Fix time zone conversions
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>
2014-07-29 13:01:46 -07:00
Dirk Hohndel
95466cb245 Sort dive table after adding a dive
The dive might not be the newest dive in the dive list.

Fixes #637

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24 08:20:34 -07:00
Tomaz Canabrava
f6f2c4e929 Only repopulate the dive info once ( we were repopulating 4 times )
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>
2014-07-23 08:10:10 -07:00
Tomaz Canabrava
99922722d2 Only use HTML if the text has a <table>
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>
2014-07-23 08:09:58 -07:00
Dirk Hohndel
b3e662a895 Pick the correct timezoneoffset for the day in question
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>
2014-07-16 20:24:56 -07:00
Tomaz Canabrava
bebcbfe92a Desselects the trip before dive add / plan, and reselects it on cancel
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>
2014-07-16 16:08:22 -07:00
Tomaz Canabrava
bf7fc97b50 Fix saving and storing the dive plan notes when there's html on it
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>
2014-07-16 15:51:13 -07:00
Sergey Starosek
14cc59898a Date picker l10n for profile and planner
- 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>
2014-07-16 13:58:06 -07:00
Sergey Starosek
dcca755343 More strings to translate for statistics tab
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 13:26:41 -07:00
Dirk Hohndel
0cf55d7e39 Correctly track the 'changed' status of the equipment widgets
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>
2014-07-15 20:36:25 -07:00
Dirk Hohndel
327ea3aca4 Dive equipment edit - fix logic for applying changes
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>
2014-07-15 20:29:14 -07:00
Tomaz Canabrava
4c8e9615e4 Remove uneeded function
This method was being unused, rip it off.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15 17:05:46 -07:00
Tomaz Canabrava
d993684fec Do not create a backup for Q_FOREACH container
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>
2014-07-15 16:55:10 -07:00
Tim Wootton
3a16a64616 misc capitalisation and spelling
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 07:06:26 -07:00
Tim Wootton
8940f29ead Prefer "temp." vs "temp" and sometimes "temperature"
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>
2014-07-10 16:30:56 -07:00
Tim Wootton
5c5168cf17 maintab capitalisation consistency
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 16:26:30 -07:00
Dirk Hohndel
a8a8bcd86a Add helper functions to ensure we have sane tag lists
There should never be empty or duplicate tags on those lists.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 09:42:28 -07:00
Gaetan Bisson
35121e1147 Complete GPS coordinates on location focusout.
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>
2014-07-09 09:40:44 -07:00
Tomaz Canabrava
6480a91756 Put a copy of the tags in the displayed dive upon save.
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>
2014-07-09 08:53:06 -07:00
Tomaz Canabrava
dbc33cb81a Correctly save the tags on the dive.
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>
2014-07-09 08:34:00 -07:00
Tomaz Canabrava
0054304cc8 Remove if to save or not save the tags.
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>
2014-07-09 08:33:21 -07:00
Gaetan Bisson
c054b18b70 make GPS coordinates autofilling really work
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>
2014-07-08 10:02:17 -07:00
Dirk Hohndel
cd5b2a372f UI restructure: cleanup the code when canceling an edit
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>
2014-07-06 12:50:30 -07:00
Miika Turkia
0c24d7d6bd Show the gas mixing information only when needed
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>
2014-07-05 22:55:52 -07:00
Dirk Hohndel
aafd918169 Add dive: don't throw away the pressure data entered
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 #582
Fixes #553

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04 11:48:02 -07:00
Dirk Hohndel
da911993f1 Small cleanups
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>
2014-07-03 21:05:08 -07:00
Gaetan Bisson
6a57ce5c6b Autofill GPS coordinates for added dives.
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>
2014-07-03 17:59:09 -07:00
Dirk Hohndel
611bae3441 UI restructure: use displayed_dive for add dive and plan dive
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>
2014-07-03 14:45:01 -07:00
Dirk Hohndel
6b1b2bc919 UI restructure: get rid of "current" pointer in cylinders and weights
Instead always display the display_dive.

Now the only thing left to slay is the stagingDive...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
a86aca0378 UI restructure: only switch to edit mode if user made change
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>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
66870add77 UI restructure: track if any data was modified
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>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
20d9fafd7c UI restructure: improve memory handling in maintab
Free strings before overwriting them. Use copy_dive() instead of just
copying the dive structure.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:55 -07:00