Commit graph

1518 commits

Author SHA1 Message Date
Berthold Stoeger
ca336d13e5 Dive list: add option to mark dives valid
If the dive the user clicked on is invalid show an option to
make the dive valid.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20 15:20:44 -07:00
Berthold Stoeger
4e47cdfa2c Undo: implement invalidate-dive command
Connect command to context menu.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-20 15:20:44 -07:00
Miika Turkia
3eff96bcd2 Typo: UCT to UTC
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-03-19 08:37:59 -07:00
Berthold Stoeger
9310d72943 models: update divesite-model when clearing/updating dive model
When the dive list is cleared or updated, the entries in the
divesite-model become stale and therefore the divesite-model
(with the actual name LocationInformationModel) also must be
updated. This was done manually in some parts of the code and
forgotten in others. Therefore, do it directly in the clear()
and reset() function of the dive list-model.

This might be a bit of a layering violation: why should one
model call into another if they are not in parent/child
relationship? However, this seems easier than introducing
a global "reset dives" function that coordinates the models.

Moreover, it does not appear 100% safe: if the clearing of
the divesite model causes accesses to the divelist-model,
they happen in the midst of a model reset and we had horrible
bugs with that kind of things. However, I don't think that
should happen.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-18 13:27:16 -07:00
Robert C. Helling
0acfa28d87 Make statistics window resizable on Mac
For some reason, the window needs an active maximize
button to be resizable on Mac.

Fixes #2671

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-12 11:48:27 -07:00
Robert C. Helling
285fa8acbc Grammar: replaces 'indexes' by 'indices'
Grammar-nazi ran

git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g'

to prevent future wincing when reading the source code.

Unfortunatly, Qt itself is infected as in
QModelIndexList QItemSelection::indexes() const

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-03-11 08:26:30 -07:00
Berthold Stoeger
b6f821886b mobile: unify download code on mobile and desktop
Use the undo-command for importing dives also on mobile. This should make the
whole disconnect-model shenigans unnecessary.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:57 -07:00
Berthold Stoeger
3b6b9951ae undo: clear undo-stack when clearing dive data
When the dive data is cleared, all pointers in the undo-stack become stale.
Desktop explicitly called Command::clear() in that case, but mobile doesn't.
Thus, move the clear() call into DiveTripModelBase::clear()

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10 09:25:49 -07:00
Dirk Hohndel
7d9e907681 debug: try to capture changes that don't invalidate git cache
At least in those cases where we are sending a divesChanged signal we can
easily check if the cache was properly invalidated. Of course this won't help
in cases where we don't notify the dive list about changes, either.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 18:47:34 -08:00
Berthold Stoeger
2a97934db4 Cleanup: Move stringToList to core/qthelper.cpp
The same code was used in desktop and undo commands. Let's unify.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06 10:00:13 +01:00
Berthold Stoeger
c495a49b1b Cleanup: use getDiveSelection() for shifting time
There are two cases where dive-times are shifted: in an explicit
dialog and when editing the date/time of a dive.

In each of these cases, the selected dives were collected manually.
Instead use the getDiveSelection() function. Since this returns
a std::vector, change the argument of Command::ShiftTime() to
such a std::vector.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06 10:00:13 +01:00
Dirk Hohndel
763dbf256a desktop UI: fix typo in GPS import UI
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-05 09:35:43 -08:00
Berthold Stoeger
2b3dc019db selection: update selection on key-presses
Commit 2cea115ddb "fixed" the selection
by hooking into mouseRelease events. An unintended consequence was
that scrolling with the cursor keys didn't update the current dive.

Therefore, also hook into the corresponding key-press events.
This is just horrible, but I'm not aware of any possibility to fix
it properly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:23:53 -08:00
Berthold Stoeger
2c038a24b0 filter: fix tab-order of filter widget
This was basically random.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
3103ca89d9 filter: on show focus on fulltext-field
After pressing CTRL-F let the user immediately enter a search
string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
2bd4c6f6ec filter: connect fulltext filter to frontend
There are now three filter modes:
1) Dive site
2) Fulltext
3) Normal

