aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/maintab.cpp
AgeCommit message (Collapse)Author
2021-08-18Remove the divecomputer naming tabGravatar Linus Torvalds
The TabDiveComputer model won't work in the new world order, where you can't even insert a new device entry without a nickname to be edited. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-04-02desktop: query DivePlannerPointsModel for planner stateGravatar Berthold Stoeger
MainTab::updateDiveInfo() is not executed when in the planner. To decide whether the application is in the planner state, it queried the profile. Instead, query the DivePlannerPointsModel. Currently, there is no autoritative carrier of that flag. However, the MainTab has a dependency on DivePlannerPointsModel anyway, and therefore this removes a dependency on the profile. This brings us closer to a state where we can have multiple profiles. Ultimately, it is hoped that the whole check can be removed at this place, making the point moot. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-02desktop: remove check for editMode in maintabGravatar Berthold Stoeger
The accept / reject message is only shown in edit-mode, no need to check it. This is a step in simplification / removal of the edit mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-04-02profile: display arbitrary diveGravatar Berthold Stoeger
So far the profile operated on the global displayed_dive. Instead, take the dive to be displayed as a parameter to the plotDive() functions. This is necessary if we want to have multiple concurrent profile objects. Think for example for printing or for mobile where multiple dive objects are active at the same time. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-02-06desktop: don't access profile directly to redraw itGravatar Berthold Stoeger
The MainWindow has a function to replot the profile. Use that instead of accessing the profile directly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-10profile: remove ProfileWidget2::dateTimeChanged()Gravatar Berthold Stoeger
This function sent a signal and the only listener was removed in the previous commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-01-03desktop: rename Statistics tab to SummaryGravatar Dirk Hohndel
We now have three different things that are kinda like statistics: - the summary tab (reasonably useful when looking at selected dives) - the yearly statistics (Ctrl/CMD-Y) - the full statistics (Ctrl/CMD-T) I'd argue that's at least one too many. But I'm sure some people will disagree. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-12-12preferences: create global settingsChanged signalGravatar Berthold Stoeger
So far, the PreferencesDialog emitted a settingsChanged signal. This meant that models that listened to that signal had to conditionally compile out the code for mobile or the connection had to be made in MainWindow. Instead, introduce a global signal that does this and move the connects to the listeners to remove inter-dependencies. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-14cleanup: remove empty function MainTab::reload()Gravatar Berthold Stoeger
This used to reload the completion models. Moreover, remove two obsolete member-function declarations. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-14desktop: automatically reload completion-modelsGravatar Berthold Stoeger
Instead of programatically reload the completion models, listen to the relevant signals in the models. To that goal, derive all the models from a base class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-12desktop: update completion models if dive was editedGravatar Berthold Stoeger
In the main-tab, when changing tag, buddy or divemaster, update the corresponding completion model. This is a quick-fix and the wrong thing to do. It works only if the currently shown dive is changed, which is not a given. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-04revert preference settings for title colorGravatar Dirk Hohndel
Because of subsequent changes there is no clean way to just revert the changes introduced in commit 8b36cf1051 ("desktop: offer different colors for info tab titles"), so this manually removes the parts we don't need anymore. This also restores a tooltip value that was inadvertantly removed in that commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-04desktop: automatically pick a good theme title colorGravatar Dirk Hohndel
The preference setting seemed far too strange to do this. And not very user friendly. So instead we figure out if this is a dark theme or not by looking at text and background colors in the palette, and make sure we get notified if that changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03desktop: generalize the colorization of the tab widgetGravatar Dirk Hohndel
Instead of doing it just for the Information tab, do it for all of the tabs. There's still room for improvement. But this certainly feels more consistent. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-11-03desktop: allow update of tab widget colors at run timeGravatar Dirk Hohndel
Adding a new virtual function to all of these classes may seem like overkill, but of course the idea is that likely we'd allow similar changes to all of them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-28cleanup: remove unnecessary includes from maintabGravatar Berthold Stoeger
These are artifacts from when the maintab contained more stuff. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25desktop: add tab-widget for dive computer namesGravatar Berthold Stoeger
If we want to include dive computer names in the undo system, there should be visual feedback on undo/redo. This would mean opening the divecomputer dialog, which would appear quite strange. Therefore, add a tab. This is not ideal, but consistent with the dive site tab, which probably shouldn't be there either. In the future, the UI needs some rethinking. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: create common QDateTime -> timestamp conversion functionGravatar Berthold Stoeger
In analogy to the timestamp -> QDateTime conversion, create a common function. 1) For symmetry with the opposite conversion. 2) To remove numerous inconsistencies. 3) To remove use of the deprecated QDateTime::toTime_t() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22cleanup: move timestampToDateTime() to qthelper.cppGravatar Berthold Stoeger
Move this function from maintab.cpp to qthelper.cpp. Since the functionality was used in numerous places, use the helper function there as well. This removes a number of inconsistencies. For example, sometime setTimeSpec(Qt::UTC) was called, even though the QDateTime object was already created with that time spec. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-22desktop: update date and time fields if user changes formatGravatar Berthold Stoeger
This was more painful than expected, because we get the "preferences" changed signal too early when the user switches to system format. The correct format is set by the preferences-widget, not the preferences subsystem. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-08desktop: hide/unhide tags if dive site was editedGravatar Berthold Stoeger
The tags of the dive site were shown/hidden when changing the current dive. Thus the following could happen: 1) User changes to dive with no tags. Tags are hidden. 2) User add image, which creates GPS tag 3) Tag is updated but not shown. Fix this by showing/hiding tags when they are calculated not when switching the dive. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-07cleanup: free tab-widgets when exiting the applicationGravatar Berthold Stoeger
This is completely irrelevant, however out of principle, let's free the tab-widgets at the end of the application. To do so, use Qt's object hierarchy. I'm not a fan of this kind of memory management, but it is how it is. Moreover, remove the explicit constructor of MainTab, since it doesn't differ from the default constructor anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07cleanup: remove clearing of displayed_dive in MainTab constructorGravatar Berthold Stoeger
Clearing displayed_dive here makes no sense for two reasons: 1) This is only called on startup, when displayed_dive is not yet initialized. 2) The tab-widgets don't use displayed_dive anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-07desktop: update tab info only if current_dive is setGravatar Berthold Stoeger
If current_dive was not set, the code would clear the tabs right after updating the data. We might just as well set the data only if current_dive is set. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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-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-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-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-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-07desktop/tabwidgets: replace editMode by booleanGravatar Berthold Stoeger
There was only one editMode left (MANUALLY_ADDED_DIVE). Therefore replace by a flag. This makes the code more consistent, because the conditions "editMode != NONE" and "editMode == MANUALLY_ADDED_DIVE) actually meant the same thing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07desktop/tabwidgets: replace IGNORE_MODE by flagGravatar Berthold Stoeger
The editMode was set to IGNORE_MODE when programatically setting fields so that we can ignore changed-signals. That seems to be orthogonal to whether we are in edit mode and indeed when setting IGNORE_MODE the edit mode was saved and restored. Therefore, replace the IGNORE_MODE by an independent ignoreInput flag. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove parameter to MainTab::enableEditionGravatar Berthold Stoeger
All remaining callers were passing MANUALLY_ADDED_DIVE as a new mode, so we may just as well remove the parameter and thus simplify the logic. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07desktop: remove EDIT modeGravatar Berthold Stoeger
The only way to enter edit mode is to edit the profile. However, that means that the profile is already visible, so there is no need to change the mode. Simply remove the EDIT mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07desktop: don't disable tabs in edit stateGravatar Berthold Stoeger
The edit state is now only used to edit the profile. There is no reason to disable random tabs. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: don't center map on rejecting editGravatar Berthold Stoeger
The editing of the dive site is controlled via an undo command. No point in centering the map when cancelling a profile-edit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove lastMode variable in MainTab::rejectChanges()Gravatar Berthold Stoeger
This stored the old editMode. However, it was not read after editMode was changed, so there is no point to it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07edit: remove multi-dive version of edit informationGravatar Berthold Stoeger
The "dive is currently" edited is only shown when the profile is edited. This affects only the current dive and therefore a message saying that multiple dives are edited makes no sense. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove strange recursive code in MainTab::enableEditionGravatar Berthold Stoeger
When enableEdition() was called with mode == NONE and the dive was a manually added dive, it would call into MainWindow:: editCurrentDive(), which would in turn call enableEdition(), however with another mode. Since the only caller of enableEdition() is now editCurrentDive() anyway, we can remove that weird code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: remove cylinders_equal check in MainTab::rejectChanges()Gravatar Berthold Stoeger
This check make no more sense since cylinder editing is now treated by undo commands. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: remove TabDiveWidget::acceptChanges and rejectChangesGravatar Berthold Stoeger
Since cylinders are now edited using the undo system, these functions are not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-18models: update divesite-model when clearing/updating dive modelGravatar Berthold Stoeger
When the dive list is cleared or updated, the entries in the divesite-model become stale and therefore the divesite-model (with the actual name LocationInformationModel) also must be updated. This was done manually in some parts of the code and forgotten in others. Therefore, do it directly in the clear() and reset() function of the dive list-model. This might be a bit of a layering violation: why should one model call into another if they are not in parent/child relationship? However, this seems easier than introducing a global "reset dives" function that coordinates the models. Moreover, it does not appear 100% safe: if the clearing of the divesite model causes accesses to the divelist-model, they happen in the midst of a model reset and we had horrible bugs with that kind of things. However, I don't think that should happen. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06Cleanup: Move stringToList to core/qthelper.cppGravatar Berthold Stoeger
The same code was used in desktop and undo commands. Let's unify. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-06Cleanup: use getDiveSelection() for shifting timeGravatar Berthold Stoeger
There are two cases where dive-times are shifted: in an explicit dialog and when editing the date/time of a dive. In each of these cases, the selected dives were collected manually. Instead use the getDiveSelection() function. Since this returns a std::vector, change the argument of Command::ShiftTime() to such a std::vector. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-28cleanup: remove setTabIcon() calls in MainTabGravatar Berthold Stoeger
These were used to remove warning-icons to mark tabs with user changes. However these icons haven't been set since commit a86aca037843167b26726926dbf2aebe0513afba. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27cleanup: don't update tabs twice in MainTab::rejectChangesGravatar Berthold Stoeger
The updateDiveInfo() call updates all tabs. No need to do it right afterwards. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27cleanup: remove weightsystems_equal functionGravatar Berthold Stoeger
This was used to test whether the "really discard changes?" message should be shown. However, we now edit weightsystems directly with undo commands. Therefore, the check is unnecessary and the whole function can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-27cleanup: remove MainTab::modifiedGravatar Berthold Stoeger
This field was not set to true since introducing undo of dive fields. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04Cleanup: remove unnecessary remember/restoreSelection() pairGravatar Berthold Stoeger
When accepting changes, the main tab refreshes the display in a remember/restoreSelection() pair. Since the display refresh doesn't lose selection, these calls can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04Selection: move selection functions from divelist.c to selection.cGravatar Berthold Stoeger
Since we now have a selection.c translation unit, put the selection- related functions there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-12-04Cleanup: Fix order of initialization in MainTab::MainTab()Gravatar Berthold Stoeger
For deterministic construction/destruction (i.e. objects are destructed in reverse order of construction) it is crucial that constructor initializer lists follow the order of the class definition. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>