This should deal with the rather confusing 'No dive in dive list' shown
while loading and processing the dive list.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of the crude and error prone bool, let's just use the right tool
for this job.
In order to avoid issues with a goto across a mutex boundary, this
slightly restructures the code in one place - 'git show -w' makes it
clear that this is really rather simple in its changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'm suspicious that an issue that some people have seen around changes
not being saved is caused by our handling of alreadySaving.
When starting with Subsurface-mobile in no-autosync mode, we were able
to end in a scenario where alreadySaving was true, even though there
were no unsaved changes. And in that case no changes made during such a
session were saved unless the user forced a manual sync with the server.
This commit radically changes our approach to handling the flag. It
moves it right next to the actual calls into code that could modify git
storage, and ensures that the flag can never stay set.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was disabled in the past because it was deemed to slow. A lot
of time has passed, since. Maybe on current phones / iPads this is
acceptable again?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds a context menu entry for top level dives that allows the user
to create a trip for that dive.
Unfortunately this creates a new string to translate right before a
release...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The location information model is updated automatically by the
divelist-model and the undo commands. Therefore remove the
QMLManager::updateSiteList() function. We do have to keep
the locationListChanged() signal though, because the list
of dive sites is not exported via model/view but rather via
a Q_PROPERTY. We really should change that.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The git parser loads into the global dive table, even if it
is called indirectly via parse_file(). However, parse_file()
may be given a different table. Fix this by extending the
git parser state.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
While I remember some of the thinking that went into doing things this way,
the more I read the code, the less it makes sense to me.
This is a rather drastic step, but in reasonably extensive testing it seems
to work in every case that I tried.
That's rather embarrassing, actually.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When editing a dive on mobile we might have to create a new
dive site. That site is added to the global dive site table
in the undo command. However, the code in QMLManager created
the dive site with create_dive_site*() functions, which already
adds it to the table. The undo command then added the dive
site again leading to a hang of the application.
To solve this problem, create new alloc_dive_site*()
functions that do the same as create_dive_site*()
but do not add it to the table.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This makes sense because USB devices will only show up when connected,
while BT/BLE will get listed once they are paired, even if not currently
connected. So the higher likelihood of being the device a user is looking
for is for any USB devices that show up, so those should go first.
Suggested-by: Christof Arnosti <charno@charno.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of relying on the std::vector staying unchanged and not freeing
its members, instead keep a copy of the object in our DCDeviceData class.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the user tries to download from a device that he hasn't given the app
permission to read from, Android will pop up a dialogue asking for that
permission. With this after giving the permission we continue (well,
technically, restart) the download which is likely the expected behavior.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way even if a USB device wasn't added through an Android intent, we
still have a way to scan for it and select it. This is especially
important in case a user has a cable that we haven't seen yet (i.e. with
a VID/PID that we haven't added to Subsurface-mobile), but that
nevertheless works with the android usb serial drivers.
This also makes the flow a little more logical / consistent when
deciding which connections to show.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This finally allows us to download from not just the first device, but specifically
the device that the user picks.
Passing the object through a void pointer is not nice - but since this traverses
C code other solutions (like passing an index into the list) seemed even worse.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This vastly simplifies our handling of devive information as we simply use
what is already in the descriptor. This way we do not duplicate information
about USB devices in the QMLManager.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
A number of our messages were misleading in the no cloud case. This should help
to reduce confusion.
Adding the save_dives() call after creation of the repo appears to help us have
a valid repo in place.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Grammar-nazi ran
git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g'
to prevent future wincing when reading the source code.
Unfortunatly, Qt itself is infected as in
QModelIndexList QItemSelection::indexes() const
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The HID devices and the Atomics Aquatics Cobalt cannot work on Android
right now. We should claim to support them.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This creates up to two undo events. This seems like such a small issue that
it's not worth creating yet another undo command for this.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While this has worked fine for a long time, it now suddenly seems to trigger
crashes. So let's not do that (there are a number of discussions online that
talk about how this could indeed lead to BadThings(tm) happening.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we remove the newest dive from its trip, it becomes inaccessible in the app,
but the dive data saved to disk appears to be correct.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we are using the existing command infrastructure, this isn't specific to
undoing a delete.
This commit renames the function and removes its use in the UI, the next commit
will then add the generic undo to the UI.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since the divelist model is now placed on top of the common
models, we can directly reset the filter.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Command that just swaps two dives. This is rather complex,
as for example a dive site might be created.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The whole load from cloud thing will have to be audited. It appears
to me that there are way too many model resets...?
The only thing that is left is dive editing. Let's do that next.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Instead of using the model, copy the code we have in the desktop version
which manually creates a 15m/40min dive and passes that to the addDive
undo command.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
After swiping through the dive list, select the currently visible dive.
Thus, the dive is highlighted in the overview pane.
The connection with the QMLManager feels atrocious, but I would prefer to have
as little logic in QML as possible.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since we want to add a second model, but not have to manage two models
everywhere, create a class MobileModels that contains both of the models. When
calling reset() on that class, it will reset both of the models, etc.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a small step in unifying mobile and desktop.
I'm unsure whether it is correct to play this via the QMLManager or whether we
should call form QML directly into the model?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The goal is to send the signal for the correct dives / divesites
and thus not having to reload the whole model.
Right now the mobile UI does not yet catch the diveSiteChanged signals.
[Dirk Hohndel: small fix to ensure that we trigger a save to storage]
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Still buggy: Removing a dive followed by undo shows the wrong dive
in the list. But clicking on it gives the correct dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The macro NOCLOUD_LOCALSTORAGE creates the path to the local git
repository as a C-string. None of the users were freeing the string
and thus leaking memory.
Replace the macro by an inline function that creates a QString
and pass down to C-functions using the qPrintable() macro.
Note that every qPrintable() invocation does a UTF16->UTF8
conversion. This could be avoided by either using a std::string
or a QByteArray. However, we are talking about microseconds of
CPU time in operations that typically take seconds. Not worth
it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If we detect any of the known PID/VID combinations, use 'usb-serial' instead of
'FTDI'. Also add the now supported additional PID/VID combinations.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
At least in those cases where we are sending a divesChanged signal we can
easily check if the cache was properly invalidated. Of course this won't help
in cases where we don't notify the dive list about changes, either.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>