Commit graph

576 commits

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