When doing a fulltext search, get the dives that match the
fulltext filter and then apply the other filters on that list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
68d6a75ea3 filter: add fulltext field to filter widget
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
41aae1aebe filter: move StringMode out of FilterData
The FilterData struct has the enum StringMode, which describes how
strings are searched (substring, startswith, exact). To make it
more generally accessible, remove it from the class. Since it is
an "enum class", the values don't pollute the global namespace anyway.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
3e9b661c22 cleanup: remove setTabIcon() calls in MainTab
These were used to remove warning-icons to mark tabs with user
changes. However these icons haven't been set since commit
a86aca0378.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-28 08:16:41 -08:00
Berthold Stoeger
cb80ff746b crash fix: Don't cast to CylindersModel or CylindersModelFiltered
The tank-info-delegate cast its model to CylindersModelFiltered,
since this is what the equipment-tab uses since implementing the
filtering of unused cylinders. However, the planner users the same
delegate and still uses the unfiltered CylindersModel. This means
that the (dynamic) cast returns a null pointer and crashes.

One possibility would be to derive CylindersModelFiltered and
CylindersModel from the same class that defines virtual functions
and cast to that class.

This is a different attempt: don't cast (i.e. stay with a
QAbstractItemModel and play it via Qt's model-view system. Firstly,
replace the passInData function by a role to setData(). Secondly,
read the working-pressure and size via new columns using data().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-28 08:12:26 -08:00
Berthold Stoeger
fb18bc0803 cleanup: don't update tabs twice in MainTab::rejectChanges
The updateDiveInfo() call updates all tabs. No need to do
it right afterwards.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27 14:49:01 -08:00
Berthold Stoeger
e3950df864 cleanup: remove weightsystems_equal function
This was used to test whether the "really discard changes?"
message should be shown. However, we now edit weightsystems
directly with undo commands. Therefore, the check is unnecessary
and the whole function can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27 14:49:01 -08:00
Berthold Stoeger
0306109e95 cleanup: remove MainTab::modified
This field was not set to true since introducing undo of
dive fields.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27 14:49:01 -08:00
Berthold Stoeger
4c5054ec4e Cleanup: remove unneeded QtConcurrent includes
These became unneeded owing to code reshuffling.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-16 16:52:12 -08:00
Berthold Stoeger
1336ea755b Planner: don't filter cylinders
In the planner we used to filter out "unused" cylinders as in the
equipment tab. It is unclear whether that makes sense or can even
easily be reproduced, since such cylinders have to come from an
imported dive.

To be on the save side, let's not do this. Replace the
CylindersFilteredModel introduced recently by a plain
CylindersModel.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11 20:37:09 -08:00
Berthold Stoeger
190a2a876e Planner: make cylinder-model subobject of planner-model
The cylinder-model had an instance() function, but actually
there were two cylinder models: one used by the equipment tab,
one used by the planner.

This is misleading. Therefore, remove the instance() function
and make the cylinder-model a subobject of the planner-model.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11 20:37:09 -08:00
Berthold Stoeger
6622f42aab Cylinders: Add CylindersModelFiltered
When the show_unused_cylinders flag is not set, the cylinder tables
in the equipment tab and the planner should not show unused cylinders.
However, the code in CylindersModel is fundamentally broken if the
unused cylinders are not at the end of the list: The correct number
of cylinders is shown, but not the correct cylinders.

Therefore, add a higher-level CylindersModelFiltered model on top
of CylindersModel that does the actual filtering. Some calls are
routed through to the base model (notably those that take indexes,
as these have to be mapped), for some calls the caller has to get
access to the source model first. We might want to adjust this.

For filtering, reuse the already existing show_cylinder function
and export it via CylindersModel.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11 20:37:09 -08:00
Berthold Stoeger
50caf38694 Filter: update filter if any of the string-modes changed
Simply hook the corresponding signals to the update-filter
slot.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11 20:29:05 -08:00
Berthold Stoeger
a07d8cf5ea Filter: implement starts-with and exact modes
Currently, we do substring search. Implement starts-with and
exact mode (for example when search for "Cave vs. Cavern" tags).
For each textual search criterion add a combo-box.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11 20:29:05 -08:00
Berthold Stoeger
8391d926c7 Cleanup: remove const bool parameters and return types
These just make no sense. Since the value is copied, it
has no meaning to the caller whether the function can
change the value (and vice versa for return types).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09 12:13:18 -08:00
Berthold Stoeger
2ec570098b Cleanup: remove exportFunc class
exportFunc was a collections of functions for exporting dive data.
It had no state, therefore there is no reason for it to ever be
instantiated.

