To make this class available from QMLManager, the run_ui()
function would create the object and then set a pointer in
QMLManager. It works, but is inconsistent with the rest of
the code. Therefore, make it a classical singleton class,
which is generated on demand.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was a sad typo in commit eecca6aab0 ("Mobile: replace model-reset
by row-addition in DiveListModel::reload()").
Additionally, we need to also refresh the dive list so that the new
dives are shown.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We get incorrect changes to a new screen width that causes us to try
draw to a much larger screen than we actually have. Ignore those
changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Different Android devices seem to have different patterns of throwing
incorrect width information at us. This seems like a really bad hack,
but for the ones I've seen so far this should give us the right width
information.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently, desktop and mobile are accessing the DownloadThread
and the DiveImportedModel concurrently. This makes a big data
flow mess. To achieve a more hierarchical data flow, start
by making the DownloadThread a subobject of DiveImportedModel.
Start the download by calling a function in DiveImportedModel.
Route the finished signal through DiveImportedModel. Thus,
the model can reload itself with the new data.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Owing to apparent QML breakage, a model-reset leads to the DiveDetail
page being reloaded for every dive in the list(!). Therefore, add
rows instead.
This leads to extremely subtle code, as it is now imperative that
the model has been properly cleared beforehand. Nevertheless, for
now we have to do this to fix a severe performance regression.
Fixes#2295
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Clearing the dive data directly in the core leaves us with an
inconsistent model. Therefore, clear via the model.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is already a role to do that. Query the model directly to
avoid creating a full DiveHelperObject.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of using the GpsLocation singleton in GpsListModel::update()
to extract the gpsTrackers, pass the gpsTrackers as function argument.
The caller has direct access to the GpsLocation object anyway and this
make things less entangled.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The way we handle singletons in QML, QML insists on allocating the
objects. This leads to a very idiosyncratic way of handling
singletons: The global instance pointer is set in the constructor.
Unify all these by implementing a "SillySingleton" template. All
of the weird singleton-classes can derive from this template and
don't have to bother with reimplementing the instance() function
with all the safety-checks, etc.
This serves firstly as documentation but also improves debugging
as we will now see wanted and unwanted creation and destruction
of these weird singletons.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This addresses the following warning when running the mobile app:
INFO: QQmlExpression: Expression qrc:/qml/DownloadFromDiveComputer.qml:339:5 depends on non-NOTIFYable properties:
INFO: QMLManager::DC_forceDownload
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This looked fine when playing with it on the desktop, but required
more space on device for some reason.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of converting the section-heading string to a trip-pointer
in QML and pass that to the tripTitle() and tripShortDate()
functions, pass the string and convert in C++ code.
Hopefully, this makes the code more robust.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>
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>
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>
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>
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>
If a dive has no weightsystems, editing the weight system has to add
a new entry in the table. Implement that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There are reported crashes on Android that suggest a null
"tables" attribute in DownloadDCThread. This should never
happen, as the table() function connected to this attribute
returns the address of a subobject. Thus, even if the original
DownloadThread is null, this would not return a null pointer
(the subobject is not at address 0).
Catch these null-object accesses and write a warning message
to the console. Hopefully, this will help is localizing the
problem.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Always keep the dive site model up to date when adding dive sites.
This hopefully avoids creation of invalid indexes followed by crashes.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Move the declarations of the "report_error()" and "set_error_cb()"
functions and the "verbose" variable to errorhelper.h.
Thus, error-reporting translation units don't have to import the
big dive.h header file.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Replace the fixed-size weightsystem table by a dynamically
relocated table. Reuse the table-macros used in other parts
of the code.
The table stores weightsystem entries, not pointers to
weightsystems. Thus, ownership of the description string is
taken when adding a weightsystem. An extra function adds
a cloned weightsystem at the end of the table.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
These functions were spread out over dive.c and divelist.c.
Move them into their own file to make all this a bit less monolithic.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>