Commit graph

479 commits

Author SHA1 Message Date
Tomaz Canabrava
42afb4972a Pass a fake dive site UUID to the callback.
This is the start of the preparations to edit the dive site,
passing a uuid so we can retrieve it later.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11 16:34:02 -08:00
Tomaz Canabrava
68691c9d6d Accept / Cancel location edit
Make it possible to cancel or accept the location edit and
get back to the mainwindow default state.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11 16:34:02 -08:00
Tomaz Canabrava
7d66dcd12d Enable the location edit widget on mainwindow
Clicking on the 'Manage' button now brings you to the widget to manage it.
Nothing has been added on it yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11 16:34:02 -08:00
Tomaz Canabrava
194dd8bd97 Finish the cleanup of mainwindow.ui
This is the last patch in the series of clearing up the
mainwindo.ui. Now to bugfixing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:46 -08:00
Tomaz Canabrava
6b038c2a9a Remove the ProfileWidget from mainwindow.ui
It is now in mainwindo.cpp

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Tomaz Canabrava
c30aee1ae5 Remove the Globe from the mainwindow.ui
Now it's started from mainwindo.cpp and it's part of the
new states

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Tomaz Canabrava
cf4d55c470 Remove the DiveList from the mainwindow.ui
It's now set up from the mainwindow.cpp file.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Dirk Hohndel
585d6a004b Only update tags in the selected dives if they were changed
If current_dive and displayed_dive still have the same tags then we
shouldn't touch the tags of other selected dives.

Fixes #826

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 06:31:37 -08:00
Miika Turkia
414b9807e6 Do not go to edit mode if nothing changed
Fixes #804

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-02 07:06:56 -08:00
Robert C. Helling
1e45858ee6 Update ceiling when changing dive mode
Without this patch, the user effectively cannot change the dive mode as
any change is overwritten by replot copying current_dive over
displayed_dive. The way out is not to call replot but only update the deco
ceiling directly.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-31 14:09:50 -08:00
Gehad elrobey
f16f4e2f6e Don't go to edit mode if the dive notes field didn't change.
The maintab view should be consistent; some fields just go to edit mode
whenever they acquire focus and most of them wait till their values are
changed.

Change the dive notes field to be consistent with the other fields and
only enter edit mode if its value is changed.

[Dirk Hohndel: changed to use same_string()]

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-30 17:03:03 -08:00
Anton Lundin
991531d847 Let notes expand to full with fbsupport off
This hides the whole QWidget with the share-to-fb button in it. This
lets the Notes field expand to the full width.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-28 07:36:34 -08:00
Dirk Hohndel
1b3c776358 While editing the coordinates we need to compare to the displayed_dive
Comparing to the master dive only made sense when we immediately modified
a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-19 21:03:42 +12:00
Dirk Hohndel
df46b85ee1 Don't just change the location when double clicking on the globe
Instead be consistent with other parts of the code and put us in editing
mode so the user can accept / reject the change.

See #800
Fixes #801

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-19 17:38:17 +12:00
Dirk Hohndel
83018619d6 Always updated the coordinates from the displayed_dive
That's why it's called the displayed dive...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-19 17:17:01 +12:00
Dirk Hohndel
f9ceff009b Clean up the header files
Lots and lots and lots of header files were being included without being
needed. This attempts to clean some of that crud up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-18 21:25:59 +12:00
Dirk Hohndel
abddb3ecb9 Make Facebook support a config option
By default it is turned off, turn on by calling qmake with
CONFIG+=FBSUPPORT.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:43:49 +13:00
Robert C. Helling
f2939dd991 Minor PSCR fixes
Update O2 metabolsim rate and adopt default gas switch depths to
pSCR oxygen drop.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:17:29 +13:00
Dirk Hohndel
bccbdf8264 Don't use current_dc unless you know there's a current_dive
This will crash if for some reason current_dive is invalid.

