aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget/profilewidget2.h
AgeCommit message (Collapse)Author
2020-01-30Cleanup: remove redundant(?) commentGravatar Berthold Stoeger
We don't have such a comment anywhere in the code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-30Profile: transport gas id and timestamp via lambdaGravatar Berthold Stoeger
When adding a gas change event via a context menu, the gas-id and timestamp were passed in two distinct ways. 1) The gas id was extracted from the text of the action. This meant doing rather complicated parsing. 2) The timestamp was passed via the "user data" of the action, which means transporting via "QVariant". There is a much simpler way to pass arbitrary data, that is strongly typed: lambdas. Instead of shoehorning the data onto the action in an archaic way, we can simply connect to a stateful lambda. That's what they're for after all. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-19Cleanup: remove ProfileWidget2::refreshDisplay signalGravatar Berthold Stoeger
It was not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09Cleanup: free plot data on exitGravatar Berthold Stoeger
Some widgets copy the full plot info. Free these data on exit to prevent monstrous valgrind reports. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-08Profile: remove ProfileWidget2::recalcCeiling()Gravatar Berthold Stoeger
The ProfileWidget2::recalcCeiling() function is used in one place, namely when an undo-command changes the mode. It recalculates decompression data and repaints the ceilings and thus avoids a full profile-redraw. This is smart, but it becomes problematic when the dive is changed and the ceiling is recalculated before the profile is redrawn. The DivePlotDataModel then still has data from the previous dive but cylinders of the new dive are accessed. This kind of situation may arise if multiple dive fields are updated, as for example when replanning a dive. Currently, this only causes a temporary mis-calculation. When removing MAX_CYLINDERS this will lead to crashes. One might attempt to fix the whole data-dependency mess. This commit goes the cheap route and simply redraws the profile when the mode is changed. Yes, it is in a way ineffective, but we do worse things. The ProfileWidget2::recalcCeiling() thus becomes unused and is removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-12Profile: stop animations on exportGravatar Berthold Stoeger
The plotDive() function had a flag to plot pictures asynchronously. This was used on export. Rename this field to "instant" and disable animations when set. This should make sure that the axes are properly exported. Fixes #2170 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-12Profile: store animation speed in profile objectGravatar Berthold Stoeger
When exporting dive pictures we don't want animations. Therefore, store the animation speed in the profile object to avoid nasty hacks with the preferences. This actually removes such a hack. Pictures and tooltips for now still use the values stored in the preferences, because their animations happen only on user-interactions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Desktop: read tab-items from current_dive, not displayed_diveGravatar Berthold Stoeger
The whole edit logic moved from displayed_dive to current_dive and it became more and more tedious to keep these in sync. Therefore, simply always display current_dive. The only exceptions are the equipment tab and the planner, as these are not yet integrated in the undo system. Once this is done, displayed_dive can be removed. Moreover, remove the clear parameter from updateDiveInfo(). Instead simply clear of there is no current_dive set. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-04Undo: implement split-out of dive computerGravatar Berthold Stoeger
Allow splitting out a dive computer into a distinct dive. This is realized by generating a base class from SplitDive. This turned out to be more cumbersome than expected: we don't know a-priori which of the split dives will come first. Since the undo-command saves the indices where the dives will be insert, these have to be calculated. This is an premature optimization, which makes more pain than necessary. Let's remove it and simply determine the insertion index when executing the command. Original code by Linus Torvalds <torvalds@linux-foundation.org>. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-07Make struct dive const in plotPicturesInternalGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2019-02-07Profile: plot pictures of correct diveGravatar Berthold Stoeger
The pictures of the current dive were plotted on the profile. In principle OK, as this is what the user is shown. Only on export this results in all profiles having the same pictures. Therefore, pass a dive argument to the picture-plotting function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-07Profile: add "synchronous" mode for picture plottingGravatar Berthold Stoeger
The thumbnails were fetched in the background to achieve a snappier UI. The problem with that is that on LaTeX etc. export only placeholder thumbnails were shown. Therefore, implement a synchronous mode. This only tries to fetch cached thumbnails or calculate thumbnails for images. Videos and remote files are not supported. Fixes #1963 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-02-07Export profile imageGravatar Robert C. Helling
With Facebook support gone, we should offer a way to export the profile image. This has been part of the TeX support but this makes it explicit. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-09-29Cleanup: reinstate override modifiersGravatar Berthold Stoeger
This reverts commit 1c4a859c8d0b37b2e938209fe9c4d99e9758327a, where the override modifiers were removed owing to the noisy "inconsistent override modifiers" which is default-on in clang. This warning was disabled in 77577f717f5aad38ea8c4c41c10c181486c4337f, so we can reinstate the overrides. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-07Cleanup: constify threshold pointers in DiveProfileItemGravatar Berthold Stoeger
These were pointers into the global prefs object. The user must not use these to modify the settings, therefore make them pointers-to-const. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-01Cleanup: remove all override modifiersGravatar Berthold Stoeger
Commit df156a56c08a56eb380711a507ef739d8150a71f replaced "virtual" by "override" where appropriate. Unfortunately, this had the unintended consequence of producing numerous clang warnings. If clang finds a override-modified function in a class definition, it warns for *all* overriden virtual functions without the override modifier. To solve this, go the easy route and remove all overrides. At least it is consistent. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-31Cleanup: replace virtual by override where appropriateGravatar Berthold Stoeger
The keyword "virtual" signalizes that the function is virtual, i.e. the function of the derived class is called, even if the call is on the parent class. It is not necessary to repeat the "virtual" keyword in derived classes. To highlight derived virtual functions, the keyword "override" should be used instead. It results in a hard compile- error, if no function is overridden, thus avoiding subtle bugs. Replace "virtual" by "override" where appropriate. Moreover, replace Q_DECL_OVERRIDE by override, since we require reasonably recent compilers anyway. Likewise, replace /* reimp */ by "override" for consistency and compiler support. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23Dive video: paint duration-bar above thumbnail in profile plotGravatar Berthold Stoeger
Paint a rectangle on top of thumbnails indicating the run-time of the video. Use the z=100.0-101.0 range for painting the thumbnails, whereby the z-value increases uniformly from first to last thumbnail (sorted by timestamp). The duration-bars are placed at z-values midway between those of the thumbnails. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-13Dive pictures: don't update all images on drag&drop to profileGravatar Berthold Stoeger
Gracefully handle drag & drop to the profile, which changes the offset of the pictures. To do this, keep the pictures in the DivePictureModel and the ProfileWidget2 sorted by offset and re-arrange if needed to keep the list sorted. This needs some code reshuffling. Introduce a helper-function that moves ranges in arrays. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13Dive pictures: update thumbnail positions on deletionGravatar Berthold Stoeger
If pictures were deleted, the remaining thumbails where staying at their positions. Only when switching between dives, the new positions were recalculated. Do the recalculation immediately. More precisely: the x-coordinate, which is determined by the timestamp, stays identical. Only the y-coordinate is recalculated such that overlapping of thumbnails is avoided. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-08Dive pictures: detach ProfileWidget2 from DivePictureModelGravatar Berthold Stoeger
As long as ProfileWidget2 and DivePictureModel showed the same set of pictures and any change would lead to a full recalculation of the set, it made sense to let ProfileWidget2 use DivePictureModel's data. Recently, keeping the two lists in sync become more and more of a burden. Therefore, disconnect ProfileWidget2 and DivePictureModel. This will lead to some code-duplication and perhaps a temporary drop in UI-performance, but in the end the code is distinctly simpler and also more flexible. Thus, for example the DivePhotoTab could be changed to support headings without having to touch ProfileWidget2 at all. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-03Profile context menu entry to split a diveGravatar Robert C. Helling
Allow the user to manually split a dive in two. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-17Code cleanup: Correct typo "Swith" to "Switch"Gravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-05-21Dive pictures: don't repopulate DivePictureModel on deletionGravatar Berthold Stoeger
On deletion of a single or multiple pictures, the whole DivePictureModel was repopulated, which was clearly visible in the UI, owing to the reconstructing of all images in the profile plot. To avoid this vexing behavior, implement proper deletion routines in DivePictureModel and ProfileWidget2. Since this needs sensible erase() semantics the QList<PictureEntry> member of DivePictureModel was replaced by a QVector. A QVector should be the default anyway, unless there are very specific reasons to use a QList (which actually is a deque, not a classical linked list). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-17Dive pictures: Don't plot pictures twice when changing current diveGravatar Berthold Stoeger
In MainWindow::current_dive_changed() first plotDive() is called, which replots all the pictures by calling plotPictures(). This is pointess, because it plots the pictures of the previous dive. Then, updateDiveInfo() is called, which resets the dive pictures and automatically replots them. Thus, switching between dives both with hundreds of pictures is way slower than necessary. Switching the plotDive() and updateDiveInfo() calls doesn't work. The reason is not 100% clear, but it doesn't make sense to plot pictures of the new dive as long as the profile still shows the old dive anyway. As a quick-fix, add a flag to plotDive(), which tells the function to clear the pictures list instead of redrawing it. Ultimately, plotDive() should probably be split in two functions. One for the callers who update the pictures themselves and one for the others. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-14Place divemode changes in submenu of context menuGravatar Robert C. Helling
Also unify the repeated code in slots. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-14Create divemode switches using profile context menuGravatar Willem Ferguson
Allow the manual creation of divemode switch events using the profile context menu. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-28Plot OC-pO2 graph for SCR divesGravatar Willem Ferguson
This commit allows plotting the OC-equivalent pO2 graph for PSCR dives. This happens in both the cases where there is no external O2-monitoring AND when there is external pO2 monitoring. The calculations are only done for PSCR dives and is achieved as follows: 1) Within plot-info create a pressure-t called OC_pO2 in profile.h and populate this variable with the open-circuit pO2 values in profile.c. 2) Create a new partialPressureGasItem ocpo2GasItem in profilewidget2.h and, in profilewidget2.cpp, initialise it to read the plot-info OC_pO2 values and enable its display by using the setVisible method. The diveplotdatamodel was also touched in order to achieve this. 3) Create a pref button that controls the display of OC-pO2 for SCR dives 4) Change the colour of the OC-pO2 grpah to orange 5) Change the connection of the crr_OC_pO2 signal to be appropriate 6) rename the OC_pO2 attribute to scr_OC-pO2 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-04-09Profile: Conditionally compile pictures-vector on mobile.Gravatar Berthold Stoeger
This vector is not used on mobile and cause iOS compilation to fail. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-09Profile: On dataChanged() only update pictures that actually changedGravatar Berthold Stoeger
Only update those pictures of the DivePictureModel that actually changed. This will be useful once pictures are loaded incrementally. To do so, replace the pictures array by an array with stable ids. Before this commit, not-shown pictures are left out of the pictures array, which makes the mapping from DivePictureModel-ids to the picture array index non-trivial. Replace the QList<DivePictureItem *> by a std::vector<std::unique_ptr<DivePictureItem>> to ease memory management. Sadly, owing to COW semantics, QVector is incompatible with QScopedPointer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Pictures tied to profile are not supported on mobileGravatar Jan Mulder
Move divepicturemodel.cpp to the desktop only category and deal with the (limited) fallout. We, currently, do not support dive pictures tied to the profile on mobile, so there is no use including this code. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10Typo: indice -> indexGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Replace CREATE_PP_GAS macro by member function in profilewidget2.cppGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Remove two arguments from ProfileWidget2::setupItem()Gravatar Berthold Stoeger
1) hAxis was always set to timeAxis 2) model was always set to dataModel Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Replace ADD_ACTION macro by member function in profilewidget2.cppGravatar Berthold Stoeger
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Remove unnecessary deletes in destructor of ProfileWidget2Gravatar Berthold Stoeger
All the deleted items were added to the scene, which takes "ownership" (a remarkably fuzzy concept in Qt) of these objects. In principle, deleting these items is a bug - even though it is handled gracefully. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-10Unused code: remove ProfileWidget2::isAddOrPlanner()Gravatar Jan Mulder
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-26desktop UI: no longer attempt to manually show error notificationsGravatar Dirk Hohndel
report_error() now does this automatically. So all these odd places in which we tried to make sure that we show errors are no longer needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-16code cleanup: remove unimplemented classes and structsGravatar Jan Mulder
Remove forward declared but not implemented classes and structs. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-29Add SPDX header to profile widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-26MOBILE: Display pO2 and Setpoint for CCR divesGravatar Joakim Bygdell
For CCR dives we want to display the setpoint and pO2 information, due to the limited screensize we have to remove the temperature graph or the view will be to cluttered. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2016-06-23Now that we are building with C++11 we need override keywordGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08Silence warnings in Profilewidget2Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-06Profile: don't compile code that isn't needed on mobileGravatar Dirk Hohndel
We were creating a couple dozen objects that we never needed and because of that triggered several dozen callbacks whenever the model data changed. All for UI elements of the profile that are either not used in the mobile app (like the calculated ceiling or the partial pressure / tissue saturation graphs), or are only useful when using the profile interactively (which we also don't do on mobile). I don't know if this will make a significant impact on performance, but it seems like the right thing to do either way. A positive side effect is that the odd blue line on top of the rendered profile is gone as well. Fixes #1007 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Start to use the QSettings ObjectWrapperGravatar Tomaz Canabrava
start of the QSettinsg Object Wrapper usage on the code this first patch removes two macros that generated around 200 lines in runtime for something like a quarter of it Basically, whenever we changed anything we called the PreferencesDialog::settingsChanged and connected everythign to that signal, now each setting has it's own changed signal and we can call it directly. The best thing about this approach is that we don't trigger repaints for things that are not directly profile related. ( actually we still do, but the plan is to remove them in due time) this commit breaks correct atualization of the profile (because everything was connected to PreferencesDialog::settingsChanged) and now I need to hunt a bit for the correct connections Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-24Drag and Drop ImagesGravatar Robert C. Helling
Now that we have the possibility to add images without meaningful time stamps to a dive, we should let the user provide that time offset manually. This patch allowed pictures to be dragged from the image list to the profile. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-06Untangle DiveCalculatedCeiling from MainWindowGravatar Lubomir I. Ivanov
DiveCalculatedCeiling is the last class the references MainWindow in the profile-widget stack. In modelDataChanged() it looks for the information() widget and sets a slot for the dateTimeChanged() signal that information() emits. To solve the issue we make DiveCalculatedCeiling recieve a ProfileWidget2 reference and make ProfileWidget2 emit the dateTimeChangedItems() signal. ProfileWidget2 itself listens for the dateTimeChanged() signal that information() emits and emits dateTimeChangedItems() to notify any possible children/item listeners in the ProfileWidget2::dateTimeChanged() slot. The connection between ProfileWidget2 and information() is set in MainWindow. This makes DiveCalculatedCeiling unaware of MainWindow and which class originally emits the dateTimeChanged() signal to ProfileWidget2. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> -- Think delegation. Tomaz, please take a look at this one, to double check if i messed up. also i have zero idea how the mobile app is setting these connections, if it does so even. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Profile: don't compile the desktop specific parts on mobileGravatar Dirk Hohndel
When building subsurface-mobile we won't be using all these UI elements, so let's not build them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-05Untangle Profile from MainWindow: edit current profileGravatar Dirk Hohndel
And action can't not just trigger a slot, it can also send a signal. With this there is no reference to the MainWindow left in the profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>