summaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2020-04-13mobile: remove fine-grained notificationGravatar Berthold Stoeger
When initializing the fulltext-cache and the dive-list, every 100 dives a notification was shown. I had a feeling that this made startup significantly slower, but that could have been purely psychological. Therefore I measured and indeed, removing the fine-grained notification, it becomes *significantly* faster. For a 3500 dives test log with mobile-on-desktop: Initialization of the fulltext: 1350 ms -> 730 ms (-46%) Initialization of the divelistmodel: 689 ms -> 113 ms (-83%) Let's remove the fine-grained notification. There *is* a visual indication of work-in-progress anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13Remove extra argument and add a testGravatar Robert C. Helling
The compiler complained about this and it seems the function does not need it. Additional-test-suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13Preserve events when editing dive in plannerGravatar Robert C. Helling
The planner does not know about events except gas changes. But if the dive comes from the log, we should preserve the dive computer events. At least those that happend before we started to delete waypoints to let the planner take over. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-13Fix compiler warning about variable length field not last in struct.Gravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-04-11media: invalidate correct dive when removing pictureGravatar Berthold Stoeger
This fixes a bug: when deleting a picture when multiple dives were selected, possibly the wrong dive was invalidated. Thus, the dive wouldn't have been saved to the git repository. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-11Merge pull request #2643 from bstoeger/cylinder4Gravatar Dirk Hohndel
First steps of cylinder-editing undo
2020-04-10Merge pull request #2736 from Subsurface-divelog/removeCloudOverrideGravatar Dirk Hohndel
core: remove cloud certificate override
2020-04-10Merge pull request #2737 from Subsurface-divelog/libgitCleanupGravatar Dirk Hohndel
Libgit cleanup
2020-04-10code cleanup: once we find a match, stop checkingGravatar Dirk Hohndel
This isn't really a useful performance improvement, but it's still better, IMHO, because we don't have a less specific match later on potentially change an already executed match. Because of our coding style the comment covering multiple cases of Pelagic dive computers now is associated just with the first of those entries. I don't see a way to do this differently without being in violation of our coding style, so I'll just keep it like this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10BLE dive computer detectionGravatar Dirk Hohndel
Both Shearwater Petrel and Petrel 2 identify as 'Petrel' as their BT and BLE names. But only the Petrel 2 supports BLE, thus only the Petrel 2 shows up in the list of known dive computers on iOS (which supports only BLE but not BT-only). By switching this around to always pick Petrel 2 we now correctly detect such a dive computer on iOS. Fixes #2739 Reported-by: Rick Holcombe <wrh@nc.rr.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10mobile/models: correctly reset the connection modelGravatar Dirk Hohndel
Qt hates empty ranges, and even for a non-empty range, this is better implemented as a reset than a remove. This fixes a crash that I have been able to create on iOS by rescanning for devices on the download page. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10media: move picture function from dive.c to picture.cGravatar Berthold Stoeger
Currently, move only those functions that do not access dive structures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10cleanup: remove picture_free()Gravatar Berthold Stoeger
There is the free_picture() function with the same functionality. The compiler/linker should recognize that and remove the duplicate code, but still... Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10cleanup: remove dive_get_picture_count() functionGravatar Berthold Stoeger
The last user was removed in 5b7e4c57f78c9ec2087726ecad89797132a32d08. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-10cloud-storage: create consistent commit message for mergesGravatar Dirk Hohndel
This never made sense and I think I just forgot to complete this code when I first worked on it. Now we can see which version of Subsurface or Subsurface-mobile created a merge. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09cloud-storage: simplify creation of git authorshipGravatar Dirk Hohndel
While having the local user information in the repo on Linux seemed clever when we implemented it, it's inconsistent with all the other platforms. Let's just not do that unless the user has indeed set a global name/email pair for git. Instead indicate if this was Subsurface or Subsurface-mobile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09cleanup: remove support for ancient versions of libgit2Gravatar Dirk Hohndel
We require a minimum of libgit2 0.26. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-09core: remove cloud certificate overrideGravatar Dirk Hohndel
This code stopped being useful a long time ago. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-08fulltext: don't call words.clear() in FullText::populate()Gravatar Berthold Stoeger
This function was not meant to be called with already existing data. However, if it was, it cleared the words without clearing the fulltext caches of the dives. This lead to crashes. Be more resilient by not clearing the words: Already existing dives are unregistered during the process of populating anyway. So this now *should* work if new dives are added to the dive list and then this function is called. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-08fulltext: rename fulltext_reload() to fulltext_populate()Gravatar Berthold Stoeger
This function was named improperly: it was only used on freshly loaded data. Indeed, attempts to use it to actually reload lead to crashes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07git: don't check for git sha in parse_file()Gravatar Berthold Stoeger
parse_file() refused to load from a git repository if we already had that repository and there were no changes. However, this only checked the global divelist_changed flag, which does not track undo-commands. Thus, after editing dives the user couldn't reload from git. Remove this check. It is somewhat questionable that the io layer refuses to load from a repository anyway. Let the caller decide. There appears to be a check_git_sha function for that purpose(?). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: more fine-grained editing of cylinderGravatar Berthold Stoeger
Don't overwrite the full cylinder when editing a single field. Implement three "modes": editing of type, pressure and gasmix. Don't consider individual fields, because some of them are related. E.g. you can change the gasmix by setting the MOD. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove same_cylinderGravatar Berthold Stoeger
The last user was uses a more general function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cylinders: use preferences modpO2 preferences valueGravatar Berthold Stoeger
Use the user-editable MOD-pO2 preferences value when creating a default cylinder. It is not clear to me, when that even has a consequence, but it looks like the right thing to do. Reported-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove commented-out evn_foreach() functionGravatar Berthold Stoeger
Apparently this was used to hide events in pre-Qt times. However, that has already been reimplemented in different ways. Let's remove that commented-out code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove remove_event() functionGravatar Berthold Stoeger
No user left. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove vintage report_error() function declarationGravatar Berthold Stoeger
Remove an old commented-out declaration. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: split out create_gas_change_event() from add_gas_change_event()Gravatar Berthold Stoeger
For undo, we want to create gas change events without adding them immediately to the dive computer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: move add_gas_switch_event to dive.cGravatar Berthold Stoeger
Since all the other event-functions are also defined there. Ultimately, we should probably move them to their own event.c translation unit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: implement renaming of eventsGravatar Berthold Stoeger
There is a slight complexity here owing to the fact that the profile works on a copy of the current dive: We get a copy of the event and have to search for the original event in the current dive. This could be done in the undo command. Nevertheless, here we do it in the profile so that when in the future the profile can work on a non-copied dive we can simply remove this function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: replot profile if event changedGravatar Berthold Stoeger
Add a DiveListNotifer::eventsChanged signal, which is emitted when the events changed. This is very coarse, at it doesn't differentiate between signal addition / editing / deletion. We might want to be finer in the future. Catch the signal in the profile-widget to replot the dive if this is the currently displayed dive. Reuse the cylindersChanged() slot, but rename it to the now more appropriate profileChanged(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: add remove_event_from_dc() functionGravatar Berthold Stoeger
We have a remove_event() function that 1) frees the event 2) works on the current divecomputer 3) compares the events because the profile has copies of events However, for undo commands 1) we want to keep the event so that we can readd it later 2) we have to work on arbitrary divecomputers 3) we don't work with copies of events Therefore, create a new remove_event_from_dc() function that does all that. Moreover, make the event argument to remove_event() const to (slightly) point out the difference in the API. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: split add_event() in two partsGravatar Berthold Stoeger
add_event() creates and adds an event from the given parameters. For undo, we want to do these separately, therefore split this function in two parts: create_event() and add_event_to_dc(). Keep the add_event() function for convenience. Moreover, keep the remember_event() call in there, so that undo-commands can call remember_event() once, not on every undo/redo action. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: use SAMPLE_EVENT_BOOKMARK in add_event() callsGravatar Berthold Stoeger
In two cases we were passing the magic value 8 instead of the symbolic SAMPLE_EVENT_BOOKMARK. Use the symbolic version instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: reorder cylinders on remove-cylinder undo/redoGravatar Berthold Stoeger
The cylinders in the events must be reordered if we remove a cylinder. To avoid duplication of code, move the reordering function into qthelper.cpp, though it might not be ideal there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: add cylinder undo commands by copy & pasteGravatar Berthold Stoeger
Do a simple copy & paste followed by a simple search & replace to generate cylinder undo commands from weight undo commands. Obviously, this is still missing the necessary code to keep the dive-data consistent after cylinder editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: move fill_default_cylinder from planner.c to equipment.cGravatar Berthold Stoeger
Moreover, move the declaration from dive.h to equipment.h. The result is a) more consistent and b) more logical. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: add create_new_cylinder() functionGravatar Berthold Stoeger
Turn the code in CylindersModel that creates a new cylinder for addition into its own function to avoid code duplication. This will be used from the undo commands. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: introduce set_cylinder() functionGravatar Berthold Stoeger
We have a set_weightsystem() function. For symmetry, introduce a set_cylinder() function so that we can more-or-less copy&paste the weightsystem undo code for cylinder undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: make free_cylinder() globalGravatar Berthold Stoeger
The cylinder undo commands will keep a copy of a cylinder and therefore need the ability to free a cylinder object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07core: introduce clone_cylinder() functionGravatar Berthold Stoeger
We have a clone_weightsystem function. For symmetry, introduce a clone_cylinder() function so that we can more-or-less copy&paste the weightsystem undo code for cylinder undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-04core/fulltext: give progress update while populating indexGravatar Dirk Hohndel
Especially with large dive logs this will prevent the user from thinking that the app is hung. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04core: add additional notification callbackGravatar Dirk Hohndel
Especially on slower devices with a large dive list the startup time has become really long. This callback allows us to give the user an idea of what the app is doing during that time. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-04cleanup: copy saved_git_id, don't use local bufferGravatar Berthold Stoeger
In an attempt to reduce the number of global variables, don't use a local buffer to store the currently loaded git-id. The git-id itself is still a global variable, which in the future can hopefully be encapsulated in a "struct File" or similar. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-24cleanup: fix unitialized valueGravatar Dirk Hohndel
Fixes CID 355179 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-22translations: use German translation for non-Swiss German localesGravatar Dirk Hohndel
Unless a German speaker explicitly asks for the Swiss localization, give them the German localization. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-22cleanup: don't allocate translators on heapGravatar Berthold Stoeger
This is pointless bike-shedding: instead of allocating the QTranslators on the heap an assigning them to a variable at translation-unit scope, we can simply generate them as static objects. That makes 1) two fewer lines of code 2) the translator-resources are properly released when the application closes. Not that either of these points would make *any* difference. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22cleanup: remove memory leak in initUiLocale()Gravatar Berthold Stoeger
The prefs.locale.lang_locale field was overwritten without free()ing the old value. Not that the function would be called numerous times, but as a matter of principle... Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22cleanup: split uiLanguage() in two functionsGravatar Berthold Stoeger
The uiLanguage() function was used for two purposes: to initialize the language related preferences and to read the current language. To make things more easy to follow, split this function in two: one for initializing, one for getting the current language. Moreover, don't return the current locale in an out-parameter as there is already a function to do that [getLocale()]. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22locale: store locate to preferences after fixing up mac-weirdnessGravatar Berthold Stoeger
In uiLanguage() the preferences fields are initialized and there is fixup for a MacOS indiosyncrasy. For some reason the uncorrected value is written to the preferences. Let's store the corrected value instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>