Commit graph

13292 commits

Author SHA1 Message Date
Stefan Fuchs
603e43f46e Use function emitDataChanged in diveplannermodel consistently
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Stefan Fuchs
337f82c876 Code cleanup: Indentation mistake plus simplification
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Stefan Fuchs
d703ba99c1 Simplify update of gflow and gfhigh values in the code
The more complex handling is no longer needed because:
- Keyboard tracking for gfhigh/low UI fields was switched off here:
  030c094854
- GFhigh was limited to 40 here:
  53fffe0ce3

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Stefan Fuchs
3ad398e3a7 Remove obsolete declaration of void gfLowAtMaxDepthChanged
in ./core/subsurface-qt/SettingsObjectWrapper.h

Code for this was removed here: 5b080bedde

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Stefan Fuchs
4db9f5dbbd Correcty typo ghflow -> gflow in diveplannermodel.cpp
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Jan Mulder
60e82cc2ac cleanup: remove unused include
And why this one? Well, while this include is renamed in Qt 5.10
and gives deprecated compile warnings. And as it unused anyway, just
remove it.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-23 11:17:47 +01:00
Berthold Stoeger
935fb3c3df Fix BuddyFilterModel
Commit 6343515fed introduced equality
instead of substring comparison for filters. This broke the buddy
filter in the case of more than one buddy, because in such a case
the buddy list is a comma-separated string.

Fix this by splitting the buddy string, trimming the individual
strings and search in the list.

Fixes #969

Reported-by: <yrevawerd@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-21 21:09:35 +01:00
Jan Mulder
e4530cd5ef cleanup: remove empty function
subsurface_OS_pref_setup() is not not used. Remove it.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-21 15:11:15 +01:00
Berthold Stoeger
28ae35e7df Make QMap<> access in deleteGpsFix() more idiomatic
To access a QMap<> entry, the value() function is used with a sentinel
as default value. If the sentinel is returned, the code assumes that
the searched for entry doesn't exist.

Make this code more idiomatic by using an iterator and testing for
end().

This fixes a compiler warning, because only one of the elements of
the sentinel was initialized, but the remaining elements were
copied. Harmless, because the code would exit early if it found
the sentinel. Still not nice.

While redoing this function, the entry-not-found message was improved
(adding of function name, space between massage and timestamp) and
elevated from debug to warning level.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-21 00:04:30 +01:00
Berthold Stoeger
22dc7b84f0 Handle plot_info->nr <= 0 gracefully
plot_info->nr should always be > 0. If this is not the case, write a
message to stderr instead of crashing in add_plot_pressure(). This
silences an use-of-uninitialized-variable warning.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-21 00:04:30 +01:00
Berthold Stoeger
0b2d22494c Fix use of uninitialized variable in core/profile.c
last_ceiling was used before initialization in the first iteration
of the loop in calculate_deco_information().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-21 00:04:30 +01:00
Berthold Stoeger
3c346bb341 Check return of fread() in core/ostctools.c
Since the corresponding error message appears thrice, it is translated
once at the beginning of the function (even in the non-error case).

A single-byte fread() was transformed into getc().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-21 00:04:30 +01:00
Berthold Stoeger
1c1ca8c1c7 Fix order of initilization list in MainTab constructor.
Besides being the right thing to do (code reflects reality), it
silences a compiler warning.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-21 00:04:30 +01:00
Jan Mulder
1fee77487b core: ignore erroneous quotes as well
A small redo of 78bafe8f62. The quotes cause the original
functionality not to work. Ignore them as well.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-20 15:39:54 +01:00
Jan Mulder
6e411cc67d core: fix commit 46004c39e2 for real (erroneous quotes)
Unfortunately, in my commit 48d9c8eb6e, I fixed only half of
the problems related to the functionality introduced by Stefan in
commit 46004c39e2. The lonely m (that was fixed) caused
a parsing error, but forgotten where the single quotes around
the depth value. These quotes simply causes the new functionality
not to work. Again, the fix is simple: do not erroneously save
quotes. And as the new functionality is pretty obscure
(replanning a non-planned dive, and manually entering a gas switch
depth), another bug that could go unnoticed for years.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-20 15:39:54 +01:00
Jan Mulder
b7dcbb58fa CHANGELOG.md
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-19 05:13:23 -08:00
Jan Mulder
8c77c15dd8 git storage: invalidate cache on merge dive site
In hindsight a very simple bug to fix, but it requires some
knowledge on the inner workings of our git storage. The changes
on merge of dive sites were simply not saved (completely) because
the git storage code has a cache that we need to invalidate
selectively (ie. for the dive we just gave a new dive site uuid)
to get things finally embedded in the overall commit.

