Commit graph

1094 commits

Author SHA1 Message Date
jan Iversen
f86dd889bf core: remove prefs-macros.h where unused
move #include prefs-macros from SettingsObjectWrapper.h to SettingsObjectWrapper.cpp
include dive.h directly (only part of prefs-macros.h used) in preference classes

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-01 22:06:28 +02:00
Murillo Bernardes
2de814fec8 desktop: fix multi-keystroke input on location
When the tooltip is hidden QInputMethodEvent is handled
by QLineEdit and works properly.
When the tooltip is visible DiveLocationListView gains
focus and receives QInputMethodEvent, without handling
them properly.

This patch just forwards the event back to the QLineEdit
object.

Fix #1405

Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
2018-06-26 08:06:07 +02:00
Berthold Stoeger
db0dd54c37 Localization: make cache thread safe and robust against use-after-free
The old trGettext() was not thread-safe and the returned C-strings
could be freed in the case of empty translations strings. Therefore:

1) Introduce a mutex protecting access to the cache.

2) Never change existing entries, even if the translation string is empty.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
Berthold Stoeger
879cb73b8b Localization: remove gettextFromC::instance()
There were a handfull instances of the kind
1) gettextFromC::instance()->tr(...)
2) gettextFromC::instance()->trGettext(...)

1) is pointless, as tr is a static function.

All instances of 2) were likewise pointless, because trGettext()
returns a C-string, which was then immediately converted to a
QString.

Thus, replace both constructs by gettextFromC::tr(...).

After this change there was only one user of gettextFromC::instance()
left, viz. the C-interface funtion trGettext(). Therefore, remove
gettextFromC::instance() and do all the caching / translating
directly in the global trGettext().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
jan Iversen
5df93e084d android/desktop: remove mapWidget from subsurface.qrc
remove mapWidget entries from subsurface.qrc, and
add reference to map-widget.qrc in CMakelist.txt

Android uses the same CMakelist.txt

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-21 20:27:58 -07:00
Lubomir I. Ivanov
769aca9e95 equipment: sanitize 'tank_info' loop limits
In a number of places the global 'tank_info' array
is being iterated based on a 'tank_info[idx].name != NULL'
condition.

This is dangerous because if the user has added a lot of tanks,
such loops can reach 'tank_info[MAX_TANK_INFO]'. This is an
out of bounds read and if the 'name' pointer there happens to be
non-NULL, passing that address to a peace of code that tries
to read it (like strlen()) would either SIGSEGV or have undefined
behavior.

Clamp all loops that iterate 'tank_info' to MAX_TANK_INFO.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-06-20 09:30:58 +09:00
Stefan Fuchs
0a3fe87f54 In dive picture shift time dialog suppress double triggering of timeEdit
In dive picture shift time dialog when pressing the up or down arrow
of the timeEdit widged there is some risk of double triggering because
the function called after this UI action ("updateInvalid()") can have
quite some runtime.

Suppress any potential double triggering by disabling the timeEdit
widget after each change until the code is processed.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 15:08:27 +09:00
Stefan Fuchs
c953aadcf8 Change from gettextFromC::instance()->tr() to gettextFromC::tr();
Code cleanup.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 07:42:39 +02:00
Stefan Fuchs
88e6ba2f61 Use correct "tr" call for translating dive mode names
Correctly use gettextFromC::instance()->tr(); instead of a simple
tr(); to translate the dive mode names.
This goes on top of 0bc9edf855
and finally makes the whole thing work.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 07:42:39 +02:00
Berthold Stoeger
1f654050fa Dive computers: turn QMultiMap into sorted vector
The list of known dive computers was stored in a multi-map indexed
by the device name. Turn this into a sorted QVector. Thus, no
map-to-list conversion is needed in the device editing dialog,
which distinctly simplifies the code.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17 06:53:13 +09:00
Berthold Stoeger
b0cc416954 Cleanup: fold DiveComputerManagementDialog::update() into init()
update() was only called in conjunction with init(). No point in
having two functions. The separation between both functions seemed
arbitrary anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17 06:53:13 +09:00
Berthold Stoeger
f54764cdbc Cleanup: use QScopedPointer for DiveComputerManagementDialog::model
Not necessary to do own memory management.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-17 06:53:13 +09:00
Stefan Fuchs
0bc9edf855 Fix an error around translation of dive modes in the UI
This fixes an mistake introduced in
3d1072f886

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17 06:36:20 +09:00
Dirk Hohndel
b9318a9ab1 desktop: better handling of progress dialog width
We shouldn't need to manually set it, but it appears we do. To avoid
constant resizing, let's only grow it - and let's set the size before we
update the text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-06-17 06:17:08 +09:00
Berthold Stoeger
3f012f4bdb Cleanup: Don't clear WA_QuitOnClose attribute on dialogs
According to Qt's documentation, the application exits if all windows
with the WA_QuitOnClose attribute are closed. This attribute was cleared
for three dialogs. This seems not necessary because:
1) The application can't be closed as long as the modal dialog is shown.
2) The flag only concerns primary windows, which these are not.

See: http://doc.qt.io/qt-5/qguiapplication.html#quitOnLastWindowClosed-prop

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-16 04:02:47 -07:00
Berthold Stoeger
4e8079f527 Cleanup: make lastUsedDir() functions static and non-slot, respectively
The lastUsedDir() functions of MainWindow and Smrtk2ssrfcWindow don't
use any member-objects and are only used in their respective translation
units. Therefore, remove them from the class and made of static linkage.

The lastUsedImageDir() function was declared as a slog, which makes
no sense. Make it a normal static function (though one might argue
why it is assiociated with the DiveListView class in the first place).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-09 17:11:29 +02:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
helpers.h included qthelper.h and all functions declared in helpers.h
were defined in qthelper.h. Therefore fold the former into the latter,
since the split seems completely arbitrary.

While doing so, change the return-type of get_dc_nichname from
"const QString" to "QString".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04 08:50:10 -07:00
Berthold Stoeger
9611e92cf0 Desktop: Derive UserManual from QDialog
In commit d21d42b691 helpView was made
a child-object of MainWindow, which is Qt's idiomatic way of having
helpView deleted with MainWindow.

As an unintended consequence, the helpView didn't show. The reason
is that UserManual derives directly from QObject. In contrast, UserSurvey
derives from QDialog and is correctly shown. Therefore also derive
UserManual from QDialog.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-31 21:29:29 +03:00
Robert C. Helling
7c6e5ed5db Distinguish between user and internal divemode names
The former should be translated but not those that
go to xml/git.

... and fix capitalization of pSCR.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-28 09:57:00 +02:00
Berthold Stoeger
308e079ad6 Dive pictures: automatically recalculate thumbnails
If a thumbnail and the original picture can be accessed and the
modification date of the thumbnail is before the modification date
of the picture, recalculate the thumbnail.

This causes more disk access and might give strange effects for
picture files with messed up file timestamps (i.e. lying in the
future) or messed up computer clocks (i.e. running in the past).
Therefore, add a preference option to disable the new behavior.
Default is set to enabled.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27 23:08:12 +03:00
Berthold Stoeger
23d38a982d Dive pictures: give user option to recalculate thumbnails
Even though hashes of image contents are calculated, the hashes are
not compared to actual file contents in routine-operation. Therefore
give the user the option to recalculate thumbnails, should they have
edited the picture.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27 23:08:12 +03:00
Berthold Stoeger
d21d42b691 Cleanup: remove three instances of deleteLater() in mainwindow.cpp
deleteLater() can be dangerous. Remove where not necessary.

Analysis:

1) `helpView` was a pointer which was initialized on demand. close() and
deleteLater() were called on closure of the main window. Firstly, there's
no point in calling deleteLater(), because no references to helpView
are used later on. Secondly, the deletion (and closing) can be done
automatically in the destructor, by passing `this` as parent object.

2) `survey`: pretty much the same situation. But here, `this` was already
passed as parent object.

3) `progressDialog` is a global (not thread safe!) pointer. The object
is deleted after use. There is no point in using deleteLater(), because
the callers are not active after hideProgressBar(), which is the
place were the deleteLater() call was found.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26 09:21:46 -07:00
Berthold Stoeger
a76f15f0f6 Cleanup: Don't defer deletion of oldModel in DiveListView::reload()
There seems to be no point in using deleteLater() of the previous
model. Set the new model and delete the old one.

This fixes a crash with Qt 5.11.

Tested-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-25 14:15:42 +03:00
jan Iversen
cb9951a484 desktop-widgets: replace (void) with no parameter name
Unused parameters in C++ are "silenced" by removing the name.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24 08:34:14 -07:00
Gaetan Bisson
d3af836467 Fix includes for building against Qt-5.11.0
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
2018-05-23 13:29:37 +03:00
jan Iversen
f92daa456a desktop-widgets/statistics: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
jan Iversen
2b84482787 desktop-widgets/.../facebook: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
jan Iversen
e536682b84 desktop-widgets: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
Berthold Stoeger
3c0c1801cd Dive pictures: change removePicture() interface
The function removePicture() had a flag "last", which would indicate
that the called had finished removing pictures. Only then would
the model be recalculated.

This is a strange interface and, matter of fact, the caller was buggy:
if the last picture to be removed didn't have a proper url, removePicture()
was never called with "last" being set.

Change the interface to take a list of pictures to be deleted. This
will allow us to make picture deletion smarter in follow-up commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21 22:17:28 +03:00
Berthold Stoeger
45395fd466 Dive pictures: Don't plot pictures twice when changing current dive
In MainWindow::current_dive_changed() first plotDive() is called,
which replots all the pictures by calling plotPictures(). This
is pointess, because it plots the pictures of the previous dive.

Then, updateDiveInfo() is called, which resets the dive pictures
and automatically replots them. Thus, switching between dives
both with hundreds of pictures is way slower than necessary.

Switching the plotDive() and updateDiveInfo() calls doesn't work.
The reason is not 100% clear, but it doesn't make sense to plot
pictures of the new dive as long as the profile still shows the
old dive anyway.

As a quick-fix, add a flag to plotDive(), which tells the function
to clear the pictures list instead of redrawing it.
Ultimately, plotDive() should probably be split in two functions.
One for the callers who update the pictures themselves and one
for the others.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-17 07:24:54 -07:00
Robert C. Helling
b8c94cad69 Planner: Add combo box for dive mode selection
I am not really sure what I am doing here but I copied
code from the gas selection.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Robert C. Helling
969dfee9ec Rename enum dive_comp_type to divemode_t
...as the usuage is not anymore about a computer but
a momentary dive mode. Rename the end indicator as well.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14 23:47:00 +03:00
Berthold Stoeger
9b4728c7a9 Cloud-storage: consistently don't save empty file on desktop version
Make the behavior consistent: Don't save an empty file to the cloud,
neither on selection of "Save to cloud" nor on "Save". The latter
was not the case. It was a bit hard to trigger: Open cloud, delete
all dives, save.

Fixes #1228

