Not that this would make any noticeable difference, but out of
principle, let's use Qt's string-literal macro for string-literals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
Still buggy: Removing a dive followed by undo shows the wrong dive
in the list. But clicking on it gives the correct dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Once we start using the commands on mobile, the dependencies for this test
break. And since we have disabled the failed attempt to create a planner for
mobile, there's no point running these tests right now.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The weight-undo commands need this. Therefore, we have to compile the
WSInfoModel if we want to access the undo commands from mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This isn't perfect yet, but it looks fairly reasonable.
This commit was mainly written by Dirk, but includes a few fixes from Berthold
which where squashed into this commit as they really should have been part of
the initial version.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To act as a drop-in replacement (at least as much as possible),
move the roles from the old DiveListModel to the common base
model of mobile and desktop.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a model which represents all top-level items and, potentially, one
expanded trip as a flat list.
Pass down roles to the source model and let the source model handle that. We'll
have to do some ifdef-ery, but so be it.
Additionally, compile the base model on mobile as well.
This contains a couple of hacks to make things compile at all.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't just pop the top page off the stack, but pop the download page.
Also explicitly switch to the dive list afterwards.
Additionally, fix a typo in the code that attempts to deal with the
shortcut buttons. I believe that right now this code is completely
broken, but while I contemplate how this should work, let's at least fix
the stupid typo.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
The macro NOCLOUD_LOCALSTORAGE creates the path to the local git
repository as a C-string. None of the users were freeing the string
and thus leaking memory.
Replace the macro by an inline function that creates a QString
and pass down to C-functions using the qPrintable() macro.
Note that every qPrintable() invocation does a UTF16->UTF8
conversion. This could be avoided by either using a std::string
or a QByteArray. However, we are talking about microseconds of
CPU time in operations that typically take seconds. Not worth
it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
If we detect any of the known PID/VID combinations, use 'usb-serial' instead of
'FTDI'. Also add the now supported additional PID/VID combinations.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
We no longer have a dive role - on the plus side, we also don't use this
variable, so I guess this isn't a big deal.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
While the project doesn't use Travis anymore, these scripts are indeed
useful when building locally, so it makes sense to keep them current and
working.
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Once the the mobile app uses the new models, this will be necessary
to get the correct number of filtered dives after startup.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is an idle "optimization": The compiler may now not need
to access the vtable when calling virtual functions.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If compiled on mobile, on change of the current dive, don't send
a signal, but send changed-event with the CURRENT_ROLE for both
dives that changed status (previously selected and newly selected).
Mobile does not use this yet, but will do so with the new flattened
models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This role returns true if the given trip contains the current
dive. This will be needed by the mobile list model to decide
if a newly added trip should be expanded right away.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Use this role to test whether a dive is the currently displayed dive.
This will be needed to transport changes of the current dive to
the mobile list models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
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>
While this is disabled and is unlikely to be completed, the typo caused
confusion with translators.
This shows one of the weaknesses of the way we set up our translations, in that
always both desktop and mobile are translated together, and disabled code is
also included in those translations, causing unnecessary work for the
translators.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
The number of dives was updated when the model of the list was
changed. Since we removed the multi-threading, the model is
not disconnected/connected anymore and therefore we don't get
the appropriate signal. Instead of introducing a different
signal, make the shown-value a Q_PROPERTY. Thus, we can easily
send a changed signal if we have to.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>