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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>