Commit graph

1148 commits

Author SHA1 Message Date
Dirk Hohndel
320d2c47aa Mobile: fix incorrect variable dereference for dive site
Since we are accessing the model, this is the variable we should use.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
f69b93de40 Mobile: don't push map page if it's already on the stack
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
4e583f9120 Mobile: avoid dereferencing undefined values
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
face9ba1a8 Mobile: fix cacheBuffer for log window
The old value made no sense at all. Why would we want to cache up to 10k
entries of the log?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 11:38:26 -07:00
Dirk Hohndel
e6298f9352 Mobile: allow editing dive number
No checks regarding duplicate numbers - we trust the user knows what
they are doing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-21 15:50:41 -04:00
Dirk Hohndel
158a2ec159 Mobile: remove remaining accesses to DiveObjectHelper from QML
Add a couple more roles and remove the dive role that allows accesss to
the DiveObjectHelper in the first place.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-20 16:08:55 -04:00
Dirk Hohndel
613a3112d2 Mobile: get dive details directly from the model
By getting a DiveObjectHelper and then dereferencing that we ended up
creating hundres and hundreds of these objects, only to immediately
destroy them after using a tiny part of the data.

Instead make those data available directly from the model, without
having to create a DiveObjectHelper forst.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-20 16:08:55 -04:00
Dirk Hohndel
01f1bea995 Mobile: ensure input fields stay visible after keyboard opens
When the user taps on a TextField to enter text, usually the virtual
keyboard will pop up. This code tries to ensure that the keyboard
doesn't cover the entry field that the user was trying to work on.

In order to centralize these changes, this introduces a new
SsrfTextField type which we use to also remove a few redundant default
settings that we previously had for every field. The one TextArea for
the Notes field didn't seem worth creating yet another type for, so
there the changes are done directly in DiveDetailsEdit.

The awkward timer mechanism is necessary as the keyboard pops up
asynchronously and then triggers a change of height for the app, so we
need to wait a little bit before doing the adjustment.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-14 13:39:45 -07:00
Dirk Hohndel
85d810119b Mobile: pick icons depending on theme
QML has ways to style icons - and we use that for the main theme color,
but it doesn't seem to work (anymore?) for the edit and save icons.
Instead of tracking down what changed there, simply switch between icons
with different foreground color, depending on theme.

All the other icons seem to work well in all three themes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-14 13:39:45 -07:00
Dirk Hohndel
5f11c94f02 Mobile: improve helper function to track selected dives
While on mobile there should always be only one selected dive, it's very
cheap to make sure that amount_selected is tracked correctly.  The
incrementing of amount_selected is done in case an invalid id is passed
in.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
fe56fa587a Mobile: bring back the adaptive size for the tool bar
When switching to the global tool bar this was lost, and then it turned
out to be broken and required more patches to fix.

Commented out because it doesn't work at all.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
56713842b9 Mobile: ensure consistent path when accessing arrow icons
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
e3eaf03d2f Mobile: implement our own back entry for GlobalDrawer
This way we'll get a working back icon on Android and also correct font
size for the (translated) Back text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
fda10b8baa Mobile: update the map when the selected dive changes
Now we see the highlighted dive flag match the dive selected in the dive
list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
9a73be9207 Mobile: add helper function to keep selection in sync
Without this the core data structure never gets updated to reflect which
dive is currently selected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
2f0689d3b8 Mobile: move pageIndex function to main.qml
This way it can be more easily called from other pages.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
2ef401ef5f Mobile: when selecting dive via map, expand its trip
Previously if the dive was in a different trip, we'd scroll to that trip
but not expand the trip, which was a confusing user experience.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
6422079de5 Mobile: when selecting dive via map, update details view
We updated the selected dive in the dive list, but not the one shown in
the details view.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
b07a1cc8b6 Mobile: when switching to the details, reuse existing page
While pageStack.push() can handle pushing a page that's already there,
that creates an unfortunate sequence of currentItemChanged signal which
leads us to do the wrong thing with our map hack.

This commit changes things around to first look for the page in the page
stack and just switch to it, and only pushing the page as new if it
cannoot be found oon the page stack.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
d8cc8732bd Mobile: use tri-state variable to improve the map hack
QML enums are a bit painful to use, so this uses poor man's emums
instead.

Basically what this changes is that a forced switch to the map doesn't
count as picking the map. That seems obviously correct, as otherwise you
could end up in a situation where a legitimate switch away from the map
is ignored.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
4e4fcda91c Mobile: insane hack to make map page work
This makes no sense and seems crazy. But it also seems to work,

