Commit graph

2963 commits

Author SHA1 Message Date
Tomaz Canabrava
806d984107 Only update the rectangle if it changed
Very often the rectangle of the ToolTip doesn't need to change but we were
calling and firing an animation for it for *every* mouse movement, even
when we didn't really needed it.
Now it will only fire something if the rectangles are indeed different.

From my tests we reduced the number of calls to the animatior by about 20%
using a real divelog as test.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:26:35 +13:00
Tomaz Canabrava
54898b15ff Do not free the membuffer, reuse it
This is an attempt to make fewer calls to alloc functions when the mouse
is moving.

We were creating a membuffer, filling it (malloc / realloc), then freeing
it just after use. but we could simply hold that allocated area and reuse
it again.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 14:23:46 +13:00
Tomaz Canabrava
501f72c697 Speed Improvemens: fewer calls to mapFromScene / mapToScene
We did three cals to mapToScene / mapFromScene on the mouse moveEvent at
the ProfileWidget2 where we only needed to call one in the common case and
two in the worst case.

This doesn't really help in terms of speed (unless you have a really old
cpu) but since it's code that gets called *very* often, it seemed a
reasonable thing to do.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 07:24:13 +13:00
Tomaz Canabrava
db4ffd0b70 Fix memory leak
The QPainter and the QPixmap were being created but never freed. A QPixmap
and a QPainter don't need to be created by new, they can be safely created
on the stack.

So, create them on the stack, pass them via const-reference
and use them correctly.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 07:23:48 +13:00
Tomaz Canabrava
633dd64d2f Major speedup when moving the mouse in the profile
After looking with great care at the result of the mouse movement
on the profile, and also playing a bit with callgrind I've found
out that one thing that we were doing wrong was the way we looked at the
items in the scene, by calling scene()->items with
Qt::ItemIntersectsShape, our shapes are very complex curves
with thousends of points and we have lots of them. and it usually
doesn't matter because *most* of the time we are getting the
tooltip information from 'get_plot_details_new', so no accessing
to items was necessary.

By changing the access from Qt::ItemIntersectsShape to
Qt::IntersectsItemBoundingRect we had a speedup of almost 500x in a
section of code that's very important, and the good thing, nothing bad
happened because one of the only things that we are using this code is to
get information from the events, not the curves.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-15 07:20:35 +13:00
Cristine Guadelupe
2b19341609 Remove instantMeanDepthLine
Take instantMeanDepthLine out of the code. We have the moving average line
plus the exact data in the information overlay.

