summaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2020-03-10core/trip handling: add helper function to get trip from idGravatar Dirk Hohndel
In the QML code we pass ids around. I had assumed that there already was a reverse lookup function, but I wasn't able to find it. So I added it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-10mobile/filter: use signal to reload filterGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile: remove dive::collapsedGravatar Berthold Stoeger
This was used by the old dive-list to mark collapsed entries. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-10mobile: unify download code on mobile and desktopGravatar Berthold Stoeger
Use the undo-command for importing dives also on mobile. This should make the whole disconnect-model shenigans unnecessary. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09mobile: use undo-command to apply gps fixesGravatar Berthold Stoeger
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>
2020-03-09GPS fixes: split collecting GPS fixes into own functionGravatar Berthold Stoeger
This finishes the spliting of the GPS fix application: One function for collecting the fixes, one for application. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09cleanup: use QStringLiterals in core/gpslocation.cppGravatar Berthold Stoeger
Not that this would make any noticeable difference, but out of principle, let's use Qt's string-literal macro for string-literals. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09GPS fixes: collect fixes first, apply laterGravatar Berthold Stoeger
Make the application of the GPS fixes in two runs: first collect dives and fixes, then apply the fixes. This will simplify turning the application of GPS fixes into an undo-command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-09Android: don't list devices with unsupported transportGravatar Dirk Hohndel
We know that we cannot support native USB, USB HID, IRDA, and USB storage on Android. On the flip side, don't try to force the long broken FTDI download. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-08usb-serial-for-android: Implement timeout-handlingGravatar Christof Arnosti
Since the Android USB stack and subsequently the usb-serial-for-android driver have problems with read-timeouts, the read-timeout is now implemented in AndroidSerial.java. Also, DC_STATUS_TIMEOUT is returned if there are less bytes returned than expected. Different chipsets seem to behave differently with usb-serial-for-android. On CP210x the read blocks until there is some data here, but on FTDI the chip seems to return whatever is currently in the buffer (so 0 bytes if the buffer is empty). This different behaviour should be mitigated by the changes by this commit. Signed-off-by: Christof Arnosti <charno@charno.ch>
2020-03-07usb-serial-for-android: ImplementationGravatar Christof Arnosti
Implement the libdivecomputer API in Java and create C/JNI translation layer. [Dirk Hohndel: whitespace harmonization - yes, some of this is Java, this still makes it much easier to read for me; also changed the FTDI conditional compilation to make sure we can still use that for mobile-on-desktop if necessary] Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-07serial-usb-for-android: Display all Serial computersGravatar Christof Arnosti
Signed-off-by: Christof Arnosti <charno@charno.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-06mobile: allow disabling BT support from the command lineGravatar Dirk Hohndel
This is a quick hack to reduce the noise in the log file when chasing other bugs. Maybe this should not be enabled on release builds, but right now I don't think the harm that having this in would do. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-06Cleanup: Move stringToList to core/qthelper.cppGravatar Berthold Stoeger
The same code was used in desktop and undo commands. Let's unify. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06Core: don't return invalid cylinders from explicit_first_cylinder()Gravatar Berthold Stoeger
For reasons which I don't yet understand, when plotting a dive whose first cylinder is not cylinder 0 and then plotting a dive with only one cylinder, it can happen that for the latter explicit_first_cylinder() returns an erroneous value. This is due to the way in which we copy the dive to be plotted to displayed_dive. For now, make sure that no invalid cylinder is returned to avoid crashes. This will have to be changed anyway, since this is very fundamentally not thread-safe and inefficient. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-05cleanup: make version_printed variable static and local to functionGravatar Berthold Stoeger
The version_printed variable is used to print version information only once. It was a global variable, but never used outside of its function. Therefore, move it into the function and make it static. Since this is a plain old datatype (POD), it makes no no difference whatsoever whether the static variable is in block scope or not. Indeed, it is initialized in the data segment). Well, we are in C mode and therefore everything has to be POD by definition. I tested this on gcc and clang. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01mobile: remove filter settingsGravatar Berthold Stoeger
These are not used anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: implement searching for tags and people in mobile filterGravatar Berthold Stoeger
Implement tag- and people-filtering in the mobile version of DiveFilter. As opposed to the desktop version, this has no different modes: it always searches "startswith" and "all of". I.e. all of the search strings must match and a tag / person is considered as matching if it starts with the search term. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: remove diveContainsText()Gravatar Berthold Stoeger
This function checked a dive for a search string. Its functionality was replaced by a fulltext index. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: implement full-text filtering in mobile version of DiveFilterGravatar Berthold Stoeger
In analogy to the desktop version, use the fulltext index in DiveFilter. This code is not yet executed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: remove DiveFilter::updateDiveStatus from classGravatar Berthold Stoeger
This function did not access any class members and was not used outside the tranlation unit. Let's make it local (i.e. static) to the translation unit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: compile fulltext index on mobileGravatar Berthold Stoeger
The code is not used yet. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: connect fulltext filter to frontendGravatar Berthold Stoeger
There are now three filter modes: 1) Dive site 2) Fulltext 3) Normal When doing a fulltext search, get the dives that match the fulltext filter and then apply the other filters on that list. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: index/unindex dives on loading or clearing logsGravatar Berthold Stoeger
When loading dive data, populate the fulltext index. When clearing dive data, free the fulltext index. When deleting a dive, remove it from the fulltext index. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: add fulltext filtering codeGravatar Berthold Stoeger
Add code that indexes all words of a dive and provides searching for words. A query is represented by the FullTextQuery class, which can be initialized by assigning a string to it. It is basically a list of words. The result of a search is stored in the FullTextResult class, which is a list of dives. The actual indexing and searching is implemented in the FullText class. However, this class is not exported because the interface is partially accessible to C. Notably, the reloading of the fulltext index is done from the C core. Currently, the indexing and searching is totally unoptimized. In a ~4000 dives test-log searches typically took single-digit ms times. There is ample room for optimization (e.g. when searching for multiple words, chose the words with few dives first and when down to a few dives, check them individually). The words of each dive are tokenized and uppercased and cached with the dive. A pointer to these words is stashed in the dive structure. For now, compile only on desktop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-01filter: move StringMode out of FilterDataGravatar Berthold Stoeger
The FilterData struct has the enum StringMode, which describes how strings are searched (substring, startswith, exact). To make it more generally accessible, remove it from the class. Since it is an "enum class", the values don't pollute the global namespace anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-22Filter: move actual filtering loop to core/divefilter.cppGravatar Berthold Stoeger
The DiveFilter class defined the showDive() function to test whether a dive should be filtered or not. This was used in DiveTripModel to loop over all dives or all dives affected by an editing action. This restricts us in how we do filtering: We can't use indexes that give us directly the result. To make the filtering more flexible, move the actual loops that do the filtering to the DiveFilter class. The undo-commands likewise called directly the showDive() function to check whether newly added dives are shown. Use the new interface here as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-17core: fix incorrect changes in divelogs.de exportGravatar Dirk Hohndel
This is complete nonsense and should never have been merged. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-16Add Cressi BLE name filtering for bluetooth discoveryGravatar Linus Torvalds
.. and update the libdivecomputer submodule to have them marked as BLE capable. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-15load-git: fix up any corrupted modechange event namesGravatar Linus Torvalds
Because of the multiple string confusion, we'd get the names wrong for modechange events. If we then made other changes to the dive and saved the end result back, they'd now be wrong in the git cloud storage too. Fix it up manually by just noticing that there's a 'divemode' string on the event line, which can only happen with modechange events. Maybe we should report the fixup? This just silently fixes it (but only for the git save format). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-15load-git: clean up string handling during parsingGravatar Linus Torvalds
We had some fairly obscure rules for how strings were parsed, and it actually caused bugs when the same line had multiple strings in it. That normally doesn't happen, and the cases where it was _supposed_ to happen had special cases for it (divecomputer ID lines, and tag lines). But by mistake, we had introduced a case of that for the event line handling in commit b9174332d ("Read and write divemode changes (xml and git)"), and nobody realized that the divemode string addition meant that "oops, now it's corrupting the event name". An event line could look like this: event 40:00 type=8 divemode="OC" name="modechange" where we now had both that "OC" and "modechange" strings, and the code to pick the name just picked the first string. So we'd end up effectively mis-parsing the above line as event 40:00 type=8 divemode="OC" name="OC" which is obviously wrong. The dive mode didn't really need to be a string in the first place (there is nothing to quote, and no spaces in it), but hey, here we are. We can't just magially fix the existing broken saves. So make it more straightforward to handle strings in the git format line parser. We still stash the different decoded strings together in one special memory buffer, but now the parser helpers automatically untangle it as they traverse the key value pairs. This is still overly subtle code, and it doesn't fix the cases where we've saved the wrong data back. That comes later. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-13mobile/gps: make sure updated GPS data are savedGravatar Dirk Hohndel
If we change the gps location of a dive that didn't have a dive site associated before (which is the normal case when a dive was just downloaded from a dive computer), a new dive site is created with that GPS fix and added to the dive. We need to mark that dive as changed in order for the changes to be saved to storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-11Filter: implement starts-with and exact modesGravatar Berthold Stoeger
Currently, we do substring search. Implement starts-with and exact mode (for example when search for "Cave vs. Cavern" tags). For each textual search criterion add a combo-box. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-09Correcting typos of the word celsiusGravatar Jason Bramwell
Corrected typo of the word celsius in three files: core/import-csv.c core/divefileter.h mobile-widgets/qml/Settings.qml These were spelled as celcius but corrected these to celsius. The 'core files were just comments but the mobile-widgets file would be 'active' code. Reported by: tormento <turment@gmail.com> Signed-off-by: Jason Bramwell <jb2cool@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-09Cleanup: remove const bool parameters and return typesGravatar Berthold Stoeger
These just make no sense. Since the value is copied, it has no meaning to the caller whether the function can change the value (and vice versa for return types). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08Cleanup: remove erroneous commentsGravatar Berthold Stoeger
Remove two erroneous comments stating that a function-local QSettings variable should not be static because it is initialized too early. Scoped static variables are initialized when execution first hits the statement. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-08core/settings: add new preference to limit number of columns on mobileGravatar Dirk Hohndel
The idea is that in portrait mode we can force the display to be single column (which makes sure that the profile in dive display mode is nice and big). This commit only implements the preference variable that we need for that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-02-08mobile/summary: implement firstDiveDate and lastDiveDateGravatar Berthold Stoeger
Instead of transporting the global first and last dive date in the dive summary, calculate it in an external function. Since we already have time and date functions in qthelper.cpp implement those functions there. Provide a stub in QMLInterface so that QML can access these standalone functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Gps coordinates: be more graceful when parsing coordinatesGravatar Berthold Stoeger
Some Wikipedia pages use special (non-ASCII) unicode symbols for representing the " and ' separators. Before parsing, replace these by the ASCII symbols to enable copy & paste from Wikipedia (and other sources?). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Coding style: remove braces around single-line if blocksGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Coding style: move & from type to variableGravatar Berthold Stoeger
Trivial white-space cleanup according to coding style document. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06CSV import: fix importing ampersand characterGravatar Miika Turkia
As we do XSLT parsing for the CSV import, ampersand characters need to be encoded with &amp; for the parsing to succeed. Fixes #2037 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-02-04Dive site: inform map of selection in DiveFilter::setFilterDiveSiteGravatar Berthold Stoeger
When starting / changing the dive-site filter, inform the map of the changed dive site selection by calling MapWidget::instance()->selectionChanged(); This fixes a bug, where on clicking dive sites in the dive site tab the dive sites from the *previous* click were highlighted. Perhaps the selectionChanged() call should be put into the setSelected() call. But the data flow between the different parts of the dive-site and map code are so convoluted that I don't want to risk anything! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04Cleanup: lower-case filenames in core/subsurface-qt/Gravatar Berthold Stoeger
We tend to use lower-case filenames. Let's do it for these files as well. Simple search & replace. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-27core/qtserialbluetooth.cpp: use QEventLoop for pollingGravatar Lubomir I. Ivanov
The Qt docs here: https://doc.qt.io/qt-5/qbluetoothsocket.html#details and here: https://doc.qt.io/qt-5/qabstractsocket.html#waitForReadyRead say that waitForReadyRead() does not work for QBluetoothSocket and that it's flaky on Windows for the underlying QAbstractSocket. Use a QEventLoop and a QTimer to poll the readyRead() signal. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2020-01-27rfcomm: make Windows use QtBluetooth tooGravatar Linus Torvalds
Windows had it's own direct socket implementation for rfcomm (ie legacy BT), while all the other platforms used QtBluetooth. This makes Windows do the same thing. Hopefully modern Qt libraries now work well enough on the Windows platform for this to work, but I can't test it. We can make a test build that Windows people can try, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-01-27Update to new libdivecomputer versionGravatar Linus Torvalds
Jef has changed the libdivecomputer iostream layer and extended it in two different ways: - iostram's now have a 'poll()' method, which does what the name implies: waits for data to be available with a timeout. - iostreams now have a 'ioctl()' method, which can be used to implement miscellaneous operations. Right now the two ones that you can do are "set latency" (this replaces the old 'set_latency()' method) and "get BLE name" (this replaces our 'get_name()' method that was never part of the upstream libdivecomputer interfaces) Neither of these is all that complicated, and the transition is fairly obvious. HOWEVER. I have absolutely no idea how to do 'poll()' on Windows sockets, and I have no intention of figuring it out. We use a direct socket interface to implement the (non-BLE) RFCOMM bluetooth serial protocol, and I'm not sure why Windows is so special here. I suspect - but cannot test - that we should just switch the Windows RFCOMM implementation over to the use the same QtBluetooth code that we use on other platforms. I assume that the Windows Bluetooth support was originally not sufficiently good for that, but these days we depend on Qt doing BLE for us even on Windows, so presumably FRCOMM works too. That would be a nice cleanup, and would make 'poll()' work on RFCOMM under Windows too. However, since I can't test it, I've not done that, but instead just made the Windows RFCOMM 'poll()' method always return success. That may or may not get the thing limping along. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-01-26code cleanup: QLatin1Literal is deprecated in Qt 5.14Gravatar Dirk Hohndel
Simply replace it with QLatin1String. There is a tiny performance penalty, but none of that code would care. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25Parse GPX dive coordinates: Qt XML frameworkGravatar willemferguson
This replaces the C-code XML parsing with a Qt infrastructure. QXmlStreamReader is used to parse the GPX file. It also takes into account comments by @neolit123 Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-01-24core: move GPX parsing into coreGravatar Dirk Hohndel
This shouldn't be part of the desktop UI code; there's still the issue that we really shouldn't hand code XML parsing, but I'll leave that for later. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>