Commit graph

2439 commits

Author SHA1 Message Date
Dirk Hohndel
6195c139dc Fix planner gas consumption
We need to start out with valid SAC rates in the diveplan.

Thanks to Gaetan for finding this and suggesting a different fix - this
seems cleaner to me.

Reported-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-26 11:34:02 -07:00
Dirk Hohndel
47226912b6 Fix missing translations for webservice responses
The webservice backend sends responses in English. Let's do a better job
presenting those in the users preferred language.

Fixes #714

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-26 10:30:41 -07:00
Tomaz Canabrava
18da0b1911 Implement the modelDataChanged to repopulate the widget on Statistics
The modelDataChanged method will remove all items and recreate everything
*right* now we will never use it, because we are not triggering any
changes on the model, but simply deleting and recreating it everytime
we open the dialog. to be changed in the future.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 14:00:38 -07:00
Tomaz Canabrava
4a6a9a6706 Use scene()->clear() instead of manually clearing the scene.
When there's a rowsAboutToBeRemoevd, remove all items from
the scene() by calling scene()->clear(), instead of creating
a method just for that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 14:00:24 -07:00
Tomaz Canabrava
3d5dde09ad Use aboutToBeRemoved instead of removed
If we used removed things from the interface we could hit a dangling
pointer, so first delete the items, then let the system delete the rows.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:59:45 -07:00
Tomaz Canabrava
b01ef9a0a5 Implement the resizeEvent to make the statistics always visible.
Always fit the whole scene in the view.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:59:17 -07:00
Tomaz Canabrava
1c56c9f626 Create stub methods and connects the model with the new statistics
Connects the YearlyStatistics model with the YearlyStatisticsWidget
nothing is shown right now, mostly because I need to do everything
but now it's easyer to add the things that are missing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:58:38 -07:00
Tomaz Canabrava
750fc529b7 Add the old Statistics to have a reference view while programming
Added the old statistics panel at the botton of the new one to have
a reference view of the statistics while programming the new one.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:58:26 -07:00
Tomaz Canabrava
2fe1dfe83a Remove a lot of non-necessary boilerplate code.
We used to have a very sad way of controlling the statistics,
now we will create the model when there's a need for it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:57:28 -07:00
Tomaz Canabrava
537b42e3f7 Add initial skeleton for the Statistics Redesign
The statistics widget is a beast, one of the parts that I dislike most
on the current subsurface implementation. This is the initial work to
change that to something amazing. This first commit adds the first bunch
of files that I think are needed, and the correct setup for the qmake and
cmake buildsystems.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:55:23 -07:00
Anton Lundin
0e91352e96 Fix NO_USERMANUAL building for android
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-25 13:54:20 -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
Tomaz Canabrava
9acf1caca3 A much better Toolbar for the profile.
Using QToolBar I was able to remove much of the dead code
from the mainwindow.ui xml file by transforming the QToolButtons
into actions and loading them dynamically in the .cpp code.
I couldn't use the designer for this ( as I wanted ) because
Qt has no notion of ToolBars outside of the areas where the
MainWindow should have one, and we use it in a very different
area.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-23 08:09:11 -07:00
Dirk Hohndel
fb371c0633 TankBar: don't risk dereferencing stale pointers
Basically we could end up in a situation where the plotInfo is no longer
valid, yet the model changes and triggers a redraw before the new data is
passed into the TankBar.

Instead of chasing that race condition it seemed much easier to just copy
the plot_data entries and the gas information in the dive.

Fixes #716

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-23 07:23:42 -07:00
Dirk Hohndel
438fe5dbde Divelist: Use more sensible default column widths
Having 100px wide columns was simplistic and stupid. It was never intended
to stay that way.

See #712

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-22 15:03:13 -07:00
Dirk Hohndel
2760f295d2 Divelist: switch to better column headers
And move the units there.
This is a long going back and forth. What we want is narrow columns. But
what we need is something that's easy to understand for our users.

I'm open to other suggestions, but I think this moves us in the right
direction.