And in general, when displaying information, we want to use the correct dc
in the displayed_dive, not the current_dc, which references the
current_dive...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-11 07:29:29 -08:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Robert C. Helling
bfe05b4340 Replot after changing divetype
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:24 -08:00
Robert C. Helling
0f7f2195d5 Add setpoint events according to divetype
When changing to a CCR dive, add a setpoint change to the default setpoint
at the beginning of the dive. Otherwise add an explicit setpoint change to 0
.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:24 -08:00
Robert C. Helling
a478eb5711 Maintab combobox to set dive type
still needs some work

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:24 -08:00
Miika Turkia
9e2e62ec4f Initialize edit hack variable
The accepting mode variable must be initialized to false to allow
editing of dive data.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-04 23:19:52 -08:00
Miika Turkia
fdd152af71 Make sure we do not fall back to edit mode on accept
On Ubuntu 14.04 the edit mode does not exit successfully when applying
the changes. It instead jumps back to edit mode (even though hiding the
option to apply/discard changes again). So let's just have a flag to
prevent faulty behavior.

Fixes #786

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-04 10:53:10 -08:00
Dirk Hohndel
71f3a29819 Trip editing: zero out potential previous edits
This was silly; if we rely on this to be zero to indicate no change then
we better zero it out when we start editing.

Fixes #805

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-04 06:43:36 -08:00
Dirk Hohndel
ccfea0872d When editing trip data, only copy actual changes
We zero out the displayedTrip and only copy changed data into it; so a
NULL value is not deleted text, it means there was no change.

Fixes #805

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-03 16:06:00 -08:00
Dirk Hohndel
57b49a7833 Fine tune some spacing
Now that we set the margins everywhere, the manual corrections here aren't
needed. At the same time, the spacing for the labels looks better if it is
a tiny bit more generous.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-02 22:24:50 -08:00
Tomaz Canabrava
ed903c42b9 Facebook integration: Always ask for a folder before sending the photo
This way we are sure that the upload was made in the correct folder.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29 09:05:53 -08:00
Tomaz Canabrava
571f86485d Move the Facebook send profile button
Move from the Dive List context menu to the Dive Info tab, it will only
appear when connected to Facebook.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29 09:05:08 -08:00
Dirk Hohndel
87febd33be Carefully create some forced margins
We don't want to waste space, but we don't want things to be too crammed
together, either. Especially not having horizontal margins for text can
look very awkward.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-23 10:16:11 -08:00
Tim Wootton
93d59c22d7 Match agreed captalisation style
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 07:57:33 -08:00
Dirk Hohndel
bf14d31804 Make the button labels for apply / cancel of edits more consistent
Before you could 'Cancel' the edit and then would be asked if you wanted
to 'Discard' your changes or 'Cancel'. So clicking 'Cancel' cancelled the
action of having clicked 'Cancel'. That's so confusing, it's even hard to
explain. Yes, it uses "typical" language for user interaction and kind of
makes sense, but it's not easy to understand for the non-technical user.

With the new labels the user is asked to whether they want to 'Apply' the
changes or 'Discard' them. And when they choose 'Discard' the verification
question is still 'Discard' or 'Cancel'. That seems much more consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-23 07:45:17 -08:00
Dirk Hohndel
3ddbab6847 Clarify the meaning of the values in the stats tab
Extend the tooltips to be shown both on the labels and the values and add
tooltips for all min/avg/max elements.

To avoid confusion when only one dive is selected, no longer show min SAC
or max SAC or min duration or max duration.

Fixes #694

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 18:44:51 +00:00
Dirk Hohndel
0c3f13d128 Add the ability to modify the cylinder use in the UI
Thanks to Tomaz for writing a first draft of the delegate.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 14:03:37 +00:00
Dirk Hohndel
44a154f7da When editing cylinders, copy all relevant data
Maybe it would be better to just copy the whole structure and then clear
the things we don't want to copy? This seems fragile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 10:45:14 +00:00
Dirk Hohndel
7196176fa0 Correctly copy weight systems on edit
We copied the string pointers instead of copying the strings. Once those
got freed, things went downhill.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 10:41:02 +00:00
Tomaz Canabrava
82a946152b 727 fixed
--047d7b8737f87ede8e050803e6b2
Content-Type: text/plain; charset=UTF-8

<div dir="ltr"><br></div>

From 3db4a422485374801ca2f6233ec23b8671a8656d Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabrava@intel.com>
Date: Sun, 16 Nov 2014 23:22:58 -0200
Subject: [PATCH] fix 727 - position correctly the popup.

