This is working around a Qt Bug https://bugreports.qt.io/browse/QTBUG-69494
which prevents correct rendering of the OnePlus fonts.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should make it much easier to debug and hopefully fix some of the odd
scenarios where we get font sizes (or even the screen layout) wrong.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since that object is very heavy, generate one object and read out all
the necessary values. The old code accessed the model again and again.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The cylindersObject list was only used by grantlee but not by
the mobile code. Since it is quite heavy, split it out and thus
don't generate it for every dive on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of handing a reference-to-dive to QML, prerender all the needed
properties and store them as values in DiveObjectHelper. Exception:
- date(): generated from timestamp
- time(): generated from timestamp
- cylinderList(): does not depend on dive anyway and should be made
static.
This hopefully avoids the random mobile crashes that we are seeing.
Clearly, this code needs to be optimized, but it is a start.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These were temporary functions as long as DiveObjectHelpers were
used to access dives. All users now access the core directly and
therefore don't have to test DiveObjectHelpers for validity.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Don't provide access to the raw dive in DiveObjectHelper. All users
now access the core directly. This is a step in making DiveObjectHelper
value-based.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of looping over all dives and search the dive with the given
id, let the source model determine the index and map that. Thus,
we do only one mapping and don't generate a ton of DiveObjectHelpers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Accesses were via DiveObjectHelpers. Provide a direct access to
struct dive *. Use this for the filter - there is no point in
mass generating DiveHelperObjects in the filter code.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In DiveListModel::data() a DiveObjectHelper was created for any
data-access. Create it only when a DiveObjectHelper is actually
returned.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since DiveListModel does not keep its own list of dives anymore,
insertDive() doesn't use the DiveObjectHelper argument. Remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of creating a pointer-to-DiveObjectHelper in commitChanges,
use a normal object. Thus, we don't have to think about ownership
issues with respect to this object.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The clear()/addAllDives() pair was bogus as the former didn't
clear the model (this is not possible anymore - the model
represents the core dive list) and the latter readded all
dives again.
Replace this by a reload() function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of keeping track of a list of DiveObjectHelpers, generate
them on-the-fly in DiveListModel. Thus, there is less danger of
model and core getting out of sync. On the flip-side, now the
DiveListModel and the DiveListSortModel might get out of sync.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveObjectHelper is a tiny wrapper around dive * to allow access
to dive data from QML and grantlee. It doesn't have to be a
full-fledged QObject with support for signals, etc. Therefore,
turn it into a Q_GADGET based object. This allows us passing the
object around as object, not as pointer to DiveObjectHelper.
This makes memory-management distinctly easier.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this data directly
from the model. In this case, don't remove from DiveObjectHelper,
as these data might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this data directly
from the model. In this case, don't remove from DiveObjectHelper,
as these data might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The canonical way of displaying lists in Qt is via models.
Thus, return the tripId directly from the DiveListModel instead
of going indirectly via a DiveObjectHelper. In the future, this
will allow us to make the DiveObjectHelper value-based, as it
is not generated numerous times for every list item.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These properties are not needed anymore, because the full text search
was decoupled from the DiveObjectHelper.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
1) The full text search was looping over the DiveListModel when
it could simply loop over the core model. Do that instead.
2) Don't generate a DiveObjectHelper to do a full text search.
Currently this is harmless as the DiveObjectHelper is only
a disguised "dive *". But from a conceptual point of view,
it represents the full representation of a dive and we don't
want to generate that in a tight loop.
This will help in
1) Making the DiveObjectHelper a non-reference object.
2) Moving fulltext search to the core and thus making it available
to desktop and more performant.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In the previous commit, we just continued downloading dives when
download errors happened, but that also makes problems a lot easier to
miss because now they are possibly just transient reports in the
progress bar that get overwritten by the next dive being downloaded.
So this turns a number of these errors from using 'dev_info()' to use a
new 'download_error()' reporting model, which then uses the generic
subsurface error reporting functionality that is sticky and can handle
multiple errors.
It also adds a few 'dev_info()' calls for actual informational messages
about the state of downloading, although the new ones will probably
mainly end up happening before the progress bar is actually shown. But
it might improve on some of the progress messages.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Eric Charbonnier reported a problem downloading the dives from his
OSTC2, and Jef debugged the libdivecomputer log and says:
"Your ostc has 75 dives, but subsurface downloaded only one, and then
stopped the download. That's because that first dive appears to be
corrupt and fails to parse:
ERROR: Buffer overflow detected! [in /win/subsurface/libdivecomputer/src/hw_ostc_parser.c:981 (hw_ostc_parser_samples_foreach)]
Subsurface (incorrectly) considers that a fatal error and stops the
entire download. From a user point of view, it would be much better to
ignore the problematic dive, and continue downloading the remaining"
Subsurface used to just stop downloading if there were parsing errors,
but Jef further says:
"How parser errors are handled is up to the application. Aborting the
download is probably the worst option here. If a dive fails to parse
(because the dive data is corrupt, the parser contains a bug, etc),
that does not necessary mean the remaining dives can't be downloaded"
so let's change the logic to just continue downloading, and hope other
dives work better.
We might want to do better error reporting, right now the errors tend to
just cause "dev_info()" reports, which just set the progress bar text.
So you'll see it in the progress bar as it happens, but it won't get
really ever noted as an error, and it's easy to miss.
But that error reporting is a separate issue, and this just does the
"continue to the next dive" part.
Reported-by: Eric Charbonnier <eric.charbonnier69@gmail.com>
Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It seems crazy to simply assume that the later code can successfully
untangle the various states that the credentials can be in - let's just
stay on the credentials enrty page until we have verified credentials.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should do the right thing in the various situations of correct &
verified credentials, credentials needing PIN verification, invalid
email/password combination, incorrect PIN, correct PIN.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the default font size is big enough to leave us fewer than 21 grid
units per row, shrink the grid unit.
In order for this to create consistent results, we need to reduce the
default column width to 21 grid units as well. And with that change, the
columnWidth property becomes obsolete.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When building and installing Qt5WebKitWidgets to a different path than
your other qt libraries, you need to actually look for it and find it to
be able to use it.
Signed-off-by: Anton Lundin <glance@acc.umu.se>