aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-10-25desktop: remove DiveComputerManagementDialogGravatar Berthold Stoeger
This is now done in a TabWidget with undo-support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25devices: connect DiveComputerModel to undo-commandGravatar Berthold Stoeger
Instead of modifying the device table directly, call the undo commands. Moreover, don't keep our own copy in the mode - show the original version. Connect to the appropriate signals. This means that the calls from the DiveComputerManagement dialog have to be removed, since this mode of editing is not supported. The whole dialog will be removed in a future commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25models: update DiveComputerModel when core data is resetGravatar Berthold Stoeger
To implement undo-semantics, we want a longer-lived dive-computer-model (currently, it is regenerated when the dialog is opened). Therefore, it must be reloaded when the core data is reset. Do this like for other models: listen to the dataReset() signal of DiveListNotifier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25devices: add index based device removal functionGravatar Berthold Stoeger
The undo machinery will need a method to remove devices based on their index instead of their name. Add it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25desktop: add tab-widget for dive computer namesGravatar Berthold Stoeger
If we want to include dive computer names in the undo system, there should be visual feedback on undo/redo. This would mean opening the divecomputer dialog, which would appear quite strange. Therefore, add a tab. This is not ideal, but consistent with the dive site tab, which probably shouldn't be there either. In the future, the UI needs some rethinking. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25undo: add device related undo commandsGravatar Berthold Stoeger
Add commands for deleting devices and editing device nicknames to include the device-handling in the undo system. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: initialize all fieldsGravatar Dirk Hohndel
This doesn't appear likely to cause an issue, but also doesn't seem wrong. Fixes CID 350734 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-25cleanup: fix over-eager Coverity warningsGravatar Dirk Hohndel
Technically get_dive() could return a nullptr. The existing code made sure the argument passed to get_dive() was one that always would result in a valid dive pointer being returned. The new code is only slightly less efficient but allows a static code analysis to easily see that we don't derefence NULL pointers here. On some level this change is unnecessary. But it's also not wrong. Fixes CID 354762 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-25cleanup: fix over-eager Coverity warningsGravatar Dirk Hohndel
Technically get_dive(i) could return a nullptr. But given the range for i that can never happen. Still, the test is extremely cheap and doesn't hurt. Fixes CID 354768 Fixes CID 354766 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-25cleanup: remove double const qualifierGravatar Berthold Stoeger
The redundant qualifier was introduced in an erroneous rebase. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24tests: move TestGitStorage to its own test configGravatar Dirk Hohndel
This way 'make check' doesn't execute TestGitStorage anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-24test: manually run gitStorageTestGravatar Dirk Hohndel
This way we should see the output and hopefully be able to figure out why that silly test keeps randomly failing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-24build-system: switch to using C++17 as default C++ dialectGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-24core: remove create_device_node() from fixup_dive()Gravatar Berthold Stoeger
The device nodes are created for all DCs, when importing the dives. There is no point in creating only the device node for the first DC in fixup_dive(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24divecomputer: add device to provided table instead of global tableGravatar Berthold Stoeger
In the specuial case of suunto, where we may add a device directly instead of via dive->dc, add the device to the provided table. The caller will then pass on the new device to the undo system. This makes downloading finally really undoable (at least I hope so). So far, the dives and dive sites were removed, but any new device remained. However, when setting the device-id via serial, we now have to check both, the global and the downloaded list of devices. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24divecomputer: add device_table pointer to device_data_tGravatar Berthold Stoeger
In one weird case (suunto), the code in libdivecomputer.c generates a device node directly instead of going the usual way (setting the data in the dc-structure of the imported dive). It is unclear to me whether that has to be that way, as it depends on the chronological order of callbacks to event_cb() and dive_cb(). Therefore add a device_table pointer to device_data_t so that the downloader can add the device to this table. This only adds the pointer, but does not yet use it in the downloading code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24cleanup: remove dc_user_device_tGravatar Berthold Stoeger
The same structure was defined as "struct dc_user_device_t" and typedefed as "device_data_t". Unify this. Since there are much more of the latter, remove the former. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24devices: create device nodes in parsersGravatar Berthold Stoeger
So far, we added a non-global device table to the parser states. Now, create device nodes in that table instead of in the global table. Thus, on undo of dive-import, the new device nodes will be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24git: add device-table to git-parser-stateGravatar Berthold Stoeger
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>
2020-10-24cleanup: rename set_dc_nickname() to add_devices_of_dive()Gravatar Berthold Stoeger
The function was misnamed in that it doesn't set the nickname of a device. Instead, it adds all (unknown) devices of a dive to the/a device-table. Let's call it appropriately. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24devices: add devices in Command::importTable()Gravatar Berthold Stoeger
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>
2020-10-24devices: return index from function adding / removing devicesGravatar Berthold Stoeger
This will be used to keep the model representing the device-list up to date. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24devices: add functions to add / remove / check for devicesGravatar Berthold Stoeger
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>
2020-10-24parser: add device_table to parser stateGravatar Berthold Stoeger
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>
2020-10-24cleanup: remove TagWidget::fixPopupPosition()Gravatar Berthold Stoeger
No user of that member function! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24desktop: overwrite drag & drop in TagWidgetGravatar Berthold Stoeger
The interaction of Qt's drag & drop with GroupedLineEdit was exceedingly weird. The user was able to scroll the viewport making the text invisible. This implements a very primitive alternative drag & drop functionality: dropped text is regarged as a distinct tag. This means that it is not possible to modify existing tags by dropping in the middle of them. Arguably, this might even be better than arbitrary drag & drop. But even if not perfect, this fixes a very nasty UI behavior. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24desktop: avoid crashes on drag&drop in GroupedLineEditGravatar Berthold Stoeger
If the user manages to "scroll" through the QPlainTextEdit by a drag&drop action, the state of the widget becomes inconsistent. On the one hand, the text-block says that it has one line. On the other hand, its layout says that it has no line. When trying to fetch the line, a crash occurs. Try to detect such a strange state and return early in GroupedLineEdit::paintEvent(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-24Update ChangelogGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-24mobile: show location service warningGravatar Dirk Hohndel
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>
2020-10-24mobile: show text with location service iconGravatar Dirk Hohndel
I don't recall why we removed that text, but this makes it much clearer that the service is active. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-23documentation: update package lists for Fedora/openSUSEGravatar Dirk Hohndel
This has been tested on Fedora 33 and openSUSE Leap 15.2. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-23cleanup: remove outdated explicit libssh2 linkGravatar Dirk Hohndel
We used to need this when building our own libgit2 on older distibutions. This shouldn't be needed anymore at all. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-23cleanup: remove unused function intdup()Gravatar Berthold Stoeger
That was used by the old xml-params code, which was recently replaced. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-23parser: replace params[] code by new xml_params structGravatar Berthold Stoeger
This fixes a load of memory holes, and makes the code (hopefully) more readable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-23core: add a small helper-struct that keeps track of xml-parametersGravatar Berthold Stoeger
The XML-parameter code is a mess. Ownership is unclear. Allocation and freeing of strings is in different functions. Sometimes only every second string is free()d, because keys are not copied. But this is done inconsistently. The caller has to know how many parameters the callee may add. Instead, let's add a small helper-struct that uses C++ memory management, but exports a C-API. The array for the XML-library is generated on the fly. This is only the implementation, the old code is not yet replaced. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-23libdc: free value strings given by libdc's dc_parser_get_field()Gravatar Berthold Stoeger
Apparently libdc gives us copies of strings. The API is very scary, because (at least according to my reading of the code), the key/value pair may be stored in a cache. Thus on free()ing the string in the cache becomes invalid and we must not access it twice. Very obscure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17devices: use case-insensitive comparison for modelGravatar Berthold Stoeger
Recently, the sorting of the devices was changed to be case-insensitive for models for consistency reasons. However, then the equality-comparison should also be case-insensitive. Break it out into its own function, to avoid that mistake in the future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17cleanup: rename clear_device_nodes() to clear_device_table()Gravatar Berthold Stoeger
For consistency with all the other clear_*_table functions (dive, trip, dive_site, ...) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17filter: don't add to filter presets when importing dive sitesGravatar Berthold Stoeger
When importing dive-sites we would add to the global filter-preset table. This data should be thrown away, just like the other tables that might be imported. This shows that we really should introduce a "struct divelog", which collects all those tables into a single structure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-17filter: remove filter_preset_table_tGravatar Berthold Stoeger
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>
2020-10-17filter: make filter_preset_table an opaque struct for C codeGravatar Berthold Stoeger
filter_preset_table_t was defined as "void" for C code. However, that meant that any pointer could be passed as such a table and such a table could be passed as any pointer, without generating compiler warnings. Indeed, we had a parameter-mixup that went unnoticed. Therefore, make filter_preset_t an anonymous structure with the name filter_preset instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16cleanup: use correct printf formatGravatar Dirk Hohndel
This fixes a warning from the CodeQL scan. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16build-system: add GitHub action for openSUSE Leap 15.2Gravatar Dirk Hohndel
This way we test a Qt 5.15 build. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16build-system: add GitHub action for Ubuntu 20.10Gravatar Dirk Hohndel
This way we test a Qt 5.14 build. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16build-system: improve finding of libdivecomputer.aGravatar Dirk Hohndel
On some systems it ends up in lib64 instead of lib. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16build-system: fix libgit2 detectionGravatar Dirk Hohndel
Usually ldconfig isn't in the user's path. Suggested-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-16core: use case-insensitive comparison for device modelsGravatar Berthold Stoeger
The code in core/libdivecomputer.c used string insensitive comparison for device models, before being merged into core/device.c. Let's reinstate that behavior, since it appears to be more logical. On would assume that two different vendors will not use the same model with different casing (and the same device-ids), so that should be safe. This uses strcoll to correctly sort unicode, which will hopefully never be needed! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16cleanup: replace std::find_if by std::any_ofGravatar Berthold Stoeger
To search for devices with the same model, we used find_if(). However, that was only to check whether such a thing exists, not to actually do something with said device. Therefore, change this to std::any_of() to make it clear what the purpose of the statement is. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16core: add device_table parameter to device table functionsGravatar Berthold Stoeger
Instead of accessing the global device table directly, add a parameter to all device-table accessing functions. This makes all places in the code that access the global device table grep-able, which is necessary to include the device-table code in the undo system. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-16core: remove call_for_each_dc()Gravatar Berthold Stoeger
The core now loops over the devices directly - no need for this callback. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>