See #712

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-22 15:02:50 -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
Robert C. Helling
b8823acef9 Planner: Control-Click removes divedatapoint and all following ones
In order to offer a simple way to remove a calculated deco, if Control is pressed
while clicking on the trash can in the dive plan, that point and all following are
removed. This way the user can Ctrl-click on the first calculated waypoint.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 16:16:38 -05:00
Karina Mochetti
66cbdea8a1 Crash clicking on the globe without a dive
When the user right clicks the globe, we should only present the menu action
if there's a current dive, if not, we disable it.

Signed-off-by: Karina Mochetti <karina.mochetti@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 14:31:15 -05:00
Dirk Hohndel
512c42e38a Dive list: seriously simplify the "add to trip" code
The existing code seemed way complicated, made way too many assumptions
and apparently was broken in certain cases.

This code seems very simple, looks correct and should fail gracefully
(i.e. simply do nothing) if things get confused.

Fixes #706

(I hope)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 14:20:03 -05:00
Joseph W. Joshua
b940f078b5 Show correct path after saving dive computer settings
When backing up dive computer settings to XML, the confirmation
dialog shows the default file path. This patch fixes that by
displaying the correct file if the user changes the backup location.

Signed-off-by: Joseph W. Joshua <joejoshw@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 13:31:34 -05:00
Dirk Hohndel
0b5e3389e2 Make sure tank bar button triggers tank bar
This worked flawlessly on Mac and Linux, but on Windows I needed to add
the explicit setVisible here - not quite sure why.

Fixes #710

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 07:52:14 -05:00
Dirk Hohndel
dd1dc11cb6 Planner: don't show CC Set Point when planning dives
So far we only plan OC dives, so let's not confuse things by showing the
set point for the tank.

