Commit graph

686 commits

Author SHA1 Message Date
Berthold Stoeger
f5eafe2a71 Cleanup: Fold add_hash() call into learnHash() function
learnHash() was always called in conjunction with add_hash(). The
pattern was that a local filename and a hash were connected in
the hash-to-filename and the filename-to-hash maps. Then, the
original picture-filename or url were registered in the filename-to-hash
map.

This commit changes learnHash() to take three parameters (original-filename,
local-filename and hash) and do all of the above. The new code is
simpler because no dummy picture struct has to be generated in
DiveListView::loadImageFromURL().

The tests were extended to check for all hash<->filename associations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05 18:04:57 +02:00
Stefan Fuchs
9a8a0afa29 Configure DC dialog: Always correctly set update firmware button
Always set the update firmware button correctly based on DC model.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-05 16:19:49 +01:00
Stefan Fuchs
1723db9d0b Configure DC dialog: Add a few missing translations
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-05 16:19:49 +01:00
Stefan Fuchs
eb08ec972d Configure DC dialog: Change order of DCs and correct names
In the configure dive computer dialog change the order of the DCs
(all HW first, then Suunto) and correct the names of some HW DCs
(make them the same as in the "download from DC selection list").
Plus added the OSTC Plus to the list of supported DC.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-05 16:19:49 +01:00
Stefan Fuchs
3eb5970bec Indentation fix in desktop-widgets/downloadfromdivecomputer.cpp
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-04 12:53:36 +02:00
Stefan Fuchs
ff076cd5d4 Correctly spell OSTC cR
Correctly spell OSTC cR (wrong: "Cr") in two files.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-04 12:53:36 +02:00
Oliver Schwaneberg
0ca52f868e Choose water presets from a qcombobox in planner, custom value possible
Add a combo box for water types with defaults for fresh water, sea water
and the EN 13319. All values taken from units.h, where EN 13319 was added
beforehand.
Custom values can be entered through a spinbox.
Also changed "Salinity" in TapDiveInformation.ui to "Water type".

Translation required!

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-03-02 08:38:22 -08:00
Willem Ferguson
e2a6b96db8 Move icd preference setting
Move the icd preference setting to the preference group that deals
with gas pressures.

I also reorganised the existing items so that the items within the
pressure widget are logically arranged according to the grid layout.
The order of items was very haphazard. No change of code at all in
this reorganisation.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-02-26 19:05:26 +02:00
Berthold Stoeger
8251a6e980 Cleanup: remove two unused macros in tabwidgets/maintab.cpp
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 08:53:12 +01:00
Berthold Stoeger
7bd860f2b7 Cleanup: Use QString as parameter for [get|save]BtDeviceInfo()
Each callsite of saveBtDeviceInfo() has a QString, which is converted
to a C-string, passed and immediately converted back. Remove these
conversions by taking a reference to QString directly.

getBtDeviceInfo() is not as clear. Here, the callsite has a C-string
handed down from libdivecomputer. Nevertheless, pass a reference of
QString here as well. Firstly, for reasons of symmetry. Secondly,
to avoid multiple conversions in the getBtDeviceInfo() functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 08:52:34 +01:00
Stefan Fuchs
95a23cf470 Use temperature_t for temperatures in struct stats_t
Use struct temperature_t for temperatures in struct stats_t and
use get_temperature_string() when printing these temperatures for
statistics and HTML export.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-24 11:45:17 -08:00
Stefan Fuchs
4b2f289e4f In configure DC dialogs don't use a space between values and units
In the configure dive computer dialogs remove all the spaces between
values and units. This makes it consistent with the standard used
all over the Subsurface UI.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-22 21:48:05 +02:00
Stefan Fuchs
e7ae749d52 Consistently use the famous l for liters in info tab
For salinity in info tab change the l character to the famous
Subsurface "ℓ".

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-17 19:48:50 -08:00
Berthold Stoeger
5c248d91cd Coding-style: remove superfluous parentheses
Mostly replace "return (expression);" by "return expression;" and one
case of "function((parameter))" by "function(parameter)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17 19:38:52 -08:00
Berthold Stoeger
1f80e100bb Cleanup: fix emits in WinBluetoothDeviceDiscoveryAgent
As far as I know, Qt's emit is defined to nothing.
Thus, the construct "emit(lastError);" is compiled to
"(lastError);", which is a no-op.

