[Dirk Hohndel: this overlapped with my commit 09e7c61fee ("Consistently
use for_each_dive (and use it correctly)") so I took the
pieces that I had missed]
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit fb82da58a2 ("Globe: assume that we are looking at the
current_dive") changed the prototype for
GlobeGPS::prepareForGetDiveCoordinates. This patches the dummy in
NO_MARBLE.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Commit 2bc76beb65 ("Globe: we always center on the current dive") changed
GlobeGPS::centerOn to GlobeGPS::centerOnCurrentDive. This patches the
dummy in NO_MARBLE, too.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
No attempt is made to ensure that what the user does is sane. So this can
result in duplicate numbers, non-consecutive numbers, non-monotonous
numbers, whatever floats the users boat.
You can renumber a single dive or all selected dives (with a starting
number given that is applied to the oldest selected dive and then for each
newer selected dive that number is incremented by one).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If a dive has multiple dive computers we enable a special context menu
when the user right-clicks on the dive computer name AND is not already
showing the first dive computer. In that case we offer to make the
currently shown dive computer the first one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For most users this is no change at all. For the few who download from
multiple dive computers this now shows them which of them is the primary
dive computer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This uses the new helper function from commit fc4f133f19d0 ("Add new
helper function that looks up the index of a dive by its uniq ID") to make
the logic implemented in commit 122593a63a46 ("Fix selection after
downloading dives from the dive computer") much saner to read.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we successfully download dives, the old selection should be cleared and
the one of the newly downloaded dives should be selected. I decided to
pick the last dive downloaded, which for most dive computers (but for
example not for the Uemis SDA) will be the first or earliest of the dives.
That seems much more intuitive than keeping the previous selection around.
Of course this is harder than it should be because of the way we track
selections and because we need a consistent dive list model in order to
change the selection.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we only did this when we did fixup_dive(), but that way we
can't reference dives "early" in their life cycle (e.g., right after they
got downloaded).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The original name was a really bad choice as we have a 'diveid' as part of
struct divecomputer - and that is not the diveid that is being used here.
Instead we use the 'id' member of struct dive which holds the "unique ID"
for this dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code was completely bogus - it's confused about what the variable
'i' is counting.
This also let's us select the Uemis mount point by default if that's the
only valid "device" that we found.
Compile tested on Windows, untested on Mac.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the user selects a Uemis divecomputer, don't show serial devices.
If the user selects a serial divecomputer, don't show the Uemis
filesystem.
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>
This makes it much more obvious what is going on when you save in
between importing multiple dive computers, since the last dive
description otherwise stays the same.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't save the dive computer timestamp and duration if they match the
dive timestamp and duration. But that means that on loading, we need to
default the dive computer time/duration to the dive one. If they
differ, the loading of the divecomputer file will then override the
default timestamp/duration.
This mainly matters if a later dive merge then changes the timestamp of
the dive: the dive computer timestamp needs to have been set correctly
and not change.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We used to do this just for dive computer downloads, but we should do it
for all imports, so that merging new import data always does the
expected thing: any new dive computers will be added to the end of the
list of preexisting dives, rather than the other way around.
(Of course, if you set the "prefer downloaded" flag, that reverses this
logic, and makes the newly imported dive computer data be the primary
dive computer. That flag is currently only exported for dive computer
downloads, not for imports).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When merging dives, if we know for sure that the dive computers are
different, don't merge them into one (by interleaving the data), but
instead keep both as separate dive computers in the same dive.
This fixes a bug when due to a faulty download the same dive from two dive
computers looks quite different. They don't get merged automatically
(which is fine - they are quite different), but when manually merging
them, we of course want one dive with two dive computers, not one dive
with one merged dive computer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The git save tries to generate a nice commit message based on the most
recent dive, but stupidly didn't check whether that dive was in a trip
or not, and unconditionally used the trip pointer to see if there was a
trip location.
Which works well enough if you always generate trips, but is an
unmitigated disaster otherwise. Oops.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This may sound counterintuitive but it actually makes sense.
If you have a default filename that's the name of you "normal working
file". If you want "Save as" something, that by definition is NOT your
normal working file but a subset or an experiment or something. And you
most definitely do NOT want to overwrite your default file with that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
C specs says that we can safelly free a NULL pointer, so there's no reason
to check if it's null before freeing it.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit renames getDiveById to get_dive_by_id, and it also removes the
Q_ASSERTS and if(!dive) return that the callers of this function were
calling. If it has a Q_ASSERT this means that the dive must exist,
so checking for nullness was bogus too. I've changed the assert (done
in a silly C-Way.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A bit longer, but we had a function named get_dive_by_diveid
and another one named getDiveByDiveid that did completely
different things, it was too easy to hit the wrong one..
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The DiveList classes were a partial mess (and some of it is still in a
messy state). The classes that deal with it where done in 'qtHelpers.h',
the extern global variable in dive.h, a few methods here and there. This
concentrates most - but not all - functions in their own file. The reason
for that is to make the new developer faster when looking for things: if
it's a divecomputer related method, it should be in a single file, not
scattered around.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
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>
I stupidly used "weekday()" without realizing we localize it. And we
really don't want to make save formats be localized (we don't localize
decimal numbers etc either).
This fixes the git save format to just use a hardcoded weekday list.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should make git loading be able to load git saves with arbitrary
weekday names. Even strange German ones.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we first get an invalid dive info and then, once we decremented the
offset, get a valid one but for the wrong dive and then try to calculate
the correct offset, we need to keep the existing offset in mind.
What a horrid design. Thanks, UEMIS.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A general review of the documentation has found more spelling errors.
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'll probably add prefixes to functions to make it easier to find method
via autocomplete from the grep or interface helpers, do you wanna know all
the functions that works with a dive? ask for the completion for dive_,
do you wanna know all the functions that works with a divelist? ask for
the completions on divelist_ or run grep -rIs divelist_ on the header
files.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's easyer to make a mistake in the loop insteaf of
using the currently correct one that's already written
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This removes unecessary creation and destruction of the object
making the code shine a bit more and be more fluffy. :)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
pretty self explanatory, the 'class' keyword is unecessary
when defining things inside a Container, be it a QList,
QVector, QMap, QHahs or anything else.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
this is not necessary when you don't have a variable
that has the exact same name as the 'this->variable' name,
also, there's no need to check if a QString is empty
before trying to use the == on them.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QStrings shouldn't be == "" to check for empty string, use .isEmpty()
QStrings shouldn't be != "" to check for non empty, use .size()
std::string shouldn't be cleared with = "", use .clear()
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Those were from the ancient Gtk times where we hardcoded the white stars
and black stars as font glyphs instead of drawing them. get rid of it.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The units are used everywhere in the application, we don't really
need to include "dive.h" to be able to use unit conversion, so I
changed them to a new file. There is still a lot of non-dive stuff
in dive.h / c, I'll try to move more later.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Small typo in CodingStyle.
".. in this file to." should be "... in this file too."
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now when we have a used flag on every cylinder that are set in
mark_used_tanks we can use it here.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
SAMPLE_EVENT_GASCHANGE2 is the libdivecomputer name of the event.
Compare with that instead of its int value.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
4243fcb915 ("Dont set coordinates when two or more dives are selected")
Changed how the prototypes in GlobeGPS looks. This aligns NO_MARBLE
version of GlobeGPS with that.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Upon pressing Ctrl-Q or the window close button a modal dialog was shown
to remind the user that the planned dive is not saved. This patch
triggers the "cancel plan" action before trying to quit.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For deco stops show the gas of the next segment in the table. In
recalculation remove old deco stops earlier.
In struct diveplan, the items are "segments" with a beginning, a duration,
and a gas. In contrast, the UI of the planner uses "waypoints" which are
the boundaries between segments. It is conventional at least for deco
stops to display the gas of the _next_ segment in the runtime table (i.e.
the gas possibly to be switched to).
Furthermore, in addStop, the old deco stops have to be removed earlier as
otherwise a new waypoint later than a previous generated gas switch
inherits the gas of the old switch.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>