Commit graph

8712 commits

Author SHA1 Message Date
Dirk Hohndel
094264014d Fix helper function
Avoid counting the selected dives - we have that number.
But also don't return 0 because we devide by the total work for the
progress bar.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 22:37:43 -07:00
Dirk Hohndel
4bdead6ad6 Avoid possible use of uninitialized variable
Errorcode doesn't get set if duppedfd is negative. So let's just issue an
error and bail.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 22:23:04 -07:00
Robert C. Helling
4094e6b233 Refactor to use gaschage_before and gaschange_after
... for better readability.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:39:17 -07:00
Robert C. Helling
d071ab4537 When displaying transitions show the gaschange at the stop if there is one
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:28:01 -07:00
Rick Walsh
26622e7e04 Planner notes - revise logic for gasmix output
The logic for when to output a gasmix in the notes table is more
complicated than it seems at first.
- On a descent leg, the gas is the gas used for descent
- At a stop (calculated or user defined), the gas is the gas used for that
  stop
- But on an ascent leg (if displayed), the gas is the gas that is ABOUT TO
  BE USED
- The gas should not be repeated if it's the same gas as used on the last
  row of the table
- Ascent legs should only be displayed if the display transitions option
  is selected, OR if there is a gas change without a stop (the user can
  now set a minimum duration for a gaschange, but zero is still allowed).

The existing code tries to track what gas is being used/switched to at
each waypoint, and whether the gas should be printed or postponed to the
next leg.  It works sometimes but not always.

