Commit graph

642 commits

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