aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget
AgeCommit message (Collapse)Author
2018-08-15profile-widget: remove SettingsObjectWrapper and update qPref callsGravatar jan Iversen
remove use of SettingsObjectWrapper:: remove include of SettingsObjectWrapper.h use qPrefFoo:: for setters and getters replace prefs.foo with qPrefXYZ::foo() where feasible (this expands to the same code, but gives us more control over the variable). Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-14core: activate qPrefPartialPressureGasGravatar jan Iversen
remove PartialPressureGas from SettingsObjectWrapper and reference qPrefPartialPressureGas update files using SettingsObjectWrapper/PartialPressureGas to use qPrefPartialPressureGas this activated qPrefPartialPressureGas and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-12core: activate qPrefTechnicalDetailsGravatar jan Iversen
remove TechnicalDetails from SettingsObjectWrapper and reference qPrefTechnicalDetails update files using SettingsObjectWrapper/TechnicalDetails to use qPrefTechnicalDetails this activated qPrefTechnicalDetails and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-07profilewidget: remove warning of unused varGravatar jan Iversen
SUBSURFACE_MOBILE does not include the single function that uses the variable add #ifndef SUBSURFACE_MOBILE to avoid warning Signed-off-by: Jan Iversen <jani@apache.org>
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-18Dive media: transport dive-id in drag'n'drop eventsGravatar Berthold Stoeger
9efb56e2d43161d952efb444d1f13d87bfdd45b5 introduced rather complex logic for picture drag'n'drop events onto the profile. Among other things, the code had to check whether the picture actually belongs to the displayed dive. This can be simplified by transporting the dive-id in the drag'n'drop event structure. The flow goes like this: DivePictureModel--(1)-->DivePictureWidget--(2)-->ProfileWidget For (1), we can use the Qt::UserRole role. This was used to transport the picture-offset, but this is not needed anymore since ProfileWidget was decoupled from DivePictureModel. For (2), we simply replace the "position" value, which was never used. Why would the receiver care which pixel was pressed in the media-tab? This commit also contains a minor cleanup in DivePictureWidget: QListView::mousePressEvent(event) was called in both branches of an if and can therefore be removed from the if. This is so trivial, that it doesn't warrant its own commit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-16Dive media: fix stacking of thumbnails in profile plotGravatar Berthold Stoeger
9efb56e2d43161d952efb444d1f13d87bfdd45b5 added code to rearrange pictures on drag'n'drop. To keep the correct repainting order (i.e. later thumbnails are painted on top of previous thumbnails), the z-value was set accordingly. In principle a sound idea, but it did not work out, because on hoverEnter and hoverExit events, the z-values were modified, thus restoring the wrong drawing order. Instead, use the QGraphicsItem::packBefore() function. Experimentation showed that this only works if stacking is done from the back of the list. Silence an erroneous compiler warning by initializing a variable to 0.0. 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-07-04core/profile: move PP_GRAPHS_ENABLED from pref.hGravatar jan Iversen
PP_GRAPHS_ENABLED is only used in profilewidget2.cpp make local to profilewidget.cpp Signed-off-by: Jan Iversen <jani@apache.org>core/profile: move PP_GRAPHS_ENABLED from pref.h
2018-06-29Dive pictures: connect DivePictureModel signals in constructorGravatar Berthold Stoeger
The DivePictureModel signals were connected int the setProfileState() function of ProfileWidget2. If this function was called repeatedly (e.g. after adding a dive), multiple connections were made, which led to multiply delivered signals. This in turn led to confusion, when deleting pictures (i.e. multiple pictures were deleted). Instead, connect once in ProfileWidget2's constructor. It is unclear whether these signals should be disconnected temporarily if no pictures are shown. In any case, the weren't, so this shouldn't introduce any regression. Fixes #1441 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24Copy divemode to ReplanGravatar Robert C. Helling
this needs copying the divemode from the dive to the plan. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-06-18Change from gettextFromC::instance()->tr() to gettextFromC::tr();Gravatar Stefan Fuchs
Code cleanup. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18Use correct "tr" call for translating dive mode namesGravatar Stefan Fuchs
Correctly use gettextFromC::instance()->tr(); instead of a simple tr(); to translate the dive mode names. This goes on top of 0bc9edf855caf95e2d58ccaf704ceeda079e06f1 and finally makes the whole thing work. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Fix an error around translation of dive modes in the UIGravatar Stefan Fuchs
This fixes an mistake introduced in 3d1072f8862e4c329dc2678df52a24137b8d4704 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Enable translation for even name "modechange"Gravatar Stefan Fuchs
Enable translations for dive event name "modechange". But clearly don't do this for the string which is used internally but only push "modechange" to the translation system to be able to translate it in the UI. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Remove a useless translation in diveeventitem.cppGravatar Stefan Fuchs
Giving the string ": %1" to translation makes no sense. And it's also not consistent with code a few lines below this line. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Code cleanup: Correct typo "Swith" to "Switch"Gravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-09profile: make profile self containedGravatar jan Iversen
move qmlprofile.* to profile dir, to keep all parts of the widget in one place. Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-09profile: clean double calls on mobile versionGravatar jan Iversen
Expanded #ifdef MOBILE with #else so that settings are only called once. Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-04Dive picture: fix toggling of picture-visibilityGravatar Berthold Stoeger
In a recent commit, the profile widget was changed to reuse DivePictureItems. This made toggling of picture-visibility disfunctional, because the visibility was set in the constructor. Only on change of dive would the setting take effect. Therefore, move the setting of the visibility up to the ProfileWidget2::plotPictures() call. This is more consistent anyway, since at this level pixmap and fileUrl are set. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04Profile: open pictures using local file pathGravatar Berthold Stoeger
Make the behavior of the profile-pictures consistent with the pictures in the photos-tab: Use the local file path to open the picture in the system viewer instead of the canonical filename (which might point to a non-existing location). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-29desktop: use QElapsedTimer to measure timeGravatar jan Iversen
QElapsedTimer is the preferred timer for measuring time so lets use it. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-28Distinguish between user and internal divemode namesGravatar Robert C. Helling
The former should be translated but not those that go to xml/git. ... and fix capitalization of pSCR. Suggested-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-24profile-widget: set printmode but allow events for ssrf-mobileGravatar jan Iversen
Reactivate printMode true for ssrf-mobile to avoid font problems, do not discard events if ssrf-mobile (even though printMode is true) Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-24profile-widget: replace (void) with no parameter nameGravatar jan Iversen
Unused parameters in C++ are "silenced" by removing the name. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21profile-widget: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
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-21Dive pictures: change removePicture() interfaceGravatar Berthold Stoeger
The function removePicture() had a flag "last", which would indicate that the called had finished removing pictures. Only then would the model be recalculated. This is a strange interface and, matter of fact, the caller was buggy: if the last picture to be removed didn't have a proper url, removePicture() was never called with "last" being set. Change the interface to take a list of pictures to be deleted. This will allow us to make picture deletion smarter in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21Dive pictures: use modelReset signal when reseting picture listGravatar Berthold Stoeger
In the old code a combination of removeRows()/insertRows() was used to signal a model reset. Replace this by a single, modelReset signal. This saves a call to plotPictures() and will allow us to be smarter in the future, when removing pictures. Reset-model and remove-items are semantically different. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-21profile-widget: divepixmapitem.cpp, silence unused parameterGravatar jan Iversen
remove parameter name for not used parameter, to silence unused warning. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21profile-widget: profilewidget2.cpp, silence unused parameterGravatar jan Iversen
Add Q_UNUSED for not used parameter Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-19Profile: minor coding style issues concerning axis-ticksGravatar Berthold Stoeger
1) Fix the English of a comment. 2) Remove a number of int-to-double compares: Make "steps" an integer variable (the number of steps). Rename the old double "steps" variable to "stepsInRange". This gives a non-integer number of steps and is necessary to calculate the correct step size 3) Replace a "x = x/y" by a "x /= y" construct. 4) Remove an unnecessary if clause. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-19Profile: Fix leak in animationGravatar Berthold Stoeger
If animDelete() was called with prefs.animation_speed == 0, the object would not be marked for deletion, as opposed to calling with prefs.animation_speed != 0. This would leak the objects. Therefore delete the objects if called with prefs.animation_speed == 0. The caller doesn't keep a reference to the objects. Therefore, a plain delete is fine, as opposed to a deleteLater(). While touching this function, use the function-pointer version of connect(). 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-17Dive pictures: Fix crash on picture deleteGravatar Berthold Stoeger
The recent simplification of the close button code introduced a crash: Deletion of pictures caused an invalid memory access, because the CloseButtonItem was deleted with the parent DivePicture item. For some (not fully understood!) reason, a reference to this button was stored in the depths of Qt. Empirically, it was found out that removing the first line of the pair QGraphicsItem::mousePressEvent(event); emit clicked(); fixed the crash. It seemed therefore prudent to remove the whole questionable signal/slot mechanism and directly call the removePicture() function of the parent. Thus, the intermediate DiveButtonItem class became unnecessary and was removed, leading to a shallower class hierarchy. Unfortunately, CloseButtonItem must still be derived from QObject owing to the Q_PROPERTY machinery, which is in turn needed for animation. To make this compile on mobile, the conditional compilation of removePicture() (#ifndef SUBSURFACE_MOBILE) was removed. After all, if DivePixmapItem is used, there are pictures, so removePicture() should be functional. Conditional compilation should concern the whole class, not only this function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-14Rename enum dive_comp_type to divemode_tGravatar Robert C. Helling
...as the usuage is not anymore about a computer but a momentary dive mode. Rename the end indicator as well. Signed-off-by: Robert C. Helling <helling@atdotde.de>
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-14Show divemode swith options only for rebreather divesGravatar Willem Ferguson
The dive profile context menu gets rather long with three additional divome switches that can be selected. This is now changed so that the additional options are only shown when in CCR or in PSCR divemode. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
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-05-14Read and write divemode changes (xml and git)Gravatar Willem Ferguson
This provides for reading of divemode change events from dive logs and for writing them to dive logs. This applies to xml and git divelogs. Divemode change events have the following structure: event->name = "modechange" event->value = integer corresponding to enum dive_comp_type (dive.c), reflecting the type of divemode change (OC, CCR, PSCR, etc). In the dive log file, the event value is written as a string that corresponds to each of the enum values, e.g. <event name='modechange' divemode='OC' /> This xml is also read from the dive log file and translated to an appropriate value of event->value. The file diveeventitem.cpp was udated to reflect this new way of dealing with divemode change events. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Provide icons for bailout events on the dive profile.Gravatar Willem Ferguson
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Core: remove dive.h from files that don't need itGravatar Dirk Hohndel
Of course, quite a few of them indirectly get it through other header files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-13Dive pictures: Don't update all pictures on drag & drop to profileGravatar Berthold Stoeger
In the old code, we used to reload the whole picture list on drag & drop to the profile. Instead, only update the drag&dropped picture and repaint the profile-pictures. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>