The main reason this bug went unnoticed for more than 2 years is
that most people use the XML/SSRF format (where this problem is
non exsistent), and dive site merging is probably not a very
much used feature either.

Fixes: #939

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-19 05:13:23 -08:00
Robert C. Helling
8633577a45 Changelog
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-18 15:35:27 -08:00
Berthold Stoeger
54feaa8fcb Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18 12:07:10 -08:00
Berthold Stoeger
05a1626c7e Implement different zoom levels for dive photos tab
This implements different zoom levels for the dive photos tab as
suggested by Stefan Fuchs <sfuchs@gmx.de> in #898.
The zoom level can be changed using a slider or CTRL+mousewheel.
Zoom levels range from a third of the standard thumbnail size to
thrice the standard thumbnail size.

Thumbnails are cached in maximum resolution and scaled down on
the fly. Because the profile widget took its pictures from the
photo list model, an extra picture copy with a fixed size had
to be introduced.

The UI is still a bit crude.

Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18 12:07:10 -08:00
Berthold Stoeger
0d01c70f3a Make protected DivePictureModel members private
The constructor and the list of pictures was protected, but the
class neither had friends nor subclasses (a subclass was removed
in a recent commit).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18 12:07:10 -08:00
Berthold Stoeger
2f5f1e036e Make scaleImages() a static function
It was only used by the DivePictureModel class, no need to export it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18 12:07:10 -08:00
Jan Mulder
78bafe8f62 core: ignore bogus m in cylinder
A bogus key/value pair was introduced in the cylinder,
consisting of a lonely "m" without value. This is caused
by commit 46004c39e2 and fixed in 48d9c8eb6e. See referenced
commits for more info.

Just ignore this key/value pair. No processing is broken
due to this, as the git storage stores only metric SI type data.
In fact, the m unit is superfluous anyway.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-18 21:00:01 +01:00
Robert C. Helling
3985a8aa8f Allow to read factor cache concurrently
In a session with the profile I saw that the planner spends
a lot of time waiting to obtain the lock for the factor cache.
Most of the time we are only reading that cache and that
is save to do in parallel (according to the Qt IRC channel).

So we can use a QReadWriteLock instead of a QMutex. This
appears to be quite a performance boost, in particular
for VPM-B

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-18 11:29:17 -08:00
Robert C. Helling
9d844801b9 Update download URL for libzip
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-18 11:29:17 -08:00
Berthold Stoeger
0f3bda4c44 Compile with -O2 optimization even in debug mode
The -O0 default is useless owing to extremely convoluted assembly.
Moreover, many warnings depending on data analysis are ineffective
with -O0.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18 08:17:35 -08:00
Jan Mulder
5e116db1a1 CHANGELOG.md
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-18 15:23:23 +01:00
Jan Mulder
825afb4db4 mobile: exit edit mode when navigating away from edit page
Navigating using the breadcrumb in the header did leave the
dive detail edit (and add) mode in such a way that (for example)
navigation in the dive list was suspended. Obviously, it is
debatable what should be done. Saving the edits/add, or
cancelling them. For now, this commit cancels them
silently. This is the exact same thing that is happening when
the user selects the dive list from the drawer menu.

