aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/locationinformation.cpp
AgeCommit message (Collapse)Author
2018-10-13Cleanup: rename MainWindow member variablesGravatar Berthold Stoeger
Instead of the weirdly named "information" and the inconsistent "dive_list" use the logical "mainTab" and the camel-cased "diveList", respectively. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Cleanup: Turn widget accessor-functions into simple pointersGravatar Berthold Stoeger
The keeps track of different sub widgets needed by other parts of the code, notably: MainTab PlannerDetails PlannerSettingsWidget ProfileWidget2 DivePlannerWidget DiveListView Access to these widgets was provided with accessor functions. Now these functions were very weird: instead of simply returning pointers that were stored in the class, they accessed a data structure which describes the different application states. But this data structure was "duck-typed", so there was an implicit agreement at which position the pointers to the widgets were put inside. The widgets were then down-cast by the accessor functions. This might make sense if the individual widgets could for some reason be replaced by other widgets [dynamic plugins?], but even then it would be strange, as one would expect to get a pointer to some base class. Therefore, directly store the properly typed pointers to the widgets and simply remove the accessor functions. Why bother? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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: don't use displayed_dive_site to store GPS coordinatesGravatar Berthold Stoeger
The displayed_dive_site object is used in the dive-site-edit widget to store the old (before-edit) data. But it was also used to store the GPS data when changed on the map or the input box. Very confusing. Instead, use the text field as only authoritative source of the GPS data. This introduces a small behavioral change: when changing the text of the GPS text field, update the list of dive sites at the same position. 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-11Geo lookup: don't pass arguments / result via global objectGravatar Berthold Stoeger
The reverseGeoLookup() fetches dive-site data via GPS coordinates. The coordinates and the result were passed via the global "displayed_dive_site" object. To make data-flow more clear, pass data as in and out parameters instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Cleanup: remove ReverseGeoLookupThreadGravatar Berthold Stoeger
Fetching the taxonomy from GPS coordinates was implemented in a QThread. But the only access to the main function was a direct call to run(). Thus, the thread was *never* started. The function call was always asynchronous [it was using an event loop though, so the UI doesn't hang]. Notably this means that the signals connected to the thread would never fire. And the spinner would never be activated. Thus: 1) Turn the thread into a simple function. 2) Remove the spinner. 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-10-09Map: avoid ugly "invalid dive site" message in location boxGravatar Berthold Stoeger
Under certain conditions the user was presented an ugly "invalid dive site" message. The condition would arise because the proxy-model which selects the list of dive sites and the code which creates a proposed dive site name had different filter conditions: - The proxy would select any dive site containing the text - The name-proposing code searched for dive sites *starting* with the text. If the user entered a text contained by a dive site name, but no dive site would start with the second line was filled with a dummy text. This text would be kept if it contained the text entered by the user. To avoid this problem, if no dive site is found, use an empty string instead. This will be filtered out by the proxy because it does not contain the user-entered string. Yes, that's horribly subtle, therefore add a comment. But ultimately, this should be solved in a less brittle way. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-08Map: zoom on dive sites when flipping through dive site listGravatar Berthold Stoeger
The dive site list was connected to centerOnDiveSite(). Apparently, the currently selected dive site should have been shown in the map. Yet, this never worked, because the actual dive site of the selected dive had precedence in centerOnDiveSite(). It seems that centerOnDiveSite() had actually to purposes: 1) center on the passed in dive site 2) center on the dive sites of the selected dives Therefore, split this function in two separate functions for each of these use-cases. This allows us to remove some pre-processor magic (mobile vs. desktop) and to remove a parameter from the MainTab::diveSiteChanged() signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-26desktop: fix multi-keystroke input on locationGravatar Murillo Bernardes
When the tooltip is hidden QInputMethodEvent is handled by QLineEdit and works properly. When the tooltip is visible DiveLocationListView gains focus and receives QInputMethodEvent, without handling them properly. This patch just forwards the event back to the QLineEdit object. Fix #1405 Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
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: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.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-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-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-29cleanup: Unchecked return valueGravatar Jan Mulder
CID 208312 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28Replace less-or-equal by less-than comparison in lessThan functionGravatar Berthold Stoeger
DiveLocationFilterProxyModel::lessThan() used less-or-equal instead of less-than comparison. This can lead to subtle bugs if two elements compare as equal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30Use better aliases for icons.Gravatar Martin Měřinský
Icon aliases were complete mess. Some icons had alias some didn't. Named with underscores vs. hyphens vs. camelCase. Lower vs. upper case. "ICON" prefix vs. suffix vs. nothing. With vs. without filename suffix. Some didn't make sence. Eg. mapwidget-marker-gray (I can see, it's grey, but what does it represent?) Some were duplicated, eg warning vs. warning-icon. Some were name after widget, which is wrong. Do not reinvent wheel. Use widely used naming scheme close to Freedesktop Icon Naming Specification. This will enable usage of common icons from current set in the future. Thus Subsurface will fit nicely to GUI. This changes icon aliases to one, easy grep-able style. Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29Revert "Use consistent aliases for all icons."Gravatar Dirk Hohndel
This reverts commit 92e9c6606f6ef3ad16d2e31f9f9a8f5fa14f2c1a.
2017-11-29Use consistent aliases for all icons.Gravatar Martin Měřinský
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase. With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs. prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some icons didn't have alias at all. This changes all icon aliases to one, easy grep-able style which complies to Freedesktop Icon Naming Specification (Guidelines). Signed-off-by: Martin Měřinský <mermar@centrum.cz>
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-11-09map-widget: allow real-time updates of edited markersGravatar Lubomir I. Ivanov
This patch allows updating the location of map markers while editing a dive site and updating the text in the LocationInformationWidget in real-time. Currently it is only possible to see the marker changes by clicking 'Apply'. The modification required the following changes: - add the MapWidget::updateCurrentDiveSiteCoordinatesToMap() slot and call it each time the GPS text updates - separate the updateCurrentDiveSiteCoordinates(FromMap/ToMap) logic by having the FromMap/ToMap suffix to method names - make MapWidgetHelper::updateCurrentDiveSiteCoordinatesToMap() call a new MapLocationModel::updateMapLocationCoordinates() method, which updates selected location coordinates and the model - add MapLocation::setCoordinateNoEmit() that does not emit a signal when updating a coordinate Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-17Tags for geo references: Nicer look, translations and warning messageGravatar Stefan Fuchs
For the geo references tags update the following: - Nicer look w/o "Tags:" text and brackets when inside location UI - Translation for "Tags:" - Warning message when no dive site layout categories are set Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16In location information UI set reverse geo lookup button activ...Gravatar Stefan Fuchs
as soon as coordinates are available . Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-09Use lrint() for all degrees_t related roundingGravatar Lubomir I. Ivanov
In certain places the '(int)' cast is used, while in other the llrint() or lrint() functions. Make the conversation from degrees in the 'double' form to the 'int' degrees_t consistent using lrint(). lrint() is the function which should give the best results, because it accepts a 'double' and results in a 'long' even if degrees_t is 'int'. If the truncation from 'long' to 'int' is discarding some of the precision then the next step would be to turn degrees_t into a 64bit signed integer type. Possible fix for #625. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-07Locationinformation: correctly handle strings on the heapGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07Warn if we edit non-existant dive siteGravatar Dirk Hohndel
And try to add it to the dive - bubt we really shouldn't get here. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-07LocationInformationWidget: make sure to clean out fieldsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Simplify the geo reverse lookup functionGravatar Dirk Hohndel
We never actually create a list of dive sites for which we call the reverse lookup service, it's always just displayed_dive_site. So make this all much simpler and just go straight for that. This commit removes a loop, but doesn't change the indentation of the code inside the loop to make it easier to see what was changed. That whitespace change will be in my next commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Remove bogus signalsGravatar Dirk Hohndel
One isn't connected to anything, the other one makes us overwrite the changes to displayed_dive_site. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Change the signature of constructLocationTagsGravatar Dirk Hohndel
We actually want to be able to pass a specific divesite structure and not have it look that up by uuid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Don't add separate country field, use taxonomyGravatar Dirk Hohndel
The more I looked at the code that added the country to the dive site, the more it seemed redundant given what we have with the taxonomy. 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-09-04remove Marble from the source treeGravatar Lubomir I. Ivanov
In desktop-widgets, remove globe.cpp, globe.h and also remove the NO_MARBLE macro usage. At this point the MapWidget will always be created and there will always be a map in the application. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28locationinformationwidget: abstract between GlobeGPS and MapWidgetGravatar Lubomir I. Ivanov
Connect the same signals for the two classes based on the NO_MARBLE macro. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-04-29Add SPDX header to desktop widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-24Fix double to int truncation in C++ codeGravatar Jeremie Guichard
Wfloat-conversion enabled for C++ part of the code Fix warnings raised by the flag using lrint Original issue reported on the mailing list: The ascent/descent rates are sometimes not what is expected. E.g. setting the ascent rate to 10m/min results in an actual ascent rate of 9m/min. This is due to truncating the ascent rate preference, then effectively rounding up the time to reach each stop to 2s intervals. The result being that setting the ascent rate to 10m/min results in 20s to ascend 3m (9m/min), when it should be exactly 18s. Reported-by: John Smith <noseygit@hotmail.com> Reported-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09Silence warnings in locationinformation.cppGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-19Fix UI issue with location managementGravatar krisalpha
The index in the fixpopup function was incorrect which caused the user to need TWO cursor down presses to move to the second element. I changed the index value so the user now needs only one key press to traverse up/dowm. Fixes #954 Signed-off-by: krishan Chopra <choprakrishan61@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-24Location completion matches on whole nameGravatar Dirk Hohndel
When typing in a partial location name, the match now considers the whole text, not just the start of the text. So typing in "Yell" will match both "Yellow House" and "Mellow Yellow". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>