For some reason with the current Kirigami version and Qt 5.13.1
selecting the map page makes the pageStack jump back to the previous
page right away. I cannot find what triggers this behavior.
Since I cannot fix the root cause, I am working around the bug. When we
select the map page we remember that fact and when a different page is
picked with the mapPage being the last page on the stack, we force the
page selection back to the map page. I can imagine countless ways in
which this could go horribly wrong - but right now I can't figure out a
better solution.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
8cd1abb7f7 Mobile: keep existing page stack when showing map
There doesn't appear to be a reason to pop all of the existing pages from the stack.
Just on principle, only close the drawer if it was open.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
a200ac0982 Mobile: need to recalculate column width when rotating
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
5025943bc4 Mobile: don't make sub-pages fill the parent
This had very strange results with the current Kirigami.
Instead set the width of those pages based on our overall column width.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
b9861a0059 Mobile: change handling of columns and column width
The old calculation was clearly bogus, we'd also get zero columns here.
Instead do a correct calculation of the number of columns and make the
resulting column width a property of the rootItem so we can refer to it
elsewhere.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
e047e97190 Mobile: ApplicationHeader is now deprecated
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Dirk Hohndel
57d50d0101 Mobile: show the undo for delete for 5 seconds
Before that it was 3 seconds that was a little too short for peopl to
be happy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-13 11:32:27 -07:00
Paul Buxton
65ec16e59d Fix text in darkmode on mobile app.
Signed-off-by: Paul Buxton <paulbuxton.mail@googlemail.com>
2019-10-06 11:39:46 -07:00
Berthold Stoeger
3db50aedea Cleanup: Turn DiveListSortModel into classical singleton
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>
2019-10-04 09:19:10 -07:00
Dirk Hohndel
e7e21aec6b Mobile: fix reloading dive list after download
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>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
1c24ac1a94 Mobile: don't allow width change without rotation
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>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
cd98cb8921 Mobile: add more debugging output for screen width issue
Somehow we need to be able to figure out which width information is
correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
c90050f449 Mobile: recalculate base units only for first real change
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>
2019-10-02 08:04:49 -07:00
Dirk Hohndel
d635d5de1f Mobile: only print debug output if there's information
On many devices the Screen property doesn't give us a manufacturer,
model, or name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-02 08:04:49 -07:00
Berthold Stoeger
ad7ffa0af0 Import: Make DownloadThread a subobject of DiveImportedModel
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>
2019-10-02 08:04:49 -07:00
Berthold Stoeger
eecca6aab0 Mobile: replace model-reset by row-addition in DiveListModel::reload()
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>
2019-09-27 16:33:37 -07:00
Berthold Stoeger
649ac1f83a Mobile: clear dive data via model
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>
2019-09-27 16:33:37 -07:00
Berthold Stoeger
f0fc1f3a56 Mobile: Don't access dive-id via DiveObjectHelper
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>
2019-09-27 16:33:37 -07:00
Dirk Hohndel
9ae7040a91 Revert the singleton PR
It turns out that this isn't working the way it was intended to.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-27 16:26:58 -07:00
Berthold Stoeger
4d3686edec Cleanup: Pass gpsTrackers directly to GpsListModel::update()
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>
2019-09-25 13:35:30 -07:00
Berthold Stoeger
05200f9266 Cleanup: unify idiosyncratic singletons
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>
2019-09-25 13:35:30 -07:00
Dirk Hohndel
b2230855e6 Mobile: make sure QML gets notified when value changes
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>
2019-09-21 16:31:27 -07:00
Dirk Hohndel
71a75bfda5 Mobile: more space around menu button on Download page
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>
2019-09-21 16:30:12 -07:00
Berthold Stoeger
9322c54b6a Mobile: pass section directly to tripTitle() and tripShortDate()
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>
2019-09-21 16:12:23 -07:00
Dirk Hohndel
cefebc17bd Mobile: don't show filter button when entering credentials
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
cf4dbbe5f2 Android: print Android HW information
This uses Android methods through JNI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
e68d287c91 Mobile: print out Qt information on the system we are running on
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
7c3b8f32db Mobile: dump the information QML has about the screen
Maybe this will allow us to customize things for certain devices?

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
dab2613791 Mobile: correct font size of 'Previously used DC' label
This appears to be the one label where we didn't set the
correct font size based on the global scaling.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
8c0af2b147 Mobile: recalculate gridUnit and font size if width changes
This could happen when you rotate a mobile device, or when running
Subsurface-mobile on the desktop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Dirk Hohndel
54f48f0b37 Mobile: move gridUnit and font adjustment to function
This way we can call it in other situations when needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-21 15:13:10 -07:00
Berthold Stoeger
e780b0a96c Mobile: don't generate numerous DiveObjectHelpers in startEditMode()
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
6a9df3bba3 Mobile: transform DiveObjectHelper into value-type
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
a4f3580e10 Mobile: remove dive argument from DiveListModel::insertDive()
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
feb11f6f5f Mobile: use value semantics for DiveObjectHelper in qmlmanager.cpp
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
0026aa3955 Mobile: replace clear()/addAllDives() pairs by reload()
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
a79c45e401 Mobile: return depthDuration directly from DiveListModel
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
c4831d7ace Mobile: return location directly from DiveListModel
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
4b389e267d Mobile: return dive-number directly from DiveListModel
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
bf081866e9 Mobile: return dive-id directly from DiveListModel
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
c6b3309d13 Mobile: return dateTime directly from DiveListModel
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
54720e6cff Mobile: move tripNrDive from DiveObjectHelper to DiveListModel
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>
2019-09-14 13:20:59 +02:00
Berthold Stoeger
1b9581369a Mobile: move tripId from DiveObjectHelper to DiveListModel
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>
2019-09-14 13:20:59 +02:00
Dirk Hohndel
b1ba687a1d Mobile: deal better with incorrect credentials
This could happen if the password was changed from a different Subsurface instance.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
f6f6a20555 Mobile: check if credentials are valid before accepting them
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>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
d717b9d2a7 Mobile: add helper function to check cloud credentials
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>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
6ab4105211 Mobile: adjust grid unit on very narrow screens
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>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
00e673230a Mobile: reserve space for the hamburger menu on Download page
Having a label with no width that can expand wasn't really a great way
to do so.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-11 21:50:41 +01:00
Dirk Hohndel
0eb14828b5 Mobile: use a default weight name when adding weight system
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
6b92edc9ab Mobile: support editing of dives with no weightsystem
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>
2019-08-11 12:23:33 -07:00
Berthold Stoeger
f3acb0ca02 Mobile: catch null references in DownloadDCThread
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>
2019-08-10 09:58:19 -07:00
Berthold Stoeger
0cce3ef2a8 Mobile: update dive site model if dive sites are created
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>
2019-08-10 09:55:11 -07:00
Berthold Stoeger
5da09a21bb Cleanup: move error reporting function declarations to errorhelper.h
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>
2019-08-08 16:26:30 -07:00
Berthold Stoeger
a5e7f4253a Core: dynamically resize weight table
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>
2019-07-18 06:01:07 -07:00
Berthold Stoeger
7f4d9db962 Cleanup: move trip-related functions into own translation unit
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>
2019-06-19 13:11:10 -07:00
Dirk Hohndel
144de49ad4 Mobile: add checkbox to force downloading all dives
This has been a feature people have asked for quite frequently. It is
taking up some valuable screen real estate - so the question could
become if there should be a switch to enable / disable it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-05-11 11:40:07 -07:00
Linus Torvalds
263c87b1cc Update (and fix) device mobile ID's for Scubapro dive computers
I'm not sure this is actually relevant for anything any more, but this
adds the USB device ID's for the Scubapro G2 Console and HUD versions.
It also fixes things to use the proper vendor name (a bit too much
cut-and-paste, where the code said "Suunto" instead of "Scubapro").

