aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/locationinformation.h
AgeCommit message (Collapse)Author
2020-08-24cleanup: fix compiler warningGravatar Robert C. Helling
... at least for llvm. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-01cleanup: remove includes from desktop-widgets/locationinformation.hGravatar Berthold Stoeger
Notably, there was a circular include locationinformation.h <-> importgps.h Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-06Dive site: give visual clue for invalid coordinatesGravatar Berthold Stoeger
On the dive site edit screen, when the user enters invalid coordinates and saves, we treat this as "no location". This is rather unfriendly, therefore warn the user with a visual clue. This is performed by setting the background color of the widget to red. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-24Desktop: Import dive coordinates directly from GPSGravatar Willem Ferguson
This allows Subsurface to obtain the coordinates of a dive directly from a GPS track. It parses a GPX file (GPX V1.0 or V1.1) from a GPS to locate the trackpoint immediatedly after the start of a dive. There is an additional "Use GPS file" button in the Edit Dive Site panel that is selected from the Notes tab. Image: This allows one to select a GPX file, bringing up the Import GPS dialog. There is extensive provision for cross-checking that the dive track synchronises with the dive start and end. If the Save button in the dialog is pressed the dive coordinates are copied into the Dive Coordinates text box in the Edit Dive Site panel. The map moves to indicate the location of the dive site. The bulk of the work is done in importgps.cpp. The code is pretty intergrated: I tried to break it up in smaller commits but that was not feasible. The code includes responses to the comments by @neolit123 and @bstoeger. The C-based file input was replaced with Qt-based code using QChar, QString and QFile. [Dirk Hohndel: fixed several small issues in the .ui file, removed various headers includes that weren't needed and fixed printing of minutes as zero padded] Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-07Dive site: close dive site edit widget when dive site is deletedGravatar Berthold Stoeger
The application could be crashed by 1) Create dive site 2) Edit dive site 3) Undo until dive site is removed 4) Continue editing now non-existing dive site Therefore, hook into the dive-site-deleted signal and if the currently edited dive site is deleted, close the widget. When closing the widget, make sure that the potentially dangling pointer is reset to zero so that there is no other potential use-after-free bug. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-04Cleanup: remove DiveLocationLineEdit::currTypeGravatar Berthold Stoeger
Apparently this field was never used...? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: Add button to display all dive sitesGravatar Berthold Stoeger
On the main dive tab, add a button that opens the dive-site selection widget showing all dive sites. This is done by setting the "temporary dive site name" to the empty string. Thus no dive sites are filtered and the "add new dive site" entries are not shown. Moreover, the text is selected. The user can therefore immediately start typing to activate the filter or enter the name of a new dive site. The idea is that after downloading dives with GPS information the user can select one of the close dive sites. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: show distance to current dive using extra dataGravatar Berthold Stoeger
Currently, in the dive-site selection widget the distance to the dive site of the current dive is shown. Instead, use the recently introduced dive_get_gps_location() function. Thus, the actual GPS coordinates extracted by libdivecomputer are used. The function is only called when the current dive changes and the location is stored in the item delegate. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11Dive site: sort by distance to current diveGravatar Berthold Stoeger
When presenting the list of dive sites on the dive-info tab, sort the dive sites by distance to the current dive. The idea is that when the user wants to select a dive site, close dive sites should be prioritized. The location of the dive is determined with the dive_get_gps_location() function introduced in the previous commit. This actual GPS data get precedence over the currently set dive site for that dive. On change of dive, the current location is updated in the DiveLocationFilterProxyModel so that a potentially expensive search for GPS data is not repeated for every comparison. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-16Cleanup: remove global DiveLocationLineEdit variableGravatar Berthold Stoeger
DiveLocationLineEdit stored a pointer to itself in a global variable so that the DiveLocationModel can access it to access the filter text. Instead, on change simply pass the filter text down from DiveLocationLineEdit to DiveLocationModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add proximity field to dive site listGravatar Berthold Stoeger
Merging dive sites is currently only possible if dive sites are at the exact same position. Introduce a field where the user can enter a distance up to which all dive sites should be listed. These can then be merged. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Desktop: Dive site editing: give up focus on ESCGravatar Berthold Stoeger
As long as a text field is active, CTRL-Z only affects this field. Thus it is suprisingly hard to undo edits. There seems to be a fundamental problem with CTRL-Z handling. To make it somewhat easier, catch any ESC-key event and move the focus to the MainWindow. This effectively removes the focus from any text field. This all appears very wrong, but so far I wasn't able to find the root cause of the problem. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove LocationInformationWidget::endEditDiveSite signalGravatar Berthold Stoeger
The signal was caught by the MainWindow to: 1) call setDefaultState() 2) call refreshDisplay() 3) call refreshDisplayedDiveSite() 1) Let's call that directly from the widget. The reason is that in the future there might be multiple way to get into the widget and therefore the widget needs finer control. 2) Remove this call as it produces an unsteady UI. 3) This should be done by undo commands, not only when finishing dive site editing. Thus, the signal becomes unnecessary and can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of geo lookupGravatar Berthold Stoeger
Simply copy code of the other edit dive site functions. Here though introduce a destructor in the undo command to free the taxonomy data. Remove the taxonomy member of the LocationInformationWidget class, because it is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: remove edit mode from dive location widgetGravatar Berthold Stoeger
Since no dive site field editing enters edit mode anymore, the whole edit mode state and code can be removed from the widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: update map when dive site location is changed by undo commandGravatar Berthold Stoeger
Simply hook into the appropriate signal. Thus, the "update dive site location" button can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site location editingGravatar Berthold Stoeger
Simply copy the code of note editing. It's a bit more complex, since we have to parse the Gps coordinates. For consitency, rename the COORD field to LOCATION (the field in the dive_site struct is called LOCATION). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site country editingGravatar Berthold Stoeger
Simply copy the code of notes editing, but use the taxonomy_* functions to read and set the value. Moreover, replace the three TAXONOMY_n field ids by a single TAXONOMY id. We will probably never show one column per taxonomy field, but rather a single column with a string derived from all taxonomy fields. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site notes editingGravatar Berthold Stoeger
Simply copy the code of description editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: use undo commands for name and description editing in widgetGravatar Berthold Stoeger
In the dive site widget, use the undo commands instead of editing only on accept. This introduces an inconsistency betwee the name and description and the other fields. This will be fixed in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: remove LocationInformation::nameChanged signalGravatar Berthold Stoeger
This signal was used by the old filter and the last user was removed in e0f473fcb49c8121a0a9c52bf0536049b0f342ed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: Implement undo of dive site name editingGravatar Berthold Stoeger
Implement an undo command that edits the name of a dive site. Connect it to the dive site table, so that names can be edited directly in the table. Send signals on undo / redo so that the dive site table and the dive site edit widget can be updated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Coding style: add tab before Q_OBJECTGravatar Berthold Stoeger
In virtually all cases we use a tab before Q_OBJECT. Fix the four exceptions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-02Cleanup: rename locationInformation.ui -> locationinformation.uiGravatar Berthold Stoeger
The .cpp and .h files are all lower-case, the .ui file is camel-case. Unify to lower-case (which is much more common in the code base). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: remove [start|stop]FilterDiveSite signalsGravatar Berthold Stoeger
This is another case of a weird pattern where an object would connect it's own signal to the slot of a different object. There seems to be no reason why the former couldn't simply call the latter. Remove the [start|stop]FilterDiveSite signals of LocationInformationWidget and call the corresponding functions of MultiFilterSortModel directly. While doing so, replace the UUID argument by a pointer-to-divesite. It will be converted anyway right at the beginning of the function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: remove UUIDs from LocationInformationModelGravatar Berthold Stoeger
Replace UUIDs from LocationInformationModel and fix the fallout. Notably, replace the UUID "column" by a DIVESITE "column". Getting pointers through Qt's QVariant is horrible, we'll have to think about a better solution. RECENTLY_ADDED_DIVESITE now defines to a special pointer to struct dive_site (defined as ~0). This fixes an interesting logic bug: The old code checked the uuid of the LocationInformationModel (currUuid) for the value "1", which corresponded to RECENTLY_ADDED_DIVESITE. If equal, currType would be set to NEW_DIVE_SITE. Later, _currType_ was compared against _RECENTLY_ADDED_DIVESITE_. This would only work because NEW_DIVE_SITE and RECENTLY_ADDED_DIVESITE both were defined as 1. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: remove argument from diveSiteSelected signalGravatar Berthold Stoeger
The diveSiteSelected signal of DiveLocationLineEdit had the dive-site UUID as argument. But the receiving slot would not use that argument. Remove this as a tiny step to remove the UUIDs alltogether. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-26Cleanup: remove declaration of unused signalGravatar Berthold Stoeger
The last use of the LocationInformation::startEditDiveSite() signal was removed in ff26ffe0d078a891cbc52afa7ffb59943644ad82. Remove its declaration. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21Add 'location_t' data structureGravatar Linus Torvalds
Instead of having people treat latitude and longitude as separate things, just add a 'location_t' data structure that contains both. Almost all cases want to always act on them together. This is really just prep-work for adding a few more locations that we track: I want to add a entry/exit location to each dive (independent of the dive site) because of how the Garmin Descent gives us the information (and hopefully, some day, other dive computers too). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-13Dive site: replace displayed_dive_site by pointerGravatar Berthold Stoeger
In the dive-site-edit widget, a copy of the current dive site was used to store the old (pre-edit) data. This is not necessary, since we can simply access the data in the original dive site. Thus, replace the subobject by a simple pointer. This is part of a series to replace dive-site uuids by pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Dive site: use own copy of taxonomy in dive-site-edit widgetGravatar Berthold Stoeger
The dive-site-edit widget uses a copy of the to-be-edited site to compare with old values. Generally, this seems overkill (the original dive-site can be used for such a comparison). But one place where it can't simply be removed is the taxonomy, because the widget needs a place to store the unsaved data. Change the code to use an explicit taxonomy structure instead of the one provided in the copy. This should ultimately allow removal of the latter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Dive site: un-globalize displayed_dive_siteGravatar Berthold Stoeger
The global object displayed_dive_site is used a a backing-store by the dive-site-edit widget. All external accesses were removed, therefore make the object local to the widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Dive site: explicitly init displayed_dive_site on show widgetGravatar Berthold Stoeger
The global object "displayed_dive_site" is used to store the old dive site data for the edit-dive-site widget. The fields of the widget were initialized from this object in the show event. Therefore the object was updated in numerous parts of the code to make sure that it was up-to-date. Instead, move the initialization of the object to the function that also initiatlizes the fields. Call this function explicitly before showing the widget. This makes the data-fow distinctly easier to understand. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Map: remove access to displayed_dive_site in GPS-filter modelGravatar Berthold Stoeger
The location information shows a list of dive sites at the same location as the edited dive site. This was done by passing a function to an "SsrfSortFilterProxyModel". Unfortunately, the latter does only support function pointers without state and therefore had to access the global "displayed_dive_site" object. Replace the SsrfSortFilterProxyModel by a proper subclass of QSortFilterProxyModel that contains information on the position and id of the currently edited dive site. Update the filter model if the location of the dive site changes. This introduces a behavioral change: editing the GPS location will lead to an updated list. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Map: pass down dive site in prepareForGetDiveCoordinates()Gravatar Berthold Stoeger
Instead of reading out the global object "displayed_dive_site", pass the dive site to be edited in arguments to prepareForGetDiveCoordinates() and enter edit mode. Simplify the code in LocationInformationWidget by not using signals to call the prepareForGetDiveCoordinates() function. While doing this, collect common code in accept() and reject() in the already existing resetState() function. This is another entry in a series of commits that makes data-flow more clear by removing access to the global "displayed_dive_site" object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Map: pass changed coordinates via signalGravatar Berthold Stoeger
The coordinates of a "dragged flag" were passed out-of-bound via the global "displayed_dive_site" object and then a signal was sent to notify of the changed coordinates. Instead, pass the coordinates directly via the signal. This makes the data- and control-flow more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Map: remove LocationInformationWidget::coordinatesChanged signalGravatar Berthold Stoeger
This was used by LocationInformationWidget to instruct the map that the coordinates of the current dive site has changed. There is no reason why this couldn't be a function call, as no other object ever connect()s to this signal. In fact, such a function already exists viz. updateLocationOnMap. Therefore, replace the signal by a simple function call. Moreover, the uuid and coordinates of the dive site were transported via the global "displayed_dive_site" object. Instead, pass this information in the parameters of the function. This makes it easier to reason about data- and control-flow. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-09-29Cleanup: reinstate override modifiersGravatar Berthold Stoeger
This reverts commit 1c4a859c8d0b37b2e938209fe9c4d99e9758327a, where the override modifiers were removed owing to the noisy "inconsistent override modifiers" which is default-on in clang. This warning was disabled in 77577f717f5aad38ea8c4c41c10c181486c4337f, so we can reinstate the overrides. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-01Cleanup: remove all override modifiersGravatar Berthold Stoeger
Commit df156a56c08a56eb380711a507ef739d8150a71f replaced "virtual" by "override" where appropriate. Unfortunately, this had the unintended consequence of producing numerous clang warnings. If clang finds a override-modified function in a class definition, it warns for *all* overriden virtual functions without the override modifier. To solve this, go the easy route and remove all overrides. At least it is consistent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-31Cleanup: replace virtual by override where appropriateGravatar Berthold Stoeger
The keyword "virtual" signalizes that the function is virtual, i.e. the function of the derived class is called, even if the call is on the parent class. It is not necessary to repeat the "virtual" keyword in derived classes. To highlight derived virtual functions, the keyword "override" should be used instead. It results in a hard compile- error, if no function is overridden, thus avoiding subtle bugs. Replace "virtual" by "override" where appropriate. Moreover, replace Q_DECL_OVERRIDE by override, since we require reasonably recent compilers anyway. Likewise, replace /* reimp */ by "override" for consistency and compiler support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-27locationinformation: don't update map location on typingGravatar Lubomir I. Ivanov
Currently when the user is typing new coordinates the marker on the map changes location right away. Disable that and add a 'flag' button that should be pressed instead. Also make the coordinates update when pressing Enter or when the text field loses focus. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-26Inform LocationFilterModel of changed dive site nameGravatar Berthold Stoeger
Since commit 01d961086c1d175732c597dc9acdba7cc4cd2d26, the location filter list is updated if a dive site is edited. The problem is that if the name of a selected dive site is changed, the selection is lost. Therefore, before repopulating, inform the location filter that a dive site changed its name. The location filter then internally changes the name and can properly transfer the old selection on repopulate. This is performed via the new LocationInformationWidget::nameChanged signal, which is connected to the new LocationFilterModel::changeName slot. A special case to be handled is the following: [ ] Site 1 [x] Site 2 and "Site 2" being renamed to "Site 1", i.e. both sites being merged. Here, the merging is detected and "Site 1" will likewise be checked: [x] Site 1 [x] Site 1 No merging is performed, as the list will be repopulated anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-07LocationInformationWidget: make sure to clean out fieldsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-02[Divesite] Hook location information interface for countryGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29Add SPDX header to desktop widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30Move qt-ui to desktop-widgetsGravatar Tomaz Canabrava
Since we have now destkop and mobile versions, 'qt-ui' was a very poor name choice for a folder that contains only destkop-enabled widgets. Also, move the graphicsview-common.h/cpp to subsurface-core because it doesn't depend on qgraphicsview, it merely implements all the colors that we use throughout Subsurface, and we will use colors on both desktop and mobile versions Same thing applies for metrics.h/cpp Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>