Reported-by: Jan Iversen <jani@apache.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-14 12:52:54 -07:00
Dirk Hohndel
ea83b5ed37 Core: remove dive.h from files that don't need it
Of course, quite a few of them indirectly get it through other header
files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Berthold Stoeger
afe20ce029 Dive pictures: Update pictures when thumbnails are ready
Connect the thumbnailer signal to the dive picture model slot.
This needs some code-reshuffling in the dive picture model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 13:52:35 -07:00
Berthold Stoeger
57bf174c4f Desktop: On dive edit from the dive list or map, switch to new state
If "Edit dive" is selected from the dive list or the map view, switch
to a new mode, which shows the dive infos and the profile.

After the edit, switch back to the previous state.

Fixes #1213

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 07:08:34 -07:00
Berthold Stoeger
9d342d0e1a Desktop: Make "Edit dive" menu entry work for downloaded dives
Confusingly, "Edit dive" did only work for planned / manually
entered dives. Change this, but only start profile-editing for
planned / manually entered dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13 07:08:34 -07:00
Oliver Schwaneberg
a1e9cce50a Fixed erroneous comparison of cylinders and weight systems.
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-11 02:41:57 +03:00
Oliver Schwaneberg
55ac07f6f6 Corrected file name "weigthsysteminfomodel" to "weightsysteminfomodel"
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-11 02:23:51 +03:00
Oliver Schwaneberg
67f96ec06c Removed a duplicate include in maintab.cpp
Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-05-10 08:31:12 -07:00
Dirk Hohndel
818f02ec4a Desktop: fix time format in main tab
Fixes #1234

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-04 05:59:17 +02:00
Miika Turkia
12e4b6d62c CSV import: include visibility and rating in import
Add support for visibility and rating to CSV import dialog.

Fixes #1212

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-01 22:42:10 +03:00
Miika Turkia
c53442e37e CSV import: parse (unit) style headers
Commit fc010456 introduced the units to column headers. Thus the
matching of these labels must take the unit into account when doing
automatic matching of the header line with our field naming.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-05-01 22:42:10 +03:00
Willem Ferguson
81a812539c Plot OC-pO2 graph for SCR dives
This commit allows plotting the OC-equivalent pO2 graph for PSCR
dives. This happens in both the cases where there is no external
O2-monitoring AND when there is external pO2 monitoring. The
calculations are only done for PSCR dives and is achieved as
follows:

1) Within plot-info create a pressure-t called OC_pO2 in
   profile.h and populate this variable with the open-circuit
   pO2 values in profile.c.
2) Create a new partialPressureGasItem ocpo2GasItem in
   profilewidget2.h and, in profilewidget2.cpp, initialise it
   to read the plot-info OC_pO2 values and enable its
   display by using the setVisible method. The
   diveplotdatamodel was also touched in order to achieve
   this.
3) Create a pref button that controls the display of OC-pO2 for SCR dives
4) Change the colour of the OC-pO2 grpah to orange
5) Change the connection of the crr_OC_pO2 signal to be appropriate
6) rename the OC_pO2 attribute to scr_OC-pO2

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-28 20:11:22 +03:00
Anton Lundin
fd359f5a88 Configure ostc3: Remove obsoleted setting
In firmware version 2.97 the setting 0x38, SETPOINT FALLBACK, has bin
obsoleted and we get a error when trying to write to it.

This removes this setting.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2018-04-27 21:33:47 +03:00
Linus Torvalds
13f5c75ac4 Convert our custom IO model to new libdivecomputer IO model
This converts our old custom IO model to the new model that
libdivecomputer introduced.  This is partly based on Jef's rough patch
to make things build, with further work by me.

The FTDI code is temporarily disabled here, because it will need to be
integrated with the new way of opening devices.

The ble_serial code goes away entirely, since now libdivecomputer knows
about BLE transport natively, and doesn't need to have any serial
wrapper around it.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Miika Turkia
4186733740 CSV import: fix setpoint (typo)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-04-19 15:09:02 +03:00
Jeremie Guichard
7753352e62 Change taglist_get_tagstring to support 'unlimited' tag list size
Previous taglist_get_tagstring signature/implementation did not allow
handling of cases where inputted buffer could not contain all tags.
New implementation allocates buffer based on pre-computed size allowing to
insert all tags in the returned string.

Added get_taglist_string in qthelper to handle conversion to QString
Added TestTagList with tests for taglist_get_tagstring

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-09 07:59:51 -07:00
Jeremie Guichard
12dc1889c7 Add "Tags" column in Desktop app's dive list view
Add DiveItem::displayTags helper method to return Tags as a QString
New Tags column is
 by default inserted before "Photos" column
 by default disabled

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2018-04-04 14:10:45 +03:00
Dirk Hohndel
7e73b30e97 Revert "GPS: use applyGpsLocation::applyLocations from core"
This reverts commit 70e0e80de5.

This caused the GPS workflow to break for Linus. Let's revert
for 4.7.8 and figure out how to do this cleanup correctly, later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-03 11:52:46 -07:00
Dirk Hohndel
ceaf26d198 Revert "cleanup: localize global variable"
This reverts commit fc7729eb78.

This caused the GPS workflow to break for Linus. Let's revert
for 4.7.8 and figure out how to do this cleanup correctly, later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-03 11:52:19 -07:00
Berthold Stoeger
9b2482aca9 Dive pictures: Move metadata functions into own translation unit
Move all metadata function into new core/metadata.cpp file.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01 16:04:48 +03:00
Stefan Fuchs
cfd4c42829 Profile heatmap/heartrate: Only enable max one of these at same time
Only allow to enable maximum one of both items tissue heatmap or
heartrate in profile.
This is done by always switching off the other one at the moment you
turn on one of the two items (heatmap or heartrate).

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-19 15:44:02 -07:00
Berthold Stoeger
8180e49427 Cleanup: Initialize variable MainTab::lastSelectedDive
This variable was read before being set.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-19 08:54:31 -07:00
Berthold Stoeger
2105d3c7d0 Cleanup: consistently use toUtf8() instead of toLocal8Bit()
These do the same, since the text-codex is set to UTF-8 on startup.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
d1572a8d95 Cleanup: introduce copy_qstring() function
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>
2018-03-14 13:55:36 +02:00
Berthold Stoeger
b72cc1f317 Cleanup: consistently use qPrintable()
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>
2018-03-14 13:55:36 +02:00
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
Jan Mulder
e16b58ee08 Desktop: follow autogroup setting in UI
When importing a dive (using import from logfile) and it is a
ssrf/xml file that contains the autogroup setting, the autogroup
is effectuated in the dive list. Not sure that I like this
behavior, but thats the way it currently is. Simply wrong
is that in this case the menu item toggle is not adapted
so we end up with a dive list that is autogrouped, but
the menu toggle is off.

This can be solved by setting the UI toggle in a more central
location.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-02 06:47:53 +02:00
Jan Mulder
ac505600f3 desktop: clear tags when hitting new logbook
A very simple commit to start 2018. When hitting new logbook from
a currently open logbook, and the current dive has tags filled in,
they stayed around in the UI. Just clear them. Further, delete
an unused variable.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-01 10:26:13 +01:00
Berthold Stoeger
3c022d8673 Get Bluetooth device nam from preferences if dialog wasn't shown
If the BT dialog hasn't been shown, the device name was taken from
the text field, which contained a formatted string. The device open
would then fail.

Fixes #1002

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-31 07:56:33 -08:00
Jan Mulder
86860b941e Get ready for 2018
Copyright strings updated.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-30 08:23:22 -08:00
Stefan Fuchs
1742de57d0 Add tool tip for negate filter button
Add tool tip for buttons introduced in:
b6bf57a13b

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-30 08:15:11 -08:00
Robert C. Helling
2478158c0f Reenable pressure interpolation in context menu
This fixes a bug reported by Willem that removing waypoints
using the right click context menu makes the cylinder
pressure lines partly disappear.

The reason was that clicking a dive handler disables the
pressure interpolation (and other things, controlled by
shouldCalculateMaxdepth). This is turned on again upon
the mouse release event. This event is not triggered when
selecting in item from the context menu (like remove
waypoint or gas selection) so we need to send it manually.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-30 11:36:47 +01:00
Jan Mulder
75142b0a63 cleanup: less than operators shall not use equal
See also commit c032006d91. Compare functions passed
to sort functions need to compare for less-than and not
less-or-equal.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 13:16:58 -08:00
Berthold Stoeger
f74308bed4 Desktop: Don't hide errors on opening cloud storage
In MainWindow::on_actionCloudstorageopen_triggered(),
getNotificationWidget()->hideNotification() was called, thus hiding
any error message produced by the cloud code. Notably, the information
"Cannot sync with cloud server, working with offline copy" was
not shown.

Therefore, remove this call. Note that on cloud save messages were
not hidden.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-29 09:19:17 -08:00
Jan Mulder
ca7b0017a7 cleanup: Unchecked return value
CID 208312

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
8634dcc393 cleanup: Uninitialized pointer field
CID 208311

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
9d1aff2972 cleanup: Unchecked dynamic_cast
CID 208309

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
0852f9a2ab cleanup: remove unused private variable
CID 208307

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
9836f57598 cleanup: Uninitialized pointer field
CID 208292

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
f057dd46ed cleanup: Uninitialized scalar field
CID 45171

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
ba813483dd cleanup: Uninitialized pointer field
CID 208320

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Jan Mulder
686544bcef cleanup: Improper use of negative value
CID 45112

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29 09:14:20 -08:00
Berthold Stoeger
c032006d91 Replace less-or-equal by less-than comparison in lessThan function
DiveLocationFilterProxyModel::lessThan() used less-or-equal instead
of less-than comparison. This can lead to subtle bugs if two elements
compare as equal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-28 13:22:51 +01:00
Berthold Stoeger
b6bf57a13b Introduce negate-toggle buttons to filter lists
Introduce toggle buttons which mean "filter all dives except
those fulfilling the selected criteria".

The old code used to check for rowCount() == 0. This should never happen,
because there is always a row "empty field". This check was moved into
the preamble of the functions to seperate it from the actual logic.

Fixes #435

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-26 13:08:49 -08:00
Berthold Stoeger
b86c70ab2c Turn filter list options into context menu
Let the menu introduced in commit 5e86442bab
pop up on right-click instead of button-click.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-26 13:08:49 -08:00
Berthold Stoeger
931947b852 Remove Q_OBJECT macros and friend declaration from *Filter classes
Since these classes do not possess any signals/slots,
these macro are unnecessary.

Likewise, the friend declaration in TagFilter is useless,
since the corresponding fields are in the base class.

Fallout of commit 1a4e7ad0dd.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-26 13:08:49 -08:00
Dirk Hohndel
eec69de7ab Small whitespace updates
We aren't really consistent. And I don't do this often enough. But based
on a few things that I saw in a recent commit, I wanted to at least fix
those. And then of course fixed everything in those two files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-24 09:10:12 -08:00
Berthold Stoeger
7451517e4a Add select-all, deselect-all and invert-selection options to filters
To every filter list add a menu button that allows selection of all,
selection of none or inversion of selection.

