Commit graph

1755 commits

Author SHA1 Message Date
Dirk Hohndel
5e3f7ba22f Fix selection after downloading dives from the dive computer
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>
2014-05-19 20:12:59 +09:00
Dirk Hohndel
cae51ff0aa Change get_dive_by_diveid to get_dive_by_uniq_id
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>
2014-05-19 20:12:59 +09:00
Dirk Hohndel
c4899aa8f1 Download from dive computer: Fix the broken selection of devices
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>
2014-05-19 20:12:58 +09:00
Dirk Hohndel
047032ee46 Divecomputer download: try to offer only those devices that make sense
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>
2014-05-19 20:12:55 +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
Dirk Hohndel
ed6a42f6f2 Do not use default filename as default for "Save as"
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>
2014-05-14 06:13:03 +09:00
Tomaz Canabrava
c86d055db7 Do not check for null before free.
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>
2014-05-13 09:26:50 +09:00
Tomaz Canabrava
e0c0ac5d5c Rename getDiveById to get_dive_by_id to keep current c code organized.
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>
2014-05-13 09:24:37 +09:00
Tomaz Canabrava
6ab05563b3 Move DiveList related methods/classes to own file.
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>
2014-05-13 09:20:28 +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
Tomaz Canabrava
cf848e5233 Correct the usage of std::string and QString
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>
2014-05-11 01:57:00 -07:00
Robert C. Helling
9a4f8b50bd When starting the planner, copy cylinders from currently selected dive.
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>
2014-05-08 14:58:47 -07:00
Anton Lundin
232098ad96 Fix building with NO_MARBLE after prototype change
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>
2014-05-08 14:57:59 -07:00
Robert C. Helling
543f226db0 Planner: Offer to discard the plan when Quit is triggered in planner.
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>
2014-05-08 13:14:51 -07:00
Robert C. Helling
e3ef1b7a1e Planner: show gas for the NEXT segment
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>
2014-05-08 13:13:49 -07:00
Robert C. Helling
00e7ef2cf8 Planner: Change when we recalculate deco
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 12:25:38 -07:00
Thiago Macieira
2e0a51264f Fix another dangling pointer
Same problem as the previous commit: toStdString() returns a temporary,
and c_str() will return a pointer to internal data, freed at the end of
the statement. So get the pointer to be strcpy'ed in the same statement.

Changed to toUtf8() to be more explicit about the encoding and to avoid
std::string

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 22:02:21 -07:00
Thiago Macieira
497d6e3e6c Fix crash on dereferencing dangling pointers
QList::first() returns a reference to an item, but that list was a
temporary. The list gets destroyed at the end of the statement (the
semi-colon), so we ended up keeping a reference to freed data (i.e., a
dangling pointer)

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 21:52:56 -07: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
6763b93619 Remove spurious debug printout
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
0ce59e5205 Even if there is progress text, still set the progress bar percentage
I don't understand why we wouldn't set the percentage if we displayed text
there as well. This looks much better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07 12:17:24 -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
223d99f79f Change the profile redraw logic after preferences were changed
I we are showing a calculated ceiling, then we have to replot the profile
after a preferences change as the gradient factors could have changed
which might change a calculated ceiling.

Also use the rulergraph preference instead of checking the settings
directly.

Fixes #511

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 15:58:25 -07:00
Dirk Hohndel
08689b2f89 Correctly parse boolean preferences
QVariant does the right thing, regardless of whether the value is stored
as int or as string - so let's just use that instead of manually checking
for integers (and failing if the values are stored as "true" and "false").

