aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
AgeCommit message (Collapse)Author
2020-05-06media: move addition of pictures out of create_picture()Gravatar Berthold Stoeger
If we want to make addition of pictures undoable, then create_picture() must not add directly to the dive. Instead, return the dive to which the picture should be added and let the caller perform the addition. This means that the picture-test has to be adapted. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06undo: make picture (media) deletion undoableGravatar Berthold Stoeger
The code is rather complex. Firstly, we have different representations of pictures throughout the code. Secondly, this tries to do add the pictures in batches to the divepicture model and that is always rather tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06Cleanup: remove DivePictureThumbnailThreadGravatar Berthold Stoeger
An empty class that was not used anywhere. This allows us to remove a few include files as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: remove unused local variableGravatar Berthold Stoeger
TabDivePhotos::saveSubtitles() had an unused local variable. Clearly a copy&paste oversight. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: put photo-view in row-selection modeGravatar Berthold Stoeger
It makes no sense to have the view in item-selection mode, since each picture represents a row. Thus we can remove a few lines of code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06media: don't send dive-id in drag&drop eventGravatar Berthold Stoeger
The profile-widget doesn't use that information anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06cleanup: don't call updateDivePictures in MainWindowGravatar Berthold Stoeger
That is already properly done by the photo-tabwidget, which displays the pictures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06desktop: avoid spurious undo commands for date/time editingGravatar Berthold Stoeger
The date and time fields of the main tab posted undo events for every date/timeChanged signal. Thus, when changing the day of the month to e.g. 21, this would result in two date change events: one to the 2nd and one to the 21st. This is very irritating. Instead listen to editingFinished() events, which thankfully exist for these widgets. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-06desktop: update statistics tab when cylinders changedGravatar Berthold Stoeger
The cylinder-based statistics where not updated when an undo command edited cylinder data. Do so. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>