Implements #435.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24 08:24:11 -08:00
Berthold Stoeger
1a4e7ad0dd Factor out *Filter code into FilterBase base class
The TagFilter, BuddyFilter, SuitFilter and LocationFilter classes
all did essentially the same thing. Therefore, factor out common
code / objects into a base class FilterBase.

The new base class stores a pointer to the filter model. It was
felt that this is simpler than introducing virtual methods.

The only thing the *Filter classes now do is setting a label and
in one case a tooltip. Thus, in principle, they could be removed
completely, but let's keep them for now.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24 08:24:11 -08: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
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
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
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
Dirk Hohndel
a225f62588 Cleanup: mark parameter as unused
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-17 10:25:44 -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
Stefan Fuchs
003e490dd2 Reenable picture tab when dive trip is selected
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13 05:48:20 -08:00
Berthold Stoeger
4ac5b9c965 Simplify mainwindow title logic: remove MainWindowTitleFormat enum
The MainWindow::setTitle() function was passed an enum, which depended
on whether existing_file is set or not. The check can be (and was!) done
directly in setTitle(). Therefore, remove the whole enum.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-11 23:10:09 -06:00
Berthold Stoeger
931bcc1966 Remove unused variable in on_actionCloudstorageopen_triggered()
This was an artifact of commit 136110784e

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-12 04:08:58 +01:00
Robert C. Helling
256ae870a6 Write profile images to correct directory in TeX export
Before, we did not look at the path of the filename to export
to but we should write the images there and not in pwd.

Fixes #931

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-11 20:26:22 +01:00
Berthold Stoeger
ea0cbba804 Remove second parameter (bool force) in set_filename()
The last force=false case was removed in commit 96d1cc570e.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-11 00:17:39 +01:00
Salvador Cuñat
2182167b53 applying gps fixes: group repetitive code under a macro
Title is self explanatory.

[Dirk Hohndel: small edits to remove typo / improve readability]

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-10 11:38:19 -08:00
Salvador Cuñat
6f42ab46da Do not prefer gps fixes just for being into dive time
ATM we were giving preference to a gps fix taken during dive time over
another taken before dive start time (proven both in predefined
SAME_GROUP 6 hours range).
While this logic is right for a static boat or a shore dive - as it
ensures a correct position - will fail for drift dives or dives where
boat changes its position during dive time.

Instead, will choose the gps fix closer to the dive start time.

fixes issue #666

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-10 11:38:19 -08:00
Berthold Stoeger
0a2e53caf2 Use QDir::exists() instead of QDir::setCurrent() to check for existence
Don't change into a directory just to see if it exists.
Remove unnecessary braces of one of the changed if statements.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-04 18:35:44 +01:00
Berthold Stoeger
ed92b60bfe Fix typo "LastIamgeDir"->"LastImageDir"
This fixes an actual bug, where the current image dir would only be
remembered on closing the program.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-04 18:35:44 +01:00
Berthold Stoeger
136110784e On failed cloud save hide progress bar
The progressbar was not hidden on failed save to cloud. In return
remove an unnecessary variable on loading from cloud.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01 16:39:58 -08:00
Rick Walsh
1985bcb29e Disable plan variation in recreational mode
Calculating variations when in recreational mode doesn't make sense, and can
prevent variations from being calculated when switching back to Buhlmann or
VPM-B modes.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-12-01 15:47:51 -08:00
Robert C. Helling
a9703628c4 Actually compute variations in background
This reenables the computation of plan variations but now in a separate
thread. Once finieshed, a signal is sent to update the notes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Dirk Hohndel
afbeccca21 desktop-widgets isn't built for mobile
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-01 13:29:13 -08:00
Stefan Fuchs
1b7ee876ac Dive picture widget: Allow pictures to use available space on resize
Small change to allow the dive pictures list to use the available
space if one resizes the window or switches to different mainwindow
view.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 09:44:34 +01:00
Stefan Fuchs
1f49608ce8 Dive picture drag&drop decrease size of pixmaps
Decrease the size of the pixmaps during drag&drop to the final
unzoomed size in the profile widget.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 09:44:34 +01:00
Stefan Fuchs
fb008120e1 Use correct selection mode for dive picture view
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 09:44:34 +01:00
Stefan Fuchs
a1e6ac2e09 Dive picture handling: Re enable multi select, improve mouse events
Some improvements for the dive picture tab and dive pictures in profile:
- Bugfix mouse event in profile: Only Left-click will open picture
- Bugfix mouse events in picture tab:
  - Re-enable context menu (Windows bug mainly)
  - Re-enable multi select in a nice way
  - Only double-left-click will open picture

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 09:44:34 +01:00
Martin Měřinský
8ef87e618a Use better aliases for icons.
Icon aliases were complete mess.
Some icons had alias some didn't.
Named with underscores vs. hyphens vs. camelCase.
Lower vs. upper case.
"ICON" prefix vs. suffix vs. nothing.
With vs. without filename suffix.
Some didn't make sence. Eg. mapwidget-marker-gray
(I can see, it's grey, but what does it represent?)
Some were duplicated, eg warning vs. warning-icon.
Some were name after widget, which is wrong.

Do not reinvent wheel. Use widely used naming scheme
close to Freedesktop Icon Naming Specification. This
will enable usage of common icons from current set in
the future. Thus Subsurface will fit nicely to GUI.

This changes icon aliases to one, easy grep-able style.

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-30 23:14:46 -08:00
Martin Měřinský
0855f6f315 Use icons relative path.
Icon paths are defined in one place only - application's embedded resources.

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-30 23:14:46 -08:00
Stefan Fuchs
4ee9791cb8 Fix views in mainwindow
Divelist only view was broken.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 04:03:30 +01:00
Stefan Fuchs
0fc4bd8976 Disable specific tabs when dive trip selected
Disable tabs for equipment, info, pictures and extra info if a
dive trip is selected.

Remember specific tab selection for dives and dive trip to recover
selection when browsing dive list.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 03:45:59 +01:00
Stefan Fuchs
ba83ce34e0 In maintab fix change of text between "notes" and "trip notes"
Old code was not functional.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 03:45:59 +01:00
Berthold Stoeger
f8a200dbce Don't use action tooltip to access recently used file
Currently, the path to the recently used file is stored in the tooltip
of the corresponding recent file action. Instead, store the number
of the recent file in the action. This allows for more flexibility
concerning formating of the tooltips (think git repositories, etc.).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01 03:39:10 +01:00
Berthold Stoeger
4296ca11a6 Dynamically generate recent files actions
Instead of using four recent files actions defined in mainwindow.ui,
generate these actions dynamically depending on the macro NUM_RECENT_FILES.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-01 03:39:10 +01:00
Berthold Stoeger
1208bc8428 Remove "#if !defined(SUBSURFACE_MOBILE)" in mainwindow.cpp
The file mainwindow.cpp is only compiled for desktop versions, so the
condition is redundant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30 16:52:22 +01:00
Berthold Stoeger
8b9c63b2d8 Move creation of QSession object into MainWindow::checkSurvey()
Instead of handing the QSession object down, simply create it in
MainWindow::checkSurvey()

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30 16:52:22 +01:00
Berthold Stoeger
135ea00d88 implify recent file handling in mainwindow.cpp
The old code used to be unnecessarily complex: the recent files list
was extended for each file and shrunk if a load failed.

By adding a file to the recent file list only if the load succeeded, a
whole method could be removed.

Other changes: keep track of the recent files using a QStringList and
clearly separate the actions:
 - Read recent files from settings [loadRecentFiles()]
 - Write recent files to settings [updateRecentFiles()]
 - Update the recent files actions in the menu [updateRecentFilesMenu()]
 - Add a file to the list of recent files [addRecentFile()]
With this reorganization the code hopefully became more clear.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30 16:52:22 +01:00
Dirk Hohndel
fd9c905ba3 Revert "Use icons relative path."
This reverts commit b0d98f6e26.
2017-11-29 14:05:07 -08:00
Dirk Hohndel
2747056889 Revert "Use consistent aliases for all icons."
This reverts commit 92e9c6606f.
2017-11-29 14:05:07 -08:00
Martin Měřinský
92e9c6606f Use consistent aliases for all icons.
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase.
With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs.
prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some
icons didn't have alias at all.

This changes all icon aliases to one, easy grep-able style which complies
to Freedesktop Icon Naming Specification (Guidelines).

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29 11:46:35 +01:00
Martin Měřinský
b0d98f6e26 Use icons relative path.
Icon paths are defined in one place only - application's embedded resources.

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29 11:46:35 +01:00
Stefan Fuchs
006a0ebb39 Don't change visibility of depth and duration UI field when no dive
After one selected a dive and then selects NO dive don't touch
the visibility of UI fields for depth and duration.
So if previously selected dive was a manually added dive, keep them
visible. If it was no manually added dive keep them invisible.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-29 01:22:01 +01:00
Stefan Fuchs
b7806d1b94 Correctly handle dive notes in maintab.cpp
Remove duplicate and incorrect setPlainText call via macro for dive notes.
Deal correctly with ASCII line breaks "\n" in dive notes with html
markup (replace them with <br>).

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-28 23:58:35 +01:00
Stefan Fuchs
d5c28e61a4 Rename string "tank bar" to "gas bar" in UI
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-28 20:22:07 +01:00
Martin Měřinský
fa7b93ba5b Fix typo connot > cannot.
Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-28 11:36:19 +02:00
Lubomir I. Ivanov
a084ea5b26 locationinformation: don't update map location on typing
Currently when the user is typing new coordinates the
marker on the map changes location right away. Disable that and
add a 'flag' button that should be pressed instead. Also make the
coordinates update when pressing Enter or when the text
field loses focus.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Stefan Fuchs
07bd8e6455 After edit the cylinders of a dive copy the full samples
After editing the cylinder table (e.g. deleting a cylinder) and
accepting the changes copy the whole dc samples for the dive edited.
This is important because the sensor idx in the samples may have changed.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
8212a923b2 Use MAX_CYLINDERS consistently
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Stefan Fuchs
276fd441b5 When replanning logged dive call CylindersModel->updateDive
reset_cylinder may transform unused cylinders into zombie cylinders
inside the planner because it adds a depth info and therefore the
planner will use them.
By calling CylindersModel->updateDive these cylinders will become visible
and can be deleted by the user.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00
Berthold Stoeger
24c72cb359 Inform LocationFilterModel of added dive site name
If the user implicitly adds a dive site by editing a dive, and
a location filter is active, check the new dive site in the
location filter.

This is done by informing the LocationFilterModel of the new
dive site name prior to repopulation. The LocationFilterModel
then adds a corresponding entry and marks it as checked.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:50:40 -08:00
Berthold Stoeger
f4bcdf46aa Inform LocationFilterModel of changed dive site name
Since commit 01d961086c, the location filter
list is updated if a dive site is edited. The problem is that if the
name of a selected dive site is changed, the selection is lost.

Therefore, before repopulating, inform the location filter that a dive
site changed its name. The location filter then internally changes the
name and can properly transfer the old selection on repopulate. This is
performed via the new LocationInformationWidget::nameChanged signal,
which is connected to the new LocationFilterModel::changeName slot.

A special case to be handled is the following:
 [ ] Site 1
 [x] Site 2
and "Site 2" being renamed to "Site 1", i.e. both sites being merged.
Here, the merging is detected and "Site 1" will likewise be checked:
 [x] Site 1
 [x] Site 1
No merging is performed, as the list will be repopulated anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:50:40 -08:00
Berthold Stoeger
2a0520d57d Simplify signal handling after dive site editing
Since commit 01d961086c, MainWindow::refreshDisplay()
is called in the refreshDiveInfo() signal of maintab after editing a
dive site. Since this was the only use of the refreshDiveInfo signal,
remove this signal and instead connect to MainWindow::refreshDisplay directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:50:40 -08:00
Berthold Stoeger
a7d71ea167 Remove redundant declaration of set_userid()
set_userid() was declared in core/dive.h and dektop_widgets/subsurfacewebservices.h.
Remove the second instance because two declarations of the same function
are a recipe for disaster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 23:17:23 +01:00
Stefan Fuchs
3649963bc4 In maintab clear location tags when selecting a dive w/o dive site
Until now when selecting a dive w/o dive site after having a previous
dive with dive site and location tags displayed, the location tags of the
previously selected dive where still displayed.

This fixes this behavior.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-26 14:17:38 +01:00
Berthold Stoeger
01d961086c Refresh display if a dive site was edited
Calls MainWindow::refreshDisplay() if a dive site was edited so that
the filter lists are updated. The old call to updateDiveInfo() was
removed because it is call implicitly in MainWindow::refreshDisplay()
anyway.

Fixes #675.

Requested-by: Stefan Fuchs <sfuchs@gmx.de>

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 15:34:51 -08:00
Stefan Fuchs
60677e513b Planner UI improvements: Enable/disable options
Don't accidentally enable o2breaks option when entering planner in
RECREATIONAL mode.
Disable also label for min_switch_duration according to dive mode.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 20:17:35 +01:00
Dirk Hohndel
357dea0bcb Merge branch 'print' of https://github.com/neolit123/subsurface 2017-11-25 08:30:24 -08:00
Berthold Stoeger
dd2466f518 Update filters on refreshDisplay and remember old selecttions
Update the filters if the list of dives is updated by calling
MultiFilterSortModel::instance()->myInvalidate();
This had the side effect of clearing all selections. Thus, in
the repopulate() methods of the FilterModels, check those
entries that were checked previously. Since all the filter
models use the same code, introduce a base class FilterModelBase.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 08:24:36 -08:00
Berthold Stoeger
4fb01dd766 Fix ownership issues in preferences code
Each preferences object owns its string members. In three cases, pointers
were copied instead of strings, leading to (in the best case) dangling
pointers if the user edited values:
1) In the GET_TXT macro in core/prefs-macros.h
2) In the PreferencesDialog::defaultsRequested() method
3) In main() of the mobile version

