summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2018-10-11Undo: make diverse trip-related operations undo-ableGravatar Berthold Stoeger
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-11Dive list: hand-code the DiveTripModelGravatar Berthold Stoeger
The dive list is fed data by means of a sorted "DiveTripModel". There are two modes: list and tree. This was implemented rather elegantly with a general "TreeModel", which can represent trees of arbitrary depths. Nevertheless, we have at most two levels and on the second level only dives can reside. Implementing proper model-semantics (insert, delete, move) will be quite a challenge and implementing it under the umbrella of a very general model will not make it easier. Therefore, for now, hardcode the model: At the top-level there are items which may either be a trip (can contain multiple dives) or a dive (contains exactly one dive). Thus, we can completely de-virutalize the DiveItem and TripItem classes, which are now trivial wrappers around dive * and dive_trip *. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Dive list: replace dive-id by dive pointerGravatar Berthold Stoeger
The undo-system now guarantees that pointers to dives are stable throughout their lifetime. Therefore, replace the unique index by pointers. This is a small performance improvement, but much more importantly, it will make it more natural to transport a pointer to the dive inside QModelIndex's private pointer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: make editing of dive-time an undoable operationGravatar Berthold Stoeger
The whole undo system assumes that the indexes in the dive table do not change under its feet. On desktop, there seems only one exception left: editing of the dive time. To circumvent this, hook editing of the dive-time to the already existing UndoShiftTime command. This introduces a temporary UI-inconsistency: this is the only edit that is reflected in the undo-list. This will be fixed in due course, when other edit actions are also made undoable. UndoShiftTime is changed to take pointers to dives (which should be stable by now) instead of uniq-ids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Dive editing: don't repeatedly loop through whole dive listGravatar Berthold Stoeger
On dive editing, for every changed field the code looped through the whole dive-list and modified the selected dives. Instead, get the list of selected dives once and use that. Whereas this may look like a gratuitous optimization, it will make things easier for subsequent commits. Notably, we can pass the list of selected dives to an "UndoObject". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: clear undo history on load / importGravatar Berthold Stoeger
Keeping undo-history across load makes little sense. The user was expressly reminded that they have unsaved work. For import (from other logs or the dive-computer) an undo-functionality would be desirable. Nevertheless, this is rather complex since new and old dives are merged. Implementation would require a finer backend<->undocommand interface. Thus, leave this for now until more experience with the undo system is acquired. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: implement rudimentary support for undo of dive-mergingGravatar Berthold Stoeger
For this, an output-parameter was added to the backend merge_dives() function. When non-zero, instead of adding the merged dive to the preferred trip, the preferred trip is returned to the caller. Since the new UndoObject, just like the delete-dives UndoObject, needs to remove/readd a set of dives, the corresponding functionality was split-off in a helper function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: implement rudimentary support for undo of dive-splittingGravatar Berthold Stoeger
For this, the core functionality of the split_dive() and split_dive_at_time() functions were split out into new split_dive_dont_insert() and split_dive_at_time_dont_insert(), which do not add the new dives to the log. Thus, the undo-command can take ownership of these dives, without having to remove them first. The split-dive functionality is temporarily made desktop-only until mobile also supports "UndoObjects". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: implement undo of manual dive-creationGravatar Berthold Stoeger
Play manual addition of dives via an UndoCommand. Since this does in large parts the same thing as undo/redo of dive deletion (just the other way round and only a single instead of multiple dive), factor out the functions that add/delete dives and take care of trips. The UI-interaction is just mindless copy&paste and will have to be adapted. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Cleanup: let MainTab::updateDiveSite() take dive * instead of idGravatar Berthold Stoeger
Both callers have a dive * and transform that into an id, the callee transforms it right back to the dive *. Simply pass the dive directly. This will allow us to use the function for dives that have not yet been added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: fix multi-level undo of delete-dive and remove-dive-from-tripGravatar Berthold Stoeger
The original undo-code was fundamentally broken. Not only did it leak resources (copied trips were never freed), it also kept references to trips or dives that could be changed by other commands. Thus, anything more than a single undo could lead to crashes. Two ways of fixing this were considered 1) Don't store pointers, but unique dive-ids and trip-ids. Whereas such unique ids exist for dives, they would have to be implemented for trips. 2) Don't free objects in the backend. Instead, take ownership of deleted objects in the undo-object. Thus, all references in previous undo-objects are guaranteed to still exist (unless the objects are deleted elsewhere). After some contemplation, the second method was chosen, because it is significantly less intrusive. While touching the undo-objects, clearly separate backend from ui-code, such that they can ultimately be reused for mobile. Note that if other parts of the code delete dives, crashes can still be provoked. Notable examples are split/merge dives. These will have to be fixed later. Nevertheless, the new code is a significant improvement over the old state. While touching the code, implement proper translation string based on Qt's plural-feature (using %n). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-10QML UI: disable rescan when no bluetoothGravatar Jan Mulder
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-10QML UI: do not try to download from DC with empty vendor/productGravatar Jan Mulder
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-09Mobile/DC download: reset the "Download" buttonGravatar Jocke
When changing to another DC, reset the "Download" button text. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09Mobile/rememberDCs: remove duplicated codeGravatar Jocke
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-09Mobile/rememberDC: update matching logicGravatar Jocke
Update the matching logic to account for known and unknown BT DCs. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09Substring match BT addressGravatar Jocke
Since a known DC will have the name prepended to the BT/BLE addresss we need to substring match the BT address. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09Mobile RememberDCs: save device addressGravatar Jocke
By saving the device address together with the vendor and product we fix the corner case where a user with two DCs would not get quick select buttons if they where the same vendor and model. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09BT OSTC 3 should be reported as OSTC PlusGravatar Jocke
Report BT/BLE capable OSTC 3/3+ as OSTC PLus as it is required to get a functional download. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09Dive locations: factor out common code of modelsGravatar Berthold Stoeger
For increased maintainability, use the same columns, roles and the same accessor function for both dive-site models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09Dive sites: remove internalRowCount from LocationInformationModelGravatar Berthold Stoeger
This was redundant. Directly use dive_site_table.nr instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09Dive sites: don't add dummy entries to LocationInformationModelGravatar Berthold Stoeger
The LocationInformationModel added two dummy sites to the front of the list (add new dive site). This was never used - desktop uses its own model, mobile only extracts the list of dive site names with a custom function. Remove this functionality. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09Dive sites: remove LocationInformationModel::setData() functionGravatar Berthold Stoeger
Editing of dive sites does not work via this model and the function was broken anyway (it didn't subtract 2 from the index). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09CHANGELOG.md updateGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09Map: avoid ugly "invalid dive site" message in location boxGravatar Berthold Stoeger
Under certain conditions the user was presented an ugly "invalid dive site" message. The condition would arise because the proxy-model which selects the list of dive sites and the code which creates a proposed dive site name had different filter conditions: - The proxy would select any dive site containing the text - The name-proposing code searched for dive sites *starting* with the text. If the user entered a text contained by a dive site name, but no dive site would start with the second line was filled with a dummy text. This text would be kept if it contained the text entered by the user. To avoid this problem, if no dive site is found, use an empty string instead. This will be filtered out by the proxy because it does not contain the user-entered string. Yes, that's horribly subtle, therefore add a comment. But ultimately, this should be solved in a less brittle way. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09Travis: build Subsurface-mobile against Qt57 as wellGravatar Dirk Hohndel
Simply adding another OS / environment on which we test building of Subsurface-mobile Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-09Travis: build Subsurface-mobile on macOSGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-09build system: work around strange cmake issueGravatar Dirk Hohndel
On both Mac and Linux cmake 3.12 complained that there were "no sources given to target" for the Subsurface-mobile target, which made no sense at all (easy enough to add debug output to ensure there were, in fact, sources given in the call to add_executable()). But splitting this across two lines like this seems to make it work both for older and newer cmake versions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-09Mobile: factor out syncToCloud [3/3]Gravatar Jan Mulder
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-09Mobile: preserve auto download status [2/3]Gravatar Jan Mulder
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-09Prefs: add bool preference cloud_auto_sync [1/3]Gravatar Jan Mulder
With removal of the git_local_only from the preferences (see ae653703a5d3f), the users choice, in the mobile app, was not stored any more in between sessions. This resulted in issue 1725. So, in order to store that user preference, we need a new preference. This is added here, but its not yet hooked up in the app yet. This deals only with the preference handling. And adapted tests are included. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-09Mobile: no switch to auto cloud in no-cloud modeGravatar Jan Mulder
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-09Mobile: mark divelist changed on no-cloud to cloud accountGravatar Jan Mulder
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-08macOS: check for system headers in SDKGravatar Murillo Bernardes
Starting with Xcode 10, system headers are located inside the macOS SDK. Add this location to the check for command line tools. Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
2018-10-08Map: zoom on dive sites when flipping through dive site listGravatar Berthold Stoeger
The dive site list was connected to centerOnDiveSite(). Apparently, the currently selected dive site should have been shown in the map. Yet, this never worked, because the actual dive site of the selected dive had precedence in centerOnDiveSite(). It seems that centerOnDiveSite() had actually to purposes: 1) center on the passed in dive site 2) center on the dive sites of the selected dives Therefore, split this function in two separate functions for each of these use-cases. This allows us to remove some pre-processor magic (mobile vs. desktop) and to remove a parameter from the MainTab::diveSiteChanged() signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-08libdivecomputer: remove ifdefs for ancient versionsGravatar Dirk Hohndel
We bundle our version of libdivecomputer and don't expect Subsurface to work with a different version, certainly not with something older than 0.5. I kept the checks for SAMPLE_EVENT_STRING and DC_FIELD_STRING and DC_SAMPLE_TTS because maybe there's a situation where being able to compile with a current upstream version is useful. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-08Mobile: show temperature graph when no gas graphGravatar Jan Mulder
In commit bd0c99dfb71 (display pO2 and Setpoint for CCR dives) the choice was made: when CCR than never a temperature graph. While this seems reasonable, there is small group of mCCR divers that do not log their po2 digitally, so the only po2 they can display is the setpoint that is reported by the used DC. As this is a bit of a dull flat line, most of these divers do not display this. And this leaves room on the small mobile display for the temperature data. So effectively: show temperature or po2 graphs. Suggested-by: Peter Zaal <pzaal@xs4all.nl> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-08Fix warning about unused variablesGravatar Linus Torvalds
Commit 810903bdb9db ("Import: pass a dive table to process_imported_dives()") introduced the variables struct dive *old_dive, *merged; into process_imported_dives(), but never used them. It seems to be an artifact of having split the function to use the try_to_merge_into() helper function (that has those same variable names and _does_ use them), but forgetting the original variables from the pre-split case. Gcc understandably warns about it: core/divelist.c: In function ‘process_imported_dives’: core/divelist.c:1351:26: warning: unused variable ‘merged’ [-Wunused-variable] struct dive *old_dive, *merged; ^~~~~~ core/divelist.c:1351:15: warning: unused variable ‘old_dive’ [-Wunused-variable] struct dive *old_dive, *merged; ^~~~~~~~ and the trivial fix is to just remove that line that declares the stale and unused variables. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-08ftdi: make the timeout be based on actual real timeGravatar Linus Torvalds
bperrybap reported on github that the ftdi timeouts can be excessive: "the timeout period while waiting for read data to be 10x or even 100x longer than it should be when there are read issues on the data cable particularly when using Android and USB OTG cables. i.e. a 5 second read timeout for not receiving data can be as long as 7 minutes" and the reason is that the code at one point tried to use the regular "gettimeofday()" to handle timeouts, but that doesn't exist in Windows. We already have Windows-specific code to sleep for a number of milliseconds in "ftdi_serial_sleep()", let's just extend that same concept and add a "ftdi_serial_get_msec()" that returns the number of msec's since some arbitrary point in time. On Windows, that's just "GetTickCount()", and in sane environments it's just a trivial wrapper around gettimeofday() to turn sec/usec into msec. NOTE! The actual msec value doesn't have any meaning. Only the difference between two calls to ftdi_serial_get_msec() is meaningful. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-08qt-ble: add 'get_name()' function to expose the BLE name to libdivecomputerGravatar Linus Torvalds
Some divecomputer backends (ok, right now really only the Aqualung i770R and i300C) want to know the bluetooth name of the dive computer they connect to, because the name contains identifying information like the serial number. This just adds the support for that to our Qt BLE code. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-07Travis: don't upload the MXE Subsurface binariesGravatar Dirk Hohndel
More specifically, don't upload them from the old Windows build - we just keep that one around for the smtk2ssrf binaries. The Subsurface binaries are now created in the container based Windows build. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07Travis: build old style Windows without FTDI supportGravatar Dirk Hohndel
This way we can still get an smtk2ssrf build until that is added to the windows-container target. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07MXE: enable building against userspace FTDI drivers againGravatar Dirk Hohndel
This still doesn't seem to work as expected and needs more testing. Also, it can be turned off via command line argument Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07MXE: use libgit2 from MXEGravatar Dirk Hohndel
MXE has had a new enough libgit2 for a while now. No reason anymore to build our own. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07Travis: add Windows build in a containerGravatar Dirk Hohndel
I expect this to become the default way to test Windows builds and create installers on Travis. The idea is that instead of downloading the pre-built MXE binaries we might as well use a container that has all this installed and can be used locally to test if things fail on Travis; which will allow us to have the exact same environment for testing locally as runs on Travis. At this point the container used is way too big - more effort needs to be spent on shrinking it. Right now this only deals with Subsurface and not with smtk2ssrf. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07build-system: minor cleanup of build.shGravatar Dirk Hohndel
That qmake -query was added for debugging a long time ago. Since the comment clearly indicate that the edit of the Makefile is only for Travis, let's only do it when running on Travis. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07build-system: remove support for local cloning in build.shGravatar Dirk Hohndel
It wasn't documented in the first place (magic first argument, anyone?). This used to be available for quite a few of the dependency and had somehow kept around only for Grantlee and Googlemaps. Let's just kill this and be consistent for all dependencies. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07build-system: add Grantlee to our get dependency scriptGravatar Dirk Hohndel
I actually don't know why this was missing... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-07Leak fix: free taxonomy data in delete_dive_site()Gravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-07CHANGELOG.md updateGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>