Fixes #511

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 15:56:49 -07:00
Dirk Hohndel
7809077b33 Fix odd indentation
I need to fix this in the tool as well...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 15:56:11 -07:00
Dirk Hohndel
7b0f737f60 Make rulergraph a pref as well
I don't see a point in treating it differently from the other graphs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 15:53:46 -07:00
Dirk Hohndel
3063991e4e Fix bug in handling of fake SAMPLE_EVENT_PO2 events
In commit bcdd6192fe ("Show translated event names in tooltip") I was
too aggressive in replacing the checking for event names with checking for
event types. It turns out that we are abusing an existing event type in
the planner (and use a different event name to mark the difference). By
just checking for the type this now caused incorrect information to be
displayed in the info box (a simply "PO2 warning" on a Suunto D9 could
turn into a "Bailing out to OC" notice).

The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from
libdivecomputer. Once we have those, we can do this the right way. For now
we just fall back to also checking the event name (which is what I wanted
to get away from so translated names don't trip us up).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 09:32:13 -07:00
Robert C. Helling
7bcb85dd54 Add images to all dive computers and refresh profile
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 08:16:16 -07:00
Robert C. Helling
7e43a45293 Correct check for existence of DateTimeOriginal exif tag
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 08:16:16 -07:00
Dirk Hohndel
8f657ff775 Add conditional so globe.cpp builds with older versions of Marble
In commit 7f3b487c77 ("Restore the previous globe zoom level after
showing dive without GPS") I was a bit too aggressive in replacing a
deprecated API function - people still need to be able to compile against
Marble versions older than 4.10.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-04 11:37:23 -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
Dirk Hohndel
7a85b9fb27 Only change dive coordinates on double click
Apparently this only happens on Windows, but there we would change the
dive coordinates on a SINGLE click when editing a dive. With this change
we simply bail if the event isn't a double click.

Fixes #505

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 21:25:20 -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
7f3b487c77 Restore the previous globe zoom level after showing dive without GPS
Thanks to commit 83c5ab5871 ("Zoom out when dive has no coords.") we
show more of the globe when displaying dives without GPS data - but that
caused us to forget the zoom level we used before and so the experience
when switching back to a dive with GPS data was disappointing.

This makes sure we track the last valid zoom level and restore it when
needed.

I also replaced the deprecated zoomView() calls with setZoom() calls.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 14:48:14 -07:00
Tomaz Canabrava
9fcd6b2658 A better guard for 'dive being editted'
Mouse activity on the globe should not select dives when one or more dives
are being edited. This improves the detection of that state.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 10:12:16 -07:00
Tomaz Canabrava
83c5ab5871 Zoom out when dive has no coords.
This patch makes the globe zoom out to show it complete when
the dive has no coordinates.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01 09:59:07 -07:00
Dirk Hohndel
0e49e61ddc Fix test for "air" in tooltip display of gaschange
The "is_air()" test works when we have the gases in permille, but not in
percent. In that case we can just check for He == 0 and O2 == 21.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-29 22:39:33 -07:00
Dirk Hohndel
bcdd6192fe Show translated event names in tooltip
In order for this to work we need to compare against the event type
instead of the event name - which makes much more sense to do, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-29 22:38:55 -07:00
Linus Torvalds
4f20bb9fb2 When scrolling to dive, scroll to trip first
The behavior at startup is actually very annoying: we select the latest
dive, and expand the trip it is in, but since we use "scrollTo()" on
just the dive, and it's not initially visible, the startup will make the
first dive be at the top of the list view.

Which means that the actual _trip_ detail is not visible at all, since
it will have been scrolled off the list view entirely.

Fix this by first scrolling to the trip, and only then scrolling to the
actual dive (using the default "EnsureVisible" policy).  Obviously, if
it's a trip with lots of dives, scrolling to the dive may end up
scrolling away from the trip header again, but at least that never
happens at startup, and at that point you have to scroll away from the
trip just to show the dive.

Do this same dance when changing the dive selection (mainly noticeable
when picking dives on the globe view).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-28 12:47:15 -07:00
Dirk Hohndel
2d24779b62 Make heartrate grid less confusing
Having all the grid lines in the same color made things visually
confusing. To clean this up a little make the heartrate lines a light gray
color.

Fixes #484

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-28 12:45:42 -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