The real device ID changes are in libdivecomputer, this is just the
Android xml list for recognized USB devices that likely nobody really
uses.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-04-25 13:22:21 +02:00
Berthold Stoeger
e99c4c9059 Dive site: introduce proxy model DiveSiteSortedModel
The LocationInformationModel used to sort its entries and was completely
rebuilt after every change. This makes it rather complex to support
incremental changes.

Instead, keep LocationInformationModel sorted by UUID so that indexes
are consistent with indices in the core dive site table.

Implement sorting by other columns than name and enable sorting in the
dive site view.

Finally, don't cache the list of dive site names for the mobile app,
since that would also need some rather convoluted methods of keeping
the list up to date. Calculate it on the fly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
e2df38d868 Dive site: add dive site ref-counting
Instead of setting dive->dive_site directly, call the
add_dive_to_dive_site() and unregister_dive_from_dive_site()
functions. In the parser this turned out to be a bit tricky.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f3e1187e65 Cleanup: move parse-function declarations out of "dive.h"
Move the declaration of these functions to "file.h" and "parse.h"
according to the translation unit they are defined in. Thus, not
all users of "dive.h" have to suck in "sqlite3.h".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
31291b1c56 Dive site: set UUID only on save or load
Since the UUID will be overwritten on save and is only used on save
and load, set it only on save or load. For other created dive sites,
leave the UUID field uninitialized.

This means that the UUID will change between saves. Let's see how
the git saver handles that.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
82af1b2377 Undo: make undo-system dive site-aware
As opposed to dive trips, dive sites were always directly added
to the global table, even on import. Instead, parse the divesites
into a distinct table and merge them on import.

Currently, this does not do any merging of dive sites, i.e. dive
sites are considered as either equal or different. Nevertheless,
merging of data should be rather easy to implement and simply
follow the code of the dive merging.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
37146c5742 Parser: parse into custom dive site table
To extend the undo system to dive sites, the importers and downloaders
must not parse directly into the global dive site table. Instead,
pass a dive_site_table argument to parse into.

For now, always pass the global dive_site_table so that this commit
should not cause any functional change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
f6e7bdc5ef Dive site: add dive site table parameter to dive site functions
To enable undo of dive site functions, it is crucial to work
with different dive site tables. Therefore add a dive site table
parameter to dive site functions. For now, always pass the global
dive site table. Thus, this commit shouldn't alter any functionality.

After this change, a simple search for dive_site_table reveals all
places where the global dive site table is accessed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12 18:19:07 +03:00
Rolf Eike Beer
c4c8094e32 get rid of some foreach and Q_FOREACH constructs
See https://www.kdab.com/goodbye-q_foreach/

This is reduced to the places where the container is const or can be made const
without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7)
and std::as_const (C++17) are not available in all supported setups.

Also do some minor cleanups along the way.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Berthold Stoeger
40a3e562b0 Cleanup: provide printGPSCoords in C and C++ versions
printGPSCoords() returned a newly allocated C-style string. Most
callers simply made a QString out of it and freed the C-style string.
This is paradoxical, as printGPSCoords internally works with QStrings
and converts them to C-style on return.

Therefore, let printGPSCoords() return a QString and create a
printGPSCoordsC() wrapper for the two C-callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-27 13:58:15 +01:00
Berthold Stoeger
04593e8ec4 Cleanup: fix printGPSCoords signature and leaks
The printGPSCoords() function returns a copied C-style string. Since
the owndership is transferred to the caller, the correct return type
is "char *" instead of "const char *".

Thus a number of casts when calling free can be removed.

Moreover a number of callers didn't free the string and thus were
leaking memory. Fix them. Ultimately we might want two versions
of the function: one for QString, one for C-style strings.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-24 21:57:13 -07:00
Dirk Hohndel
9d582c5512 Mobile: only show dive computers in the Bluetooth connection list
And offer an option to show all devices in the settings. This is intentionally
not stored in the preferences as this should never be needed. We don't support
BT or BLE dive computers that we don't recognize. This is a last resort in case
a new firmware were to change the name or some other weird issue causes us not
to recognize a dive computer - and that should be fixed instead of worked
around.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14 09:05:58 -08:00
Berthold Stoeger
891fcbf520 Import: control process_imported_dives() by flags
process_imported_dives() takes four boolean parameters. Replace these
by flags. This makes the function calls much more descriptive. Morover,
it becomes easier to add or remove flags.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
ff9506b21b Import: don't add to new trip while downloading
Since process_imported_dives() can add dives to a newly generated
trip, this need not be done in the downloading code. This makes
data flow distinctly simpler, as no trip table and no add-new-trip
flag has to be passed down to the libdivecomputer glue code.

Moreover, since now the trip creation is done at the import step
rather than the download step, the latest status of the "add to
new trip" checkbox will be considered.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
1cd0863cca Import: add add_to_new_trip flag to process_imported_dives()
If this flag is set, dives that are not assigned to a trip will
be assigned to a new trip. This flag is set if the user checked
"add to new trip" in the download dialog of the desktop version.

Currently this is a no-op as the dives will already have been
added to a new trip by the downloading code. This will be removed
in a subsequent commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-19 13:48:17 -08:00
Berthold Stoeger
0249e12589 Import: split process_imported_dives() function
Split the process_imported_dives() function in two:
1) process_imported_dives() processes the dives and generates
   a list of dives and trips to be added and removed.
2) add_imported_dives() calls process_imported_dives() and
   does the actual removal / addition of dives and trips.

The goal is to split preparation and actual work, to
make dive import undo-able.

The code adds extra checks to never merge into the same
dive twice, as this would lead to a double-free() bug.
This should in principle never happen, as dives that
compare equal according to is_same_dive() are merged
in the imported-dives list, but perhaps in some pathologival
corner-cases is_same_dive() turns out to be non-transitive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
0dfc59f38c Import: add merge_all_trips parameter to process_imported_dives()
When importing log-files we generally want to merge trips. But
when downloading and the user chose "generate new trip", that
new trip should not be merged into existing trips.

Therefore, add a "merge_all_trips" parameter to process_imported_dives().
If false only autogenerated trips [via autogroup] will be merged.
In the future we might want to let the user choose if trips
should be merged when importing log-files.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
1593f2ebad Import: merge dives trip-wise
The old way of merging log-files was not well defined: Trips
were recognized as the same if and only if the first dives
started at the same instant. Later dives did not matter.