This patch fixes these issues, by using copy_string() or copy_prefs()
as appropriate.

The only reason that the old code didn't crash regularly is that the
default_prefs object was only used at startup and defaultsRequested()
is (at the moment?) dead code.

This patch also aligns the backslashes in core/pref.h and fixes a typo.
The declaration of copy_prefs() is moved to the core/prefs.h header.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 07:41:09 -08:00
Dirk Hohndel
160c7c56ef Fix build without BT support
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-24 16:58:55 -08:00
Lubomir I. Ivanov
65f0600679 printing: update the coping of bundled templates
This update includes:
- Instead of copyPath() use a new specialized function:
  copy_bundled_templates()
- The new function supports overwriting of templates
in the user path, but only if a template file is read-only
- If the file is RW create a backup of the file in the
form of: <file-name>-User.html
- Collect backup files and store them in a QStringList
which is then shown in a QMessageBox from MainWindow
to notifying the user about the backup

This change allows moving the maintenance of the bundled
templates back to the application developers and contributors
as currently the only one who can edit the templates in the user
path was the user.

Suggested-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 23:06:52 +02:00
Lubomir I. Ivanov
fc48cde77c printing: only load *.html files in the UI
The function find_all_templates() thus far handled
all files in the user template directory.

This patch makes it so that only files with the .html
extension are loaded.

Also remove brackets for single lined `if` statement.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 23:06:51 +02:00
Lubomir I. Ivanov
712697e0c2 printing: detect a 'statistics' template when editing
Prefix the path for 'statistics' templates when
detecting if a template is read-only.

Import / Export for statistic templates is not supported.
So the user has to manually copy and chown a '/statistics'
templates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 22:27:30 +02:00
Lubomir I. Ivanov
ba7f2a399b printing: handle overwriting in import / export
Show an error message if trying to:
1) Import over an existing read-only template with the same name
2) Export to a read-only file with the same name
3) Delete a read-only template

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 22:27:30 +02:00
Lubomir I. Ivanov
c57df085a4 printing: make sure that exported templates are .html
Thus far the exported template did not had the .html
extension. This patch makes sure that the extension
is always added to the file if missing.

Also handle the case where the user used ".htm" and
replace that with ".html".

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 22:27:30 +02:00
Lubomir I. Ivanov
a2ec791f2f printing: store the last import / export template
Store the last template file name which the user
imported / exported and then try to pre-select
it in the combo box.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:16 +02:00
Lubomir I. Ivanov
bc6146577d printing: improve messaging in printoptions.cpp
1) on_deleteButton_clicked() show a proper message box with
icon title and also quote the file name.
2) When exporting a file, make sure that the destination is not
read-only even if the source is.
3) Do not allow editing of read-only templates (e.g. the bundled ones).
Instruct the user to Export first.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:16 +02:00
Lubomir I. Ivanov
c6c9b3bd8b printing: minor improvements to import / export
1) Always open the user path on Import / Export
2) Update the list after Export, as the user might
have exported to the user path

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:16 +02:00
Lubomir I. Ivanov
9209382c18 printing: add set_bundled_templates_as_read_only()
Add the function set_bundled_templates_as_read_only()
in templatelayout.cpp/h. The function is used to
mark the bundled template files as read-only in
the user folder. It is called in mainwindow.cpp,
after the files are copied from the bundle.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:12 +02:00
Jan Mulder
c995069e14 Desktop UI: allow user defined cylinder as default
Currently, it was only possible to use a hard-coded default
cylinder in the preferences. At the same time, the user is
allowed to add own cylinders to a dive (by just typing in
a new name and cylinder properties). These own cylinders
could not be selected in the preferences, requiring the
user to manually add this every dive.

Not sure the reason for all this was intentional, or just
an overlooked aspect in the implementation. It appeared
that the selection list in the UI was constructed before
any logbook was parsed, so at that moment, there are only
hard-coded cylinders.

The fix is simple. Refresh the UI of the preferences just
before it is shown. While opening the logbook, a new
list of cylinders, including the own cylinders is
constructed, so the UI is refreshed to that.

While a simple change, there is a use case that might be
considered strange. Open a logbook, choose new logbook,
and change the default cylinder preference to an own
(from the previously opened logbook). Do not add a dive
with the new (own) cylinder and save this logbook.
Reopen this new logbook, and see that the default
cylinder in the preferences is empty. This is logical,
as the list of own possible cylinders is constructed
from the (new) logbook, that has no dive with that
specific own cylinder. I consider this acceptable
behavior, as it can be also be used to copy own
cylinders to a new logbook.

Fixes: #821

Proposed-by: Davide DB <dbdavide@gmail.com>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-21 19:25:35 +01:00
Berthold Stoeger
dd8e4fae2a Make handling of booleans consistent on the C++-side of preferences
In general, the C++-side of the preferences code consistently uses
the bool data type for boolean settings. There are five exceptions,
which use short instead:
  showPo2
  showPn2
  showPhe
  saveUserIdLocal
  displayInvalidDives
This patch attempts to make the code more consistent by turning
these into bools as well.

Tests showed that writing as short and reading as bool is handled
gracefully by the Qt variant code. Therefore, an upgrade should not
cause user-visible changes to their settings.

As a bonus, two extern declarations of the set_save_userid_local()
function, which is not defined anywhere, were removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 20:56:13 +01:00
Berthold Stoeger
e762fd2d41 Fix typo: successfull -> successful and succesfully -> successfully
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-20 10:01:15 +01:00
Jan Mulder
c8a7712ea5 Show all autocompletes after entry of comma in tag list
The almost 3 year old commit e1db5f21b1 introduced the behavior
that you need to type at least 1 character for a tag to show any
autocompleted data. While this went unnoticed for years, there
is always a user that notices this changed behavior.

The solution is rather simple. Do allow the 0 lenght string
to act as seed for autocompletion instead of just returning, and
doing no autocomplete at all.

As the afore mentioned commit was explicitly meant to prevent over
active firing of the tag list autocompleter, this (simple) change
is carefully tested on this, and no adverse effects are visible.

Fixes: #605 (wrt the 1 character issue)

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-17 09:19:03 +01:00
Stefan Fuchs
010f5f2abc In maintab disable correct label when dive trip selected
Until now accidentally the dateLabel was disabled and the timeLabel
was enabled. Changed this the other (correct) way round.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-16 11:34:12 -08:00
Berthold Stoeger
aca4a3a4fa Introduce mode field in Bluetooth device selection dialog
Some BT devices support both, classical and LE, modes. Users could
choose either by prepending or removing "LE:" in the device address
field. After commit d23bd46a1b, the
device field is always disabled in Bluetooth mode.

Therefore, add a mode combo box to the Bluetooth device selection
dialog. In the default mode (auto), the old code path (based on
the Qt device flags) is used. The two other modes (force LE, force
classical) allow the user to force the preferred behavior.

This feature is meant as a stop-gap measure until a more refined
transport choice is implemented. Therefore, the value of the new
combo box is not saved in the settings, to avoid cluttering of
the preferences with soon to be obsolete entries.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-16 14:26:51 +01:00
Berthold Stoeger
de81effb25 Make Bluetooth naming consistent
Currently, on Linux, after selecting a Bluetooth device the name of the
device is shown. On reopening the download dialog, on the other hand,
the address is shown. In the device selection dialog both are shown.

This patch changes the download dialog such that both, name and address,
are shown. The bulk of the patch introduces the name of the device in
the preferences and DCDeviceData. It has to be noted that DCDeviceData
is an encapsulation of the libdivecomputer device_data_t. Nevertheless,
the new Bluetooth-name field is, at the moment, not passed through to
libdivecomputer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-13 20:48:17 -08:00
Stefan Fuchs
d0e5653e39 Planner and profile limit minimum GFlow to 10 and minimum GFhigh to 40
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-13 11:53:55 +01:00
Berthold Stoeger
6addfe1660 Trivial: Replace a QSharedPointer by a QScopedPointer
Since the QSharedPointer is never passed or copied, reference counting
is certainly not needed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-12 20:12:32 +01:00
Berthold Stoeger
b32251a5a8 Typo: modp02 -> modpO2
Fixes two function names, where O2 was written as 02.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-12 15:11:30 +01:00
Berthold Stoeger
efabf0a55c Fix memory leak in download-from-dive-computer widget
Instead of (re)allocating the vendor and product models, use the
setStringList method on sub objects.

