Commit graph

1466 commits

Author SHA1 Message Date
Berthold Stoeger
38a784f5af desktop: automatically reload completion-models
Instead of programatically reload the completion models, listen
to the relevant signals in the models. To that goal, derive all
the models from a base class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-14 10:01:50 -08:00
Dirk Hohndel
360123d432 mobile: add missing word to location warning
Thanks to Johan, one of our Swedish translators for noticing this
oversight.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-05 14:22:15 -08:00
Dirk Hohndel
1a0cf0bb44 cleanup: remove struct/class confusion
DiveSiteChange is defined as a struct, not as a class.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26 19:27:03 -07:00
Berthold Stoeger
2b86fe84f9 cleanup: move application flags to core/subsurfacehelper.h
These flags are not dive-related, therefore move their declaration
to the appropriate header file. Likewise, move their definition
from parse-xml.c to subsurfacehelper.c

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:52 -07:00
Berthold Stoeger
3358bff432 cleanup: move mark_divelist_changed() to qmlmanager.cpp
Desktop does not use mark_divelist_changed() anymore - all is done
via the undo machinery. Therefore move this function (and its
counterpart unsaved_changes()) to qmlmanager.cpp.

Ultimately, it probably should be removed from there as well, but
currently I don't dare to touch all the cloud-logic!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25 13:59:04 -07:00
Berthold Stoeger
255f561aff git: add device-table to git-parser-state
In analogy to the xml-parser add a device-table to git's parser-state.
Currently this is unused. In upcoming commits the git parser will
then be changed to add device nodes in this table instead of the
global device table. The long-term goal being to detach the
parsers from global state and to make dive-import fully undoable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:51:37 -07:00
Berthold Stoeger
39a4090c0a devices: add devices in Command::importTable()
Add a device_table parameters to Command::importTable() and
add_imported_dives(). The content of this table will be added
to the global device list (respectively removed on undo).

This is currently a no-op, as the parser doesn't yet fill
out the device table, but adds devices directly to the global
device table.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:51:37 -07:00
Berthold Stoeger
53118be1f9 devices: add functions to add / remove / check for devices
To include the device code in the undo system, we need functions
to check for the existence of devices and to add or remove them.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:51:37 -07:00
Berthold Stoeger
a261466594 parser: add device_table to parser state
If we want to avoid the parsers to directly modify global data,
we have to provide a device_table to parse into. This adds such
a state and the corresponding function parameters. However,
for now this is unused.

Adding new parameters is very painful and this commit shows that
we urgently need a "struct divelog" collecting all those tables!

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24 09:51:37 -07:00
Dirk Hohndel
28107efd30 mobile: show location service warning
Google play now requires that we show an explicit notification when turning
on background location. This is an attempt to fulfill that requirement - we
won't know if this is 'good enough' until we submit the app, though.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-24 09:47:37 -07:00
Dirk Hohndel
4638936a22 mobile: show text with location service icon
I don't recall why we removed that text, but this makes it much clearer
that the service is active.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-24 09:47:37 -07:00
Berthold Stoeger
a7bbb6c1cc filter: remove filter_preset_table_t
We used a typedef "filter_preset_table_t" for the filter preset table,
because it is a "std::vector<filter_preset>". However, that is in
contrast to all the other global tables (dives, trips, sites) that we
have.

Therefore, turn this into a standard struct, which simply inherits
from "std::vector<filter_preset>". Note that while inheriting from
std::vector<> is generally not recommended, it is not a problem
here, because we don't modify it in any shape or form.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17 09:04:20 -07:00
Dirk Hohndel
b3e28eed5d Update translations from Transifex
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-06 14:58:21 -07:00
Berthold Stoeger
1fcf4f891d filter: implement loading of filter presets from git repositories
This is mostly copy and paste of other git loading code. Sadly,
it adds a lot of state to the parser-state. I wish we could pass
different parser states to the parser_* functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
41cf83583d filter: load filter presets from XML files
This is a bit painful: since we don't want to modify the filter
presets when the user imports (as opposed to opens) a log,
we have to provide a table where the parser stores the presets.
Calling the parser is getting quite unwieldy, since many tables
are passed. We probably should introduce a structure representing
a full log-book at one point, which collects all the things that
are saved to the log.

Apart from that, this is simply the counterpart to saving to XML.
The interpretation of the string data is performed by core
functions, not the parser itself to avoid code duplication with
the git parser.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Berthold Stoeger
634e26cbce filter: unify desktop and mobile filters
Switch the mobile code to use the constraint-based filter. The one
thing that is still commented out is dive-site mode, since mobile
doesn't (yet) have a dive-site edit feature. And even if it had,
the dive list probably wouldn't be shown at the same time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00
Dirk Hohndel
a469dfa348 mobile/dive-list: correctly update view when changing dive date
If the dive timestamp changes, the dive could move in the dive list. But the
current dive actually doesn't change (it's still the same dive, right?). Yet
we need to update the dive list as well as the shown dive (especially if this
is after adding a dive, which is first inserted with the current time and then
updated with whatever the user enters).

