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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
When changing the values of air/water temp after the first time and save,
it will be reset the intial value.
This is fixed by removing the "select_dc" (which makes the change to the
dive struct instead).
Fixes#457
Signed-off-by: Yousef Hamza <jo.adama.93@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As a warining for the user mark the field red.
If the user inputs invalid input that will be ignored
while parsing.
But with adding a one character error margin to prevent it from toggling
between Red and Yellow while editing existing values, for example "After
Deleting unit and last number after '.'"
Signed-off-by: Yousef Hamza <jo.adam.93@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently the feature to show temperature units while adding dive is
provided through checkbox in preferences->units section. This patch
disables this checkbox and always enables this feature.
Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's a tricky problem as we need to remember this across a divelist sort
(as the user might have edited the date / time). The old code made not one
but two incorrect assumptions.
a) it assumed that the added or edited (but previously manually added)
dive was the last one in the dive list (clearly wrong when adding a dive
that has an earlier date)
b) it ignored the fact that refreshDisplay() would select the top dive in
the list if no dive was selected
This patch addresses both of them and makes the code easier to understand.
Fixes#480
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove redundant spaces from dive master and buddy list fields.
Ticket also mentions about similar space behaviour in tag field, which I
couldn't reproduce.
Fixes#476
Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Manipulating cylinders, especially changing the exact gas content (o2,
he), changes the pp02, ppHe graphs. This patch simply replots the profile
in case of cylinder change at time of saving.
Signed-off-by: Jan Mulder <jlmulder@planet.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In bf205726 DEPTH/Switch at was disabled by commenting out that code.
This puts it back behind ifdefs
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
After editing values in cylinders or weights hitting save will not save
the changes to save the edit one must move the focus to a different
field first this is fixed by losing the focus before saving the changes
Fixes#412
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There are no utf8 in those strings, and we can translate them as
everything else with tr() instead.
QApplication::UnicodeUTF8-part is deprecated and removed in Qt5.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The selection logic was a bit random: some places would return NULL if
the dive computer index was out of range, others would return the
primary dive computer, and actually moving between dive computers would
just blindly increment and decrement the number.
This always selects the primary computer if the index is out of bounds,
and makes sure we stay in bound when switching beteen dive computers
(but switching between dives can then turn an in-bound number into an
out-of-bounds one)
Fixes#464
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the user tries to delete a cylinder that is in use and that action is
rejected, the cylinder widget (and the whole dive) should not be put into
edit mode. After all, nothing changed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently when user wants to add a new dive information,
the ways to know what unit system is being used are
- Through preferences panel.
- Save the dive information, which displays units in
the text field.
This patch provides an option to the user to show current
unit system by displaying the unit on the side of the label
when the user is editing the fields.
This feature can be enabled or disabled by using the new
checkbox option i.e. `Show units in text labels` included
in `preferences->units` section.
Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So this is totally unrelated to the git repository format, except for
the fact that I noticed it while writing the git saving code.
The subsurface divetag list handling is being stupid, and has a
initial dummy entry at the head of the list for no good reason.
I say "no good reason", because there *is* a reason for it: it allows
code to avoid the special case of empty list and adding entries to
before the first entry etc etc. But that reason is a really *bad*
reason, because it's valid only because people don't understand basic
list manipulation and pointers to pointers.
So get rid of the dummy element, and do things right instead - by
passing a *pointer* to the list, instead of the list. And then when
traversing the list and looking for a place to insert things, don't go
to the next entry - just update the "pointer to pointer" to point to
the address of the next entry. Each entry in a C linked list is no
different than the list itself, so you can use the pointer to the
pointer to the next entry as a pointer to the list.
This is a pet peeve of mine. The real beauty of pointers can never be
understood unless you understand the indirection they allow. People
who grew up with Pascal and were corrupted by that mindset are
mentally stunted. Niklaus Wirth has a lot to answer for!
But never fear. You too can overcome that mental limitation, it just
needs some brain exercise. Reading this patch may help. In particular,
contemplate the new "taglist_add_divetag()".
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This code cleanup fixes the two issues that I raised on
my last e-mail. hurrah.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>