Obviously "emit error(lastError)" was meant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-11 12:53:57 -08:00
Berthold Stoeger
1127a425de Cleanup: use constructor directly instead of move-assignment
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-11 12:53:57 -08:00
Robert C. Helling
920aa613c9 Add a preference to turn on ICD warnings
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-02-10 10:26:34 +01:00
Berthold Stoeger
a3d61c1575 downloadfromdivecomputer.cpp: remove unused variable err_string
This was a relict from Gtk days.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-04 13:40:32 -08:00
Berthold Stoeger
7fc3a345ff Cleanup: Remove redefinition of DC_TRANSPORT_BLUETOOTH
This transport option was defined at a time where libdc didn't know
anything about bluetooth. Nowadays, this enum is defined by libdc to
a different value.

Since it is never returned from libdc, not a problem at the moment.
But this looks like a recipe for desaster, therefore let's just use
the libdc version.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-04 13:40:32 -08:00
Oliver Schwaneberg
eb38a64149 Do not remove seconds from duration input field
This change deals with issue #554.
If you enter a dive duration manually, the cell renderer cuts the seconds
away when the changes are saved. I added the helper "render_seconds_to_string"
as a counterpart to "parseDurationToSeconds". The helper keeps the seconds,
if not null. The rendering of the cell is done at two places in the code,
so I think it is cleaner to add a dedicated method for it.

Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-02-04 13:40:02 -08:00
Stefan Fuchs
b5ce06c8b9 Free various struct membuffer in different functions
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-02 11:29:55 -08:00
Berthold Stoeger
8f81a22e7f Make report_error() reentrant
Remove the global error buffer and pass the error string directly
to the frontend. The frontend is then responsible for accumulating
errors.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00
Berthold Stoeger
df81a39aa5 Remove unnecessary check for MainWindow instance
The error-callback is installed in the MainWindow constructor.
Therefore, in the error-callback the existence of the MainWindow
instance is guaranteed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00
Berthold Stoeger
a25f54e3c2 Use queued connection to thread-safe MainWindow error handling
Up to now, errors produced by threads were not directly shown in
the MainWindow. Code running in the GUI thread had to manually
show the errors.

This can be simplified by using Qt's queued connection as message
passing facility.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00
Berthold Stoeger
1704e08012 Make future_watcher a subobject of NotificationWidget
This was a raw pointer. No point in doing error-prone manual
memory management.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31 14:47:26 +01:00
Stefan Fuchs
79ce3c02cb Use correct alias for satellite icon for revers geo lookup
Bring back the satellite icon for the reverse geo lookup by using
the correct alias name.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-27 12:29:00 -08:00
Jan Mulder
e592dfe17c Whitespace only
Now that we properly return when raising an error, do not
if () else if(). Useles.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-18 09:44:08 +01:00
Jan Mulder
d28f48a793 Fix preferences handling with invalid passwords
This fixes 2 problems related to entering passwords with
illegal characters in it:
1) Do not save an invalid password in the preferences, but keep the old
one.
2) On password change, check both old and new password for format
validity instead of pushing an invalid password to the server that
has to ignore it.

Fixes: #1048

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-18 09:44:08 +01:00
Berthold Stoeger
ff9bdfd0df Fix PreferencesNetwork::passwordUpdateSuccessful slot
In preferences_network.cpp, the CloudStorageAuthenticate::passwordChangeSuccessful
signal was connected to the PreferencesNetwork::passwordUpdateSuccessful
slot. This never worked, because passwordUpdateSuccessful() was declared
as a normal member function, not a slot (hooray for Qt's weird runtime-checked
signal system).

While touching this code, change the weird SIGNAL/SLOT macros to
actual member function, to at least get *some* compile-time checks.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-18 08:56:27 +01:00
Robert C. Helling
de49f2484f Resize progress bar width to fit all text
At least on Mac with larger font sizes part of the label
text of the git access progress bar is cut off (even though
it should automatically resize). This patch adds explicit
resize.

Fixes #1041

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-13 19:13:14 +01:00
Berthold Stoeger
6a07ccbad2 Use helper function empty_string() instead of manual checks
For code consistency, substitute boolean expressions:
 s && *s     -> !empty_string(s)
 s && s[0]   -> !empty_string(s)
 !s || !*s   ->  empty_string(s)
 !s || !s[0] ->  empty_string(s)

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Berthold Stoeger
e85ecdd925 Introduce helper function empty_string()
There are ca. 50 constructs of the kind
  same_string(s, "")
