aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2020-05-06desktop: update information tab when cylinders changeGravatar Berthold Stoeger
The SAC rate, etc were only updated when switching between dives. They should always be updated when an undo command changes (adds, edits, removes) the cylinders of a dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-05cleanup: capitalize use dcGravatar Monty Taylor
It was suggested in a review of a previous patchset that we should capitalize the use of "use dc" to "Use DC" - but if we were going to do that we should do it everywhere, not just in the one place. This is the followup to do that. Signed-off-by: Monty Taylor <mordred@inaugust.com>
2020-05-05cleanup: Change Salty to BrackishGravatar Monty Taylor
In the code, the difference between SALTYWATER and SALTWATER is hard to see. More importantly, in the UI - Brackish is the word for water that has more salt that freshwater but less salt that seawater. The docs already use the word to clarify what is meant.
2020-05-05Grantlee: Add salinity and water type to grantlee variablesGravatar Monty Taylor
These can be useful in a printed divelog, especially if the log entry is also showing weight and exposure suit. Signed-off-by: Monty Taylor <mordred@inaugust.com>
2020-05-04Add conneciton for display variations checkboxGravatar Robert C. Helling
...this gat lost at some point. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-05-04CSV export: include dive mode fieldGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2020-05-04planner: on printing, restore textual plan using a saved stringGravatar Berthold Stoeger
When printing, the dive plan was prepended with a logo, a disclaimer and the profile. Then it was restored by setting the plan of displayed_dive. Instead, simply save the original plan in a QString and restore that. This removes a further dependency on displayed_dive, which I'd like to make local to the planner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04desktop: remove unused if-branch in MainWindow::editCurrentDive()Gravatar Berthold Stoeger
MainWindow::editCurrentDive() used to be a general function to enter edit mode. Nowadays, this is only called for one very specific case, namely editing the profile of a manually added dive. Therefore, we can remove the if-branch that dealt with planned dives. Moreover, we can do the test right at the beginning and remove a warning message for duplicate "edition", as this is not possible anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04Planner: fold MainWindow::setupForAddAndPlan into createSimpleDive()Gravatar Berthold Stoeger
There was only one caller of MainWindow::setupForAddAndPlan() left and that caller immediately called DivePlannerPointsModel::createSimpleDive(). Thus, we might just as fold the former in the latter and thus concentrate all the prepare-dive-for-plan business in one place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04planner: send plan in calculatedPlanNotesGravatar Berthold Stoeger
Thus, the MainWindow doesn't have to extract the plan from displayed_dive. This is a tiny step in an attempt to detangle the interfaces. The bigger goal will be to make displayed_dive local to the planner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-04planner: update variations in planner not mainwindowGravatar Berthold Stoeger
When calculating variations, they were sent to the mainwindow, which updated displayed_dive accordingly. Do this directly in the planner-model. The idea is to detangle interdependencies and to make the code reusable (planner on mobile?). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03selection: create global single_selected_trip() functionGravatar Berthold Stoeger
The DiveListView had a singleSelectedTrip function that returns the selected trip if exactly one trip is selected. This could be very slow if numerous non-trip items were selected, because all the selection indices were back- translated by the proxy model. This could make selection changes very slow, because the MainTab used said function to determine whether it should show trip or dive data.. Indeed, with a 3500 dive test log, when selecting all dives in tree mode, the updating of the TabWidgets is sped up from 130 ms to 5 ms this commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03selection: inform core of trip selection in DiveListViewGravatar Berthold Stoeger
When selecting / deselecting trips, keep the core updated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03selection: introduce clear_selection() functionGravatar Berthold Stoeger
The DiveListView would touch the selection-innards directly. Let's encapsulate that. Moreover, take care to reset the trip selection when resetting the core data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03cleanup: don't explicitly clear tabs in MainWindow::selectionChanged()Gravatar Berthold Stoeger
When there is no current dive, mainTab->updateDiveInfo() implicitly clears the tabs. There is no need to call this explicitly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03profile: don't interpret NULL as current_dive in plotDive()Gravatar Berthold Stoeger
ProfileWidget2::plotDive() had this weird interface, where passing in NULL as dive would mean "show current_dive". However, most callers would already pass in current_dive. Therefore, unify and always pass in current_dive if the caller wants to draw the current dive. This allows us to interpret NULL as "show empty profile". Thus, passing in current_dive when there is no current_dive simply shows an empty profile. This makes the calling code in MainWindow::selectionChanged() simpler. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03profile: remove outside callers of ProfileWidget2::replot()Gravatar Berthold Stoeger
There was a mix of ProfileWidget2::replot() and ProfileWidget2::plotDive(current_dive, true), which is equivalent. Since there was more of the latter and it is more flexible, unify on that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03cleanup: remove parameter to ProfleWidget2::replot()Gravatar Berthold Stoeger
Firstly, the parameter appears conceptually wrong, as replot suggests that the currently shown dive is replot. Secondly, the only caller that passed a parameter was passing in current_dive, which is just what happens if one doesn't pass a parameter. Therefore, change that caller (call plotDive directly) and remove the parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-03desktop: ask user when quitting application while planningGravatar Berthold Stoeger
We used to cancel a plan (or profile edit) when the user quit the application while planning. This is inconsistent with respect to closing or opening a different log, where the user was asked for confirmation. Thus, for consistency and to avoid loss of a planned dive, use the okToClose() function in on_actionClose_triggered() of MainWindow. As an added bonus, this saves a few SLOC. Fixes #1078 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-02desktop: fix editing of tripsGravatar Berthold Stoeger
In 2021035cfcee08ec4c6f9d16683db8ce400bef30 a bug was introduced: currentTrip of MainTab was not set in trip mode. Thus, when editing the trip notes, the notes of all selected dives were edited instead. Set the member variable and not a local variable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move declaration of utc_mk* functions to new subsurface-time.h headerGravatar Berthold Stoeger
No point in slurping in all of dive.h for translation units that only want to do some time manipulation without ever touching a dive. Don't call the header "time.h", because we don't want to end up in a confusion with the system header of the same name. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-05-01cleanup: move dive_table from dive.h to divelist.hGravatar Berthold Stoeger
This allows us to decouple dive.h and divelist.h, a small step in include disentangling. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30desktop: don't replot profile when populating dive information tabGravatar Berthold Stoeger
When the dive mode is changed, the profile has to be replot. This is by a function of the TabDiveInformation. However, that function was also executed when populating the tab. Thus, when changing dive, the profile was plot twice. Move the profile plotting out of the function. Ultimately, the profile should listen to the appropriate signals itself. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26selection: replace selectedTrips() by singleSelectedTrip() functionGravatar Berthold Stoeger
To check wether the tab widgets should show the trip view, they called the selectedTrips() function. The trip view was shown if that contained only one trip. However, the selectedTrips() function was very slow, because it has to query to core models. Change the function to singleSelectedTrip(), which returns a trip if there is exactly one trip selected. The function returns early if there is more than one trip selected. This makes the select-all case much faster. There are two cases which are still very slow: - List mode, because here all top-level items are queried. - Dive log with many only top-level items. Ultimately, we will have to cache the trip selection because querying the model is too slow. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26desktop: select dives at onceGravatar Berthold Stoeger
The old code would call QItemSelectionModel::select() once for every dive. Instead collect the selection in a QItemSelection and only call QItemSelectionModel::select() once. This makes selecting multiple dives significantly faster. The loop also expanded the trips with selections. This has now to be done in an extra loop. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26dive list: don't access selected dives via indicesGravatar Berthold Stoeger
When determining the selected dive sites to highlight them on the map, the DiveListView code used the local indices of the selected dives. However, that was unreasonably slow. Even though a layering violation, let's access the core data structures directly. In my tests this improved from 700 ms to 0 ms! Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26cleanup: make DiveListView slots privateGravatar Berthold Stoeger
It makes reasoning about code so much easier when one knows that functions cannot be accessed from the outside. Therefore, make a number of DiveListView slots private. Moreover, unslotize functions that never were used in connect calls. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-26selection: move test for programmatical selection changes to widgetGravatar Berthold Stoeger
The DiveListView widget has to differentiate between programmatical und user-initiated selection changes. It did so by using the DiveListNotifier::inCommand() flag. However, 1) There is only one point of entry for such selection changes, viz. the MultiFilterSortModel::selectionChanged() signal 2) This signal is not only emitted in command-context. Another source is for example dive-map selection changes. Therefore, move the programmatical-selection-change status down to the widget and set/reset it in the diveSelectionChanged() slot. This makes "select all visible dive sites" somewhat faster. Sadly, not as much as expected. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25cleanup: make various functions in DiveListView privateGravatar Berthold Stoeger
Outside callers had no business calling these functions. Especially some functions that were simply there to override default DiveListView behavior. Mark these as overridden. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25cleanup: remove DiveListView::selectDives()Gravatar Berthold Stoeger
This was used by the map to select dives. However, the map now calls the core function directly, so this can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25map: call set_selection() core function to select divesGravatar Berthold Stoeger
The map widget called the dive list to select dives. This is inconsistent and complex. The dive list has to call down to the core anyway. Therefore, change the code to call the common core function. This means that we have to transform integer ids into dive-pointers. That is a bit sad, because the dives were just transformed into indices. Let's address that in a future commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25desktop: remove selectionChangeDone() from DiveListView::selectDive()Gravatar Berthold Stoeger
This was erroneous, as it should only be called at the end of a selection change, not after every single dive. It made selection of multiple dives extremely slow. Reported-by: Jan Mulder <jlmulder@xs4all.nl> Debugged-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25desktop: fold DiveListView::selectDive into DiveListView::selectDiveGravatar Berthold Stoeger
DiveListView::selectDive() is an overloaded function. The second version was only called by the first version, so we can fold one into the other. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25desktop: remove scrollto default parameter of DiveListView::selectDive()Gravatar Berthold Stoeger
No caller was using that parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25desktop: remove selection-code to select a new current_diveGravatar Berthold Stoeger
The undo-machinery makes sure that a current_dive always exists after an undo command. This part of the code should never be called. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25desktop: don't select current dive after collapsing tripsGravatar Berthold Stoeger
This appears to be an artifact. Collapsing does not unselect the current dive, so reselecting it appears pointless. Also it is unclear why the selection should be restricted to a single dive after collapsing. Probably that was originally meant to expand only the trip with the current dive in it? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-25desktop: make DiveListView::selectDive() privateGravatar Berthold Stoeger
Thus, it is made clear that these member functions can only be accessed from DiveListView itself. This should make debugging easier. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24cleanup: move clearing of event names to clear_dive_file_data()Gravatar Berthold Stoeger
Move this to the core so that desktop and mobile don't have to call this explicitly. Matter of fact, mobile didn't call this. It is unclear, whether that was even used on mobile, though. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24cleanup: move clearing of device nodes to clear_dive_file_data()Gravatar Berthold Stoeger
It makes no sense to keep the device nodes if all the other data is cleared. Let's do this automatically and not explicitly. This ensures that the function is also called on mobile. Currently it was only called on desktop. Weirdly, the parser-tests were expecting that the device nodes were not reset by clear_dive_file_data() and therefore divecomputers were accumulating in the test results. Thus, the additional computers had to be removed from the expected test results. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24filter: implement filtering for divemodeGravatar Berthold Stoeger
This only checks the first divecomputer as the semantics for multiple dive computers with different dive modes are not clear. Should we check them all? The implementation is a bit hackish: the indexes [0...n] of the combobox are mapped onto [-1...n-1], where -1 means don't filter and n-1 is the last valid dive mode. Implements #2329 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21cleanup: replace constructs of the type &vector[0] by vector.data()Gravatar Berthold Stoeger
It appears that some misguided compiler / library combinations crash on &vector[0] for empty vectors. Even though very unfriendly, they are technically correct, so let's remove these constructs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-21desktop: don't access first data element if no cylindersGravatar Berthold Stoeger
TabDiveInformation::updateProfile() does some statistics via the per_cylinder_mean_depth function. It passes down arrays with one entry per cylinder, which are allocated by means std::vector. To pass the array, the expression "&vector[0]" is used. It seems like some compilers through an assertion violation if vector has no elements. They are technically correct in that this is undefined, but still this appears like very unfriendly behavior. After all, std::vector should behave just like a dynamic C-array that is automatically freed, when going out of scope. Replace the "&vector[0]" by "vector.data()" and don't do the call if there aren't any cylinders for good measure. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-20desktop: rearrange widgets on the dive site tabGravatar Berthold Stoeger
Move the more commonly used filter to the left and the less commonly used "purge unused sites" button to the right. Add a spacer so that the filter-textbox doesn't extend over the whole free space. With apologies to sinistroverse users (is there an option to make the layout direction depend on the locale?). Suggested-by: Hartley Horwitz <hhrwtz@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-19desktop: remove user surveyGravatar Dirk Hohndel
We have never made good use of the results. Let's just remove it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-18Reorganise and reword divelog export panelGravatar willemferguson
Perform slight reorganisation and rewording of the divelog export panel. Specifically the wording is changed and expanded to make clear the 2 types of export of profile data. All the CSV export options are grouped together. With respect to profile export to CSV format, it is made clear that one option concerns export of dive computer-related profile data, whereas the other option involves export of computed dive profile data from the Dive Profile panel. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
2020-04-13desktop: remove special QGroupBox stylesheet for non-Windows systemsGravatar Berthold Stoeger
That style-sheet made things look really ugly on most Linux themes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12delegates: remove TankInfoDelegate::createEditor()Gravatar Berthold Stoeger
When creating a TankInfoDelegate editor, reploting of the profile was disabled to avoid replotting when the user scrolls through the tank-info list. Since the code was changed to only set the tank-info when the editor is closed, this became unnecessary (hopefully). Indeed the clearing of the flag was removed in a previous commit. This means that we also have to remove the setting of the flag. Since this is all the TankInfoDelegate::createEditor() function was doing, we can remove the whole function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12cleanup: remove unnecessary profile update after adding new diveGravatar Berthold Stoeger
MainWindow::on_actionAddDive_triggered() updated the profile after calling Command::addDive(). However, that is redundant because the undo-machinery does the profile reload. Remove the call. 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