When the user entered a tag and that made the message box display
the popup with the possible choices was still in the old position
hidding the line edit.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 06:02:21 +00:00
Lubomir I. Ivanov
200699706e maintab.cpp: use copy_string() instead of strdup()
The .location and .notes fields can end up being NULL,
in which case copy_string() is safer.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-11 11:59:35 -08:00
Anton Lundin
0b0e5d834f Reorder initializers to be more c++-strict
c++ have some idea about in what order things should be initialized.
This makes us comply with that order.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:17:11 -08:00
Dirk Hohndel
45251ec724 Show extra data in separate tab on MainTab
This way any extra data probided by the dive computer is visible to the
user (without other processing). This data cannot be edited by the user as
it reflects the information given by the dive computer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 13:00:58 -08:00
Dirk Hohndel
d643bde61a Always copy data in copy and paste mode
While in a multi dive edit we want to apply our usual semantics (only edit
things that are the same as in the current dive), when doing an explicit
copy and paste that doesn't seem to make sense. So we manually override
that behavior.

Fixes #753

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-05 07:13:20 -08:00
Dirk Hohndel
c9e7528370 Change tank editing behavior for multi dive edit
Previously we only applied the type of tank (description, volume, working
pressure) to all selected dives where the tank description matched.

With this patch we also copy the gas mix into all matching cylinders.

Additionally this addresses the issue that we should have a separate copy
of the cylinder description string for each dive.

Fixes #754

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04 15:05:16 -08:00
Dirk Hohndel
dfc7ee0b29 Delay replot of dive so changes aren't overwritten too early
When changing tanks we triggered a replot - but that overwrote the
displayed_dive with the current_dive before the remaining data from the
displayed_dive was used to edit the current_dive.

So now we delay this until later in the function, this way copy of paste
of both tanks and weights works.

Fixes #753

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-03 09:47:24 -08:00
Dirk Hohndel
6ce0afb99c Don't call strdup on NULL by mistake
Hunting down a different issue I managed to cause a crash here when trying
to copy a string that ended up being NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-01 22:36:42 -07:00
Dirk Hohndel
fa5c713f73 After editing tags, get the right tags into the displayed dive
We forgot to clear out the pre-existing tags. We did this for the actual
selected dives that were being edited, but not for the displayed_dive, so
deleted tags showed up again on screen (even though they were correctly
deleted from the selected dives in the dive list).

Fixes #732

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-30 13:03:50 -07:00
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
Dirk Hohndel
56501dda1e UI restructure: updateDiveInfo displays displayed_dive
Instead of passing in a divenr of -1 to make it clear things this changes
things to use an options "clear" flag.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
635a7ab771 UI restructure: updateDiveInfo shows the selected dive by default
So don't be redundant.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
a221a6e9f5 UI restructure: use a global variable to hold the dive we show / edit
There is massive confusion about what we display when and where and which
dive structure (or pointer to a dive structure) contains which information
at which stage. This is the first step towards restructuring all of this.

This creates a global variable displayed_dive which at any point in time
should be what is displayed on screen (both in the profile and in the
maintab). It removes the editedDive concept from MainTab.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-02 11:56:36 -07:00
Dirk Hohndel
81f8ed901f Add dive: remove cylinder pressures from samples
These cylinder pressures are actually just artefacts of the way we track
gas consumption in the code shared between planner and add dive. We don't
want them in the actual dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01 10:28:42 -07:00
Dirk Hohndel
8bd16a7808 Equipment edit: for some reason we need a local copy of index
Calling enableEdition appears to corrupt the index that is passed into
this slot.

This doesn't fix the problem that we can't edit the cylinder start and end
pressure of a manually added dive, but at least we no longer try to edit
and invalid index.

See #582

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01 10:18:21 -07:00
Anton Lundin
b2288e1e3d Calculate approx gas bill on dives
This uses a bit of naive gas computations to figure out how much of
different base gases you used up on the dives the statistics is done for.