Fixes: #932

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-18 15:23:23 +01:00
Berthold Stoeger
7b88f8301e Elevate "can't write hashes" message from debug to warning level
I never realized that my hashes weren't written, because it only
outputs a debug instead of a warning message.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18 15:23:12 +01:00
Jan Mulder
48d9c8eb6e core: fix git storage save (regression 4.7.4 -> 4.7.5)
Commit 46004c39e2 introduces a new field in the logbook outputs
(depth of a cylinder). While in XML the depth unit is stored with a space
between value and unit (m), in our git storage, the unit m is without
space. As the git storage parser uses a space to separate individual
key/value pairs, the erroneously saved space results in parsing warnings
when opening the logbook.

The unwanted space is normally saved just after download of a new dive
from the dive computers, so all desktop-git-storage uses are affected,
and more worrying, mobile beta users.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-18 15:22:50 +01:00
Dirk Hohndel
a225f62588 Cleanup: mark parameter as unused
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 10:25:44 -08:00
Dirk Hohndel
edf569ee6c CLeanup: remove duplicate typedef
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 10:25:30 -08:00
Dirk Hohndel
6b80b41c7c Cleanup: durations are now signed
Somehow a whitespace fix snuck in here. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 10:25:01 -08:00
Dirk Hohndel
648fec7a3d Cleanup: fix potential uninitialized use of uuid
And make sure we don't create a dive site for an empty location string.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 09:12:44 -08:00
Dirk Hohndel
bd66ab15da Turn on -Wall
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 09:08:21 -08:00
Jan Mulder
b59778abd8 mobile: use short date format in edit mode
See issue #949. In the dive list, dates are shown in short format, and
when we start to edit an existing dive, the date field on the edit
page is shown in sort format. However, when adding a new dive, the
initial date shows up in long (normal) format. This in not only
inconsistent, but also introduces the parsing problem, as described
in the mentioned issue.

This can be fixed by using short formatted dates in all cases in
the mobile app. As the screen real estate is precious on mobile,
this seems the most logical choice.

Fixed: #949

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-17 09:04:16 -08:00
Berthold Stoeger
a748e7f239 Unify float calulations: use double
Internal floating point (FP) calculations should be performed using double
unless there is a very good reason. This avoids headaches with conversions.
Indeed, the vast majority of FP calculations were already done using double.
This patch adapts most remaining calculations. Not converted where things
that were based on binary representations and variables which weren't used
anyway.

An analysis of all instances follows:

core/plannernotes.c, l.404:

This was a comparison between two floats. On the left side, first an integer
was cast to float then multiplied with and integer and divided by a constant
double. The right hand side was an integer cast to a float. Simply divide by
1000.0 first to convert to double and continue with calculations. On the right
hand side, remove the cast, because the integer will be implicitely cast to
double for comparison. This conversion actually emits less instructions,
because no conversion to double and back is performed.

core/planner.c, l.613:

Same analysis as previous case.

subsurface-desktop-main.cpp, l.155:

A local variable representing the version OpenGL version. Turn this into
integer logic. Not only does this avoid dreaded FP rounding issues, it also
works correctly for minor version > 10 (not that such a thing is to be
expected anytime soon).

abstractpreferenceswidget.[h/cpp]:

A widget where the position is described as a float. Turn into double.

desktop-widgets/divelogexportdialog.cpp, l.313:

total_weight is described as float. Use double arithmetics instead. This
instance fixes a truncation warning emitted by gcc.
2017-12-17 09:02:44 -08:00
Jan Mulder
b1d94b2470 mobile: manual add dive and cancel fails when repeated
This commit fixes a very subtle bug. Probably there for ages,
but never noticed. When manually adding a dive, and canceling
the add right away, the divetable was extended by 1 dive (using
the core function add_single_dive), but canceling never removed
that dive (using delete_single_dive). This is corrected here.