This patch replaces the postponed gas logic with:
- Is this an ascent leg? (determines whether the applicable gas is the
  preceding or following leg, and whether the leg should be displayed at
  all if the transitions option isn't selected)
- Is it an ascent with a gaschange without a stop?
- Has the gas actually changed from the last output?
- Will the next leg be at the same level and same gas (in which case merge
  them)?

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:24:56 -07:00
Tomaz Canabrava
21c46b8c2d Preferences infrastructure for GeoManagement
Simple preferences infrastructure with default prefs, prefs and hooks for
the Qt Settings system and our preferences ui.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:11:51 -07:00
Tomaz Canabrava
ce4333e8fd Defaults for the Preferences dialog for GeoCoding
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:11:30 -07:00
Tomaz Canabrava
7f83b35ec9 Add model to populate the Preferences for GeoRef
Simple model that list the options for GeoRef.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:10:57 -07:00
Tomaz Canabrava
a19bbcc715 Add configuration options for geo coding
Just the interface changes for configuration options for geo coding.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:10:33 -07:00
Tomaz Canabrava
e27f9ab0a6 Show warning if user loads an old datafile
Show the user a warning if he opens an old version of the divelog
file, the warning tries to explain some things that are different
on the new version.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:09:48 -07:00
Tomaz Canabrava
7071bf0e23 Do not mess with dive location automatically
This might be what the user wanted, but also might not
be it. So wait for the user to request it manually.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:01:52 -07:00
Tomaz Canabrava
35a4ef88be Create layout on parent, not on items around it
Correctly handles resizing of interface items by
creating the layout on the parent instead of selecting the
items and applying the layout around them.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:01:24 -07:00
Tomaz Canabrava
5d236d6475 do not set default sizes for expanders
This was creating a lot of empty spaces on the preferences
dialog and making Dirk unhappy.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 16:59:59 -07:00
Dirk Hohndel
979eb464b3 Cloud storage: update File menu options once PIN is verified
The code didn't trigger the update routine after PIN verification, only if
just email/password were shown. A simple oversight. This is fixed now and
so the visibility of cloud open and cloud save options should refelect
whether verified credentials are in the preferences or not.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 14:04:31 -07:00
Dirk Hohndel
f150c3b911 Prevent potential division by zero
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:57 -07:00
Dirk Hohndel
86b8d796c8 Prevent null pointer dereference
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:56 -07:00
Dirk Hohndel
90f20f4c76 Better error handling
Most of these will likely have no big impact, but it's better not to just
ignore them as they could lead to crashes.

Uemis downloader: if lseek fails, return 0
Uemis downloader: consistently check for failure to open req.txt
Zip file handling: dup could fail

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:56 -07:00
Dirk Hohndel
64c7202e2d Address of array is always non-NULL
We want to test the string instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:56 -07:00
Dirk Hohndel
1ecc9b0cc0 Address uninitialized member warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 10:57:51 -07:00
Dirk Hohndel
85dfb88f51 Cloud storage: correctly store pictures even if they weren't shown before
We could end up in a situation where the hash for a picture hadn't been
recorded yet and then the lookup to make sure that we find the correct
file actually got us nothing.

Now we make sure that the picture is in the hash table before looking up
the file location and before creating the name of the blob that we store
in git.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 06:45:48 -07:00
Dirk Hohndel
a4168ed591 Preferences: don't show error when resetting cloud email / password
Empty values won't work, of course, but they aren't an error, either.

Fixes #887

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 06:42:35 -07:00
Dirk Hohndel
a6e9db196f Initialize members
Globe: initialize doubleClick member
ShiftTimesDialog: initialize when (not sure this could be a problem)
SetpointDialog: dc could be uninitialized or could be 0 and dereferenced

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 22:31:03 -07:00
Dirk Hohndel
83a5778f62 Uemis downloader: open returns -1 on error
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 22:16:23 -07:00
Dirk Hohndel
b8b0364873 Prevent unintended integer division
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 22:11:49 -07:00
Dirk Hohndel
895d6e0000 Comparing the address of a member to 0 is pointless
Or... this code doesn't do what you think it does.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 22:11:49 -07:00
Dirk Hohndel
2c0223fbb2 Fix missing curly braces that change control flow
Indentation thankfully is not the same as scope.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 22:00:21 -07:00
Dirk Hohndel
99bcdb3f30 OSTC tools: prevent unknown dc family
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:58:10 -07:00
Dirk Hohndel
66375689b8 Prevent null dereference
In each case there are scenarios where we would have dereferenced NULL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:53:53 -07:00
Dirk Hohndel
18d52ec86e Prevent possible null pointer dereference
Neither of these functions should ever be called with dc == NULL.
But it's easy to prevent the potential crash.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:40:21 -07:00
Dirk Hohndel
52ee5f28c2 Initialize variable to avoid false positive in coverity
We now that plotInfo.nr will always be positive. Still, this is cheap and
shuts up the "defect".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:35:04 -07:00
Dirk Hohndel
c01c35ca0c Cylinder model: fix an obscure case that would access cylinder -1
If we remove a cylidner for a unique gas and that is allowable, then don't
try to copy from cylinder with index same_gas (which is still -1).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:30:38 -07:00
Dirk Hohndel
ce1be9c2eb Prevent theoretical out of bounds access
When I stare at the code enough I can convince myself that cylinderindex
will always be assigned a sane value, but on the flip side, making sure
nothing stupid happens is cheap insurance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:17:42 -07:00
Dirk Hohndel
f5726c3d18 Fix a number of resource leaks
Free memory returned from parse_mkvi_value()
Free memory returned from printGPSCoords()
Free memory allocated in added_list and removed_list
Free memory allocated when adding suffix to dive site name
Free memory allocated in cache_deco_state()
Free memory allocated in build_filename()
Free memory allocated in get_utf8()
Free memory allocated in alloc_dive()
Free memory allocated as cache but never used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:13:32 -07:00
Dirk Hohndel
004705e33e Fix missing return statement
Returning 0 implies success.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 20:18:58 -07:00
Dirk Hohndel
6811f77cdd Fix incorrect buffer length calculation
Oops, this is bad as it will lead to a certain buffer overrun.

The other change is more cosmetic - nested open comment '/*'.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 20:02:01 -07:00
Dirk Hohndel
152eeb45d6 Some file dialogs insist on adding a default extension
We already had code to deal with this in the Save As case, but similar
handling is needed in the Open case.

This commit also makes the regular expression handling a bit stricter and
identical between the two cases.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 16:28:38 -07:00
Rick Walsh
48aa0bdfd0 Planner: change timestep to 2 seconds
Change the timestep used to calculate tissue pressures and ascents from 3
seconds to 2 seconds. But whats wrong with using 3 seconds?

Deco stops are at 3 m (10') intervals, and our ascent rate is usually
9 m/min (30'/min), or at least multiples of 3 m/min (10'/min).  Hence time
to ascend from one stop to the next stop is 20s (or any factor of 60).
Using 3s increments, we round our ascent interval up to 21 s, which leads
to messy durations and runtimes.

But what about me?  I like SI units and whole decimals.  Don't worry, 2s
timesteps fit nicely when using 10 m/min ascent rate (18 s between stops).

[Dirk Hohndel: edited the commit message to fix minute/second confusion]

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 15:29:22 -07:00
Dirk Hohndel
6f03aeaf08 Restructure preferences dialog so it fits on smaller screens again
Designer is such a pain to work with. Once I ended up editing the .ui file
by hand for the hard stuff and then just use designer to get it
consistently formated. Such a disappointment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 15:21:56 -07:00
Dirk Hohndel
174cb1ffb1 HTML export: need to work harder to find the pictures
Simply looking at the filename in the picture structure isn't enough (now,
arguably one might say that it should be and that that data structure
should be updated, but that's not how other parts of Subsurface have
implemented things so I don't want to break that assumption here).

So instead we look up where the pictures actually was loaded from and then
copy that file into the right location.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 12:49:05 -07:00
Dirk Hohndel
31fbc16785 Git storage: implement picture loading from git
The interesting challenge here is what to do with the picture data stored
in the git repository. If the pictures are already in the file system (for
example because Subsurface is runnin on the same machine that this data
file was saved on) it would be silly to extract them again every time the
dive log is opened.

So instead we try to figure out if the pictures can be located and only
create local copies of them if that isn't the case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 12:49:05 -07:00
Dirk Hohndel
785f9ba835 Cmake support: the printer files are part of the UI
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 12:49:05 -07:00
Dirk Hohndel
c9d48c9a72 Add helper function to return local filename of picture as C string
This way we can actually find the picture that we are showing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 12:49:05 -07:00
Dirk Hohndel
97386a6f3d Git storage: store pictures in the repository
In order to be able to see pictures when using cloud storage from
different machines, we really need to store the pictures with the dive
data.

This could be made optional with a preference, but for now I'll just
enable it by default.

Loading the pictures from git still needs to be implemented.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 10:47:00 -07:00
Dirk Hohndel
2005723989 Make helper function deal with files that don't exist
Ignoring when you can't open a file and happily hashing its contents seems
wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 10:47:00 -07:00
Dirk Hohndel
b27538feba Move helper declarations into a better header file
This way the helpers can be more easily used by other modules.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 07:45:22 -07:00
Dirk Hohndel
9d8b05f47e Git storage: replaces colons with equal in picture offset
I found another place where we had colons in file names...

This fixes a small cut and paste error in an error message as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 06:23:49 -07:00
Dirk Hohndel
217c6462f5 CMake support: turn building for mobile into an option
This way it can be easily turned on and off from ccmake.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 05:56:36 -07:00
Dirk Hohndel
ff906ba699 Cmake support: fix typo
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 05:48:10 -07:00
Rick Walsh
e5a4b5a618 Planner - end deco stops at whole minutes of runtime
--20cf303ddd3893b1500518e9204e
Content-Type: text/plain; charset=UTF-8

Use an adjusted timestep to calculate length of deco stops, so that they
always end at whole minutes of runtime.  This makes for a cleaner ascent
profile.

<div dir="ltr">Use an adjusted timestep to calculate length of deco stops, so that they always end at whole minutes of runtime.  This makes for a cleaner ascent profile.<br></div>

From 15e08450252f304fc7d46931e2aca5c991c2f3de Mon Sep 17 00:00:00 2001
From: Rick Walsh <rickmwalsh@gmail.com>
Date: Sat, 20 Jun 2015 11:36:07 +1000
Subject: [PATCH 2/2] Planner - end deco stops at whole minutes of runtime

Use an adjusted timestep to calculate length of deco stops, so that they always end at whole minutes of runtime.  This makes for a cleaner ascent profile.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 18:20:18 -07:00
Grace Karanja
2f25fe9f0b Rename dive class to avoid conflict
Rename the Dive class in divelistmodel.h to a void a conflict with
the Dive class in templatelayout.h

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-20 14:29:24 -07:00