Simply remove the class. Rename the saveProfile function to
exportProfile so that all export functions start with "export".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09 12:13:18 -08:00
Berthold Stoeger
5b302235f4 Cleanup: Remove global QFuture from exportFuncs
When exporting dives we show a message. The message is closed when
the export is finished. This is coordinated by a QFuture. Instead
of keeping a global QFuture in the export-code, pass it around
as a local variable.

This is supported according to Qt's documentation:
"QFuture is a lightweight reference counted class that can be
passed by value." and the source code indicates the same.

Not only does this remove a global, it also makes the code
more flexible: Now we could show one notification per export,
for example.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09 12:13:18 -08:00
Berthold Stoeger
2cea115ddb Dive list: be more careful on when updating the UI after selection
Fix two issues:

1) When narrowing the selection, we didn't get setSelection()
   calls. Only, when the user released the mouse button was
   the selection updated. Therefore, hook into the mouse-release-
   event and update the UI if the selection changed.

2) We updated the ui in setSelection(). However, this was called
   on mouse-move even if the actual selection didn't change.
   Therefore, compare selection before and after processing of
   the event and only refresh the UI if there are changes.

Clearly, this can only be a quick stopgap solution and we
should find out how to properly hook into the selection change
machinery. Though see commit 4928c4ae04
for the reason why we do things as we do them.

Fixes #2595

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08 14:06:18 -08:00
Berthold Stoeger
285ea9b7ca Cleanup: don't initialize DivePlannerPointsModel at startup
The whole point of having X::instance() functions is to solve
the infamous "Static Initialization Order Fiasco": When having
global objects in different translation units, their order
of initialization is undefined. Thus, when these objects access
each other one cannot guarantee the correct order of
initialization. The X::instance() functions generate the objects
on first use.

DivePlannerPointsModel has such an instance() function. However,
for convenience(?) in diveplanner.cpp we find the global variable
 static DivePlannerPointsModel* plannerModel =
	DivePlannerPointsModel::instance();
Thus, the DivePlannerPointsModel constructor is run before main(),
negating the whole purpose of the instance() function.

Let's remove this line to avoid hard-to-debug startup issues.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06 08:51:32 -08:00
Berthold Stoeger
96a03b4b26 Dive site: don't save invalid GPS coordinates
On the dive site screen, when entering invalid GPS coordinates,
we cleared the location of the dive site. Don't do this. To
clear the location, the user now has to enter the empty string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06 08:50:22 -08:00
Berthold Stoeger
cabaaa69db Dive site: give visual clue for invalid coordinates
On the dive site edit screen, when the user enters invalid
coordinates and saves, we treat this as "no location". This
is rather unfriendly, therefore warn the user with a visual
clue. This is performed by setting the background color of
the widget to red.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06 08:50:22 -08:00
Berthold Stoeger
5e0ce206a0 Cleanup: remove capture-all lambda clauses
These were forgotten the last time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 16:24:29 +01:00
Berthold Stoeger
670a5bd55a Dive sites: select each dive site only once
After selecting dives, the selected dive sites are collected.
This was done using the selectionModel()->selection().indexes(),
which is wrong, because it gives one index per row *and* column.
Accordingly, every dive site was added numerous times to the
array of dive sites to be selected. Change this to
selectionModel()->selectedRows(), which gives one entry per row.

Moreover, if multiple dives with the same site were selected,
this site was also added to the array multiple times. Therefore,
check the array before adding sites.