Change this to merge dives if they are overlapping.
Moreover, on parsing and download generate trips in a separate
trip-table.

This will be fundamental for undo of dive-import: Firstly, we
don't want to mix trips of imported and not-yet imported dives.
Secondly, by merging trip-wise, we can autogroup the dives
in the import-data to trips and merge these at once. This will
simplify the code to decide to which trip dives should be
autogrouped.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
f542dc4030 Import: add trip_table argument to DiveImportedModel::repopulate()
In the future we want to download trips into a distinct trip-table
instead of the global trip-table to allow for undo of import.

Therefore add a trip_table argument to DiveImportedModel::repopulate()
and a trip_table member to DiveImportedModel. To correctly set these,
add a DownloadThread::trips() function, which currently simply returns
the global trip table.

Finally, make "struct trip_table *" a Q_METATYPE, so that the corresponding
arguments can be passed from QML.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
7e33369dc8 Parser: add trip_table parameter to parsing functions
To allow parsing into arbitrary trip_tables, add the corresponding
parameter to the parsing functions and the parser state. Currently,
all callers pass the global trip_table so there should be no change
in functionality. These arguments will be replaced in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
ec37c71f5e Core: add trip_table parameter to trip-functions
Currently trips are added to the global trip table. If we want to
make dive-import undoable, we should be able to parse trips of a
log-file into a distinct table. Therefore, add a trip_table
parameter to
	- insert_trip()
	- create_and_hookup_trip_from_dive()
	- autogroup_dives()
	- unregister_trip()
	- remove_dive_from_trip()

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
517fb7a462 Core: keep trips in table(s)
Currently, all trips are kept in a linked list. Replace the list
by a table in analogy to dive_table. Use this to keep the trip_table
sorted as suggested by dump_trip_list(). When inserting a trip into
the table do that after adding the dives, to avoid warnings coming
out of dump_trip_list().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Berthold Stoeger
d1971a64f9 Core: Rename functions to more generic names
Rename
 - dive_get_insertion_index() -> dive_table_get_insertion_index()
 - unregister_dive_from_table() -> remove_from_dive_table()
 - get_idx_in_table() -> get_idx_in_dive_table()
 - sort_table() -> sort_dive_table()
This will make it more straight-forward to generate these functions
from macros.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-01-09 20:58:04 -08:00
Lubomir I. Ivanov
0903bef9db update year to 2019 in about screens
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2019-01-02 09:45:01 -08:00
Berthold Stoeger
691d44dfd1 Mobile: fix editing dive site
Commit 68961a169e made it impossible
to edit a dive site on mobile if a dive-site was already set: If
divesite was non-null, no actions were taken. Remove the conditional.

Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-29 16:19:56 -08:00
Dirk Hohndel
c38215dfa7 Mobile: deal with BT name and address when tapping Download
Instead of trying to update this whenever the connection text changes,
instead deal with it right before it actually gets used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 14:53:45 -08:00
Dirk Hohndel
ef8656998a Mobile: add helper function to fill in the BT name
For some devices the BT device name is different from the product name.
Make sure that name is available to the mobile UI. This helper fills it
in from the scan data (based on the device address).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 14:52:02 -08:00
Miika Turkia
10a0393b1b Mobile: force update of ui on paste
Apparently this does the trick of updating the dive list when pasting
data on mobile. Tnx janmulder.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
3f8583de36 Mobile: initialize copy variables
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
53ba950c8f Mobile: copy the dive data when configuring settings
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Miika Turkia
8e7a9a4f4c Mobile: UI for selecting what to copy-paste
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-12-21 09:13:37 +02:00
Berthold Stoeger
bfe69239df Import: unglobalize downloadTable
To make data flow more clear, unglobalize the downloadTable object.
Make it a subobject of DownloadThread. The difficult part was making
this compatible with QML, because somehow the pointer to the
download-table has to be passed to the DiveImportedModel. Desktop would
simply pass it to the constructor. But with objects generated in QML
this is not possible. Instead, pass the table in the repopulate()
function. This seems to make sense, but for this to work, we have to
declare pointer-to-dive-table as a Q_METATYPE. And this only works
if we use a typedef, because MOC removes the "struct" from "struct
dive_table". This leads to compilation errors, because dive_table is
the symbol-name of the global dive table! Sigh.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
abf942f303 Cleanup: make DCDeviceData a "normal" singleton
DCDeviceData was using that weird pattern where the instance
variable was set in the constructor. There is no apparent
reason to do so, therefore convert to a "normal" singleton.

Access that directly in QMLManager instead of saving it in
a member variable first.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-12-17 07:37:32 -08:00
Berthold Stoeger
68414531ad Mobile: don't format trip heading for all dives
QML's ListView uses the "section" property to test if items belong to the
same section. Apparently, this must be a string and therefore we can't
pass e.g. a dive-trip object. Therefore a specially formatted string
was passed in, which was guaranteed to be unique (contained the dive-trip
pointer value) and the fully formatted trip-title and short-date.

The disadvantage of that approach is that the formatting is performed for
every dive and not every trip. Perhaps not a problem now, but it makes
it for example necessary to cache the number of filtered dives.

To be more flexible, pass in only the pointer value formatted as
hexadecimal string and provide a function to convert that string
back to a trip-pointer (in the form of a QVariant, so that it can
be passed to QML). Moreover provide two functions for formatting the
title and the short-date.

The three new functions are members of DiveListSortModel. This might not
be the perfect place, but it is easy to reach from the DiveListView.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-23 13:22:24 -08:00
Berthold Stoeger
6bf4120dbb Core: replace tripflag by notrip boolean
The only remaining use of the tripflag was to mark dives that
were removed explicitly from a trip, i.e. shouldn't be autogrouped.
Therefore replace the enum by a simple boolean.

Currently, there is no way of unsetting the notrip flag. But this
shouldn't result in a user-visible change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-20 08:14:54 -08:00
Berthold Stoeger
6b283e598a Dive list: replace dive-list of trips by a table
The dives of each trip were kept in a list. Replace this by a
struct dive_table. This will make it significantly easier to
keep the dives of a trip in sorted state.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-18 16:50:09 -08:00
Berthold Stoeger
0618aa737f Core: unify insert_trip() and insert_trip_dont_merge()
There were two versions of the insert_trip() function: one
would merge trips if a trip with the same date already existed,
the other wouldn't. The latter was introduced with the dive-list
undo work.

