aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2018-10-29Dive site: pass pointer-to-dive_site via QVariantGravatar Berthold Stoeger
There was this ugly pattern of passing pointers-to-dive_site via a QVariant of void * type. This is of course inherently unsafe. Pass these pointers using their proper types instead. This makes it necessary to register them in Qt's meta-type system. Doing so, fixes a bug: QML couldn't call into updateDiveSiteCoordinates() because it didn't know the type and thus the coordinates of the moved flag were not reflected in the divesite-dialog. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: replace dive->dive_site_uuid by dive_siteGravatar Berthold Stoeger
Replace the UUID reference of struct dive by a pointer to dive_site. This commit is rather large in lines, but nevertheless quite simple since most of the UUID->pointer work was done in previous commits. 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: pass pointer to updateDiveSiteCoordinates()Gravatar Berthold Stoeger
There are two updateDiveSiteCoordinates() member-functions, viz. in MapWidget and MapWidgetHelper. Adapt them to take a pointer to dive_site instead of a UUID. This is part of an effort to replace UUIDs by pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: Pass dive-site pointer to MapWidgetHelper::enterEditMode()Gravatar Berthold Stoeger
Replace the uuid argument to MapWidgetHelper::enterEditMode() by a pointer. Likewise, adapt the only caller prepareForGetDiveCoordinates(). This is a small step in a bigger effort to replace dive-site UUIDs by pointers. 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-29Dive site: replace UUID_ROLE by DIVESITE_ROLEGravatar Berthold Stoeger
Access to dive-sites in the LocationInformationModel was via UUID. Replace this by a direct access to the struct dive_site pointer. Accordingly, rename the UUID_ROLE to DIVESITE_ROLE. This is a small step in replacing dive-site UUIDs by pointers throughout the code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: pass dive-site pointers to merge_dive_sites()Gravatar Berthold Stoeger
Instead of passing uuids, pass a pointer to the dive site. This is small step in an effort to remove uuids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: pass dive-site pointer to delete_dive_site()Gravatar Berthold Stoeger
Instead of passing a uuid, pass a pointer to the dive site. This is small step in an effort to remove uuids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: pass dive-site pointer to is_dive_site_used()Gravatar Berthold Stoeger
Instead of passing a uuid, pass a pointer to the dive site. This is small step in an effort to remove uuids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29Dive site: pass dive-site pointer to nr_of_dives_at_dive_site()Gravatar Berthold Stoeger
Instead of passing a uuid, pass a pointer to the dive site. This is small step in an effort to remove uuids. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>