It's quite useful to get a minimum line about how big your gas bill is
going to be after a dive trip.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-29 17:15:09 -07:00
Dirk Hohndel
3ef490fe11 Fix crash when cancelling a trip edit
We were comparing the wrong data and freeing things that shouldn't be
freed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28 13:42:38 -07:00
Sergey Starosek
e88f37d327 Start external viewer on photo double-click
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 06:56:21 -07:00
Dirk Hohndel
a925e677f1 Correctly use our "localtime"
We use time stamps without timezone, so we need to correct for the current
time zone offset before showing dates and times in time zone aware
widgets.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26 16:05:48 -07:00
Tomaz Canabrava
81fd56b16f Fixed changing dates with the new date widget.
The maintab was connecting with an invalid slot on the
new date widget, QDateTime instead of QDate

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26 15:48:49 -07:00
Tomaz Canabrava
1e2349e794 Added code for TimeEdit
This makes the TimeEdit work again.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26 15:48:33 -07:00
Tomaz Canabrava
89816f64c2 Headers cleanup.
Too much noise on the headers, this commit remove uneeded
headers when they are uneeded.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26 15:47:02 -07:00
Tomaz Canabrava
0223ebf510 Added the new Date Widget on the MainTab.
the new date widget still needs a bit of work, but the
design is working already.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20 15:41:42 -07:00
Tomaz Canabrava
867d9f1391 Simplify code
If a class inherits QObject, it doesn't needs to call
QObject::tr for the tr function.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20 15:41:35 -07:00
Dirk Hohndel
a4050c2a71 Don't copy the current dive ontop of editedDive after edit has started
If you switch to edit mode by making a change to cylinders or weights,
then the data in the editedDive was changed and afterwards the current
dive was once again copied into the editedDive - even though we already
did that earlier when setting up the display.

Fixes #539

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-12 13:34:57 -07:00
Dirk Hohndel
f54849987e Remove unused variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 13:18:16 -07:00
Dirk Hohndel
e6fe4760a0 Improve statistic on used gas
This raises the maximum number of gas mixes listed to 20 and also changes
the layout / design of the stats tab to make it much more attractive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 11:45:20 -07:00
Dirk Hohndel
8a0d852a7c Add gas consumption statistic for selected dives
We already did a list of gases and volume consumed for the selected dive
on the Dive Info tab, but did not provide that same data on the Stats tab
for all the selected dives.

I arbitrary limited this to eight gases (as the list can get quite long
when you select a lot of dives). The gases are sorted by volume consumed.

Fixes #535

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 22:48:21 -07:00
Dirk Hohndel
0102604645 Don't show the average depth for the selected dives
Being shown between the deepest and shallowest dive's max depth it
confuses a lot of people - the average depth is frequently less than the
shallowest of the dives, so at first glance it looks like the "average" is
less than the "minimum". So having three numbers grouped like this that
use different algorithms is just distracting.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 20:32:44 -07:00
Dirk Hohndel
95cb4e85ee Dive edit: do a better job noticing when the coordinates were changed
Previously the code could get confused by edits (including trivial things
like deleting the coordinates). It seems much more reliable to simply
compare the coordinates of the edited dive with the ones in the current
dive before the edits.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 10:55:56 -07:00
Dirk Hohndel
37910751a0 Dive edit: avoid memory leaks
If we edit any of these fields, we create new strings via strdup (or a
fresh tag_list). So if the edits are rejected, free all that memory.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 18:12:24 -07:00
Dirk Hohndel
c5437c7499 Dive edit: don't free the taglist of the master dive
We do all of our edits on a copy of the dive - but the tag_list points to
the tag_list of the master dive (based on how we create that copy of the
master dive). So only free the tag_list if it is already different from
the master dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 18:04:39 -07:00
Dirk Hohndel
a12b10c008 Ask before discarding edits
This is equivalent to what we do for the planner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 18:01:00 -07:00
Tomaz Canabrava
eb24d90c8e Add a static 'instance()' member for the Photos model.
This will make referencing it from  a few places more easy.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:40:01 -07:00
Dirk Hohndel
fafaf0eef0 Cancel dive edit when escape key is pressed
Also seems intuitive. What's odd is that in the Planner you get a
confirmation dialog while here you don't. We should be consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 15:31:21 -07:00
Tomaz Canabrava
3595ad0294 Make the new picture widget display the pictures.
Small changes in the model to display the pictures of the dives.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 00:05:24 -07:00
Dirk Hohndel
eb9d6d0f94 Rewrite dive edit logic
The existing code took an odd approach. It tried to change all selected
dives whenever the user edited a field, and kept all this backup data in
case the user rejected the edits.

This code takes the opposite approach. Only edit a copy of the selected
dive and then when the user accepts it, edit all the dives and when the
user rejects the edit simply redraw the screen (as all the "real" data is
still unchanged).

This not only saves quite a bit of code, it should be much easier to get
correct.