The problem is that the "date" of a trip (i.e. the first dive)
seems ill-defined as this is a volatile value. Moreover in
the context of making dive-import undoable this is a very
dangerous notion, as the caller needs control over when the dives
are added to a trip.

Therefore, unify these two functions and never merge trips.
The decision on merging dives now has to made by the caller.
This will be implemented in a future commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-11-18 16:50:09 -08:00
Miika Turkia
b609b06b11 Mobile: visual indication for copy and paste operations
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18 06:33:27 +08:00
Miika Turkia
577e295d2f Mark cache invalid to get data saved
Seems that we need to invalidate the cache to get the modifications
actually saved.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18 06:31:44 +08:00
Miika Turkia
88d5eccb17 delete-copy-paste buttons layed out properly
Now these buttons are finally shown with long press and seem to be
working more-or-less as intended.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18 06:31:44 +08:00
Miika Turkia
37e7602a1e Verify that copy is done
Naturally the paste button should be disabled, if this is the case, but
it still makes sense to do this check.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18 06:31:44 +08:00
Miika Turkia
76a68f71a4 Support for copy-pasting specific fields on mobile
Initial implementation/prototype of copy-paste support for
Subsurface-mobile. The UI part is really lacking; right now the copy
button is initially visible and paste is achieved by long press on a
dive and clicking the paste button when it appears. Delete is currently
not possible at all, as I just failed to layout the buttons properly
using QML. It just sounds so simple, to put all the copy-paste-delete
buttons next to each other...

The data to be copied is currently hard-coded. A dialog to choose
inteded fields would be nice, but it'll take quite a bit effort to get
used to QML enough to be able to hack something together.

Anyway, this seems to work, even though the UI is not always reflecting
the paste without switching dives (when testing on laptop).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-11-18 06:31:44 +08:00
Jocke
03143f1ef1 Mobile: Allow multiple divemasters
While not something that many will use, editing a dive on
Subsurface-mobile should not result in data loss.
This makes the divemaster field behave in the same way as the buddy
field with regards to multiple entries.

Fixes #1853

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-11-15 18:10:13 +08:00
Dirk Hohndel
4636fcc834 Mobile/filtering: don't show the filter line when pulling divelist down
Even though the height was zero, when pulling down the dive list for refresh,
the filter input line would still be visible. With this fix it no longer is.

Also remove unused property.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-31 14:34:43 -07:00
Berthold Stoeger
724055f0af Dive site: replace dive->dive_site_uuid by dive_site
Replace the UUID reference of struct dive by a pointer to dive_site.
This commit is rather large in lines, but nevertheless quite simple
since most of the UUID->pointer work was done in previous commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Berthold Stoeger
75b5d61522 Dive site: replace UUID by pointer in mobile code
Replace UUIDs by pointers to dive-site in mobile code. In both
cases, the value is transported via a QVariant. The function
getCoordinatesForUUID(), which was only used from mobile, can
be replaced by a getCoordinatesFor() function taking a variant
supposed to contain a dive-site pointer. Likewise, the variant
of the centerOnDiveSite function is now supposed to wrap a
pointer-to-divesite.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Berthold Stoeger
d3a7c5448f Dive site: return pointer to dive_site in create_dive_site_*()
This changes more of the dive-site interface to return pointers
instead of UUIDs. Currently, most call sites directly extract
UUIDs afterwards. Ultimately, the UUIDs will be generally replaced
by pointers, which will then simplify these callers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Berthold Stoeger
68961a169e Dive site: return pointer to dive_site in get_dive_site_*()
As a first step in removing dive-site uuids, change the interface
of the get_dive_site_*() functions to return pointers instead
of uuids. This makes code a bit more complicated in places where
the uuid is extracted afterwards (needed NULL check). Nevertheless,
these places should disappear once pointers instead of uuids are
stored in the dive-structures.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Dirk Hohndel
01cd2e224f QML UI: we don't need Controls 2.4
In commit 99c06dec3d ("Mobile/filtering: simple busy indicator") we switched to
Controls 2.4 which requires Qt 5.11. Revert that one line of the commit as it
isn't necessary.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-27 07:17:51 -07:00
Dirk Hohndel
e0e3b63601 Mobile/filtering: make busy indicator smaller
Suggested-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
3eabb80398 Mobile/filtering: update number of dives shown when resetting filter
Otherwise we start showing an illogical '0' there when first opening the filter
dialog, and the equally wrong previous count when closing and then re-opening
the filter dialog.

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
51e7603d7e QML UI: remove some of the log file noise
A couple came from this series, others are much older.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
1e6c5d002b Mobile/filtering: show a better message while waiting for the filter
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
cf3fcc53b6 Mobile/filtering: implement the filter update through a thread
It's important to disconnect the model from the ListView, otherwise the update in a
different thread will fail.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
84822ebd2f Mobile/filtering: remove redundant busy indicator on dive list
We should use the global one instead.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
b0a0e1e374 Mobile/filtering: simplify the filter toggle
Simply make it always reset the filter. There's no point remembering the last
filter pattern and explicitly setting it, if the last thing we do is to reset
this pattern.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
466a0bf758 Mobile/filtering: update filter in separate thread
We can't use that while the model is shown, which is why this isn't hooked up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
2183e41bb0 Mobile/filtering: add properties for dive list model and filter text
This allows us to modify those from different parts of the code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
09507416c8 QML UI: add busy indicator to the main window
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
8d01d421d4 QML UI: make the QML window object part of the QMLManager class
This way we can access it from that code (which we'll need to invoke methods in QML code
from C++).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
6d77e66b69 Mobile/filtering: clean up whitespace from last commit
This one does nothing but whitespace - separating it into two commits makes the
previous one a lot easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
00a80c0e08 Mobile/filtering: add background rectangle for filter row
We are still trying to ensure that the filter is indeed shown in front of the
dive list. This is working when running on the desktop without the rectangle,
but on Android this appears to be needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
76e4826fbc Mobile/filtering: simplify transitions
We don't need to toggle visibility, toggling height is sufficient. This
dramatically simplifies the transitions.  But as a result we need to use the
'enabled' property to reset the filter.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
e4e0c608e1 Mobile/filtering: simple busy indicator
Filtering takes a noticeable time on mobile, so lets show the user we are doing
something.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
c0540d7682 Mobile/filtering: add Settings options for filtering
Toggle case sensitive and whether or not to include the notes in full text search.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
2caaf8889b Mobile/filtering: make sure the header is top-most element
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
97e6494eee Mobile/filtering: ensure filter input field has focus when shown
QML's logic for who gets focus is a bit complicated. But forceActiveFocus()
cuts through the confusion and makes sure that your field does indeed get
focus.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
fd31dfe40d Mobile/filtering: use margins instead of rectangles to create space
I'm not sure why this had initially failed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
c797038bd8 Mobile/filtering: only filter when editing is finished
This is a usability / performance tradeoff. I like it better when it filters as
I type, but on mobile this may make things feel sluggish.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
f965492241 Mobile/filtering: reset the filter text when toggled
This seemed less UI clutter than adding a clear button.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:30 +01:00
Dirk Hohndel
cadb072a0c Mobile/filtering: improve code readability
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
e5ee895793 Mobile/filtering: animate the filter header
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
90d321f0ff Mobile/filtering: add count of filtered dives to search bar
The count in the trip headers is still that for the complete trip and therefore
misleading.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Dirk Hohndel
65aa6bc43b Mobile/filtering: make the search box an overlay
This way it stays at the top of the dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Jan Mulder
0bc0b6bfe8 Mobile/filtering: first attempt to filter on dive site
[Dirk Hohndel: this is the starting point of my following commits, I decided to
	       leave it in place to give Jan credit for the work he did on
               figuring out some of the plumbing needed to get things to work]

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Jan Mulder
f1bb2c8478 Mobile/filtering: add icons for filter and sort
Add 2 icons for filter and sort capabilities. And as before, these
icons are coming from the Google Material design set.

