Commit graph

616 commits

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