Admitedly this code will need quite a bit more testing to make sure it
works as intended, but as far as I can tell it already gets more scenarios
right than the previous implementation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 23:38:36 -07:00
Tim Wootton
d825d689dd Override the MinMaxAvgWidget tool tips for the depth instance.
Add new methods to the MinMaxAvgWidget class to allow us to override the
default tooltips of its min and max icons, and then uses these methods to
make the tooltips for the Stats tab Depth instance more descriptive.

See #521

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 20:20:17 -07:00
Tomaz Canabrava
b601db30ad Fix edition of manually added dives.
This patch correctly sets the state of the planner to "NOTHING"
after trying to edit a manually added dive.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:06:27 -07:00
Tomaz Canabrava
c3306c39f1 Fix crash on adding / removing a dives from add menu
This patch removes some inconsistencies that were happening on the add
dive / cancel actions. a bit of legacy code from the old system was still
in, which made things quite...  EXPLOSIVE.

This fixes restoring the selection only if we have a selection and not
deleting the temporary dive twice.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:03:47 -07:00
Dirk Hohndel
b08969ac33 Dive add: fix crash when canceling
We need to reset the editMode right away, otherwise all the changes to the
input field (when resetting the data after the user cancels) will cause
Subsurface to crash as current_dive will temporarily be NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 20:31:18 -07:00
Dirk Hohndel
f2ecb6d0eb Fix manually adding dive
I'm sure canceling the plan when saving an added dive made sense at some
point for some reason. Right now it makes things crash, so let's not do
it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 16:12:09 -07:00
Dirk Hohndel
b9e9eeb441 No need to separately enable and switch focus to the dive list
RefreshDisplay() does this for us.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:48:38 -07:00
Dirk Hohndel
0d58cfb641 Planner: don't try to update the MainTab dive info while in plan mode
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 15:18:15 -07:00
Tomaz Canabrava
feff22c222 Planner: Re-enable using the new profile.
This correctly enables the planner on the new profile,
but it doesn't triggers the correct paint on the canvas.

[Dirk Hohndel: remove other remnants of the disabled planner as well]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:17:32 -07:00
Dirk Hohndel
5ba573240f Gratuitous whitespace changes
I keep trying to get to consistenct.
Completely hopeless.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 11:40:22 -07:00
Tomaz Canabrava
fe1df6b1cc Back to profile or empty state when finishing addition.
This patch adds a signal to MainTab, that should be removed from there
when we finish the rework on the edit part, to go to the edit classes,
but in the meantime, let's keep it there.

The signal is connected to the ProfileWidget in a way that the end of the
edit will also trigger the profile to go back to ProfileState (show the
dive, if there's any) or empty Profile (if there's none).

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-22 09:12:32 +09:00
Dirk Hohndel
09e7c61fee Consistently use for_each_dive (and use it correctly)
The way the macro is written there is no need to test the dive against
NULL before dereferencing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20 06:37:19 +09:00
Dirk Hohndel
6d42a99e7f Improve the tag widget to allow us to tab to the next field
If the last key that went in ended a tag and the next key is a tab -
deliver that to the TabWidget instead so we can navigate between input
fields.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-18 14:32:15 +09:00
Tomaz Canabrava
2b06e4be67 Move printGpsCoords from MainTab to QtHelper
Last time I touched this I got a scream from dirk, but then I
looked at the code again and the problem that I faced was that
I broke translations in a sad way, well, now I broke it again.

However, this method shouldn't belong to MainTab ( because of
that thingy that I said before and also many others: Separate
the logic of your application from the UI specific code )

