aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget
AgeCommit message (Collapse)Author
2020-12-12profile: move connect() calls to profileGravatar Berthold Stoeger
The mainwindow was connecting preferences changes to the profile. Do this directly in the profile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12cleanup: remove unused signal ProfileWidget2::updateDiveInfoGravatar Berthold Stoeger
Last user was remove in 0bd821183d. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12profile: move DiveHandler to profile-widget folderGravatar Berthold Stoeger
These are the small dots that describe dragable points on the profile when in the planner. It makes no sense to have them in desktop's planner-widget code. They belong to the profile. Therefore, move the code there and compile on mobile. Not everything can be compiled on mobile for now, but it is a start. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-12profile: call clearHandlers() in setPlanState()Gravatar Berthold Stoeger
This function, which removes the handlers from the profile, was called in setAddState() but not in setPlanState(). In the latter case it was called explicitly by the caller. Move the call from the caller into the function. This allows us to make clearHandlers() private in to the profile widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-10-26cleanup: replace deprecated swap() usageGravatar Dirk Hohndel
Instead of using the two different ways Qt supports swap, depending on the Qt version in use, let's simply use std::swap() Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: replace deprecated pos() memberGravatar Dirk Hohndel
Again, replacement was just recently added. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-26cleanup: replace long obsolete delta() memberGravatar Dirk Hohndel
This has been deprecated for years. The delta() member dealt with the old style mouse wheel that is associated with a vertical scroll - so we need the y-component. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-25cleanup: split out divecomputer functions from dive.cGravatar Berthold Stoeger
Since dive.c is so huge, split out divecomputer-related functions into divecomputer.[c|h], sample.[c|h] and extradata.[c|h]. This does not give huge compile time improvements, since struct dive contains a struct divecomputer and therefore dive.h has to include divecomputer.h. However, it make things distinctly more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: break out event-related code into event.[c|h]Gravatar Berthold Stoeger
In an effort to reduce the size of dive.h and dive.c, break out the event related functions. Moreover event-names were handled by the profile-code, collect that also in the new source files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-05Use get_n2 helper functionGravatar Robert C. Helling
Now, that we have this helper function that should have been introduced long ago, we can make some more expressions more idiomatic. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-09-13cleanup: fold core/divecomputer.cpp into core/device.cGravatar Berthold Stoeger
core/device.h was declaring a number of functions that were related to divecomputers (dcs): creating a fake dc for manually entered dives and registering / accessing dc nicknames. On could argue whether these should be lumped together, but it is what it is. However, part of that was implemented in C++/Qt code in a separate core/divecomputer.cpp file. Some function therein where only accessible to C++ and declared in core/divecomputer.h. All in all, a big mess. Let's simply combine the files and conditionally compile the C++-only functions depending on the __cplusplus define. Yes, that means turning device.c into device.cpp. A brave soul might turn the C++/Qt code into C code if they whish later on. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-08cleanup: remove count_divecomputers() functionGravatar Berthold Stoeger
There is a number_of_computers() function which does the same thing with two exceptions: 1) checks for null-dive 2) returns an unsigned int Replace calls to count_divecomputers() by calls to number_of_computers(). In one case, the return type makes a different - add a cast to int there. Ultimately, we should probably change the dc_number to signed int throughout the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-03Increase event icon size in print modeGravatar Robert C. Helling
When plotting the profile in higher resolution for export, increase the icon size in the same way. This is commented out for the mobile version as that uses printMode for profile display. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-26Add an "Edit Gas Change" right-click option.Gravatar Michael Werle
This new option allows a user to select a new destination tank for an existing "Gas Change" event. This is useful when Subsurface's heuristics get tanks wrong after an import from a divecomputer. The use-case arose from sidemount divers with air-integrated transmitters as well as carrying a deco tank. Signed-off-by: Michael Werle <micha@michaelwerle.com>
2020-05-06profile: clear pictures when displaying empty diveGravatar Berthold Stoeger
Since the profile does not listen to DivePictureModel resets anymore, the pictures weren't cleared when clearing the canvas. Do this explicitly. 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-06undo: implement undo of setting a picture time by drag&dropGravatar Berthold Stoeger
Even though the functionality is seemingly trivial, this is a bit invasive, as the code has to be split into two distinct parts: 1) Post undo command 2) React to changes to the divelist Don't compile that code on mobile. 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: use member-to-function style connect() statementsGravatar Berthold Stoeger
This makes things compile-time instead of run-time checked. 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-01profile: properly update lastgasmix when populating eventsGravatar Berthold Stoeger
When populating the events of a profile, a pointer to the current gasmix was passed around to properly calculate isobaric_counterdiffusion. The DiveEventItem::setupToolTipString() function updated this gasmix when processing gas change events. I inadvertently broke the code when replacing gasmix-pointers by values. We could of course simply revert this part of the commit. However, the data flow was horrible anyway: for example is supposed that the setup functions were called in the correct order (i.e. DiveEventItem::setupToolTipString() is called after all other functions using the gasmix). Not exactly easy to follow. Therefore, keep passing around the gasmix as value to make it clear that the functions don't modify it. Keep the gasmix up-to-date at the caller's site in ProfileWidget2::plotDive(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30cleanup: replace Q_ASSERT by qWarningGravatar Berthold Stoeger
These two Q_ASSERTs made no sense - their expression (a string literal) always evaluated to true. A qWarning() was intended here. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-27profile: set empty state when there is no current dive to showGravatar Berthold Stoeger
The profile data was not properly cleared when not showing a dive. Fixes #2787 Reported-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-24cleanup: move get_dc_nickname from qthelper.cpp to divecomputer.cppGravatar Berthold Stoeger
1) qthelper is already huge. 2) set_dc_nickname et al. is already there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13cleanup: turn protected into private membersGravatar Berthold Stoeger
Some profilewidget classes hat protected members which can be made private as there is no subclassing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-13cleanup: remove protected access specifier in ProfileWidget2Gravatar Berthold Stoeger
There were a number of protected member functions in ProfileWidget2. However no class subclassed ProfileWidget2, so this appears to have been an artifact. Therefore, make these functions private. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-12profile: remove ProfileWidget2::replotEnabledGravatar Berthold Stoeger
The last setter was removed in the previous commit. Let's remove this complexity. 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
2020-04-10media: move picture function from dive.c to picture.cGravatar Berthold Stoeger
Currently, move only those functions that do not access dive structures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: implement gas switchGravatar Berthold Stoeger
This is a bit hairy as - in theory - one gas switch can remove other gas switch(es) at the same timestamp. However, I did not find a way to test it. Moreover, it is not clear whether the dive-tabs are properly updated on undo/redo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: add event removal undo commandGravatar Berthold Stoeger
This was a trivial copy & past of the event-adding undo command with a switch of the undo() and redo() actions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: implement renaming of eventsGravatar Berthold Stoeger
There is a slight complexity here owing to the fact that the profile works on a copy of the current dive: We get a copy of the event and have to search for the original event in the current dive. This could be done in the undo command. Nevertheless, here we do it in the profile so that when in the future the profile can work on a non-copied dive we can simply remove this function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: switch SetpointDialog from divecomputer to dive + dc-numberGravatar Berthold Stoeger
Since pointers to divecomputers may not be stable, the undo commands take a dive + a divecomputer number. Update the SetpointDialog accordingly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: un-singletonify SetpointDialogGravatar Berthold Stoeger
We have too many global objects. There is no reason why this dialog should be a persistent global object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: add undo command for dive-mode switchGravatar Berthold Stoeger
This basically copies the bookmark code, with the addition that the dive mode is recorded in the text of the undo command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: replot profile if event changedGravatar Berthold Stoeger
Add a DiveListNotifer::eventsChanged signal, which is emitted when the events changed. This is very coarse, at it doesn't differentiate between signal addition / editing / deletion. We might want to be finer in the future. Catch the signal in the profile-widget to replot the dive if this is the currently displayed dive. Reuse the cylindersChanged() slot, but rename it to the now more appropriate profileChanged(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: implement addBookmark undo commandGravatar Berthold Stoeger
Create a new translation unit for event-related undo commands. Create a base class of commands that add events and one subclass that adds a bookmark event. Use this command in the profile-widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: demote slots in ProfileWidget2 to private functionsGravatar Berthold Stoeger
Since we call these with lambdas, they don't need to be slots anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: use QMenu::addAction() convenience overloadGravatar Berthold Stoeger
Since we removed the setData() calls of the QActions in ProfileWidget2::contextMenuEvent(), we don't have to manually generate the QActions. We can simply use the convenience overload of addAction() that takes a string and a functional. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: use lambdas to transport DiveEventItem to actionsGravatar Berthold Stoeger
The removeEvent(), hideEvents() and editName() actions need the DiveEventItem they are applied to. This was transported via QAction's user-data, which means casting to void and back. By using lambdas instead, this can be made perfectly type-safe: First we are 100% sure that we have a DiveEventItem because we check the result of a dynamic_cast<>. Then we can pass it to the even using its proper type. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: use lambda to transport event-time to context menu actionsGravatar Berthold Stoeger
This is not such a big gain as for addDivemodeSwitch(), but still simpler. Therefore, let's do it for consistency. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: don't set unnecessary action userdata for unhideEventsGravatar Berthold Stoeger
The unhideEvents context menu action was fed with the click-position. However, that was not used. Therefore, remove it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07profile: use lambda for addDivemodeSwitch callsGravatar Berthold Stoeger
The data was transported via the action in a most complicated way: The text was backtranslated. Simply use a lambda - perhaps hard to read, but much simpler to follow and less brittle. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07cleanup: use SAMPLE_EVENT_BOOKMARK in add_event() callsGravatar Berthold Stoeger
In two cases we were passing the magic value 8 instead of the symbolic SAMPLE_EVENT_BOOKMARK. Use the symbolic version instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-07undo: update profile on cylinder editingGravatar Berthold Stoeger
In the profile, catch cylinder-editing signals and redraw the profile if the currently displayed dive has changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-30cleanup: fix initialization order in QMLProfile constructorGravatar Berthold Stoeger
The compiler complains that members were initialized out-of-order. Even though this is not an issue here it is correct to emit a warning, since only then it is guaranteed that the objects are destructed in reverse-order with respect to construction. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-25mobile/profile: adjust offsets when scalingGravatar Dirk Hohndel
If the user is scaling out again we need to make sure that our offsets are adjusted so that we always show a subset of the profile and not 'empty space' outside of it. Instead of reimplementing the offset logic, let's just trigger another paint() call. This requires a trampoline function because of different signal and slot signatures. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-25mobile/profile: don't pan outside the actual profileGravatar Dirk Hohndel
When zooming and panning the profile, make sure we always show a subset of the profile and don't end up showing the empty space outside of the profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-03-11Grammar: replaces 'indexes' by 'indices'Gravatar Robert C. Helling
Grammar-nazi ran git grep -l 'indexes' | xargs sed -i '' -e 's/indexes/indices/g' to prevent future wincing when reading the source code. Unfortunatly, Qt itself is infected as in QModelIndexList QItemSelection::indexes() const Signed-off-by: Robert C. Helling <helling@atdotde.de>