Note that all this should not change the user experience in
any way, it is only a code-hygiene thing.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:18:28 +01:00
Berthold Stoeger
d27b6805f3 Cleanup: rename plannerShared to PlannerShared
Usually, we use PascalCase (i.e. camelCase with a capital
letter at the start) for class names. For consistency, let's
do it here as well.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:17:52 +01:00
Berthold Stoeger
9ed886e4be Cleanup: lower-case filenames in core/subsurface-qt/
We tend to use lower-case filenames. Let's do it for these files
as well. Simple search & replace.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04 02:16:46 +01:00
Berthold Stoeger
8396b4bf01 Remove plannerShared::instance()
This class contains only static functions (i.e. it does not contain
any state). There does not seem to be a reason to have an instance
of that class. Therefore, remove the instance() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31 21:31:26 +01:00
jan Iversen
ff360d28f5 diveplanner: add surface_segment to plannershared
Add surface_segment to plannerShared and then
update desktop-widgets.

Signed-off-by: jan Iversen <jan@casacondor.com>

desktop-widgets: use plannerShared for surface_segment

Change getter/setter for surface_segment to plannerShared, in
order to share the conversion with mobile diveplanner

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
cd3c2266f9 dive planner: correct bottomsac/decosac calc.
Move conversion cuft <-> liter from desktop-widget/diveplanner.cpp
to plannerShared, to facilitate the same results in mobile
diveplanner

Use Backend for bottomsac/decosac and update to check
for switch LITER <-> CUFT

Add bottomsac/decosac to QMLinterface.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
5548376776 mobile-widgets: correct error in connect
connect to set_o2narcotics missed an & but the compiler did not
complain (which it usually does).

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
e55c740d84 diveplanner: call planner model directly for simple variables.
Variables without conversion, do not need to pass plannerShared
(due to the QML interface).

Simple variables do not pass plannerShared, but diveplanner
in desktop-widgets and qmlinterface in mobile-widgets call the
implementation directly.

Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25 17:13:20 -08:00
jan Iversen
b0e46c208d mobile: move dive planner notes access to pure interface
Make notes rates available to QML through the Backend interface.
Remove the corresponding variables from plannerShared.

Getters are from prefs. while setters are linked to diveplan model.

Remark: signals from qPrefDivePlanner is used, because the diveplanner model
sets qPrefDivePlanner but do not issue special signals.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 20:20:42 -08:00
Dirk Hohndel
ee5a156498 core: move GPX parsing into core
This shouldn't be part of the desktop UI code; there's still the issue that we
really shouldn't hand code XML parsing, but I'll leave that for later.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 09:51:02 -08:00
Willem Ferguson
1ecd5065a0 Desktop: Import dive coordinates directly from GPS
This allows Subsurface to obtain the coordinates of a dive directly
from a GPS track. It parses a GPX file (GPX V1.0 or V1.1) from
a GPS to locate the trackpoint immediatedly after the start of a
dive. There is an additional "Use GPS file" button in the Edit Dive
Site panel that is selected from the Notes tab. Image:

This allows one to select a GPX file, bringing up the Import GPS
dialog.

There is extensive provision for cross-checking that the dive track
synchronises with the dive start and end. If the Save button in the
dialog is pressed the dive coordinates are copied into the Dive
Coordinates text box in the Edit Dive Site panel. The map moves
to indicate the location of the dive site.

The bulk of the work is done in importgps.cpp. The code is
pretty intergrated: I tried to break it up in smaller commits but that
was not feasible.

The code includes responses to the comments by @neolit123 and
@bstoeger. The C-based file input was replaced with Qt-based
code using QChar, QString and QFile.

[Dirk Hohndel: fixed several small issues in the .ui file, removed
               various headers includes that weren't needed and
               fixed printing of minutes as zero padded]

Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24 09:51:02 -08:00
jan Iversen
d924afdf52 qt-models: add suffix Display to unit system aware asc/desc setters
Change ascent/descent setter function names to set_<name>Display
to show the value is prepared for displaying (common for desktop and QML).

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 15:45:20 -08:00
jan Iversen
b1751ac0c6 desktop-widgets: use set/get asc/desc rates in diveplannermodel
The spinboxes are already connected to diveplannermodel set_ functions, remove
second connect to plannerShared.

Change get functions to use diveplannermodel.

Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20 15:43:53 -08:00