[Dirk Hohndel: Jan's commit forgot to add the actual icons, I added
               those so the commit matched its message]

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-23 22:45:29 +01:00
Jocke
9c6d24e50e Mobile UI: make SsrfSwitch resizable
Back in 8ab8a67f the checkbox where made resizable.
This applies the same functionality to the selector switch and makes the
two objects match in vertical size.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-21 14:43:41 -04:00
Linus Torvalds
28e3413ff6 Add 'location_t' data structure
Instead of having people treat latitude and longitude as separate
things, just add a 'location_t' data structure that contains both.

Almost all cases want to always act on them together.

This is really just prep-work for adding a few more locations that we
track: I want to add a entry/exit location to each dive (independent of
the dive site) because of how the Garmin Descent gives us the
information (and hopefully, some day, other dive computers too).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-21 19:55:09 +03:00
Jan Mulder
4263d1c3f5 QML, cleanup: remove stackView
There is no reason (any more?) to have a property defined
that basically renames the global pageStack into a local
pageView. Just cleanup.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-12 08:22:26 -07:00
Berthold Stoeger
f427226b3b Undo: make diverse trip-related operations undo-able
AddDivesToTrip, CreateTrip, AutogroupDives, RemoveAutogenTrips
and MergeTrips basically all did the same thing as RemoveDivesFromTrip,
which was already implemented. Thus, factor our the common functionality
and hook it up to make all these functions undo-able.

Don't do the autogroup-call everytime the dive-list is rebuilt
(that would create innumberable undo-actions), but only on dive-load /
import or if expressly asked by the user [by switching the autogroup
flag].

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:22:27 -07:00
Jan Mulder
8074f12b91 QML UI: disable rescan when no bluetooth
This is cosmetic only. It make no sense to selected rescan when
Bluetooth is off.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-10 06:27:21 -07:00
Jan Mulder
8034af5ad5 QML UI: do not try to download from DC with empty vendor/product
Disable the Download button when one of the fields vendor, product,
connection is not filled in. The app will crash when trying.
In addition, make the underlying core code to actual download
more safe by checking this, and silently fail instead of crash.
And, yes, this is a double fix in this scenario, but the core code
is used in more places, so better safe than sorry.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-10 06:27:21 -07:00
Jocke
8686b53c37 Mobile/DC download: reset the "Download" button
When changing to another DC, reset the "Download" button text.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09 21:04:23 -07:00
Jocke
3ce019cf1a Mobile/rememberDCs: remove duplicated code
The code to disable a quick button has moved to the DC matching logic,
in order to inactivate the correct button also for USB DCs.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09 21:04:23 -07:00
Jocke
e7fd50113f Mobile/rememberDC: update matching logic
Update the matching logic to account for known and unknown BT DCs.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09 21:04:23 -07:00
Jan Mulder
a95e658946 Mobile: factor out syncToCloud [3/3]
After the previous commits, we now have a preference that nicely
preserves the state of the UI, and we have the well known git_local_only
global, that is used to denote whether we want to use to local repo
only, or we want to interact with the online cloud as well.

This commit gets rid of the now superfluous syncToCloud logic. Instead
we simply set the git_local_only directly.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-09 10:03:21 -07:00
Jan Mulder
87b8155576 Mobile: preserve auto download status [2/3]
Hook up the new preference to the UI. So now, an earlier choice
if automatic or manual download to the cloud is preserved in
between sessions. Strictly speaking this fixes issue 1725.

Notice that there is also a higly related syncToCloud thing
present. As factoring out that seemingly duplicate piece
of code is non-trivial, this will be done in a seperate
commit.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-09 10:03:21 -07:00
Jan Mulder
26234d326f Mobile: no switch to auto cloud in no-cloud mode
We disabled the drawer menu button to switch between auto/manual
sync when in no cloud mode. Unfortunately, disabeling does not
give a visual cue to the user (like greyed out). Instead, just
make this button invisable in no cloud mode.