to test for empty or null strings. Replace them by the new helper
function empty_string().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11 06:07:13 +01:00
Jan Mulder
d0ff3917b1 Unused code: GroupedLineEdit::removeAllColors()
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10 16:45:42 +01:00
Berthold Stoeger
339f214384 Remove redundant setting of prefs.git_local_only
In MainWindow::on_actionCloudOnline_triggered(), prefs.git_local_only
was set twice in the case of going online. Remove the second,
unnecessary, assignment.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 12:01:04 +01:00
Berthold Stoeger
099662023c Move resetting of current file out of clear_dive_file_data()
This is the only case where C-code sets the current file.
Remove this call for a better separation of C-backend and
C++-frontend parts.

There were four callers of clear_dive_file_data(). Two of them
would call set_filename() anyway. For the remaining two add an
explicit call to set_filename().

This commit fixes a bug introduced in commit b3901aa8f9:
The cloud-online menu entry was still enabled after "closing" the
cloud storage.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-08 12:01:04 +01:00
Miika Turkia
b808723f9c Refactor CSV import
Move CSV import related functions into import-csv.c.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-01-08 06:06:12 +02:00
Berthold Stoeger
59526e948a Remove cloud_background_sync preferences option
The preferences flag cloud_background_sync used to be used heavily in
the mobile code, but is not used there anymore. Now, it is accessed
only in one place, but does not do what it actually says: If it is off,
the remote storage is not synced on save (but will be synced on next
load).

Syncing on save can also be prevented by unchecking the "Cloud online"
menu checkbox. Since the latter seems more logical and general
(support for non-cloud remote git repositories), remove the cloud_background_sync
option.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
b3901aa8f9 Enable cloud-online menu entry only if connected to cloud
Enable the menu item cloud-online only if the current file is the
cloud storage. Since this has to be checked every time the current
file is set, factor this out into the new MainWindow::setCurrentFile()
function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
bb64c6bda8 Turn take-cloud-online menu action into checkbox
Replace the "Take cloud storage online" menu entry by a "Cloud online"
checkbox. After this change, the user can also force going offline.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Berthold Stoeger
dbef391786 Sync cloud storage on take-cloud-online
When taking the cloud online, actually sync with the online cloud storage.
If there are no unsaved changes, do the same as "Open cloud storage".
If there are unsaved changes, ask the user if they want to commit them
(do the same as "Save to cloud storage") or if they want to sync manually.

If syncing failed, inform the user.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06 10:46:07 -08:00
Jan Mulder
97127e1652 Do not save WebserviceID in preferences until asked for
Do not save the WebserviceID in the preferences until we ask
for this. That is simply wrong.

This is definitely not a full fix for all the weirdness that is
going in related to the WebserviceID but saving the ID even
if we do not ask for it, adds to possible confusion.

To always automatically pull in the ID from the server based
on cloud credentials, just leave the ID field empty in the
network preferences.

Fixes: #1013 (well ... a tiny part of this mess)

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-06 10:42:44 -08:00
Jan Mulder
2371c6ada6 cleanup: use new urls
Just rename some old hohndel.org urls

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-06 09:21:16 +01:00
Jan Mulder
fc7729eb78 cleanup: localize global variable
Not needed to be global.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-06 09:21:16 +01:00
Jan Mulder
70e0e80de5 GPS: use applyGpsLocation::applyLocations from core
Fixes a big duplication of code. The code to apply GPS locations
from the location service was already in core, and used from mobile,
but there was an almost literal copy in the desktop code.

See also commits 6f42ab46da and ee9531f76e, where only
one side of the duplicated code was fixed.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-06 09:21:16 +01:00
Berthold Stoeger
40fa148548 Replace BEHAVIOR macro by initializer lists
The macro BEHAVIOR expanded to "QList<int>()". This was used to
generate temporary QList<int>s with constructs such as
  BEHAVIOR << COLLAPSED << EXPANDED
Instead, simply use initializer lists such as
  {COLLAPSED, EXPANDED}

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00
Berthold Stoeger
f8517c583b Replace macro TOGGLE_COLLAPSABLE by function toggleCollapsible()
There was no reason to do this in a macro. Let the compiler decide
if it wants to inline or not. Note that for consistency with the
Qt functions, collapsAble was replaced by collabsIble.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00
Berthold Stoeger
b4e36c5912 Use set_autogroup() function
Since this function exists, use it instead of setting the global
variable directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-04 08:21:43 -08:00
Stefan Fuchs
34d1dd469c Enable translation of ctrl key name for tool tip in dive notes
This really enables the translation of the ctrl key name.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-02 09:12:31 -08:00
Stefan Fuchs
b7494bfb2e Cleanup: Rename preferences ui file names according the standard
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-02 09:12:31 -08:00
Stefan Fuchs
ecd6dcaf6d Remove leading space from kg/l units for salinity
Change this according to our standard of NOT having a leading space
before any unit.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-02 09:12:31 -08:00