Fixes #261

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 22:15:59 -05:00
Dirk Hohndel
1620f7ec0c Planner: make sure start time is reflected in diveplan and displayed_dive
Fixes #709

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 22:10:27 -05:00
Dirk Hohndel
642ad1e0fe Fix crash when calling the planner twice in a row
Turns out that the fix in commit f7119bdccf ("Planner: make sure no old
handles are around when entering Add/Plan") was incorrect. We ONLY want to
remove the existing handlers when we re-plan a dive, NOT when we call add
or plan.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:57:15 -05:00
Dirk Hohndel
1894bdd3cb Don't trigger creation of dive from invalid plan in planCreated()
This is subtle. The modifications to the selection cause a redraw of the
profile. So we need to make sure that we leave the plan state and return
to profile state BEFORE we do this, otherwise we'll call into
createTemporaryPlan() with invalid data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
5b0f4e79c4 Mark manually entered waypoints as such
With this information, when we re-plan a dive we can bring the user right
back to the point where they ended - they have the waypoints in the dive
pointes table and handles are shown on the right points in the profile -
and the rest of the dive is once again calculated by the planning
algorithm.

For now this state is lost when saving the dive file as we don't add this
flag in the sample to our saved files. So if we don't find any samples
marked as manually added we add ALL of the samples as way points on the
diveplan and the user has to manually remove the ones that were
calculated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
f7119bdccf Planner: make sure no old handles are around when entering Add/Plan
In some cases we don't appear to remove all of the old handles from the
scene and end up showing a handle from a previous instance of the planner
in the upper right corner of the profile.

This patch makes sure that we remove any stray handles that might still be
around before entereing plan or add mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
d45a991460 Planner: after canceling a plan, redraw the profile
While planning we might have made changes to the displayed_dive. So we
need to make sure that the profile is redrawn after we cancel a plan (or a
re-plan).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
d7630032e2 Planner: clear out model before re-planning a dive
Otherwise points from a previous run might be around.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
a85a219df3 Add ability to replan a dive that we planned before
When doing this, all waypoints of the calculated ascent are now waypoints
in the plan - so the user has to remove the ascent part of the dive in
order to really replan the dive. That's a pain, but we don't keep the data
around that would tell us which waypoints are user input and which ones
were calculated.

Fixes #527

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:17:52 -05:00
Dirk Hohndel
76f3c0f028 Planner: don't calculate ascent while adding waypoints
It's silly to carefully calculate our ascent for each new waypoint that we
add to the plan. Let's get them all in and THEN calculate an ascent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 15:06:48 -05:00
Dirk Hohndel
77f9bf06fd Planner: correctly free divedatapoints
Simply setting the pointer to NULL leaks memory.
And that C++ recursive two function implementation... oh boy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 15:06:39 -05:00
Dirk Hohndel
6ed189f32c Planner: bring sanity to the SAC rate handling
The old implementation was... let's call it creative.
This tries to actually get things right instead of using magic.
Don't pretend that double values are ints.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 11:36:54 -05:00
Dirk Hohndel
150676ce3d Merge branch 'joshua-gsoc' of git://github.com/thiagomacieira/subsurface into josh
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	subsurface.pro
2014-08-18 20:25:06 -05:00
Dirk Hohndel
48fe5254dc Preferences: increment/decrement partial perssure values by .1
This defaulted to +/-1 which really isn't all that useful.

Fixes #703

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-18 14:21:11 -05: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
88fe28636e TankBar: make outline zero-width
In some circumstances Qt will draw a really thick border around
rectangles. This explicitly makes the border of the tank bar thin.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-18 11:47:18 -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
822eb7558d Selective copy: forgot tags in the UI
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16 18:35:44 -06:00
Dirk Hohndel
4a7432e3d5 Don't always clear the dive before selectively copying
This will be needed when pasting the data back into a (set of) dive(s).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16 18:34:27 -06:00
Dirk Hohndel
34fceb4a1b Cut'n'paste for dive data: implement copy side
Admittedly not very useful without working paste, but it's progress.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-16 10:07:06 -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
64c9fff850 Survey: rename "Save" button to "Send"
Fixes #701

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-15 21:41:41 -06:00
Dirk Hohndel
e8d430341c TankBar: hook into prefs and make ppGraphs resize accordingly
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-15 08:11:14 -06:00
Dirk Hohndel
e71119b40b TankBar: use the itemPos as intended
Which actually makes the code much clearer as now the object is at the
correct spot on the canvas and the positions inside are relative to that.
No more magic gradiants starting at "92"

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-15 07:30:31 -06:00
Linus Torvalds
5b14ed16ac Add "download into private trip" dialog checkmark
This adds a checkbox for the divecomputer download dialog that allows you
to tell the download to put the newly downloaded dives into a trip of
their own. That in turn will disable the dive merging with any existing
dives, which means that you will not mix up your newly downloaded dives
with any old dives.

That, in turn, is very convenient of you know that some of the dives were
done by other divers (or from testing that happened during servicing etc),
or the dive dates etc were wrong because the dive computer date had reset
due to battery changes etc.

Once you have all the dives in a private trip of their own, you can then
fix them up (delete dives you don't want to merge etc), and then after all
the data is ok you might want to merge the cleaned-up results with
previous trips etc, and then manually ask subsurface to merge the dives or
whatever.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-14 22:40:14 -06:00
Dirk Hohndel
87ca15c5c3 Add gas text to tank bars
Also restructures the code a bit to make it a little more sane and changes
the colors slightly.

With these changes I think we can claim that this
Fixes #557

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-14 22:39:47 -06:00
Dirk Hohndel
fa3c18d83b Add initial support for a visual tracker of gas used
This shows a color-coded bar at the bottom of the graph that corresponds
with the active gas.

Todo:
- text that explicitly states gas on the left edge of the bar
- better vertical positioning of the bar
- ability to turn this on and off

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-14 18:22:27 -06:00
Robert C. Helling
ecf0408aae Make SAC values in planner settings respect unit settings
So far, the fields for the two SAC rates did not show a unit and were implictly l/min.
Now they respect the settings for volume units. This was harder than I thought for two reasons:

1) Imperial units for SAC are cuft/min but a typical value would be .70. So I made the point
the field prefix and what is entered is actually hundreth of cuft per minute.

2) I had to get the rounding right in order not to get effects like 20l/min become .70 cuft/min (19800 ml/min
internally) which would then become 19l/min when switching back.

While being at it, I gave the gradient factors '%'-signs as units.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-13 21:11:07 -06:00