Make the application of the GPS fixes in two runs: first
collect dives and fixes, then apply the fixes. This will
simplify turning the application of GPS fixes into an
undo-command.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We know that we cannot support native USB, USB HID, IRDA, and USB
storage on Android.
On the flip side, don't try to force the long broken FTDI download.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the Android USB stack and subsequently the usb-serial-for-android
driver have problems with read-timeouts, the read-timeout is now
implemented in AndroidSerial.java. Also, DC_STATUS_TIMEOUT is returned
if there are less bytes returned than expected.
Different chipsets seem to behave differently with
usb-serial-for-android. On CP210x the read blocks until there is some
data here, but on FTDI the chip seems to return whatever is currently in
the buffer (so 0 bytes if the buffer is empty). This different behaviour
should be mitigated by the changes by this commit.
Signed-off-by: Christof Arnosti <charno@charno.ch>
Implement the libdivecomputer API in Java and create C/JNI translation
layer.
[Dirk Hohndel: whitespace harmonization - yes, some of this is Java,
this still makes it much easier to read for me;
also changed the FTDI conditional compilation to make
sure we can still use that for mobile-on-desktop if
necessary]
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a quick hack to reduce the noise in the log file when chasing other
bugs. Maybe this should not be enabled on release builds, but right now I don't
think the harm that having this in would do.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For reasons which I don't yet understand, when plotting a dive
whose first cylinder is not cylinder 0 and then plotting a dive
with only one cylinder, it can happen that for the latter
explicit_first_cylinder() returns an erroneous value.
This is due to the way in which we copy the dive to be plotted
to displayed_dive.
For now, make sure that no invalid cylinder is returned to avoid
crashes. This will have to be changed anyway, since this is very
fundamentally not thread-safe and inefficient.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The version_printed variable is used to print version information
only once. It was a global variable, but never used outside of
its function. Therefore, move it into the function and make it
static. Since this is a plain old datatype (POD), it makes no
no difference whatsoever whether the static variable is in block
scope or not. Indeed, it is initialized in the data segment). Well,
we are in C mode and therefore everything has to be POD by definition.
I tested this on gcc and clang.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Implement tag- and people-filtering in the mobile version of
DiveFilter. As opposed to the desktop version, this has no
different modes: it always searches "startswith" and "all of".
I.e. all of the search strings must match and a tag / person
is considered as matching if it starts with the search term.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function checked a dive for a search string. Its functionality
was replaced by a fulltext index.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In analogy to the desktop version, use the fulltext index in
DiveFilter. This code is not yet executed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function did not access any class members and was not used
outside the tranlation unit. Let's make it local (i.e. static)
to the translation unit.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
When loading dive data, populate the fulltext index. When clearing
dive data, free the fulltext index. When deleting a dive, remove it
from the fulltext index.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Add code that indexes all words of a dive and provides searching
for words.
A query is represented by the FullTextQuery class, which can be
initialized by assigning a string to it. It is basically a list
of words.
The result of a search is stored in the FullTextResult class,
which is a list of dives.
The actual indexing and searching is implemented in the FullText
class. However, this class is not exported because the interface
is partially accessible to C. Notably, the reloading of the
fulltext index is done from the C core.
Currently, the indexing and searching is totally unoptimized.
In a ~4000 dives test-log searches typically took single-digit
ms times. There is ample room for optimization (e.g. when
searching for multiple words, chose the words with few dives
first and when down to a few dives, check them individually).
The words of each dive are tokenized and uppercased and
cached with the dive. A pointer to these words is stashed
in the dive structure.
For now, compile only on desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
The DiveFilter class defined the showDive() function to test
whether a dive should be filtered or not. This was used in
DiveTripModel to loop over all dives or all dives affected by
an editing action.
This restricts us in how we do filtering: We can't use indexes
that give us directly the result. To make the filtering more
flexible, move the actual loops that do the filtering to
the DiveFilter class.
The undo-commands likewise called directly the showDive()
function to check whether newly added dives are shown.
Use the new interface here as well.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Because of the multiple string confusion, we'd get the names wrong for
modechange events. If we then made other changes to the dive and saved
the end result back, they'd now be wrong in the git cloud storage too.
Fix it up manually by just noticing that there's a 'divemode' string on
the event line, which can only happen with modechange events.
Maybe we should report the fixup? This just silently fixes it (but only
for the git save format).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We had some fairly obscure rules for how strings were parsed, and it
actually caused bugs when the same line had multiple strings in it.
That normally doesn't happen, and the cases where it was _supposed_ to
happen had special cases for it (divecomputer ID lines, and tag lines).
But by mistake, we had introduced a case of that for the event line
handling in commit b9174332d ("Read and write divemode changes (xml and
git)"), and nobody realized that the divemode string addition meant that
"oops, now it's corrupting the event name". An event line could look
like this:
event 40:00 type=8 divemode="OC" name="modechange"
where we now had both that "OC" and "modechange" strings, and the code
to pick the name just picked the first string. So we'd end up
effectively mis-parsing the above line as
event 40:00 type=8 divemode="OC" name="OC"
which is obviously wrong.
The dive mode didn't really need to be a string in the first place
(there is nothing to quote, and no spaces in it), but hey, here we are.
We can't just magially fix the existing broken saves.
So make it more straightforward to handle strings in the git format line
parser. We still stash the different decoded strings together in one
special memory buffer, but now the parser helpers automatically untangle
it as they traverse the key value pairs.
This is still overly subtle code, and it doesn't fix the cases where
we've saved the wrong data back. That comes later.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
If we change the gps location of a dive that didn't have a dive site associated
before (which is the normal case when a dive was just downloaded from a dive
computer), a new dive site is created with that GPS fix and added to the dive.
We need to mark that dive as changed in order for the changes to be saved to
storage.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Corrected typo of the word celsius in three files:
core/import-csv.c
core/divefileter.h
mobile-widgets/qml/Settings.qml
These were spelled as celcius but corrected these to celsius.
The 'core files were just comments but the mobile-widgets file would be
'active' code.
Reported by: tormento <turment@gmail.com>
Signed-off-by: Jason Bramwell <jb2cool@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
Remove two erroneous comments stating that a function-local
QSettings variable should not be static because it is initialized
too early. Scoped static variables are initialized when execution
first hits the statement.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The idea is that in portrait mode we can force the display to be single column (which
makes sure that the profile in dive display mode is nice and big).
This commit only implements the preference variable that we need for that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of transporting the global first and last dive date
in the dive summary, calculate it in an external function.
Since we already have time and date functions in qthelper.cpp
implement those functions there. Provide a stub in QMLInterface
so that QML can access these standalone functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Some Wikipedia pages use special (non-ASCII) unicode symbols for
representing the " and ' separators. Before parsing, replace these
by the ASCII symbols to enable copy & paste from Wikipedia (and
other sources?).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
As we do XSLT parsing for the CSV import, ampersand characters need to
be encoded with & for the parsing to succeed.
Fixes#2037
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
When starting / changing the dive-site filter, inform the map of
the changed dive site selection by calling
MapWidget::instance()->selectionChanged();
This fixes a bug, where on clicking dive sites in the dive site
tab the dive sites from the *previous* click were highlighted.
Perhaps the selectionChanged() call should be put into the
setSelected() call. But the data flow between the different
parts of the dive-site and map code are so convoluted that I
don't want to risk anything!
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
Windows had it's own direct socket implementation for rfcomm (ie legacy
BT), while all the other platforms used QtBluetooth.
This makes Windows do the same thing. Hopefully modern Qt libraries now
work well enough on the Windows platform for this to work, but I can't
test it.
We can make a test build that Windows people can try, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Jef has changed the libdivecomputer iostream layer and extended it in
two different ways:
- iostram's now have a 'poll()' method, which does what the name
implies: waits for data to be available with a timeout.
- iostreams now have a 'ioctl()' method, which can be used to implement
miscellaneous operations. Right now the two ones that you can do are
"set latency" (this replaces the old 'set_latency()' method) and "get
BLE name" (this replaces our 'get_name()' method that was never part
of the upstream libdivecomputer interfaces)
Neither of these is all that complicated, and the transition is fairly
obvious.
HOWEVER.
I have absolutely no idea how to do 'poll()' on Windows sockets, and I
have no intention of figuring it out. We use a direct socket interface
to implement the (non-BLE) RFCOMM bluetooth serial protocol, and I'm not
sure why Windows is so special here. I suspect - but cannot test - that
we should just switch the Windows RFCOMM implementation over to the use
the same QtBluetooth code that we use on other platforms.
I assume that the Windows Bluetooth support was originally not
sufficiently good for that, but these days we depend on Qt doing BLE for
us even on Windows, so presumably FRCOMM works too.
That would be a nice cleanup, and would make 'poll()' work on RFCOMM
under Windows too. However, since I can't test it, I've not done that,
but instead just made the Windows RFCOMM 'poll()' method always return
success. That may or may not get the thing limping along.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Simply replace it with QLatin1String. There is a tiny performance penalty,
but none of that code would care.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This replaces the C-code XML parsing with a Qt infrastructure.
QXmlStreamReader is used to parse the GPX file.
It also takes into account comments by @neolit123
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
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>
prefs.unit_system is set at the top, so no need to set it again.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
prefs.unit = x needs to be after the setters are called, otherwise the setter
will not do anything, and result in an inconsistency between the values stored
on disk and in prefs.units.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove string version of unit_system, duration_units, length, pressure,
temperature, vertical_speed_time, and volume, including tests and make signals
strongly typed in C++
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Register enums to allow them to be used in signal handlers instead of int.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add CLOUD_STATUS enum to interface.
Add cloud_verifification_status variable to interface, and make
it strongly typed in QML.
using backend.cloud_verification_status = 1 will fail but
backend.cloud_verification_status = backend.CS_UNKNOWN is correct.
Added note to the original definitions of the enums that they have been
duplicated.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a header file that contains a duplicate of the enums,
that are needed in QML in one class.
the unit enums are added imidiatly, since they are needed
or will be neede shortly in Settings and DivePlannerSettings
This class will also contain Q_PROPERTY and signal/slot for
variables used in QML. This is done to allow e.g.
deco_mode qPrefUnits::planner_deco_mode()
void qPrefUnits::set_planner_deco_mode(deco_mode)
as strongly typed in C++
and
DECO_MODE planner_deco_mode()
void set_planner_deco_mode(DECO_MODE)
as strongly typed in QML
Remark: wrong assignments gives errors in QML
The advantage over using strings or the value directly is that
QML detects typos and flags them as errors/warnings.
It is important to note that the class may only contain
a) a function call to the implementation
b) a reference to a global variable e.g. prefs.
Added note to the original definitions of the enums that they
have been duplicated.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>