aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/downloadfromdivecomputer.cpp
AgeCommit message (Collapse)Author
2018-09-24Desktop/remember DCs: insert the remember connection into dropdownGravatar Dirk Hohndel
This still doesn't do the right thing for BT/BLE connections on a Mac, but it should work on Linux and possibly Mac. We definitely need to figure out how to get the Mac to successfully connect back to a BT/BLE device. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-23Core: split process_dives() in post-import and post-load versionsGravatar Berthold Stoeger
process_dives() is used to post-process the dive table after loading or importing. The first parameter states whether this was after load or import. Especially in the light of undo, load and import are fundamentally different things. Notably, that latter should be undo-able, whereas the former is not. Therefore, as a first step to make import undo-able, split the function in two versions and remove the first parameter. It turns out the the load-version is very light. It only sets the DC nicknames and sorts the dive-table. There seems to be no reason to merge dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-23Desktop/remember DCs: move non-UI-specific code into the core layerGravatar Dirk Hohndel
This way we can use the same functionality from the mobile UI as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-23Desktop/remember DCs: hook up the shortcut buttonsGravatar Dirk Hohndel
The straight forward code to update the currentIndex of the combobox doesn't appear to work on macOS (but works fine on Linux). Calling the event loop and then calling update afterwards seems very unintuitive, but it appears to fix the issue in my testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-23Desktop/remember DCs: remember dive computers that were usedGravatar Dirk Hohndel
The algorithm tries to keep the order of the buttons the same. So if a dive computer was used that's already remembered, don't reorder the buttons. But if a new dive computer is used, add it as the first one and move the others back, potentially dropping the oldest one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-23Desktop/remember DCs: base UIGravatar Dirk Hohndel
Simply create the buttons that can be used as shortcuts to previously used dive computers. This isn't hooked up at all. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-01Desktop: allow using a file dialog to find Garmin folderGravatar Dirk Hohndel
If we don't auto-detect where the Garmin Descent is mounted, the user can either just type in the correct path, or can use a file diealog to specify it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-27Make device enumeration use the device transport dataGravatar Linus Torvalds
This removes some special-case code for Uemis, replacing it with simply passing in the device transport information. This makes device enumeration work for the Garmin Descent (if it is listed by libdivecomputer as a USB storage device, that is). I don't actually do any of the libdivecomputer parsing yet, and only have a stub for the Garmin Descent, but now the directory selection works with that stub. The actual download obviously does not. [Dirk Hohndel: removed obsolete FIXME from code] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-27Show new firmware notice for OSTC PlusGravatar Jan Mulder
Also show a new firmware notice for a HW OSTC Plus. This appeared to be broken (as can be verified on the current master from today, as HW just released version 2.98 of the firmware). Notice that there is some confusion in both Subsurface and Libdivecomputer with respect to types of OSTCs. Physcically, there exist 2 type of OSTC3's. The first edition with only DC_TRANSPORT_SERIAL (and an USB connector), and a second version that lacks the connector but supports both BT and BLE. Confusingly, the second version is marked OSTC3 on the device, but the user needs to select OSTC Plus (which is basically a 3rd version of the OSTC3, combined with a successor of the OSTC Sport) to download dives using BT/BLE. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-08-15desktop-widget: remove SettingsObjectWrapper and update qPref callsGravatar jan Iversen
remove use of SettingsObjectWrapper:: remove include of SettingsObjectWrapper.h use qPrefFoo:: for setters and getters replace prefs.foo with qPrefXYZ::foo() where feasible (this expands to the same code, but gives us more control over the variable). Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-26Whitespace cleanup desktop-widgetGravatar Dirk Hohndel
Not entirely script based because of the broken 'else if'. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-25core: activate qPrefDiveComputerGravatar jan Iversen
remove DiveComputer from SettingsObjectWrapper and reference qPrefDiveComputer update files using SettingsObjectWrapper/DiveComputer to use qPrefDiveComputer this activated qPrefDiveComputer and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21desktop-widgets: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-24Convert our custom IO model to new libdivecomputer IO modelGravatar Linus Torvalds
This converts our old custom IO model to the new model that libdivecomputer introduced. This is partly based on Jef's rough patch to make things build, with further work by me. The FTDI code is temporarily disabled here, because it will need to be integrated with the new way of opening devices. The ble_serial code goes away entirely, since now libdivecomputer knows about BLE transport natively, and doesn't need to have any serial wrapper around it. Signed-off-by: Jef Driesen <jef@libdivecomputer.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-03-14Cleanup: introduce copy_qstring() functionGravatar Berthold Stoeger
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common occurrences that they seem worthy of a short helper-function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-04Indentation fix in desktop-widgets/downloadfromdivecomputer.cppGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-03-04Correctly spell OSTC cRGravatar Stefan Fuchs
Correctly spell OSTC cR (wrong: "Cr") in two files. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-04downloadfromdivecomputer.cpp: remove unused variable err_stringGravatar Berthold Stoeger
This was a relict from Gtk days. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-04Cleanup: Remove redefinition of DC_TRANSPORT_BLUETOOTHGravatar Berthold Stoeger
This transport option was defined at a time where libdc didn't know anything about bluetooth. Nowadays, this enum is defined by libdc to a different value. Since it is never returned from libdc, not a problem at the moment. But this looks like a recipe for desaster, therefore let's just use the libdc version. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-31Use queued connection to thread-safe MainWindow error handlingGravatar Berthold Stoeger
Up to now, errors produced by threads were not directly shown in the MainWindow. Code running in the GUI thread had to manually show the errors. This can be simplified by using Qt's queued connection as message passing facility. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Introduce helper function empty_string()Gravatar Berthold Stoeger
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-31Get Bluetooth device nam from preferences if dialog wasn't shownGravatar Berthold Stoeger
If the BT dialog hasn't been shown, the device name was taken from the text field, which contained a formatted string. The device open would then fail. Fixes #1002 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-17Cleanup: mark parameter as unusedGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-11-13Make Bluetooth naming consistentGravatar Berthold Stoeger
Currently, on Linux, after selecting a Bluetooth device the name of the device is shown. On reopening the download dialog, on the other hand, the address is shown. In the device selection dialog both are shown. This patch changes the download dialog such that both, name and address, are shown. The bulk of the patch introduces the name of the device in the preferences and DCDeviceData. It has to be noted that DCDeviceData is an encapsulation of the libdivecomputer device_data_t. Nevertheless, the new Bluetooth-name field is, at the moment, not passed through to libdivecomputer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-11Fix memory leak in download-from-dive-computer widgetGravatar Berthold Stoeger
Instead of (re)allocating the vendor and product models, use the setStringList method on sub objects. Even though only a theoretical problem, the model objects are moved in front of the ui object, so that the widgets referencing the models are destroyed first. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-06Remove unnecessary == NULL test.Gravatar Berthold Stoeger
Test not necessary, because the QString in question is not a pointer and the string is tested for emptiness (which also flags null-strings). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-04Correct, cleanup, translate and unify file filtersGravatar Stefan Fuchs
Correct spelling and typos in file filters. Unify and translate file filter names. Don't pass a file filter to a directory open dialog - not needed. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04Replace QMap::operator[] with QMap::value()Gravatar Berthold Stoeger
QMap::operator[] creates a new default constructed entry in the map if no entry with the given key exists. While not problematic (since typically nullptrs are inserted) this is usually not what you want for read access. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-01Reset device field in DownloadFromDCWidget according to dive computerGravatar Berthold Stoeger
Fixes minor interface inconsistency: The device field in the download-from-dive-computer widget is disabled when selecting a non-serial-transport dive computer. In contrast, post-download the field was reset to enabled for all dive computers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-31Postpone error message display if not in GUI threadGravatar Berthold Stoeger
Calls to report_error() crashed if not called from GUI thread. Fix this by postponing error message display if not in GUI thread. Code that creates a thread which possibly calls report_error() is responsible for calling MainWindow::showErrors() to flush the accumulated messages. Note that there is a race condition in report_error() and get_error_string(). Nevertheless, hitting it should be rather unlikely (two threads producing error messages at the same time) and hopefully it can be fixed rather easily. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-16Connect finished signal of download thread only onceGravatar bs
Connect finished signal of download thread only once in constructor of DownloadFromDCWidget instead of every time the Download / Cancel / Retry button is clicked. Fixes minor nuisance: On repeated download attempts multiple massage boxes were shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-09-17DC download: show info messages on MacGravatar Dirk Hohndel
For some reason the progress bar on macOS doesn't show the progress text. This creates a label below the progress bar and shows the text there instead. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17DC download: better message at beginning of downloadGravatar Dirk Hohndel
Especially on BT/BLE devices, where there is a longer negotiation phase at the beginning of the download, this seems more user friendly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17DC download: don't clear message if no dives downloadedGravatar Dirk Hohndel
Otherwise the text telling the user that no new dives were found will be deleted right away. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28Fix possible memory corruptionGravatar Jan Mulder
A user reports a SIGSEGV that points to DownloadFromDCWidget::updateProgressBar() in relation to strlen()/strdup(), at end of download. Reading the code, as I can't reproduce the crash, it seems that the progress_bar_text is set to NULL and later strdup-ped. The man page is not fully clear on this, but setting it to the empty strings is much safer. Might fix: #507 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-06-22Convert to new libdivecomputer custom IO modelGravatar Linus Torvalds
Instead of being "custom serial", it's a IO model that allows serial or packet modes, independently of each other (ie you can have a bluetooth device that does serial over BT rfcomm and packet-based communication over BLE GATT with the same serial operations that describe both cases). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-15Correctly hook up libdivecomputer log and dumpGravatar Dirk Hohndel
This was checking the status of the wrong UI elements. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-29Don't leak memory on downloaded dives not pickedGravatar Dirk Hohndel
I noticed this in the mobile download code when fixing an unrelated issue - and then realized that the same was true in the desktop app as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-28Fix abort when Bluetooth mode is defaultGravatar Jan Mulder
Commit dec47e11cd3 introduces a SIGSEGV in case the user has Bluetooth download selected from its previous sessions. Accessing the "Import from dive computer" crashes immediately. Reverting a small part of commit dec47e11cd3 solves this. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-05-27QML UI: add the DownloadThreadGravatar Tomaz Canabrava
For this I had to also make the DCDeviceData accessible, and for that it needed to be a pointer. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27Reduce the scope of variablesGravatar Tomaz Canabrava
Those variables should have local scope, not class scope. We are using it only inside of pickDump/LogFile metohds. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27Extract the device_data_t into helper classGravatar Tomaz Canabrava
Keeping the Desktop and QML versions of Subsurface using the same codebase will keep the code saner, this change makes the Desktop version use the DCDeviceData helper sturct that encapsulates the device_data_t member for easy access on the QML. This also helped move a bit of initializations from the UI to the Core - and that's always good. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27Move the fill_computer_list() out of widgetsGravatar Tomaz Canabrava
fill_computer_list() creates a Qt friendly structure that contains all of the necessary information about dive computers and it's devices, and it's needed both in Qml and Widgets to allow the user to download their dives. This patch makes it possible to use the code in QML without duplication. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27Separate the download thread from the widget logicGravatar Tomaz Canabrava
This is important to not duplicate code for the Qml view. Now the DownloadFromDiveComputer widget is mostly free from important code (that has been upgraded to the core folder), and I can start coding the QML interface. There are still a few functions on the desktop widget that will die so I can call them via the QML code later. I also touched the location of a few globals (please, let's stop using those) - because it was declared on the desktop code and being used in the core. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-27Move model code to modelsGravatar Tomaz Canabrava
This makes it easery to use it on Qml. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-05-26Creation of dive duration string and surface interval stringGravatar Stefan Fuchs
Update the function to create the dive duration string in a way that it can be used also in info and stats tab and added some more flexibility. Changed layout for <1h freedives to "0:05:35" (w/o units) or "5:35min" (with units and :) or "5min 35sec" (with units with space). Add a new function to create the surface interval string. Completely remove old function get_time_string() and get_time_string_s(). Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-29Add SPDX header to desktop widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>