Even though only a theoretical problem, the model objects are moved
in front of the ui object, so that the widgets referencing the models
are destroyed first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-11 21:01:42 +01:00
Berthold Stoeger
d1d4b4edb1 Initialize Facebook page only when dialog is shown
Quick hack to avoid Facebook access on every program start. Move the initialization
of the login page from the FacebookConnectWidget constructor to the show event handler.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-10 10:04:28 -08:00
Lubomir I. Ivanov
513f5a0230 preferences: support a pre-defined list of time formats
Add a combo-box that holds a list of pre-defined time formats
in the Language preferences.

The user is still allowed to enter a custom time format.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-10 09:21:47 -08:00
Lubomir I. Ivanov
4fde26fb2c preferences: re-use a tr() string in _language.cpp
Also, tell "in date format" instead of "in time format"
for dates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-10 09:21:47 -08:00
Lubomir I. Ivanov
2c06cb027f preferences: support a pre-defined list of date formats
Add a combo-box in place of the single line text field and
support some pre-defined date formats, such as:
MM/dd/yyyy

Each long format has a corresponding short variant stored in the
QMap dateFormatShortMap and it's updated automatically once
the user selects a combo box item for the long format.

The regex for dates is slighly modified:
[^dMy/\\s:;\\.,\\-]

The user is still allowed to enter custom long / short date foramats.

Fixes #276

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-10 09:21:47 -08:00
Lubomir I. Ivanov
746874a78e map-widget: allow real-time updates of edited markers
This patch allows updating the location of map markers
while editing a dive site and updating the text in the
LocationInformationWidget in real-time.

Currently it is only possible to see the marker changes by
clicking 'Apply'.

The modification required the following changes:
- add the MapWidget::updateCurrentDiveSiteCoordinatesToMap() slot
and call it each time the GPS text updates
- separate the updateCurrentDiveSiteCoordinates(FromMap/ToMap) logic
by having the FromMap/ToMap suffix to method names
- make MapWidgetHelper::updateCurrentDiveSiteCoordinatesToMap()
call a new MapLocationModel::updateMapLocationCoordinates()
method, which updates selected location coordinates and the model
- add MapLocation::setCoordinateNoEmit() that does not emit
a signal when updating a coordinate

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-09 12:40:25 -08:00
Berthold Stoeger
77aaaa787b BT device selection dialog: make Save the default button
When a user presses enter, they probably want their selection saved,
not discarded.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-06 14:05:26 -08:00
Berthold Stoeger
20922e261a Remove unnecessary == NULL test.
Test not necessary, because the QString in question is not a pointer
and the string is tested for emptiness (which also flags null-strings).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-06 14:05:26 -08:00
Lubomir I. Ivanov
956b45ddfd map-widget: move the widget and its resources to 'map-widget'
Move all the map widget platform agnostic files to the
<subsurface-root>/map-widget folder.

This avoids the confusion about the desktop version of subsurface
using mobile components. The map widget is planned as a shared
component between the mobile and desktop versions.

desktop-widgets/mapwidget[.h/.cpp] still remain as those are specific
to the desktop version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-05 14:48:56 -08:00
Berthold Stoeger
617c6d3564 Replace itemClicked() by currentItemChanged() in Bt device selection
This fixes two problems:

1) Using the keybord or clicking below the list and moving the mouse
up while holding the mouse button did not properly update the status
message and the save button. For example, one could save with a non-
paired device selected.

2) The code assumed that a device is selected if the save button is
active, but the save button was not disabled on scan. Thus, one could
provoke a crash by selecting an item, scanning and then pressing save.
This problem is fixed indirectly, because the save button is now always
disabled if the selection is cleared.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-04 09:27:24 -07:00
Stefan Fuchs
ac25b238dd Disable o2 break option if last stop is not at 6m/20ft
Disable the possibility to plan o2 breaks of option
"last stop at 6m/20ft" is not set.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
3ae0b5cbdd O2 breaks code enhancements and cleanup
Remove unused variables o2time and breaktime or convert into boolean.

Never consider minimum gas switch time when switching to o2.
Reflect this behavior also in the UI.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
f8ca5a55fc Planner UI: Move dive mode UI element to the top of the column...
and add a label for it.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
57032e9fcb In planner for different deco modes enable/disable options correctly
Disable option "safety stop" for all deco modes other than
"recreational".

Disable also labels "reserve gas", "GF ..." and "VPM conservatism"
correctly.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:51:02 +01:00
Stefan Fuchs
8b56dc30d7 Correct, cleanup, translate and unify file filters
Correct spelling and typos in file filters.
Unify and translate file filter names.

Don't pass a file filter to a directory open dialog - not needed.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:27:00 +01:00
Berthold Stoeger
92ba4b9cc7 Replace QMap::operator[] with QMap::value()
QMap::operator[] creates a new default constructed entry in the map
if no entry with the given key exists. While not problematic (since
typically nullptrs are inserted) this is usually not what you want
for read access.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-04 14:26:21 +01:00
Stefan Fuchs
a94fba2439 Planner copy salinity only if current dive exists
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 09:15:59 +01:00
Berthold Stoeger
d23bd46a1b Reset device field in DownloadFromDCWidget according to dive computer
Fixes minor interface inconsistency: The device field in the
download-from-dive-computer widget is disabled when selecting
a non-serial-transport dive computer. In contrast, post-download
the field was reset to enabled for all dive computers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-01 07:13:47 -07:00
Berthold Stoeger
3acc28cebf Postpone error message display if not in GUI thread
Calls to report_error() crashed if not called from GUI thread.
Fix this by postponing error message display if not in GUI thread.
Code that creates a thread which possibly calls report_error()
is responsible for calling MainWindow::showErrors() to flush
the accumulated messages.

Note that there is a race condition in report_error() and
get_error_string(). Nevertheless, hitting it should be rather
unlikely (two threads producing error messages at the same time)
and hopefully it can be fixed rather easily.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-31 16:32:08 -07:00
Stefan Fuchs
d470ef05e0 New dive plan set salinity to current dive salinity if dive selected
This helps people who always use a std. salinity of e.g. 1020g/l.
If they have a log with their dives open and plan a new dive they will
have also for new planned dives the salinity set to their prefered value.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-30 21:45:56 +01:00
Stefan Fuchs
4e320cca5b Remove three obsolete preferences options for geocoding
These options are not used any longer/were never used and can be
removed to not confuse the users.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-29 11:07:52 -07:00
Lubomir I. Ivanov
4357e06ba0 mainwindow.cpp: fix whitespace
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-28 17:39:19 +02:00
Stefan Fuchs
81492b8cba Set checked status of menu entry for dive list filter correctly
When enabling the dive list filter via the menu entry
"Log->Filter dives" and then switch off the filter via the small "close"
button of the filter:
Set the checked status of the menu entry correctly.
Also set it correctly when switching on/off via the menu entry to avoid
any situation where it is not synced.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-28 14:16:38 +02:00
Dirk Hohndel
9c4782fa5c cloudstorage: better member name when updating authentication state
This isn't just about showing the PIN or not.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 20:44:02 +02:00
Dirk Hohndel
e64dcd12bd desktop UI: no longer attempt to manually show error notifications
report_error() now does this automatically. So all these odd places in which we tried
to make sure that we show errors are no longer needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 15:55:49 +02:00
Dirk Hohndel
752d9b60c4 Divelistview: use report_error to report and error
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 15:53:47 +02:00
Dirk Hohndel
f088aa4c8b desktop UI: always show errors when reported
Instead of waiting for a manual call to showError(), simply use the new
callback to always immediately show the error in the notification widget.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 15:50:53 +02:00
Jan Mulder
87db35de3c Fix broken multi selected dive to trip
See referenced issue number. It leads back to an ancient (3 year old)
commit 512c42e. Not sure this issue is introduced there, but that's not
relevant.

Key in reproducing this is the location where the context menu is
requested (using the right mouse button). When it is the row next
to the trip, the add-to-trip succeeds correctly, otherwise
it is a no-op.

The solution is rather trivial (in hindsight). Just loop over the
selected dives, and try to find the trip we want to add to.

Fixes: #522

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-23 10:06:33 -04:00
Guillaume GARDET
5d12143a6a [Facebook] Back to previous behavior when we were able to upload data,
even without album creation permission
2017-10-23 10:05:23 -04:00
Guillaume GARDET
ee1e03c774 [Facebook] add more debug when we are not able to create a new album 2017-10-23 10:05:23 -04:00
Lubomir I. Ivanov
3f7900bf4e mainwindow: disable fullscreen support by default
Require the FULLSCREEN_SUPPORT macro to enable fullscreen
support.

The toggle was added 4 years ago in Subsurface, but with the
current version of Qt 5.9.x, it's very buggy on Windows and
Ubuntu. While it's possible to make this work on Windows,
it seems to behave broken in different ways on different
versiosn of Ubuntu.

Fixes #705

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-22 06:09:05 -04:00
Dirk Hohndel
27c49fe3ad Silence random warnings
None of these seem to point to actual issues, so let's quiet them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20 17:25:18 -04:00
Dirk Hohndel
59bf217157 Turn off Facebook debug messages unless verbose
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-20 06:51:51 -04:00
Robert C. Helling
a422957cd6 Use displayed_dc instead of current_dc
current_dc is a macro that determines the dive computer
based on the current dive number. When the planner is started
from an emtpy dive list, the dive number ends up being -1 and
that doesn't produce a valid dive computer. Use the divecomputer
of the displayed_dive instead. This is done via a macro that
can also be used in two other places. Without this patch, the
planner crashed when called on an empty dive list.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-19 14:57:02 -04:00
Robert C. Helling
e955099e6c Refuse to save an empty log to the clould
This should prevent the problem of a user accidentally
"deleting" their dives in the cloud by hitting "save to cloud"
in the wrong moment.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-19 07:37:47 -04:00
Lubomir I. Ivanov
e9673938fb printoptions.cpp: correctly remember the last selected template
To find the last selected template index in the combo box,
comparing against `printOptions->p_template` would work fine,
except the `on_printTemplate_currentIndexChanged()` slot updates
`printOptions->p_template` each time QComboBox::addItem() is
called. This makes the `for` loop to add new combo box items
and find the index of the last selected template not possible.

To work around the issue, a local QString variable `storedTemplate`
is introduced and it does not change during the `for` loop.