In conjunction a question. The manual sync to cloud menu item
takes you to the Cloud Credetials page in case pressed in
no cloud mode. While valid, this seems strange. This is not
changed in this commit.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-09 10:03:21 -07:00
Jan Mulder
315a3335c2 Mobile: mark divelist changed on no-cloud to cloud account
This simple one-liner fixes an actual bug. On switching from
a no-cloud account to a actual cloud account, the dives from
the no-cloud are added to the actual cloud account. And indeed
the dives appear correctly. However, when exiting the app
right away, these added dives are not commited to the local
storage. Simply, the divelist needs to be marked dirty.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-09 10:03:21 -07:00
Jan Mulder
68fdc0b6f4 QML UI: set proper active background color for downloaded dives
And another simple one. Make the active background of the
dowloaded dives follow the theme.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-07 17:43:34 +03:00
Jan Mulder
3c18618bfb QML UI, trivial: set proper background color GPS list
The background color was plain white, where we use a slightly different
color in other places.  In addition, the background when clicking on a row
did not follow the theme setting. Consistency fix.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-07 17:43:34 +03:00
Jan Mulder
a8f45406bd QML UI, consistency: add text attribute for all actions
Something I only see on mobile-on-desktop, so at this point in time
not very relevant to the device apps. When hovering on the action
button, a toast message shows a hint box. These where empty in some
cases. So, just give the actions a text attribute where it was
missing.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-07 17:43:34 +03:00
Jan Mulder
684e3eec6b QML UI, cleanup: remove usesless Item
Trivial cleanup. A QML Item is intendend for visual items, so embedding
a timer in it is plain useless.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-07 17:43:34 +03:00
Berthold Stoeger
6dc1dcaea5 Import: pass "downloaded" parameter to process_imported_dives()
process_imported_dives() is more efficient for downloaded than for
imported (from a file) dives, because it checks only the divecomputer
of the first dive.

This condition is checked via the "downloaded" flag of the first
dive. Instead, pass an argument to process_imported_dives().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-06 19:47:06 -07:00
Berthold Stoeger
ab14889563 Core: remove preexisting field from struct dive_table
Dives are now in all cases imported via distinct dive_tables.
Therefore the "preexisting" marker is useless. Remove.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-06 19:47:06 -07:00
Jan Mulder
42eae7e48b Mobile: simpify startup logic
When starting the mobile app, I noticed a short display of an empty
page with title "Cloud creditials" just before showing the
divelist. Simply a not nice visual effect.

This commit simplifies some logic and resolves this. As the code
in this part is fragile, this is tested for normal and clean
startup of the app, switching credentials, from no cloud to
valid account (which even nicely imports the no cloud dives:
this surprised me as I have never seen this working).

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-02 22:27:19 +02:00
Jocke
b29f6ef2c0 Mobile: remove all related data when forgetting DCs
We need to delete all related data when forgetting dive computers or we will
have an issue if we connect a DC from the same vendor but of a different model.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-02 18:40:47 +02:00
Jocke
c504c08097 Mobile download from DC: improve selection logic
Improve the logic when auto selecting a DC for download.
Some USB cables only supply vendor information  but we can select the correct
model if we have downloaded from it before.
For BT/BLE our discovery process adds the device name to the address, so we need to keep that in mind when we try to match against what we seen before.
When we have a positive match for a DC we have seen before we deactivate the
corresponding button of our saved DCs.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-01 06:32:41 -07:00
Jan Mulder
9b199602c6 Mobile QML UI: bump Kirigami imports to 2.4
Primarily for reasens of keeping up with upstream. And hopefully
bugfixes and added functionality.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-01 05:29:46 -07:00
Jan Mulder
e321d1563e QML UI: clip divedetails Listview
A technically trival commit, but one with long story. This commit
basically reverts dd1d90b529 (1.5 year ago). While upgrading
Kirigami after Kirigami commit 26b8bdea24c39, we suddenly have
overlapping divelist and details pages in case they are both
on the pageStack (this occurrs when navigating from divedetails
to the divelist using breadcrumb navigation). At this point, its
not clear (to me) if this the by design of Kirigami, or an unintended
effect of the mentioned Kirigami commit.

This all said. Simply clipping resolves our issue of overlapping
pages, and it does not harm.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-01 05:29:46 -07:00
Jan Mulder
bec029c766 QML UI: trivial resize of datebox
Something that I simply overlooked earlier with respect to scaling the
divelist. The trip databox did scale a bit, but it was not nicely
related to the hight of the trip header. So there was a tiny
overflow on the small scale on a small device. Fixed here.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-01 05:28:18 -07:00
Jan Mulder
c6a4250a58 QML UI: correct trip separator line
Partially cosmetic and partially a bug fix. 1) the seperator line
between trips and dives that are not in a trip was drawn in the
background color => the line was invisible. 2) When looking very
closely, there was a 1-2 pixel wide error between the seperator line
between trips and dives that are not in a trip. 3) there was a comment
that the trip separator needed to be extra thick. IMHO, this
looks ugly, and is superfluous as there is a nice sidebar along
the dives that belong to the trip. Finally, the line shall not
be displayed when not in a trip.

So, basically, the line (the QML rectangle) is completely rewritten,
to take care of all issues. There is 1 hack: the line color is
taken from the dive separator line. But its fully unclear to me
where that color is defined in Qt/QML or Kirigami, so I hardcoded
the proper color. That just works.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-30 08:16:52 -07:00
Jan Mulder
40a65a2e6b QML UI: center delete from divelist button
A small cosmetic change. The delete from divelist button was "glued"
to the top of the line. Not nice, so just center it vertically, and
make the button a tiny bit smaller, so that it fits nicely on the line.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-30 08:16:52 -07:00
Jan Mulder
751286e4e7 QML UI, cleanup: no reason for 2 overlapping mouseareas
Fully usure why the code was as it was. The trip header had 2
overlapping mouse areas, to expand the trip and vise versa. Simply
remove the smallest one.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-30 08:16:52 -07:00
Jan Mulder
bce952615c QML UI, cleanup: do not use iconSizes for unrelated sizing
A very unimportant change, but found when looking through the code
for places where size of icons where used. The one changed here
has nothing to do with icon related placement of a string, so
its replaced by a way more logical placement of the affected string.