Signed-off-by: Cristine Guadelupe <cristineguadelupe@me.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-14 12:24:57 +13:00
Joseph W. Joshua
25fc828458 Ignore QWebView in Android
Ignore QWebView instances in the preferences dialog when compiling under
Android, as QWebView is not yet supported under Android.

Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-14 07:49:24 +13:00
Dirk Hohndel
a0c52237ea Dive download UI: sort the dive computer dropdown
I could have sworn we did this at some point. The vendors are already
sorted, but the products for each vendor should be sorted, too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-13 22:05:55 +13:00
Dirk Hohndel
af3dd1e835 Attempt a better layout for the download dialog
This seems to work well and provides a lot less wasted space.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-13 21:58:28 +13:00
Dirk Hohndel
578e9c22af Dive d/l selection UI: clear table when retrying
After a partial download (because the user hits cancel or because there
was an error, if the user hits Retry the list of dives downloaded so far
should be cleared because we will simply try to re-download the same dives
again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-11 07:46:21 -08: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
7d8ecf8ec8 Add preferences field for default set-point
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
Robert C. Helling
d01c6c824b Rebreather type selector UI
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
Dirk Hohndel
762f33bd13 Dive d/l UI: redo the states, the flow, the buttons
This is bigger and more invasive then I wanted, but it's hard to break it
down into smaller pieces. Here's what it does:

The former "Download" button becomes the "Download", "Cancel download" and
"Retry" button. So this button controls your interaction with the dive
computer.

The other two buttons are now purely "OK" and "Cancel" for the dialog.
"Cancel" discards what happened (much easier now that we download into a
different table), and "OK" adds the dives that were selected in our
selection UI (by default all downloaded dives) to the real dive_table.

And while redoing all this, I also redid some of the state machine
underlying the dialog. The biggest change that the user will see is that
partial downloads (after canceling or after an error) will still offer the
dives that were completely downloaded up to that point in the selection
menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:25 -08:00
Dirk Hohndel
f10b66237e If we can't find the dive, simply return no data
This seems better than forcing a crash or accessing random data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:25 -08:00
Dirk Hohndel
7357633905 Now use our table when downloading from the dive computer
We pass a different table to libdivecomputer (and the uemis code) and have
that table filled. And then we simply copy the dives from that table into
the real dive_table when the user accepts the download.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:25 -08:00
Dirk Hohndel
e43ea018fa Add a private table for downloaded dives
This still isn't actually used, just puts it in place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:25 -08:00
Dirk Hohndel
6f25713408 Add more infrastructure for a separate dive table
This will allow us to download the dives from the dive computer into a
separate table just for that purpose and not into the main dive_table.

I really dislike the code that's in place that dates back to the very
earliest code written for Subsurface. Dumping the dives straight into the
main dive_table seems really stupid to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:18 -08:00
Dirk Hohndel
a92484e4ed Dive d/l selection UI: remove setData() method
Since we now track all clicks on the row, having the setData() actually
neutralized the action that we took on the clicked() signal.

Now you can select / deselect a dive, regardless where in the row you
click.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 12:42:09 -08:00
Dirk Hohndel
4d26e3a0cb Dive d/l selection UI: fix the row count ranges
Yet another bug because the indices are inclusive. We need to start off
with the last being smaller than first and we need to adjust the row
count. It might be easier to just fix thing to make last be exclusive...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 12:42:09 -08:00
Dirk Hohndel
80af8e7fa2 Dive d/l selection UI: update checkmark state correctly
This fixes the issue where there was no visual feedback when clicking on
the second or third column in the grid. It would actually change the
checked state of the checkmark internally (and you would see the new state
once you clicked on another dive), but it wouldn't give immediate visual
feedback.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 12:42:09 -08:00
Dirk Hohndel
15fb6158bc Dive d/l selection UI: the indices are inclusive, allocate enough space
The array we allocated was one entry too small.

On the flip side, let's just make sure we cannot call this with a negative
range. That would be bad, too.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 12:41:38 -08:00
Dirk Hohndel
cd2cee4974 Dive d/l selection UI: only allow one download for now
We may reconsider this as this might replace the Retry function that's
currently completely broken.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 12:00:34 -08:00
Dirk Hohndel
e9e6e75feb Dive d/l selection UI: don't setup the model if there are no dives
Setting things up for zero dives will cause all kinds of weird corner
cases. Just don't do it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 11:28:15 -08:00
Willem Ferguson
d45e870289 Repair minor bug in CCR setpoint graph
Correct minor malfunction with CCR setpoint display. It was showing even
when the po2 display was turned off. This patch ensures that the setpoint
graph only shows when the po2 toolbar button is activated (and in addition
the appropriate checkbox in the Preferences).

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 09:16:29 -08:00
Anton Lundin
3c15834c3c Remove unused headers
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 14:35:09 -08:00
Anton Lundin
8a5f2ef52f Only suggest OSTC3 fw upgrade on newer version
Previous code suggested a "upgrade" if your firmware where other than
whats parsed from the autofirmware call.

This switches that logic into only suggesting firmware upgrade if the
found firmware is newer than the firmware your device runs.

The previous logic was very annoying if you have a device running a
development version of the firmware. If you have taken that step of the
guided path, you shouldn't be told to "upgrade" to something older
every time you download from your computer.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 14:35:03 -08:00
Anton Lundin
4f8536c253 Remove stray debug prints
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 14:34:51 -08:00
Dirk Hohndel
d7762f8fbe No need for a new variable
We already have provider in a local variable. The lookup and "model"
variable is redundant.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 13:44:51 -08:00
Dirk Hohndel
562f88d2b7 Use setEnabled() instead of setDisabled()
I don't like mixing setEnabled() and setDisabled()... let's just always
use setEnabled().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 12:56:17 -08:00
Dirk Hohndel
0dd8d11a18 Dive d/l selection UI: hook up select / unselect all
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 12:54:53 -08:00
Dirk Hohndel
3ae664b6dc Dive d/l selection UI: add select all / unselect all
This isn't hooked up, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 12:41:45 -08:00
Dirk Hohndel
e6b5a00e35 Dive d/l selection UI: allow clicking anywhere in a row
It seemed silly to only be allowed to click the tiny checkbox.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 11:39:34 -08:00
Dirk Hohndel
d16bff13bb Dive d/l selection UI: fix more array access errors
The checked array is zero based, reflecting the rows shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 11:27:47 -08:00
Dirk Hohndel
32824e8db8 Dive d/l selection UI: brute force size optimizations
This is horrible, but it gets something in place and hopefully we can
clean this up soon.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 11:19:01 -08:00
Dirk Hohndel
3854495832 Give reasonable names to layouts
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 10:22:31 -08:00
Dirk Hohndel
d143527732 Dive d/l selection UI: show reasonable column headers
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 10:12:43 -08:00
Dirk Hohndel
1ce2d42e8d Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 10:02:28 -08:00
Dirk Hohndel
17b9597f3e Dive d/l selection UI: fix check if things were checked
Math is hard.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 10:00:30 -08:00
Dirk Hohndel
847289605b Dive d/l selection UI: close the dialog when done
This is where we need to call accept()

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 09:59:01 -08:00
Dirk Hohndel
cb6f04f16c Dive d/l selection UI: Only show checkbox on the first column
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 09:43:29 -08:00
Dirk Hohndel
9d38ceb95d Dive d/l selection UI: disable OK until things are downloaded
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 09:39:47 -08:00
Dirk Hohndel
a20040a561 Fix missing return value
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 09:33:52 -08:00
Dirk Hohndel
c1bc29bd4b Dive d/l selection UI: show useful data in a useful format
We don't get location data from the dive computer (at least not from
99.99% of the dive computers today). And we really need to show the data
in a human readable format.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 09:33:47 -08:00
Dirk Hohndel
a3ea1d51f9 Dive d/l selection UI: don't close the dialog when we're done downloading
The whole point is that we then want to pick and choose which dives to add
to the divelist.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 09:33:40 -08:00
Tomaz Canabrava
747afa314a Dive d/l selection UI: Rename button
Fix the name of a button so the download from dc actually works.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-08 07:48:07 -08:00