Fixes #595

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-19 14:04:38 +03:00
Stefan Fuchs
884e690049 Tags for geo references: Nicer look, translations and warning message
For the geo references tags update the following:
- Nicer look w/o "Tags:" text and brackets when inside location UI
- Translation for "Tags:"
- Warning message when no dive site layout categories are set

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-17 06:12:07 -04:00
Stefan Fuchs
ac7830ea91 Correct spelling for text in prefs georeferences
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-17 06:12:07 -04:00
bs
1fe76b02da Connect finished signal of download thread only once
Connect finished signal of download thread only once in constructor of
DownloadFromDCWidget instead of every time the Download / Cancel / Retry
button is clicked.

Fixes minor nuisance: On repeated download attempts multiple massage
boxes were shown.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-16 14:02:06 -04:00
Stefan Fuchs
bfe52f6689 Correctly name member function gasChange of DivePlannerPointsModel
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 17:14:17 +02:00
Stefan Fuchs
0b6fb49489 In location information UI set reverse geo lookup button activ...
as soon as coordinates are available .

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 03:43:02 -08:00
Lubomir I. Ivanov
56e755b711 Use lrint() for all degrees_t related rounding
In certain places the '(int)' cast is used, while in other the
llrint() or lrint() functions. Make the conversation from degrees
in the 'double' form to the 'int' degrees_t consistent using lrint().

lrint() is the function which should give the best results,
because it accepts a 'double' and results in a 'long'
even if degrees_t is 'int'. If the truncation from 'long' to 'int'
is discarding some of the precision then the next step
would be to turn degrees_t into a 64bit signed integer type.

Possible fix for #625.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-09 13:38:58 +03:00
Stefan Fuchs
f5f2754b81 Preferences units dialog: Tab order and silence warnings
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-09 11:49:29 +03:00
Stefan Fuchs
78cda85444 Display units in dive list table based on prefs option
Add a preferences option which enables or disables display of units in the
main dive liste table.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-09 11:49:29 +03:00
Lubomir I. Ivanov
2cb5d45231 preferences: add missing dialog icon
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-08 16:01:03 -07:00
Dirk Hohndel
20f42e7aa8 Locationinformation: correctly handle strings on the heap
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 17:04:26 -07:00
Stefan Fuchs
2d47fd1fed Tab order for location information dialog
Fixed the tab order and excluded "notes" and "dive sites with same
coordinates" from accessability via tab key.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-07 21:53:28 +03:00
Robert C. Helling
030c094854 Remove disfunctional asc. rate signals and add disable keyboardTracking
The connection wasn't working anyway since the signal comes without
value while the slot wanted a value and thus only created a runtime
warning.

Turning of keyboard tracking means that when typing the number 123 the
value change signal is not fired three times (with values 1, 12, and 123)
but is only fired upon pressing enter or the spin box losing focus.

We should add a similar setting to the depth, duration and runtime
columns of the DivePlannerPointsModel but i have no clue how to do that.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-10-07 08:42:06 -07:00
Dirk Hohndel
1b0812a8cb Warn if we edit non-existant dive site
And try to add it to the dive - bubt we really shouldn't get here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 08:16:53 -07:00
Dirk Hohndel
53b1b17f4f LocationInformationWidget: make sure to clean out fields
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 08:16:53 -07:00
Dirk Hohndel
0799d046ba Disable editDiveSiteButton without dive site name
Entering a name first creates and hooks up a dive site which we can then
use in the edit dive site dialog to store modifications.

This doesn't really fix these two bugs, but it might impact whether they
can still be recreated

See #633
See #636

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07 08:16:53 -07:00
Lubomir I. Ivanov
174b414436 map-widget: don't crash if the map QML failed to load
If the QML modules for QtLocation and QtPositioning are
missing the QML in mapwidget.cpp will fail to load,
which can lead to crashes.

To solve the issue check if the QML has loaded and set
a flag 'isReady' to true. If the loading has failed
load another QML which is for showing a red error text
in the lines of `MapWidget.qml failed to load!`.

If the map QML has failed, use a macro in all relevant
MapWidget members to turn them into a NOP. This approach
leaves the rest of the codebase intact - e.g. no checks
in classes which connect to the MapWidget class.

Fixes #596

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-07 08:09:05 -07:00
Dirk Hohndel
09b02aae4e Simplify the geo reverse lookup function
We never actually create a list of dive sites for which we
call the reverse lookup service, it's always just displayed_dive_site.
So make this all much simpler and just go straight for that.

This commit removes a loop, but doesn't change the indentation of the
code inside the loop to make it easier to see what was changed. That
whitespace change will be in my next commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
ff26ffe0d0 Remove bogus signals
One isn't connected to anything, the other one makes us overwrite
the changes to displayed_dive_site.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
ed78aeade0 Change the signature of constructLocationTags
We actually want to be able to pass a specific divesite structure
and not have it look that up by uuid.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
21d78121ad Don't add separate country field, use taxonomy
The more I looked at the code that added the country to the dive site,
the more it seemed redundant given what we have with the taxonomy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Stefan Fuchs
cf409b59ba Planner settings ascend and descende rate: Wire up UI elements correctly
Wire up the UI elements (QSpinBoxes) for ascend rates (4x) and descend rate
(1x) correctly so that the profile and calculation is updated immediately
after the value is changed (e.g. increased/decresed by 1) by clicking
the QSpinBox arrows.
Until now one had to click into the profile or change another planner
preference first before the change became effective.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-04 08:41:10 +02:00
Lubomir I. Ivanov
52445ec8f5 dive-list: maintain a single instance of DiveTripModel
A weird crash occurs if DiveListView creates another local
instance of DiveTripModel inside reload(). Re-use the member
variable tripModel and assign it a new instance of DiveTripModel.

Reported-by: Gaetan Bisson <bisson@archlinux.org>
Tested-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-03 21:34:43 -07:00
Lubomir I. Ivanov
e3118d915c divelist: prevent a crash for missing column width
The `static int defaultWidth[]` definition in divelistview.cpp
could potentially end up missing an element which can later result
in out-of-bounds access when iterating through the list of
columns and updating their widths.

Add a couple of methods in DiveTripModel for setting and getting
the widths and use those. The default values are now pre-set in a
QVector in the DiveTripModel() constructor.

Throw warnings if out-of-bounds columns are requested.

Reported-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-03 15:43:03 -07:00
Tomaz Canabrava
516527e1bd [Divesite] Hook location information interface for country
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 09:52:54 -07:00
Tomaz Canabrava
dd1c48de66 [Divesite] hook interface for country
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 09:52:46 -07:00
Tomaz Canabrava
aca8fea2a9 [Facebook] Enable the send button on edit
Not when you press enter.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
527078e277 [Facebook] Use statusbar instead of popup messages
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
3e2a86cf80 [Facebook] More debug calls
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
3a564f412c [Facebook] Use correct albumName variable
and code cleanup

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
5595d9a8b0 [Facebook] Lots of debug messages
Important debug messages, don't remove.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
15c4fadde9 [Facebook] Use the nonblocking calls to post on fb
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
e662ce1cec [Facebook] Fill the info struct
This will be used to send the profile to Facebook

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
dd17c6355d [Facebook] Remove broken function
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
1d8eb0d78a [Facebook] Code organization
Create the variable near its use.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:54:03 -07:00
Tomaz Canabrava
df166247af [Facebook] Signal that the album is found
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:53:59 -07:00
Tomaz Canabrava
a2734e6aaf [Facebook] New method, grabProfilePixmap
Just some code organization

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:52:03 -07:00
Tomaz Canabrava
5778dceb52 [Facebook] Prepare the FacebookInfo struct
This will hold the information for the profile upload.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:51:53 -07:00
Tomaz Canabrava
ba8e6878a8 [Facebook] Remove dead code
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02 08:51:19 -07:00
Stefan Fuchs
7713c7e607 Use helper function dive_endtime() where apropriate
Calculating dive.when + dive.duration doesn't always give the correct
endtime of a dive especially when a dive has surface interval(s) in
the middle.
Using the helper function dive_endtime() fixes this issue.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-01 23:55:37 +03:00
Dirk Hohndel
571918feaa Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:34 -07:00
Tomaz Canabrava
f159802053 [Facebook] Add hability to choose size of profile
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:34 -07:00
Tomaz Canabrava
9b1a949a39 [Facebook] Resize the profile before sending it
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:34 -07:00
Tomaz Canabrava
2db4f626ed [Facebook] Only mark as connected if user id is received
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:34 -07:00
Tomaz Canabrava
a6aeaf897a [Facebook] create userIdReceived slot
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:34 -07:00
Tomaz Canabrava
689dcf1058 [Facebook] Mem leaks
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:34 -07:00
Tomaz Canabrava
475dfe1194 [Facebook] Use only one Network Manager
Fixes quite a few memory leaks.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:57:28 -07:00
Dirk Hohndel
7b8832bc0b [Facebook] fewer UI freezes while accessing facebook
Use signal / slots on the networkreply instead of freezing the event
loop.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:45:28 -07:00
Tomaz Canabrava
c8c9a5dc65 [Facebook] conversion to new connect syntax
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:44:39 -07:00
Tomaz Canabrava
f6ac79296e [Facebook] Dont use deprecated feature
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:43:45 -07:00
Tomaz Canabrava
73c242b6eb [Facebook] Use unblocking call for QNetworkRequest
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:43:45 -07:00
Tomaz Canabrava
8ce4692b5c [Facebook] Use QByteArray directly
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-29 12:43:41 -07:00
Federico Masias
777cf6c3fd Change Facebook upload description to eliminate confusion
Signed-off-by: Federico Masias <fede@masias.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-26 23:34:38 -04:00
Robert C. Helling
5b080bedde Remove option to apply GFlow at maxdepth
This option should have never been there. This is not how
gradient factors are supposed to work. It would only trick
users to use the wrong value..

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Robert C. Helling
a6f186279f Add a checkbox to turn off plan variations
... as those come with a performance penalty

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Dirk Hohndel
ae209a3d9f Merge branch 'macBLE' of github.com:Subsurface-divelog/subsurface 2017-09-17 15:40:16 -07:00
Dirk Hohndel
49fe120d95 DC download: show info messages on Mac
For some reason the progress bar on macOS doesn't show the
progress text. This creates a label below the progress bar
and shows the text there instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17 15:04:14 -07:00
Dirk Hohndel
d03fabd373 DC download: better message at beginning of download
Especially on BT/BLE devices, where there is a longer negotiation
phase at the beginning of the download, this seems more user friendly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17 15:02:11 -07:00
Dirk Hohndel
605400a029 DC download: don't clear message if no dives downloaded
Otherwise the text telling the user that no new dives were
found will be deleted right away.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17 14:49:37 -07:00
Dirk Hohndel
26e610c3f4 BLE: create controller from QBtDeviceInfo
Creating it from an address is a) deprecated and b) impossible on Mac or iOS.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17 09:58:11 -07:00
Dirk Hohndel
e5b7fb74b4 BLE: on Mac/iOS use UUID instead of address
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17 09:56:28 -07:00
Stefan Fuchs
19df57d7d3 Remove some very small marble leftovers
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-09-16 08:36:30 -07:00
Tomaz Canabrava
19db825240 Facebook support: fix export dialog layout
Dialog layout was broken, now we can actually resize.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2017-09-13 09:36:22 -07:00
Tomaz Canabrava
e43a116457 Facebook support: use the new Graph Api
This is basically a one liner.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2017-09-13 09:36:09 -07:00
Miika Turkia
f3ab2ee674 Fix crash on manually added ZXU/DL7 file
The CSV import crashed if the input file had no samples in it.

