No reason to keep this as a macro - a function is easier to
read, type safe and easier to debug. Moreover, give it the
more appropriate name "nearly_equal()". After all, it precisely
does NOT check floating points for equality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The FP_IS_SAME macro uses a relative precision to compare
floating points. This fails when comparing to 0. Therefore,
use an absolute precision in this case. Implement as an
inline function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We have two different API endpoints. supportEmail() which adds the
default subject, recipient, and message body, and the generic
shareViaEmail() which takes all of these as arguments.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was added for Android a while ago, but now this works on iOS as well which
is a very welcome addition for the recipient of these support emails (i.e. me).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes it marginally easier to deal with debug builds and release builds in
parallel. The quick builds work most of the time, but not always.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For Ratio dive computers we can't tell by the Bluetooth name which model it is.
There are BT only models and BLE only models. The failure case here was a user
on iOS (BLE only) with a BLE only dive computer which we didn't recognize
because previously we returned a BT only device (which isn't supported on an
iPhone), and the lookup won't return a valid descriptor if the transport needed
isn't available.
These days BLE is far more common, so return a BLE enabled name by default, but
try a BT only name just in case.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For some reason the flag to exclude . and .. breaks this functionality.
It works just fine without that flag, so let's just remove it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Other overridden functions of this class are marked as well,
so let's do it for this function for consistency reasons.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When there is no map support, selection of dive sites is suppressed.
There is no point in calculating the selected dive sites in this case.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The last caller of find_cylinder_index() was removed in
3629a87fcc. Also remove functions that where only called by
this function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When a dive has both real dive computers as well as at
least a planned version (which is just another dive
computer with a special name), only use the data from
real dive computers for aggregate values like maxdepth,
dive time, average depth etc in order not to have
imagined data on the dive list, statistics etc.
Macro-magic-provided-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Robert C. Helling <helling@atdotde.de>
One would think that calling free() on a dive structure, as the code
did in some places, would lead to a memory leak.
(Insert rant about C memory management.)
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is stored as uint32_t, so no reason to use the larger time_t.
It appears to be, after all, relative to the dive start.
Coverity was complaining about the down-conversion later in the code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If the entries in the DiveLocationModel don't have their entries
set as editable, the auto-completion popup turns of composition
if such an item is highlighted (see Qt code in
/src/widgets/itemviews/qabstractitemview.cpp), thus disabling
composition of multi-key characters.
Therefore, set this flag. Seems weird, but what should we do!?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is crazy: when view() is called, the dive-site-suggestion
popup (DiveLocationListView) clears its WA_InputMethodEnabled
flag. This makes key composition not work as long as the
popup is open.
Thus, when showing the popup, explicitly set the flag.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Adds a preference setting in the "Default" settings tab to toggle whether
to display shortened names in the Map.
TODO: instead of using the generic "settingsChanged" signal, it would be much
more efficient to only update items based on the actual setting which was
changed.
Signed-off-by: Michael WERLE <micha@michaelwerle.com>
Only the last component of the Site Name is displayed, otherwise the full
name is displayed. Site Name components are separated using slash (/)
characters.
For example, if the full dive-site name is
"Japan / Izu Peninsula / Atami / Chinsen-Aft" then only "Chinsen-Aft" is
displayed on the Map.
Signed-off-by: Michael WERLE <micha@michaelwerle.com>
In bc3b56a969, the import of the dive mode was simplified,
by replacing an if-else-if chain by bit manipulations.
However, the bitmask was wrong: 0b00111000 is 0x38 not 0x30,
which means that "odd" dive modes were not recognized as such.
Bug found by coverity.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Attn: horrible hack!
For some reason the completion-popup does not have the
Qt::WA_InputMethodEnabled flag set. Thus, if the popup is open
composition of characters breaks.
Therefore, when starting completion, explicitly set the flag
on the popup.
This is 100% not how this was intended, but seems to work for
now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The TagWidgets hook into the textChanged() signal to invoke
the word-completer. However, that signal is also emitted for
composition-keys, making composition impossible if the completer
decides that it should show some entries.
Instead, hook into the inputMethodEvent() function, where one
can test whether a real character was input.
Also, don't hook into cursorPositionChanged(), since that led
to an uncanny cascade of reparse() calls when editing text.
The UI experience is still rough as sometimes the completer
popup steals the focus and hinders further entry.
Also, this doesn't fix the location field, which is its own class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The git save format is designed to be entirely line-based, where all the
dive data is on individual lines that are independent.
That is very much by design, so that you can merge these files
automatically, and not worry about what it does to the context (contrast
this to structured files like JSON or XML, where you have multiple
levels of indentation, and the context of a line matters).
So the parser can just ignore any conflict markers, and parse everything
one line at a time.
Well, almost.
We do have *one* special form of multi-line context, where flowed text
(think things like dive notes) will have one "header line" that starts
the note, and then it can continue for several lines until the final
line that ends the quote.
In such a situation, the dive merging can result in a partially merged
string note, which has the ending line from one dive, and then continues
with more string data from the other dive.
That will confuse our parser mightily, because it will have seen the end
of the string, and parsed the rest of those string comments as garbage lines.
That part in itself is fine - the garbage lines won't pass as any real
data (because they don't start with a proper keyword), but while parsing
that garbage the *next* end of the string will be seen as a start of a
new string.
And *that* then confuses the git parser to think that the line after
that is now part of the string, and so it won't correctly parse the
non-string line that follows.
To give a more concrete example, the git dive data (here indented and
abbreviated) might look like this:
suit "5mm long + 3mm hooded vest"
notes "First boat dive.
Giant-stride entry."
Saw a turtle."
cylinder vol=10.0l description="10.0ℓ" depth=66.019m
where the two notes from the two dives were
notes "First boat dive.
Giant-stride entry"
and
notes "First boat dive.
Saw a turtle."
respectively, and the merged result contained parts of both.
When we parse this, we will parse the 'notes' line as having the string
First boat dive.
Giant-stride entry
which is fine. But then the next line will be that
Saw a turtle."
and now the ending double quote character on that line will be seen as
the beginning of a new string, and the cylinder information on the next
line will then be mixed up. The resulting mess will be ignored, but in
the process the data on the "cylinder" line will basically have been
lost.
There are several ways to deal with this, but this particular fix
depends on the fact that we can recognize stale string continuation
lines: they are either empty (for an empty line), or they start with a
TAB character.
So to solve the problem with the mis-identified end quote, this
recognizes that we're in such a "stale left-over comment line" context,
and will just skip such lines entirely.
That does mean that when you have conflicts in dive note sections due to
having edited the dive concurrently on different machines, you may just
lose some of the edits.
But this way at least you shouldn't lose any other data due to the merge
conflict.
NOTE! We could try to improve on this by instead noticing that a "end of
multi-line string has a continuation entry on the next line", and just
say "ok, that wasn't a real end after all".
But that would be an independent thing anyway - this "ignore stale text
comment lines" logic would be required anyway, in case those stale text
comments ended up somewhere *else* than right after another text line.
So do this more important fix first.
Reported-by: Michael Werle
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
In utc_mkdate() we find the interesting statement
val = timestamp /= 60;
which not only calculates timestamp / 60, but also overwrites
timestamp with the new value. However, timestamp is never used
in the remainder of the function, because the whole point is to
switch to 32-bit types. Thus, replace the division-assignment
by a simple division operator to avoid head-scratching.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
And the way this gets bundled into an iOS app means that we have to declare
permissions that we don't use because the SDK we use could use them. On some
level I can understand that logic, but in general... this is just dumb.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The Qt Company apparently didn't feel the need to have the correct
tags in all of the module directories. So this now has to manually
pick the correct SHA. What a pain.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
State requirements for email address and
password format within cloud preferences UI
If email address or password entered in cloud
preferences, raise a warning within a
QMessageBox instead of the less-visible
report_error method
Signed-off-by: Jon Massey <jon.massey@thedatalab.org>
The liter symbol is written as 'ℓ'. To allow searching for
that, normalize unicode strings to their base letter. This
corresponds to the 'compatibility' mode.
We might also think about stripping diacritics.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This should avoid build failures on platforms where we don't know if
QtWebKit will be available or not.
The options for printing and user manual are awkward to work with. This
all needs to be cleaned up at some point. Right.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The code works ok falling back to just Perdix and Petrel 2, but
it looks confusing to the user to see an incorrect name in the
connection drop down.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>