Recently we changed the MapLocationModel-items to store whether
they are selected. Thus, we can directly export an isSelected
flag instead of calling a function taking a dive-site argument.
1) This makes the QML easier to read.
2) This avoids passing pointers through QML which has caused
us lots of pain.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To connect a model to QML, one is supposed to provide a
QHash<int, QByteArray> MapLocationModel::roleNames()
function that returns a role -> attribute-name hash.
That was realized by filling the hash in the constructor,
storing it as a member variable, using static strings that
were declared in the class-definition and defined in the
translation unit.
Adding a new role was a pain and the whole thing was totally
pointless as the attribute names were used nowhere else and
the roleNames() function is called only once.
Simply do, what we do everywhere else: initialize the hash
in the roleNames() function and use normal string literals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When editing the dive site, for certain fields a divesChanged signal
was emitted so that the dive-list can be updated.
Arguably it is wrong to decide which fields are relevant to the
dive list in the undo-command code. Therefore, let the list
catch the dive-site-edited signal and decide itself.
But the actual reason for this commit is that if the dive-site
field of a dive changes, we might have to reload the dive-location-model
because suddenly a new dive site appears. Now if this is done
in QML context on some Qt version (notably 5.9) we get crashes
later on. But that can happen if the user moves a flag. So in that
case only send a diveSiteChanged signal.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since changing the highlighting to use the selected dive, dive
sites with no dive were never highlighted in dive site mode.
Obviously, because there was no dive to be selected.
Therefore special-case all dive-site selection code to recognize
when we are in dive site mode.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since selection change doesn't to a full map reload, we have to
reload the map on filter changes, since the shown dive sites change.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one-liner was called in only one place from the same class.
Just fold it into the caller.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since not fully reloading the map on selection change,
the selected sites were not moved to the top. Not calculating
the z-value in QML, but making it a simple model property
helps.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Owing to the recent changes, when the selection flag in the
MapLocationModel was not updated correctly when the user
manually selected the dive. Do that before raising the
divesSelected signal in DiveListView::selectionChanged()
because that will cause the MainWindow to repaint the flags.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When clicking a dive site on the map, the QML code would set
the selected dive site, but then all dives of dive sites in
the vicinity were set. But still only the clicked-on dive site
was shown.
Therefore, don't set the list of selected dive sites in QML,
but later in DiveListView::selectDives(), where we know all
the dives that were selected.
This, again, gives nasty entanglement of diverse widgets and
models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When changing the selection the MapLocationModel was reset.
This lead to crashes on Qt-5.9 which are due to QML accessing
data that was freed during model reset. This putative Qt bug
doesn't happen on newer Qt versions. At least Qt-5.12 is known
to work.
Instead of fighting the bug, let's simply not reset the model
but send a dataChanged() for every element of the MapLocationModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In MainWindow::refreshDisplay() with doRecreateDiveList=true
the map was reset before the dive list was recreated. This
makes no sense and only worked because the map was reloaded
again when a dive in the list was selected.
Reload the map after recreating the dive list.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Experimentation has shown that the image of a flag will
only be changed after dataChanged() if it is a simple
property. The old code had a complex QML expression and
then - for some reason - it didn't work.
To give us better control over the flags and avoid full
reloads of the map therefore introduce a model-property
pixmap name. The name depends on whether the site is
selected and if not, whether we are in divesite-edit mode.
This makes the code rather convoluted. Firstly, we have
to save whether the site is selected in the map-item.
Secondly we have to access the global map-widget, which
in turn has to go to the map-widget helper (layering
violation!).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When clicking on a flag
1) The QML would call MapLocationModel::setSelected() with
fromClick = true
2) MapLocationModel::setSelected() would emit a signal
selectedLocationChanged()
3) MapWidgetHelper would catch that signal and do the actual
processing.
Other functions would call MapLocationModel::setSelected() with
fromClick = false, which would not emit the selectedLocationChanged()
signal.
Detangle this a bit by calling the selectedLocationChanged() function
directly from QML and remove the fromClick parameter.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There weree two functions in MapWidgetHelper: one to enter and
one to exit edit mode. Both functions set the flag and emitted
a signal if the flag had changed.
Since the edit mode only depends on a flag of the filter this
can be simplified to a simple function that updates the flag
and raises the signal if the flag changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
For this we need our own hand crafted trusty container with Qt 5.12,
including QtWebKit and an updated cmake and libdbus, as well as already
build googlemaps plugin, grantlee and libgit2.
At the same time stop uploading the Subsurface AppImage in the
traditional trusty build.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
To recognize HTML-notes the text was scanned for <div> tags. But
apparently the planner notes do not feature such a thing. Therefore
extend recognition of HTML to <table> tags.
Note we can't use the <html> or <span> tags, because these are
*always* produced by the QTextEdit::toHtml() function.
Fixes#2265
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Nothing huge, but this fixes the Deepblu Cosmiq+ gasmix parsing, and
properly stops downloading when we've hit a dive we already have.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Replaces some enums with names that do not clash with windows #defines.
Specifically:
ERROR -> ERRORED, PASCAL->PASCALS, IGNORE->IGNORED,FLOAT->FLOATVAL
Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
Just to be sure, refuse to add null divesites to the selection.
Moreover, refuse to call the setSelected function on a null-divesite.
I got an unfriendly Qt-Warning there:
"Passing incompatible arguments to C++ functions from JavaScript is
dangerous and deprecated."
"This will throw a JavaScript TypeError in future releases of Qt!"
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The create_plot_info_new() function releases old plot data. This
can only work if the plot_info structure was initialized previously.
The ProfileWidget2 did that by a memset, but other parts of the code
did not.
Therefore, introduce a init_plot_info() function and call that when
generating a plot_info struct. Constructors would make this so much
easier - but since this is called from C, we can't use them.
Fixes#2251
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I got confirmation from Tiago Thedim Dias that my libdivecomputer patch
makes BLE downloading work from the i200c, and already pushed out the
libdivecomputer changes earlier. This updates the subproject in
subsurface to have those changes.
This also adds the bluetooth name patterns for the i300c and a few other
Aqualung dive computers we hadn't added yet. That should make them show
up in the bleutooth device list even without having to check the "Show
all bluetooth devices" check-box.
Tiago claims he didn't need that, and I wonder if we have some overly
permissive match somewhere, but it's the right thing to do regardless.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The constructor of PasteState was clearing an uninitialized
weightsystem-table. Very silly. Initialize it instead.
Fixes#2253
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of generating cylinder data in the form of
CylinderObjectHelper objects for every DiveObjectHelper,
generate it only if needed. DiveObjectHelper is used extensively
in the mobile interface, which doesn't use the cylinder data.
Let's not generate unnecessary CylinderObjectHelpers in this
case!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
CylinderObjectHelper is used for structured formatting of cylinder
values in grantlee types. Instead of keeping a reference to a
cylinder, turn it into a value type containing the formatted strings.
This should be distinctly safer, as we don't risk having stale
references flying around. Moreover, we don't have to use pointers
but can use containers containing plain CylinderObjectHelper. Thus,
no explicit memory management is needed, making the code distinctly
easier to understand.
Sadly, currently grantlee does not support Q_GADGET based Q_PROPERTY.
Therefore a GRANTLEE_*_LOOKUP block has to be added. This can be
removed in due course, as a patch to remedy this issue is in current
grantlee master.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We used a table lookup for CNS equivalent times. Turns
out the log of this table falls pretty much on a straight
line for po2 <= 1.5bar. We now fit this tabel two two
lines, one for <= 1.5 bar and one above. This four
parameter fit has half the sum of errors squared
than the five parameter fit using a fourth order
polynomial.
Fitting the log has the advantage that this never
crosses 0, which would have the bad effect of
resulting in negative CNS values as we divide
by the table value.
We don't adopt a maximum pO2 cut-off for the CNS calculation
but rather live with the large values that the interpolation
formula produces when extrapolating.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
It turns out that the dive site saving was subtly but horribly buggy.
To save the value of the dive site, it did
show_utf8_blanked(b, t->value, " value='", "'/>\n", 1, anonymize);
which looks sane on the face of it, but the problem is that it puts the
final closing xml marker in the 'append this at the end' case.
That means that if the value is empty, the value won't be saved, but
neither will the closing tag. Resulting in an xml line that looks like
this:
<geo cat='3' origin='0' <geo cat='5' origin='0' value='Other name'/>
where the first geo tag was saved without the ending marker.
That then makes all the xml nesting entirely wrong, and the whole file
fails to save.
Now, the code around it does check that 't->value' is not NULL, but it
doesn't check for a value that is empty or all spaces (which also will
make 'show_utf8()' just skip it.
Fix it by saving the end marker separately:
show_utf8_blanked(b, t->value, " value='", "'", 1, anonymize);
put_format(b, "/>\n");
so that the xml is valid even if the goe marker value wasn'r.
Reported-by: Bob Barker <barkerb1965@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
But don't show our cloud storage entry (as that is already in the File menu,
anyway).
This is extremely useful because while you can manually enter a file name to
save to (and therefore can use the 'magic' git repo syntax), on most OSs there
is no way to enter that non-existing 'file name' (which is the git branch in
square brackets) in the file open dialog.
Fixes: #2236
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It needs a newer version of libdivecomputer to actually download, but
early very experimental code exists in the Subsurface-NG branch.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Indexes go from 0 to count - 1. Thus, the comparison for invalid
indexes has to read ">= count", not "> count".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't support null-dives in DiveObjectHelper. Defaulting the
dive parameter to NULL seems to send the wrong message.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If a dive has no weightsystems, editing the weight system has to add
a new entry in the table. Implement that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When removing the max-weightsystem restriction, the semantics of
the DiveObjectHelper::singleWeightSystem() function changed:
it now returned false for "no weightsystem". Change it back,
to 0 or 1 weightsystems, because the mobile frontend uses this
to check whether it can edit dive systems.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>