Fixes #566

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-09-11 07:21:43 -07:00
Miika Turkia
40cc0b0e4b Import dive number from DL7 log
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-09-11 07:21:43 -07:00
Lubomir I. Ivanov
2b40e15713 remove Marble from packaging and build scripts
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>

---
please note, that i have no way to test most of the scripts ATM.
2017-09-04 07:46:35 -07:00
Lubomir I. Ivanov
4bb180b117 remove Marble from the source tree
In desktop-widgets, remove globe.cpp, globe.h and also remove
the NO_MARBLE macro usage.

At this point the MapWidget will always be created and there will
always be a map in the application.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-09-04 07:46:35 -07:00
Lubomir I. Ivanov
a7d8e0d187 googlemaps: clear the cache folder on language change
Open the cache folder via QDir and call removeRecursively().
At that point the user needs to restart Subsurface to be able to
use the map in another language properly.

This change is triggered by the fact that the user might want to see
the street map in his preferred language after he/she picks another
language from Settings. But one problem here is that the cached files
do not carry a language flag - e.g. they are in the lines of:
    googlemaps_100-1-9-445-245.png

Which means that the only way to not mix tiles in different languages
is to clear the cache and start downloading the new tiles in the newly
picked language after Subsurface has restarted.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-09-04 07:41:21 -07:00
Dirk Hohndel
548c062aa5 Another unused variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26 14:48:05 -07:00
Dirk Hohndel
e0b1d2dc84 Tex export: remove incorrect code
These two variables are calculated later in the function and the
same two lines of code are there again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26 12:08:22 -07:00
Robert C. Helling
514c298600 More details for TeX export
Include the gasname, get rid of more spaces in front of units,
update the template to use new gas fields.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-10 09:08:02 -07:00
Robert C. Helling
d5d97870c3 Move the decision how to typeset unit to TeX-style file
This way, the user can adopt those once and for all for all
her dives. This includes the space between number and unit symbol.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-10 09:08:02 -07:00
Robert C. Helling
0c426c37b2 Use letters instead of digit in TeX macro names
TeX doesn't like digits there, so let's use letters

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-10 09:08:02 -07:00
Robert C. Helling
de47c96763 Cleaning up TeX export
Removed some merge artefacts and made sure code compiles and
produces wellformed TeX. Shortend some comments.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-10 09:08:02 -07:00
Ben McCandless
72e302a1c2 Add additional data to TeX-export
The purpose of this work is to allow for generation of more complete log
pages using TeX/LaTeX.

Previously, the exporting to TeX generated a document that contained
very limited information about the dive.  For example: the only details
reported about air consumption were delta pressure and SAC.  In addition
no data was reported about what equipment (weights, tanks, suit) was
used.

Per feedback, code was updated to use helper functions, and now exports
data with the units set by the user in the Subsurface preferences.  Some
characters (Degree symbol) do not render correctly by default in LaTeX,
so sample code to address this was included in the top comments.  Volume
units do not export an ideal character string, so another string was
substituted.

This update adds the following information:
   * GPS Location
   * Dive computer used
   * Max, Min, Air, and Water Temperatures
   * Average depth
   * Number of cylinders listed, mix, and start/end pressure for each
   * Total weight used, and the description and quantity of each weight
   * Dive rating (previously, only visibility was reported)
   * Buddy
   * Dive master
   * Suit

This update moved several fields that had no output or had unexpected
names (i.e. "spot", "place") into a "Deprecated section"

Future work:
   * The export currently only includes the first entry in the tag list.
   * Future versions should export all tags.
   * Ideally, this would export a screenshot of the dive location.
   * Create a table of correct size for weights and cylinders.
   * It would be nice to have a bit more control over the generation of
     profile images, but that may be beyond me.

Rebased-and-cleaned-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Ben McCandless <mccand@gmail.com>
2017-08-10 09:08:02 -07:00
Anton Lundin
5e0c2a7693 Configure ostc4: Correct button sensitivity range
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-01 13:39:35 -07:00
Anton Lundin
cfd5f8bf95 Configure ostc4: Wire up reset button
I previously forgot to enable the reset button.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-01 13:39:35 -07:00
Dirk Hohndel
7c92c7dc0a Map: try to wait for Map to load
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28 22:06:34 -07:00
Dirk Hohndel
c59cdd6efd Switch new files to unix line endings
I thought we had this automated, but Lubomirs commits introduced a few
files with dos line endings. This is purely a change of line endings, no
other changes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28 22:01:36 -07:00
Jan Mulder
7e39be436b Fix possible memory corruption
A user reports a SIGSEGV that points to DownloadFromDCWidget::updateProgressBar()
in relation to strlen()/strdup(), at end of download. Reading the code, as I
can't reproduce the crash, it seems that the progress_bar_text is set to NULL
and later strdup-ped. The man page is not fully clear on this, but setting it
to the empty strings is much safer.

Might fix: #507

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-28 15:16:46 -07:00
Lubomir I. Ivanov
69f8fc3c5b map: whitespace cleanup in QML and C++ files
- remove ";"s
- remove {} where not needed or move them to the same line

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
4a004f37ea mapwidget: add a method to set update editMode in MapWidgetHelper
The local slot coordinatesChangedLocal() tracks the MapWidgetHelper
coordinatesChanged() signal and emit a coordinatesChanged() signal
to any listeners (e.g. MainWindow).

Also add a small change in centerOnDiveSite(), to not be called if
we are skipping the reload (skipReload is updated by
selectedDivesChanged()).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
7486682f43 mapwidget: add the "skipReload" guard
This guard is to prevent a meaningless reload on the map marker list,
when the user selects a new dive and nearby dives. The flag is updated
in selectedDivesChanged() which on it's now cannot possibly trigger
changes in the markers, only the selection. The selection of active flags
is already handled by the model and automatically updated in the QML.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
64697375cf mapwidget: connect the helper selectedDivesChanged() signal
The selectedDivesChanged() signal from MapWidgetHelper is connected
to a local slot. One problem here is that this crashes with the calls to
DiveListView().