This generates a string that's going to be used on the Interface,
it doesn't display it on the interface. Move it down below makes
it easier to test ( I don't need to create an Widget and worry
about the parent-relationship with the mainwindow just to test
this function, for instance. )

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13 09:16:11 +09:00
Anton Lundin
b5cc387f03 Apply the edit of trip locations
This re-adds this code that got removed in a209dfbfd5 ("Multi dive
edit: don't change location texts until user saves the change")

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:18:59 -07:00
Anton Lundin
b59a106251 Only mark location changed when in edit mode
Otherwise the code loading a dive into the field would mark it as
changed.

This re-adds this code that got removed in a209dfbfd5 ("Multi dive
edit: don't change location texts until user saves the change")

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:18:53 -07:00
Dirk Hohndel
94937d2ad9 Improve the color coding when editing coordinates
This still gets it wrong (i.e. marks things as edited when they are not or
not edited when they are) but at least they are no longer incorrectly
marked as incorrectly parsed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
0a6c16f35a Hack around a translation issue
I cannot figure out how to get the hemisphere letters translated correctly
in qthelper.cpp. Short term hack for now - someone who understands how
this is supposed to work really needs to take a look.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
fb82da58a2 Globe: assume that we are looking at the current_dive
As in commit 3870bdafee53 ("Globe: we always center on the current dive")
passing in a specific dive here makes no sense - it's always about the
current dive.

Fixes #513

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:58 -07:00
Dirk Hohndel
2bc76beb65 Globe: we always center on the current dive
Simplify the API (we'll take advantage of this in the next commit).
We always center the globe on the current dive, so no point in passing
that dive in.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 15:17:47 -07:00
Dirk Hohndel
a209dfbfd5 Multi dive edit: don't change location texts until user saves the change
If we keep updating the location text of all selected dives we can lose
the status of which dives had the same text of the original dive and which
did not (this happens if the location we are adding is identical to a
selected location but adds text to the end of it).

Now we only edit the other dives after we accepted the change.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 13:15:33 -07:00
Dirk Hohndel
0c836ebc47 Simplify string comparison
This is based on Linus' idea on the mailing list.
Treat NULL strings and empty strings as identical.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 14:15:59 -07:00
Dirk Hohndel
024420a60d More multi-edit fixes
This time for values that aren't simply text.
For normal integers this is rather straight forward. For the 'when'
timestamp we simply assume that this is a shift in time.

What is still missing is consistent handling of the three fields that are
implemented as tags: tags, buddy and divemaster. We have special code for
tags that makes no sense in a multi-edit scenario. And we treat divemaster
and buddy as a single string - which kinda works but treats "Bill, Joe"
and "Joe, Bill" as different.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 13:59:06 -07:00
Dirk Hohndel
bcf973190c Only change identical fields when editing multiple dives
This was broken when porting to Qt - we used to do this correctly in the
Gtk version.

When editing multiple dives we show the current dive to the user and allow
them to edit that and then apply those edits to all selected dives. The
way this is SUPPOSED to work is that we only change those selected dives
that had the same value for the edited field as the current_dive had for
that field.

Let's say you select ten dives. The current dive shows divemaster Joe. You
change that to divemaster Jim. Then only the selected dives that had
divemaster Joe should change to Jim. All other dives should stay
unchanged.

This seems to implement that logic.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 11:13:24 -07:00
Dirk Hohndel
217c82f6c4 Change EDIT_SELECTED_DIVES macro
The way this is implemented is broken in several ways.
This fixes the first issue.
For the invocations where we are in the 'WHAT' checking to see if the
value we are changing in the selected dive was previously the same as in
the current dive (which is the one shown to the user for editing), then we
need to make sure we change the current dive last, otherwise the
comparison will fail.

Of course, right now we only do this check for gps location, which is a
massive bug as far as I am concerned.

Fixes #515

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06 09:58:27 -07:00
Dirk Hohndel
3364e5b490 Re-center on current dive if dive edit is canceled
If the user changes the coordinates for a dive but then cancels the dive
edit, the globe would stay at the location that was temporarily set and
not rotate back to the still active coordinates.

This fixes it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 21:26:18 -07:00
Tomaz Canabrava
4243fcb915 Dont set coordinates when two or more dives are selected
If a trip is selected (or for other reasons more than one dive), this
would change the GPS coordinates of the whole selection which almost
certainly isn't what the user wanted.
Instead, only allow changes of the coordinates on the globe if exactly one
dive is selected.

[Dirk Hohndel: massively rewritten and extended - but I didn't want to
               simply "steal" the commit from Tomaz...
	       This now maintains the "zoom out mode" for dives without
	       GPS coordinates and deals with edits of multiple dives that
	       are initiated the "normal way" by starting to edit other
	       data as well.]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 15:23:33 -07:00
Dirk Hohndel
dad3c5d9db Only auto-fill coordinates for non-empty location strings
When editing the location string we try to be smart and automatically add
the correct coordinates (assuming we have a location of this name already
in the dive list). So if you return to the same dive spot you'll get the
correct coordinates by default. But this creates bogus result if we allow
an empty location to be matched, as it makes no sense to assume that all
dives without a location name were at the same coordinates.

Fixes #498

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-28 09:34:27 -07:00