Commit graph

17044 commits

Author SHA1 Message Date
Dirk Hohndel
64ae6d54a7 mobile/divelist: set up the new model for the dive list
And remove the reference to the collapsed model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
30d242efc0 mobile/divelist: trip date and title roles for new model
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
89f8457857 mobile/divelist: implement trip title and short date for mobile
We pass this through to the underlying data function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:41:11 -07:00
Berthold Stoeger
c5d17c3d4d mobile/divelist: copy & paste the roles-code from DiveListModel
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>
2020-03-09 12:41:11 -07:00
Berthold Stoeger
35b33b8c6a mobile/divelist: add first version of new MobileListModel proxy model
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>
2020-03-09 12:41:11 -07:00
Dirk Hohndel
90f8c1138e mobile/DC-download: be more careful exiting download page
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>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
8138279a04 mobile UI: ensure download page is shown if started by plug-in event
The order of execution of the various routines is a bit counter intuitive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
174bb91326 mobile UI: move code to open download page on device plug-in
This makes the code easier to reuse and uses the helper we just added.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
93080f129d mobile UI: add consistent way to show a page
And have the existing shortcut functions use that helper.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-09 12:40:44 -07:00
Dirk Hohndel
e5c62f0858 Android: don't list devices with unsupported transport
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>
2020-03-09 12:40:44 -07:00
Berthold Stoeger
2fcd4fff0a cleanup: fix NOCLOUD_LOCALSTORAGE leak
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>
2020-03-09 12:11:01 -07:00
Christof Arnosti
b15b9c6cd0 usb-serial-for-android: Implement timeout-handling
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>
2020-03-08 11:22:55 -07:00
Dirk Hohndel
fe932059fe usb-serial-for-android: switch detection to usb-serial and add more PID/VID
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>
2020-03-08 11:21:54 -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
Dirk Hohndel
45d37fd51b mobile UI: remove obsolete access to already removed model role
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>
2020-03-07 18:47:18 -08:00
Dirk Hohndel
b92b5998ff mobile UI: re-enable download status when restarting download
When tapping on 'retry' we didn't clear the flag that decided which message to
display.

Fixes: #2651

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 16:48:34 -08:00
Christof Arnosti
4e51af7d62 usb-serial-for-android: add changelog line
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 12:34:43 -08:00
Christof Arnosti
debc7ae1f2 usb-serial-for-android: add PID/VIDs
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 12:34:43 -08:00
Christof Arnosti
6e38f85ba7 usb-serial-for-android: Implementation
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>
2020-03-07 12:34:43 -08:00
Christof Arnosti
6ffb1e3129 serial-usb-for-android: Display all Serial computers
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 12:34:43 -08:00
Christof Arnosti
33643bb0af travis build-scripts: update container
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>
2020-03-07 12:34:43 -08:00
Christof Arnosti
e6158c55e1 usb-serial-for-android: add dependency
Signed-off-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07 12:34:43 -08:00
Berthold Stoeger
f7cf3e6b16 divetripmodel: send shown changed signal on reset
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>
2020-03-07 12:04:19 -08:00
Berthold Stoeger
2e52f43d94 divetripmodel: mark derived classes as final
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>
2020-03-07 12:04:19 -08:00
Berthold Stoeger
b575a794ea divetripmodel: use change of CURRENT_ROLE to propagate current dive
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>
2020-03-06 13:46:41 -08:00
Berthold Stoeger
dbddec59d3 divetripmodel: add TRIP_HAS_CURRENT_ROLE
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>
2020-03-06 13:46:41 -08:00
Berthold Stoeger
a88ab64cf8 divetripmodel: introduce CURRENT_ROLE
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>
2020-03-06 13:46:41 -08:00
Dirk Hohndel
97e26fd51b mobile: allow disabling BT support from the command line
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>
2020-03-06 10:00:13 +01: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
Berthold Stoeger
62adc24d15 Core: don't return invalid cylinders from explicit_first_cylinder()
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>
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
8a0eecfd5e cleanup: make version_printed variable static and local to function
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>
2020-03-05 11:07:32 +01:00
Dirk Hohndel
9f8d593a15 Mobile UI: fix typo in disabled planner setup
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>
2020-03-04 08:03:44 -08:00
Dirk Hohndel
bd1e0eea51 Update translation source strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-03 09:58:55 -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
d6114fc37e mobile/filter: derive numShown from a new Q_PROPERTY
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>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
6f2a6fef14 CHANGELOG.md update
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
4cff23ef7a mobile: remove filter settings
These are not used anymore.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
eed4e2746d filter: don't search in background on mobile
I experienced weird crashes that seemed timing-related when
using the filter. Therefore, remove the multi-threading thing.
So far no more crashes, but keep a close eye on that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Dirk Hohndel
b5a427c880 mobile/filter: use more appropriate placeholder text
This way it matches the filter mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
e0766aa4bd filter: introduce people- and tags-filtering in the mobile UI
Add a combo-box where the user can switch between "fulltext",
"people" and "tags" filtering. Connect the combobox to the
already existing filter-code.

Dirk: make combo-box smaller by using a smaller font and restricting
the width. Setting both maximum and preferred widths gives more
consistent results.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
c1e33aac21 filter: implement searching for tags and people in mobile filter
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>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
f3a3d93b85 filter: remove diveContainsText()
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>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
8cb43ed237 filter: use DiveFilter on mobile
Use the DiveFilter class on mobile to update the filter. This
is mostly for convergence of the mobile and desktop models.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
fd7dd5421b filter: implement full-text filtering in mobile version of DiveFilter
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>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
e754b2df84 filter: remove DiveFilter::updateDiveStatus from class
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>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
78405c7265 mobile: remove DiveListSortModel::getFilterString()
This member function was never used.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -08:00
Berthold Stoeger
5bbc0fdb58 filter: compile fulltext index on mobile
The code is not used yet.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01 10:21:44 -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