Fixes: #2971

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-27 14:16:18 -07:00
Dirk Hohndel
21d70cbeb1 mobile/cleanup: use local variable to simplify code
The old code wasn't wrong, and likely the compiler turned this into something
that wasn't really terrible... but yeah, 5 unnecessary calls to a helper
function just bugged me. And I think the new code is much easier to read.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:23:19 -07:00
Dirk Hohndel
ebcfb46d8c mobile/dive-edit: fix incorrect handling of multi tank gas mixes
A silly copy and paste error caused us to overwrite the gas mixes for
all the tanks with the gas mix in the first tank.

Fixes #2913

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-16 16:23:19 -07:00
Dirk Hohndel
4ec62441c1 mobile/download: don't allow download without connection set
It appears that multi line attributes silently fail. Without this change, the Download
button is enabled if vendor and product are chosen, even if there isn't a connection
selected. With this change (having all three conditions on the same line) the code
works as expected.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-14 10:57:10 -07:00
Dirk Hohndel
5ff08598ca mobile: show sync state in menu plate
This seems like the easiest way to show the state without disrupting the UI
elsewhere. Directly below the email address used for cloud storage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
3a409c51ea mobile: add status text for cloud sync state
This allows the mobile UI to reflect the three states that the dive list can be
in:
- changes that haven't been written to local storage
- there potentially are changes in local storage that were not synced with the cloud
- dive list is in sync with cloud storage

The last state could be misleading if the user access the cloud from a
different device and makes changes to the cloud storage from there, but from
the point of view of this device, the states are consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
01de67a5a6 mobile: track if we have changes that aren't synced to cloud
If we haven't connected at all to the cloud server we assume that there are
local changes. And whenever we save changes only locally, we also set that
flag.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-14 13:35:33 -07:00
Dirk Hohndel
8a4a9382d3 mobile/dive-details: restrict width of tags field
Having a lot of tags (or more precisely, a tags string that is very long) could
cause the width of the dive details view to extend past the width of the the
page. The txtTags label was missing a maximum width, and to make the result
more useful, I also added correct wrapping and elide to the mix (stupidly, we
had the wrap and width for the fixed name of the field ('Tags'), but not for
the user determined content of that field).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-08 12:27:50 -07:00
Dirk Hohndel
e00e72d430 mobile: add option to merge local cloud cache data
The UI is ugly, and of course this is hidden in the developer options that have
to first be enabled in the advanced settings. As I mentioned in the previous
commit, I believe the actual risk that something gets damaged here is very low,
but still, explaining this so it makes sense to the casual user may be a bit...
difficult.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-07 19:47:52 -07:00
Dirk Hohndel
208d46d58e mobile: add helper to import data from local cloud cache
If you pass in the repo name, it isn't treated as cloud storage, but simply as
local git storage and imported (i.e., added) to the current dive list.

This allows the user to work around failed no-cloud->cloud transitions, merge
different accounts, and most importantly deal with situations were conflicts on
the server caused us to move a cache out of the way and potentially make dives
that were on the mobile device inaccessible to the user.

Once a UI is added, this allows the user to recover those dives (realistically
this is not really all that potentially 'dangerous' to do, but it's definitely
something that would best be done after talking to someone who understands the
cloud storage and can guide the user...).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-07 19:47:52 -07:00
Dirk Hohndel
dd82149726 mobile: make list of local cloud cache directories available
This way QML can show those to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-07 19:47:52 -07:00
Dirk Hohndel
8b167c14ad mobile: tiny whitespace update
Every time I edit main.qml, QtCreator fixes this for me. And then I filter it
from the commit to not mix white space and actual changes. So let's just get
this fixed and move on.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-06-07 19:47:52 -07:00
Dirk Hohndel
afdcccc9fe mobile/dive-edit: fix broken editable combo boxes
This is a partial revert of commit 99438121c4 ("mobile/dive-edit: use template
components and theme colors")

Clearly the information given in the Qt documentation on how to theme ComboBox
is flat out broken. The trade-off between 'better dark theme' and 'broken user
experience' is fairly easy to make.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-30 11:19:54 -07:00
Dirk Hohndel
9deb4f4a22 mobile/credentials: email address must be lower case
I could have sworn that I have fixed this several times in various places,
but apparently (as shown by todays support emails) it's still possible to
setup a mixed case email address. So let's try to solve this problem at
the very top.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-25 08:36:01 -07:00
Berthold Stoeger
8f80129bac cleanup: create common QDateTime -> timestamp conversion function
In analogy to the timestamp -> QDateTime conversion, create a
common function.
1) For symmetry with the opposite conversion.
2) To remove numerous inconsistencies.
3) To remove use of the deprecated QDateTime::toTime_t() function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22 12:31:06 -07:00
Dirk Hohndel
99438121c4 mobile/dive-edit: use template components and theme colors
Another small step to make the dark theme at least marginally useful.
We now use our template components and add the necessary elements to have
consistent text color.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-18 13:00:03 -07:00
Dirk Hohndel
58d97c571d mobile/UI: correctly theme template spin box
This was all hard coded and wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-18 13:00:03 -07:00
Dirk Hohndel
4798382e70 mobile/dc-download: fix dark theme appearance
I noticed that the download from dive computer page looked especially bad
in the dark theme (a user sent us some screenshots for a different reason)
and a quick look at the sources showed that we weren't using our template
label. Switching to that gives us the correct size by default so we can
drop all those explicit font size parameters. And we get the correct color
as used in the theme.

