strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common
occurrences that they seem worthy of a short helper-function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace constructs of the kind
s.toUtf8().data(),
s.toUtf8().constData(),
s.toLocal8Bit().data(),
s.toLocal8Bit.constData() or
qUtf8Printable(s)
by
qPrintable(s).
This is concise, consistent and - in principle - more performant than
the .data() versions.
Sadly, owing to a suboptimal implementation, qPrintable(s) currently
is a pessimization compared to s.toUtf8().data(). A fix is scheduled for
new Qt versions: https://codereview.qt-project.org/#/c/221331/
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>