Commit graph

615 commits

Author SHA1 Message Date
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