aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2018-10-29Dive site: return pointer to dive_site in create_dive_site_*()Gravatar Berthold Stoeger
This changes more of the dive-site interface to return pointers instead of UUIDs. Currently, most call sites directly extract UUIDs afterwards. Ultimately, the UUIDs will be generally replaced by pointers, which will then simplify these callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-28Dive list: remove rememberSelection() without restoreSelection()Gravatar Berthold Stoeger
Remove three cases of rememberSelection() which did not possess the corresponding restoreSelection() twins. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-28Dive list: remember/restore selection only on view changeGravatar Berthold Stoeger
The selection was remembered/restored anytime the sort-order changed. Yet, this is only necessary if the view (tree, list) changes. Therefore, handle the selection only if this is the case. This automatically fixes the problem of the trip-selection not being remembered if the view doesn't change. If the view does change, trip selection is lost. But since the list view doesn't have trips to start with, losing trip-selection seems like an understandable behavior. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-28Dive list: show sort indicatorGravatar Berthold Stoeger
On desktop, show the a sort indicator to give a visual feedback on changes of the sort order. This is trivially done by calling the setSortIndicatorShown() function in DiveListView's constructor. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-28Dive list: switch to a default sort order on column-header clickGravatar Berthold Stoeger
On desktop, clicking on a column header sorts the dive-list. This has the interesting property that every click reverses the sort order (unless changing from list to tree-mode). The much more common idiom seems to be to define a default sort order for each column and switch to that when changing sort-column. Switch order after clicking the same column again. Implement this more common behavior. For now, sort # and date in descending, all other columns in ascending order. While doing this, use the proper enum (NR) for setting the default sort-column instead of its integer representation (0). 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-25Dive list: emit selectionChanged signal in filterFinished()Gravatar Berthold Stoeger
In commit 9829e49815de1b81b5c9848b71eaa810faab2bcf the dive selection code was moved from the filter to the dive list. As a consequence of that change, the selectionChanged signal was not emitted anymore and therefore the map widget was not informed of the new dive site list. This had funky effects on the dive-site editing. Notably, changing the location would move the map, but not update the flag. Explicitly emit selectionChanged in filterFinished() to fix dive site editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-25Fix bug in for loop that can lead to segfaultGravatar Simeon
In case of big log files, where MAX_TANK_INFO is reached, tank_info[i] != NULL should be checked after i<MAX_TANK_INFO Signed-off-by: Simeon Geiger <simeon.geiger@gmail.com>
2018-10-24Show coordinates if no tags from reverse geolookupGravatar Miika Turkia
This will display the dive site coordinates after the Location label if there are no associated tags from reverse geolookup. Thus it'll be clearer for users that we do have GPS location stored for the dive, and might be able to see more easily if the recorded coordinates are correct. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2018-10-23Dive site: remove webservice code in MainTab::updateDiveSite()Gravatar Berthold Stoeger
There was still code in MainTab::updateDiveSite() related to dive-sites obtained from the obsolete web-service. Remove. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21Dive list: remove three unnecessary instances of qobject_cast<>.Gravatar Berthold Stoeger
In DiveListView, the result of model() was dynamically cast to QSortFilterProxyModel. But then, only the virtual match() function was used. The whole point of virtual functions is that you can cast them on the base-class and it will execute the function of the derived class. Thus, remove these casts and operate directly on the QAbstractItemModel base class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-21Dive list: move dive-selection code from filter to listGravatar Berthold Stoeger
After invalidating the filter, the dive-selection was modified to ensure that at least one dive is selected. This was done in the filter code, but it seems preferrable to do this in the dive-list code, which has direct access to the selection-model. Therefore, move the code from MultiFilterSortModel to DiveListView. While doing so, split the code in DiveListView into more functions to: 1) Get the index of the first dive (if any). 2) Select the first dive (if any). This allows a distinct size reduction of conditional compilation in MultiFilterSortModel (accesses to MainWindow are not possible in mobile code). 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-19Preferences: set deco parameters correctly enabledGravatar Jan Mulder
And fix another bug in this area of the code. It appeared that the gflow/gfhigh and conservatism deco parameters where not enabled at startup, but after toggling the VPM vs BUEHLMANN setting they were. So, fix this as well. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-19Preferences: wire-up the deco parametersGravatar Jan Mulder
The deco parameters need special treatment to wire them up to the underlying deco model code. And with the new preferences setup this is a lot of boilerplate. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-15Dowload: Deselect dives only if at least one dive was downloadedGravatar Berthold Stoeger
On dive-download old dives are deselected and a new one is selected. If no dives were downloaded, accordingly no dives were selected. This deselect only dives if at least one dive was downloaded. Fixes #1793 Reported-by: Jan Mulder <jlmulder@xs4all.nl> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-15Bluetooth cleanup: remove pointless download_modeGravatar Dirk Hohndel
This was used to track whether we had selected the native BT mode in the download dialog. But the information is redundant as we can tell from the device name whether this is a BT/BLE download or not. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-15Desktop/trivial: fix misleading commentGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-14Desktop: Enable next/prev DCs only for applicable divesGravatar Jan Mulder
Does not solve any problem, but might help users that are confused about the next/prev DC menu items, to select a different profile for the currently selected dive. So, enable these menu items only for dives where more than one DC is used. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-14Autogroup only when selectedGravatar Jan Mulder
Comits f427226b3b and 43c3885249f of the undo series introduced 2 calls of autogroup_dives() without checking the autogroup global boolean. This is a bug. An import from DC (for example) then triggers an autogrouping, the divelist is autogrouped, and the UI button is off. This commit solves this. I've chosen for a guard in the autogroup_dives() that now is a no-op when called when the user did not select autogrouping. In additon, simplified the other calls to this function, as we do not need to check before calling any more. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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-13Cleanup: remove outdated commentGravatar Berthold Stoeger
Remove a comment which is outdated in two ways: 1) The global variable "displayed_dive_site" was not used at all. 2) The location box cannot be used to rename dive sites. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Dive site: use displayed_dive in MainTab::refreshDisplayedDiveSiteGravatar Berthold Stoeger
MainTab::refreshDisplayedDiveSite() was used after dive-site edit to update the information of the location entry box. This should always display the dive-site of the currently shown/edited dive, therefore it makes no sense to use the displayed_dive_site here. Simply use the dive site of displayed_dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Dive edit: always use dive site of displayed_dive in updateDiveInfoGravatar Berthold Stoeger
The old code had a special case for dive-editing mode: The dive site uuid of displayed_dive_site instead of displayed_dive was used. This makes no sense, because displayed_dive_site is only used by the dive-site-edit widget, which firstly cannot be activated during dive-edit and secondly doesn't change the dive site id anyway. Thus, use the dive site of the currently edited/displayed dive in all cases. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-13Desktop: enable tab-changes-focus for TagWidgetGravatar Berthold Stoeger
When tabbing through the dive-info screen, a dive-master and a dive-buddy would be added. The reason is that pressing tab would be interpreted as a text-input. Disable this behavior by calling setTabChangesFocus(true) in the TagWidget constructor. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-12Bluetooth: actually download from the device selectedGravatar Dirk Hohndel
If we update the device with a shortcut button, this is the reliable way to get the information we need. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Bluetooth: show the user that we are waiting to connect to DCGravatar Dirk Hohndel
Previously nothing was shown while we were trying to connect; now we show a busy indication in the progress bar and ensure that the 'waiting to connect' text is displayed. The progress bar switches back to showing actual progress once we have connected and are downloading data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Bluetooth: start discovery if address isn't already knownGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Bluetooth: run a discovery agent for BT/BLE dive computers on macOSGravatar Dirk Hohndel
This way the scan time will be shorter (which on macOS can be 25+ seconds). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Cleanup: remove unused function MainTab::showLocation()Gravatar Berthold Stoeger
The last caller was removed way back in 266e754d08499a4ed45024d4886c4e799e7951e7. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-12Whitespace onlyGravatar Jan Mulder
Separated from the previous commit as I do not like big whitespace changes in a small functional commit. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-12Edit: prevent not needed change markingGravatar Jan Mulder
While trying to understand more of the big change from PR 1528, I found that the divelist was marked changed while it was not changed at all. Reason is simple. The MODIFY_DIVES code assumes its called only for truly changed data. But in case of saving tagged strings, it was not. This fixes this. And I do not believe this has any visual effects. Further, the now broken indentation is fixed seperately. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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: split void MapWidget::setEditMode()Gravatar Berthold Stoeger
The setEditMode(bool) function behaves very differently, when entering and exiting edit mode. Therefore, split it in two versions. This will allow to pass arguments that make sense only when entering the edit mode. Since setEditMode() doesn't exist anymore, turn the editMode Q_PROPERTY line to the MEMBER version. Accordingly, remove the reader function. If QML wants to enter edit mode, it should invoke the appropriate function and not simply set the flag. 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-11Dive site: remove access to displayed dive site from LocationFilterDelegateGravatar Berthold Stoeger
When editing a dive, in the location box a list of dive sites is shown containing the distance to the current dive site. This was implemented via the global displayed_dive_site object, which is set when switching between dives. This seems like an unnecessary indirection. Instead, use the current_dive macro. This is part of a series to refactor dive-site handling to use pointers instead of UUIDs and a general push to reduce global state. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: make adding of planned dive undo-ableGravatar Berthold Stoeger
Planned dives were still added by directly calling core code. This could confuse the undo-machinery, leading to crashes. Instead, use the proper undo-command. The problem is that as opposed to the other AddDive-commands, planned dives may belong to a trip. Thus, the interface to the AddDive command was changed to respect the divetrip field. Make sure that the other callers reset that field (actually, it should never be set). Add a comment describing the perhaps surprising interface (the passed-in dive, usually displayed dive, is reset). Moreover, a dive cloned in the planner is not assigned a new number. Thus, add an argument to the AddDive-command, which expresses whether a new number should be generated for the to-be-added dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Filter: Make filters aware of added / removed divesGravatar Berthold Stoeger
Instead of reloading all the filter, only increment / decrement the count of the entries of added / removed dives. Originally, this was planned to be done via the signals from the divelist, but it turned out that this was suboptimal, because if the filter decides that the new item is selected, this has to be done *before* adding the dive. Otherwise, it wouldn't be shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Dive commands: set filter flag when adding divesGravatar Berthold Stoeger
When adding dives to the list, set the filter flag accordingly. Thus, dives that are hidden by the filter are not shown on redo/undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Dive list: propagate current-item to frontendGravatar Berthold Stoeger
The command-objects select a current item, but this selection was not propagated to the front-end. The current item is the base for keyboard-navigation through the dive-list and therefore should be set correctly. It took some experimentation to get the flags right: QItemSelectionModel::Current Hopefully, these are the correct flags across all supported Qt versions! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>