One random whitespace cleanup snuck into this commit. Oh well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-18 13:00:03 -07:00
Dirk Hohndel
f6b09dd8c3 mobile/dive-details: show tags
So far the user can't edit them, but at least they are now shown as
part of the dive details. Usage of tags varries widely, I've seen
people who use a LOT of tags to classify their dives, so I'm giving
this a complete row by itself.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
6f96edd766 mobile/dive-details: less whitespace at the top
This always seemed odd - the location looked like it sat 'low' on the
screen.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
6e47bb11d5 mobile/dive-details: use our labels to create denser display
This makes better use of the screen real estate, without (IMHO) seeming
too crowded. This is a tough balance to strike.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
7720e97db5 mobile: reduce vertical white space around labels
Our labels all seem to have a lot of empty vertical space around them.
Try to be a bit more conservative with space.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Dirk Hohndel
46d582ef0a mobile: add smaller, vertically dense template label
By default single line text has too much white space around it. This
smaller, denser label works well to more efficiently use screen real
estate, I think.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-14 12:57:08 -07:00
Berthold Stoeger
fb6210a99a cleanup: invert control-flow when resetting the core structures
To reset the core data structures, the mobile and desktop UIs
were calling into the dive-list models, which then reset the
core data structures, themselves and the unrelated
locationinformation model. The UI code then reset various other
things, such as the TankInformation model or the map. . This was
unsatisfying from a control-flow perspective, as the models should
display the core data, not act on it. Moreover, this meant lots
of intricate intermodule-dependencies.

Thus, straighten up the control flow: give the C core the
possibility to send a "all data reset" event. And do that
in those functions that reset the core data structures.
Let each module react to this event by itself. This removes
inter-module dependencies. For example, the MainWindow now
doesn't have to reset the TankInfoModel or the MapWidget.

Then, to reset the core data structures, let the UI code
simply directly call the respective core functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07 08:43:27 -07:00
Berthold Stoeger
9b8eed7821 cleanup: replace constructs of the type &vector[0] by vector.data()
It appears that some misguided compiler / library combinations crash
on &vector[0] for empty vectors. Even though very unfriendly, they are
technically correct, so let's remove these constructs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21 07:50:38 -07:00
Dirk Hohndel
47506028ca mobile UI: indicate status of verbose flag
This way the user can verify that they have set the log to verbose
mode in the developer menu.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-18 09:00:21 -07:00
Berthold Stoeger
3d4412ad1a mobile: don't call main loop for notifications once initialized
Calling qApp->processEvents() in QMLManager::setNotificationText()
caused crashes, because it could lead to the context-menu that
initialized the call being deleted. Something that QML apparently
doesn't like.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 08:33:47 -07:00
Berthold Stoeger
24eac8df87 mobile: remove overwriting of line special case in ui-notification
On startup, we showed progress of the population of the fulltext
and listmodels for every 100th dive. This worked by overwriting
the last line if the new line started with '\r'. Since we don't
do that anymore, we can remove this special case.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13 08:30:51 -07:00
Dirk Hohndel
c7c5dac621 mobile/startup: fix potential crash when switching back and forth
If the user switches away from Subsurface-mobile and back while we are
in our initialization phase, that code might run more than once leading
to undesirable results.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:12:52 -07:00
Dirk Hohndel
8414f83926 mobile/cleanup: create helper function to hide verbose casts
The strange enum casts (that apparently we needed in order to have strongly typed
enums in QML) are really ugly and confusing in the code. Since we had this three
times it seemed worth to create a little helper that hides this nonsense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
6aaa9a40b6 mobile/cloud-storage: correctly transition from no-cloud to cloud
We know that we have valid credentials, so calling openLocalThenRemote()
makes no sense, worse, it doesn't respect the special case of
transitioning between accounts. That's the whole point of having a
separate loadDivesWithValidCredentials() call.

Once we have transitioned state, we need to record the now current state
as the old state so that future transitions will work.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
7757ce878b mobile/cloud-storage: fix test for no cloud to cloud transition
The noCloud variable contains our desired state, we need to test for the
previous state for this to make sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Dirk Hohndel
46032af320 mobile/cleanup: remove outdated comment and fix whitespace
We haven't supported the GPS web service for a long time.

Also, add another message for the log to be able to more easily trace
one error case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04 16:10:50 -07:00
Berthold Stoeger
1de56d468f mobile/undo: set undo stack as clean after save
If we're using the undo stack for determining the whether there are
unsaved changes, we have to mark the undo stack as clean after save.

This duplicates code from desktop. It is planned to unify this in
the near future.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04 16:09:57 -07:00