Simply center the "no dives in the dive list" for an empty logbook
on the screen, instead of at some random place in the upper left
corner. Like I said: very unimportant, but it just looks nicer
in the UI.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-30 08:16:52 -07:00
Berthold Stoeger
fbc4b2ac72 Mobile: don't call clear_dive() on deleteDive
clear_dive() will be called anyway in the subsequent call to
copy_dive().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-29 14:02:07 -07:00
Jan Mulder
0ad7df9859 mobile, QML UI: Settings page scalability
A relatively big change for such a simple page. Most relevant
changes are:

1) Do not use Kirigami.Header anymore. It appears that this header
has word wrapping on (and we cannot override that). This is
annoying on this page, as headings seems randomly be split over
2 lines, even in cases where there is more than enhough room to
display it on one line. And as the Kirigami.Header is just a
trivial wrapper of a Text field, we can simple replace it.

2) A lot of the toplevel GridLayouts had width properties set. These
are not needed (and confused my debugging code), so they are removed
withput any visual change. As a general rule, do not try to set
properties that are not needed. In general, it can only lead to
binding loops or undefined behavior.

3) Add a font size to our Theme. The step from regular to title size
was a little too big.

4) And, obviously, numerous font.pointSize lines are added to actually
resize the font.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-27 06:36:22 -07:00
Jan Mulder
441e06cdb8 mobile, QML UI: whitespace in dive details page
There was a strange big margin at the top of the the dive details
page. Just make it a bit more "normal".

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-26 08:38:53 -07:00
Jan Mulder
97031da0d8 mobile, QML UI: margings and paddings in download screen
There was a significant of not needed whitespace on the download from
DC page. Most importantly, the bottom buttons where not on the bottom,
so we had to truncate the downloaded dives early (to prevent overflowing
the buttons). Further, a tiny bit of padding is removed between the
3 top pull down items.

All this, results in the diplay of more dives without scrolling.
For example, previously, only 1 dive (with 1 stored DC) was shown
on my 5.5" device, and now 3 (scale: regular).

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-26 08:38:53 -07:00
Jan Mulder
8ab8a67f81 mobile, QML UI: make SsrfCheckBox resizable
Changed some hard coded size and positioning of the SsrfCheckBox,
in such a way that is scales nicely to the current setting of the
mobile_scale.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-26 08:38:53 -07:00
Jan Mulder
7367d2535f mobile, QML UI: fix overlapping button
The select buttons in the downloaded dives delegate overlapped
the dive data. Simple margin change fixes this.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-26 08:38:53 -07:00
Jan Mulder
be1d3a7986 mobile, QML UI: ssrfButton and download controls resizable
Make the ssrfButton and the pull down menu's on the download page
resizable. Notice that also the contents of the pulldown
menu's is scaled based on the font size.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-26 08:38:53 -07:00
Berthold Stoeger
0aab39b35d Mobile: use editText instead of currentText in Suit and DiveMaster boxes
A user reported problems with editing the Suit and DiveMaster fields.
Apparently, editing does not change the currentText. Without doing
a deeper analysis, simply use editText (a more proper fix might be
changing the currentIndex on editing).

(Parially?) fixes #1694

Reported-by: Mark Powell <mcpowell123@gmail.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-25 09:27:16 -07:00
Jan Mulder
6850e6d567 mobile, QML: correct font scaling of the divelist
Changing the scale, it seems that the header of trips is not rescaled.
The reason for this is simple. That string does not use our manipulated
font but a different one. In fact, this is the only ocurrence on the
divelist that did not scale. However, other screens hardly rescaled at
all. All these will be fixed in seperate commits.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-25 16:01:39 +02:00
Jan Mulder
b332dd108a mobile, QML: scale font from the buttons
After the work in the previous commit, it gets very simple to implement
font scaling. Just assign a the new desired font scale to the used
font metrics. The QML engine does all the work.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-25 16:01:39 +02:00
Jan Mulder
c2c751c164 mobile, QML: introduce basePointSize in subsurfaceTheme
By manipulation the used font pointSize property, we can dynamically
scale fonts and derived UI objects. At the same time, we have
some logic to determine the default font, its size, etc, for example
depending on screen properties. The scaling of the UI (and its font)
does not need to interfere with those defaults.

However, when we want to reset the pointSize, we alter the default, so
a backup of the default is needed. Ok, not al full backup, as the only
thing we like to manipulate is the pointSize, to which we want to be
able to return.

All this leads to this commit. A basePointSize property is added, that
is initialized from the default. Due to the binding logic of the QML
engine, it is not a classic initialization, but a binding between the
2 properties. We need to break that binding explicitly, so that
the original PointSize is always preserved.

In addition, a display of the new font property is added to the
developers theme test.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-25 16:01:39 +02:00
Jan Mulder
a9c6b1472b mobile, QML: do not user a local font metric object
This theme test display created a new local FontMetrics object, that
does not per definition correspond with the "global" font metric
as defined in main.qml. The fix is simple. Display the font theme
data based on the one and only font metric from main.qml

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-25 16:01:39 +02:00
Dirk Hohndel
be0468b706 QML UI: add settings for scale factor
The visual feels backwards as the selected one is grayed out...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-25 15:58:17 +02:00
Dirk Hohndel
38307a5b3c QML UI: ensure we use the correct default font
It seems the documentation is incorrect - unless you explicitly set the
ApplicationWindow font to the the Application Font (just writing this
down sounds so silly...), it doesn't actually work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-25 15:58:17 +02:00
Jocke
c68ac31425 Mobile/download DC: disable selected DC button
Disable the button for the currently selected DC.
This gives an extra visual hint of which DC is currently selected.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-09-25 15:35:43 +02:00
Jocke
2d3777ce87 Mobile/settings: clear all of qPrefDiveComputer.vendor
To prevent stale data in the download DC path we need to clear the entire
 qPrefDiveComputer.vendor() object when the user purges the used DCs.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-09-25 15:35:25 +02:00
Jocke
3b8f36ff13 Mobile/Settings: Disable unusable option
Disable the "Forget DCs" button when there is no DCs saved. 

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-09-25 15:35:02 +02:00
Jocke
69cead138b Mobile/download DC: simplify startup
Since we now store the last used DCs in out preferences we can use the information
to pre-populate the DC selector.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-09-25 15:34:49 +02:00
Jocke
0a3130cd86 Mobile/downloadDC: always start with empty index
To prevent stale data being visible always set the combobox indexes to -1

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-09-25 15:34:36 +02:00