The dive list widget triggers events that call reload() on the MapWidget
(same happens for Marble's Globe class) and that crashes somewhere in
the QML shared library. TODO: investigate.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
b7c4a7fbfc qrc: use "MapWidget.qml" as a QRC alias
Apparently, if it's required to import a QML component inside any QML
file from resource, the compoment QRC alias has to have the same name
as the component - e.g. add QRC alias MapWidgetContextMenu.qml allows
creating a MapWidgetContextMenu compoment inside MapWidget.qml.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
8fe068f191 mapwidget: call MapWidgetHelper::reloadMapLocations()
MapWidgetHelper::reloadMapLocations() is now called from MapWidget::reload()
and MapWidget::repopulateLabels().

The mobile version should do similar.

NOTE: These MapWidget methods names are from the Marble "port".

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
52316229cd mapwidget.cpp: register the MapLocation and MapLocationModel types
Apparently the "safe way" is to register C++ types is before the QML
code has loaded. The idea here is that the QML code should know about
these type definitions and be able to operate with them.

TODO: do the same for the mobile version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
2cb8fee827 add the SPDX-License-Identifier to new source files
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
5cc2c02dfb qmlmapwidgethelper: add the centerOnDiveSite() method
MapWidget sould not handle any of the map backend.
Instead it should just pass calls to MapWidgetHelper.

Do that for centerOnDiveSite().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
99c2bf6290 mapwidget.cpp: obtain a reference of the MapWidgetHelper from QML
Use findChild() to obtain the only MapWidgetHelper object created
in the MapWidget.qml. Store the reference as a member variable -
m_mapHelper.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
e2a4f3fcee desktop-widgets/mapwidget: register the MapWidgetHelper QML type
This commit registers the class MapWidgetHelper for QML
in the desktop version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
63d7b315c1 desktop-widgets/cmake: include "qmlmapwidgethelper.cpp"
As noted in previous commits, a folder named "shared-widgets" which
holds QML/CPP files might be the better (less confusing) choice.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
a8af2f5548 globe.cpp/h: remove the dummy QLabel based widget
If NO_MARBLE is defined don't create a dummy replacement widget in
the GlobeGPS class.

At this point all cases of NO_MARBLE are covered by the MapWidget
solution.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
ab7d6a73d4 mapwidget.h: force-undefine the IGNORE macro from winbase.h
By including <QQuickWidget>, <winbase.h> is included from <windows.h>.
<winabase.h> has the IGNORE macro defined.

Undefine it localy in mapwidget.h to prevent a conflict with maintah.h's
EditMode::IGNORE enum.

NOTE: possibly similar case to the undefine in
btdeviceselectiondialog.h:22.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
c2e172a874 mapwidget.h: remove redundant "core/divesite.h" include
The header should be included only in the .cpp file

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
6e916b6764 locationinformationwidget: abstract between GlobeGPS and MapWidget
Connect the same signals for the two classes based on the NO_MARBLE
macro.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
df519be01e mapwidget: add the placeholder prepareForGetDiveCoordinates() slot
Port from GlobeGPS.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
97a3051089 mapwidget: add the coordinatesChanged() signal
Port from GlobeGPS.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
b89ecd5ab8 subsurfacewebservices: abstract between GlobeGPS and MapWidget
Call same methods from the two classes based on NO_MARBLE.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
8f52b129af mapwidget: add the placeholder repopulateLabels() method
Another placeholder for the Marble port.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
ae52e2a272 maintab: use GlobeGPS / MapWidget abstraction
Based on NO_MARBLE, call the same methods in the two different classes.
Later the dummy Marble GlobeGPS (for NO_MARBLE) should be removed.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
4334d33413 mapwidget: add the method centerOnIndex()
Again for the port from Marble, later can be removed / renamed.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
0d3d9c01eb mapwidget: add public slot endGetDiveCoordinates()
Later this has to be replaced / renamed if needed.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
39af5bb05b mapwidget: add an empty reload() method
Call same method in MainWindow if the NO_MARBLE macro is defined.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
86f4a26a83 mainwindow: rename GLOBE_MAXIMIZED to MAP_MAXIMIZED
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
4a10c94840 mainwindow: rename "actionViewGlobe" to "actionViewMap"
Also change the menu entry text itself to "Map" instead of "Globe".
"Map" covers both Marble and Qt Location in terms of "map" solutions.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
b054c211a1 mainwindow: don't remove the "view globe" action from the menu
We now have a map no matter NO_MARBLE.
TODO: rename the action itself.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
1a5122e8f8 mainwindow: enable centerOnDiveSite() no matter the NO_MARBLE macro
The same public slot now exists for both widgets, so the ifndef macro
check is redundant.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
a1fbffc96c mapwidget: add placeholder centerOnDiveSite() public slot
This is WIP and would be developed futher, so that the new
map widget can center on a divesite location.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
b0b5f701fc mainwindow: create an instance of MapWidget for NO_MARBLE
This is an attempt for a smooth transition between Marble
and Qt Location map integration. If NO_MARBLE is defined
an instance of MapWidget (Qt Location) is created,
else an instance of the Marble widget would be used.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
0f0a953727 mainwindow: rename the variable 'globeGps' to 'mapWidget'
This is needed by the transition to the new map widget. Also
generalizes the variable name.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
70ab937296 desktop-widgets/cmake: include mapwidget.cpp as a UI class
The next step would be to create an instance of the class in MainWindow.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Lubomir I. Ivanov
b083795233 map: add placeholder .cpp and .h files for the new map widget
The files are WIP and located in desktop-widgets, as these
would only be used by the desktop version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28 07:31:11 -07:00
Dirk Hohndel
1b8b112048 Fix slot handling in Photos tab
This clearly has never been tested, never worked.
Oh well.

Fixes #478

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-12 08:25:58 -07:00
Dirk Hohndel
6837120bb1 BLE handling: create helper function to add the LE: prefix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-30 13:12:07 -07:00
Dirk Hohndel
a4d4d1c83b Better colors for BT pairing dialog
Linus had complained about these colors for a while. I think
this is a massive improvement.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-29 15:19:33 -07:00
Robert C. Helling
81362e6441 BT address 0 is bogus
Grey out those devices in the scanning list and prevent
the user from selecting those.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-06-30 07:10:32 +09:00
Linus Torvalds
d0c3ef4cf8 Bluetooth: make LE-only devices add "LE:" as an address prefix
This seems a bit odd, but it actually has three different reasons for it:

 - It's a visual indication of BT LE mode for users

 - the rfcomm code only works with legacy BT support, and if we scan a
   device that only does LE, we want the custom serial code to instead
   automatically fall back on a "emulate serial over LE packets" model.

 - we want rfcomm to remain the default for devices that do both legacy
   BT _and_ LE, but we want people to have the ability to override the
   choice manually.  They can now do so by just editing the address
   field and adding the "LE:" prefix manually, and it automatically gets
   saved for next time.

So while a bit hacky, it's actually a very convenient model that not
only works automatically, but allows the manual override.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-26 22:20:01 -07:00
Linus Torvalds
add253ca9e Convert to new libdivecomputer custom IO model
Instead of being "custom serial", it's a IO model that allows serial or
packet modes, independently of each other (ie you can have a bluetooth
device that does serial over BT rfcomm and packet-based communication
over BLE GATT with the same serial operations that describe both cases).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-22 08:43:47 -07:00
Anton Lundin
2fa7e86708 Remove old duplicated code
Way back in time this code was copied from downloadfromdcthread, so
de-duplicate and call that code instead.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-06-21 18:43:15 -07:00
Dirk Hohndel
6afe6baa14 Desktop UI: reset cloud storage progress 'percentage'
The fake percentage needs to at least start at 0 for every cloud interaction.
Yes, the file global variable is ugly. So sue me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-18 01:46:49 -07:00
Dirk Hohndel
b2b51c833a QML UI: redesign the user notification
The old system of cloud access updates with fake percentages just wasn't
helpful. Even worse, it hid a lot important information from the user.
This should be more useful (but it will require that we localize the
messages sent from the git progress notifications and make them more
'user ready').

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-17 23:22:37 -07:00
Jan Mulder
26a0e741b8 code cleanup: remove unimplemented classes and structs
Remove forward declared but not implemented classes and structs.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-16 05:31:41 +09:00
Jan Mulder
db39f1a847 code cleanup: remove 2 unused structs
Luckily these 2 structs in this ugly code are not used. Remove them.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-16 05:31:41 +09:00
Dirk Hohndel
816863dccf Correctly hook up libdivecomputer log and dump
This was checking the status of the wrong UI elements.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-15 02:24:48 -07:00
Lubomir I. Ivanov
1ddda0755b TabDiveInformation.cpp: use lrint() for sac.mliter in updateData()
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 15:57:29 -07:00
Lubomir I. Ivanov
16efcf2af8 simplewidgets.cpp: silence warning about parentheses
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-11 15:57:08 -07:00
Dirk Hohndel
57d01701aa Don't leak memory on downloaded dives not picked
I noticed this in the mobile download code when fixing an unrelated
issue - and then realized that the same was true in the desktop app
as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29 10:35:21 -07:00
Jan Mulder
84b1b63d46 Fix abort when Bluetooth mode is default
Commit dec47e11cd introduces a SIGSEGV in case the user has Bluetooth
download selected from its previous sessions. Accessing the "Import from
dive computer" crashes immediately. Reverting a small part of commit
dec47e11cd solves this.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-28 03:53:05 -07:00
Dirk Hohndel
5a4485b63b Random whitespace cleanup
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:20 -07:00
Tomaz Canabrava
7858376727 QML UI: add the DownloadThread
For this I had to also make the DCDeviceData accessible,
and for that it needed to be a pointer.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:20 -07:00
Tomaz Canabrava
c370b876b2 Reduce the scope of variables
Those variables should have local scope, not class scope.
We are using it only inside of pickDump/LogFile metohds.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Tomaz Canabrava
09904ddff5 Extract the device_data_t into helper class
Keeping the Desktop and QML versions of Subsurface
using the same codebase will keep the code saner,
this change makes the Desktop version use the
DCDeviceData helper sturct that encapsulates
the device_data_t member for easy access on the
QML. This also helped move a bit of initializations
from the UI to the Core - and that's always good.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Tomaz Canabrava
54bb5ccf9e Display the dialog correctly
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 11:07:19 -07:00
Tomaz Canabrava
a55efcf7d8 Move the fill_computer_list() out of widgets
fill_computer_list() creates a Qt friendly
structure that contains all of the necessary
information about dive computers and it's
devices, and it's needed both in Qml and Widgets
to allow the user to download their dives.

This patch makes it possible to use the code
in QML without duplication.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 08:07:35 -07:00
Tomaz Canabrava
dec47e11cd Separate the download thread from the widget logic
This is important to not duplicate code for the Qml
view. Now the DownloadFromDiveComputer widget is mostly
free from important code (that has been upgraded to the
core folder), and I can start coding the QML interface.

There are still a few functions on the desktop widget
that will die so I can call them via the QML code later.

I also touched the location of a few globals (please, let's
stop using those) - because it was declared on the
desktop code and being used in the core.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:53:14 -07:00
Tomaz Canabrava
3c3f91dcb2 Move model code to models
This makes it easery to use it on Qml.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27 07:46:01 -07:00
Stefan Fuchs
e6d884cf26 Creation of dive duration string and surface interval string
Update the function to create the dive duration string in a way that
it can be used also in info and stats tab and added some more flexibility.

Changed layout for <1h freedives to "0:05:35" (w/o units) or "5:35min"
(with units and :) or "5min 35sec" (with units with space).

Add a new function to create the surface interval string.

Completely remove old function get_time_string() and get_time_string_s().

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-26 15:50:52 -07:00
Jan Mulder
f2e23e7815 Allow weight system name to be edited
Issue #272 lead to the introduction of a new private property of the
ComboBoxDelegate class (editable). This new property was not correctly
set when creating the weight system delegate. This corrects the (trivial)
error, and now allows edit of the weight system name.

Fixes: #392

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-09 07:40:26 -07:00
Dirk Hohndel
d7cf3408e5 Merge branch 'seabear-refactor'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-07 07:52:55 -07:00
Miika Turkia
0dfa448d8c Refactor Seabear import
Moving the GUI independent Seabear import functionality to Subsurface
core. This will allow Robert to call it directly from download from DC.

Tested with H3 against released and daily versions of Subsurface. The
result differs somewhat, but it is actually fixing 2 bugs:
- Temperature was mis-interpreted previously
- Sample interval for a dive with 1 second interval was parsed
  incorrectly

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 13:53:52 +03:00
Miika Turkia
ab1813a445 Move intdup to qthelper
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-05-07 09:41:27 +03:00
Dirk Hohndel
876b479d69 Wire up duration units preference UI
Now we track the preference, but we don't act on it, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-06 13:49:36 -07:00
Dirk Hohndel
38b9185974 Add UI for duration preference
This isn't hooked up, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-06 13:11:04 -07:00
Dirk Hohndel
ad5819c42e Save tags when manually adding dive
Tags are handled differently from other fields, we need to call
the special handling after the new dive was added and marked as
the current dive.

Fixes: #369

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-06 12:47:04 -07:00
Dirk Hohndel
9e45999a01 Fix some warnings
Two unused variables and one case of sign confusion.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-06 11:12:28 -07:00
Dirk Hohndel
38af1f2ab9 Check if we have an instance before dereferencing it
If we don't have a GPS service userid in the preferences and the GpsLocation class
isn't instantiated, this would cause a crash.

Fixes #367

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-06 11:12:07 -07:00
Robert C. Helling
462797396b File selector should filter images we can actually handle.
So better ask Qt about image formats known to it.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-06 08:07:16 -07:00
Stefan Fuchs
59bbaa7820 Image import: Make Exif handling more tolerant, better info,...
Changes to the "Add pictures to dive" function:
- Make Exif handling more tolerant by removing the JPG sanity
  check for EOI
- Give info to user if exif.cpp can't identify a Exif date/time
- Restrict file dialog filter for correct picture time by DC photo
  to JPG because Exif is only available from JPG

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-06 08:07:16 -07:00
Anton Lundin
f14ad7f183 Implement OSTC4 specific settings
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Anton Lundin
5a4e1a5586 Connect up all the OSTC4 common settings
Connect up all the settings that are the same, and remove those who are
not, and correct those who only are minor differences.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Anton Lundin
527763f306 Start to read/write and present some OSTC4 settings
This is mostly copy-paste from the ostc3 case, but there are some minor
differences. Some minor things have different meaning, and there's a
slightly different command set, but I couldn't figure out a sane way of
joining them.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Anton Lundin
4cbf64bf99 Wire up a skeleton for configure OSTC 4
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Anton Lundin
0c276403ac Build a gui for configure OSTC 4
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Anton Lundin
6e23ce1488 Remove unneccecery spacer names
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Anton Lundin
4ba9781a68 Remove unneccecery label names
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-05-04 10:50:15 -07:00
Stefan Fuchs
a784b15cb8 Update translation and strings for gas usage in stats
Giving the string " and " to transiflex seems to fail and/or
it's highly possible that the translators make a mistake by
translating it into "and" or " and" or "and ".
Change the string to "and" and hard code the whitespaces before and after.

Change O2 to O₂ in statistics.

Translate "He" and "O2" in statistics.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-01 21:24:02 -07:00
Stefan Fuchs
257f7c082d Show min/max SAC in statistics only if different to average...
...and don't show a minimum depth in stats if there is only a single dive.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-05-01 21:24:02 -07:00