Notice that commit ef543da5af claims to fix issue #950.
With this commit, however, that issue can be seen sometimes
again.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-16 19:04:57 -08:00
Stefan Fuchs
2890be9256 divepicturemodel: Reset start and end row for displayed_dive correctly
Correct way of using indices for rowDDstart and rowDDend.
Reset rowDDstart and rowDDend at beginning of updating dive pictures.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-15 09:11:28 -08:00
Jan Mulder
ef543da5af mobile: clear internal data when edit/add dive is finished
When editing (or adding) a dive, the internal data containing the
attributes on the edit page was not cleared when editing was
finished (in any way, by saving the edit or by cancelling it).
As long as the user only edits existing dives, all this poses
no problem, as at the start of a dive edit, the data is filled
from the dive to be edited. However, when adding a dive, data
coming from previous edits shows up. This not clearing data
also causes the strange effect as written in issue #950: adding
a dive, deleting it, and adding a dive again, added the first
added dive data, without the edit screen being shown.

All this can be solved by clearing the data from the edit when
editing is done.

Fixes: #950

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-15 09:03:24 -08:00
Miika Turkia
9e165602c4 Add git submodule init to build script
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-12-14 08:54:53 -08:00
Jan Mulder
c2e76aab4b CHANGELOG.md
I think that every published issue that is fixed should be in
the changelog.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-14 08:53:06 -08:00
Jan Mulder
dd87350cb7 mobile: stay on same dive after edit
See issue #875. In hindsight the reason for this bug is easy to
understand. When updating a dive, the dive was first removed
from the model, and added in its new state again. This does seems
resonable, but the delete in the model causes the internal (QML)
state to be changed, and the previous state (like the currentIndex
that was pointing to the just deleted row, so that one is changed to
something valid internally) is not restored at recreation of
the edited dive. The QML engine has no way to understand that
the remove and subsequent add are in fact one atomic operation.

This can be solved by simply updating the underlying data in
place, and notifying the change using a dataChanged emitted
signal. The dataChanged signal takes care of the repaint of
the screen, and there is no need for removeRow/insertRow pairs.

Fixes: #875

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-14 08:53:06 -08:00
Jan Mulder
62ef78b5e8 mobile: show message when going offline
Trivial fix. Show the message "Turning off automatic
sync to cloud ..." when turning automatic sync to offline. Just
a more logical moment to show this message. Also rephrase the
message "Enable auto sync" to "Auto sync enabled". It shows
a status, and not an action.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-14 17:01:51 +01:00
Berthold Stoeger
c21e998277 Don't create GeneralSettingsObjectWrapper object
Instead use the application-wide instance. Creating a local
object defeats the whole purpose of these objects - nobody
can receive signals in case the settings changed.

No other cases of locally created SettingsObjectWrapper
objects were found.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-14 17:01:34 +01:00
Berthold Stoeger
074ddc0596 Remove function isCloudUrl()
The function isCloudUrl() was only called in one place, parse_file().
But, isCloudUrl() could only return true if the filename was of the
git-repository kind (url[branch]). In such a case, control flow would
never reach the point where isCloudUrl() is called, since
is_git_repository() returns non-NULL and the function returns early.

Therefore, remove this function. Moreover, adapt the affected if-statement
by replacing "str && !strcmp(str, ...)" with the more concise
"same_string(str, ...)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-14 17:01:05 +01:00
Jan Mulder
375490dfc9 CHANGELOG.md
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-13 08:23:27 -08:00
Jan Mulder
239974d600 mobile: reset download screen in a sane state
Set download srceen in a sane state after a previous download
session using this screen. The erroneous behavior was very
similar to the one fixed in commit 7fe9bbe295dcf92. For example,
download some dives, quit the screen, go back, and the bottom
buttons are still selectable.

This commit resets some values when leaving the download screen
(ie. not only swiping it away), so that it looks sane at a next
visit.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-13 08:23:27 -08:00
Jan Mulder
59f86a06ad mobile: reset Retry button to Download
Reset the Retry button on exit of the Download from divecomputer
page. So, it it not reset wehen swiping this page away, or
cancelling a running download, but resetting it on accepting
downloaded dives.

As we do not have real error reporting (from download failures),
this all is a little arbitrary. Another "fix" could be, not
changing the button text at all.

Further notice, this is not specific iOS, but also Android.

Fixes: #895

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-13 08:23:27 -08:00
Dirk Hohndel
88141fb70d Add CHANGELOG for the last merge
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-13 05:51:39 -08:00