aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget
AgeCommit message (Collapse)Author
2018-10-20Profile: show correct info box for multiple DCsGravatar Jan Mulder
Update the dive info box when toggling the chosen DC using the keyboard. The keyboard toggle does not generate a mouse move event, so this data was not repainted. For this, a sub-optimization of not repainting when not moving the mouse had to be removed. This does not impact ant performance as 99.9999% of the calls of the repaint are caused by mouse movement anyway. Fixes: #1802 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-10-11Undo: select dives after add, remove, merge, split dive commandsGravatar Berthold Stoeger
Select the proper dives after the add, remove, split and merge dives commands on undo *and* redo. Generally, select the added dives. For undo of add, remember the pre-addition selection. For redo of remove, select the closest dive to the first removed dive. The biggest part of the commit is the signal-interface between the dive commands and the dive-list model and dive-list view. This is done in two steps: 1) To the DiveTripModel in batches of trips. The dive trip model transforms the dives into indices. 2) To the DiveListView. The DiveListView has to translate the DiveTripModel indexes to actual indexes via its QSortFilterProxy- model. For code-reuse, derive all divelist-changing commands from a new base-class, which has a flag that describes whether the divelist changed. The helper functions which add and remove dives are made members of the base class and set the flag is a selected dive is added or removed. To properly detect when the current dive was deleted it became necessary to turn the current dive from an index to a pointer, because indices are not stable. Unfortunately, in some cases an index was expected and these places now have to transform the dive into an index. These should be converted in due course. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: isolate undo-commandsGravatar Berthold Stoeger
This refactors the undo-commands (which are now only "commands"). - Move everything in namespace Command. This allows shortening of names without polluting the global namespace. Moreover, the prefix Command:: will immediately signal that the undo-machinery is invoked. This is more terse than UndoCommands::instance()->... - Remove the Undo in front of the class-names. Creating an "UndoX" object to do "X" is paradoxical. - Create a base class for all commands that defines the Qt-translation functions. Thus all translations end up in the "Command" context. - Add a workToBeDone() function, which signals whether this should be added to the UndoStack. Thus the caller doesn't have to check itself whether this any work will be done. Note: Qt5.9 introduces "setObsolete" which does the same. - Split into public and internal header files. In the public header file only export the function calls, thus hiding all implementation details from the caller. - Split in different translation units: One for the stubs, one for the base classes and one for groups of commands. Currently, there is only one class of commands: divelist-commands. - Move the undoStack from the MainWindow class into commands_base.cpp. If we want to implement MDI, this can easily be moved into an appropriate Document class. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Undo: implement rudimentary support for undo of dive-splittingGravatar Berthold Stoeger
For this, the core functionality of the split_dive() and split_dive_at_time() functions were split out into new split_dive_dont_insert() and split_dive_at_time_dont_insert(), which do not add the new dives to the log. Thus, the undo-command can take ownership of these dives, without having to remove them first. The split-dive functionality is temporarily made desktop-only until mobile also supports "UndoObjects". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-08Mobile: show temperature graph when no gas graphGravatar Jan Mulder
In commit bd0c99dfb71 (display pO2 and Setpoint for CCR dives) the choice was made: when CCR than never a temperature graph. While this seems reasonable, there is small group of mCCR divers that do not log their po2 digitally, so the only po2 they can display is the setpoint that is reported by the used DC. As this is a bit of a dull flat line, most of these divers do not display this. And this leaves room on the small mobile display for the temperature data. So effectively: show temperature or po2 graphs. Suggested-by: Peter Zaal <pzaal@xs4all.nl> Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
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-11desktop/profile-widget: update signal from _changed to ChangedGravatar jan Iversen
Update connect calls to use Changed from qPref, due to QML demands Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-10Profile: fix SAC calculation for air divesGravatar Berthold Stoeger
Commit f5b11daffd6f240268ce78d72c64be43670988ea changed gasmix arguments and return values to be passed by value instead of using pointers. Notably, get_gasmix() is fed a default-value and returns a new value. In the old code, NULL was passed in in a first loop iteration and non-NULL was always returned in the first iteration. Thus, an equality comparison of passed-in an returned gasmix would always fail in the first loop iteration. The new code passed in air as default. Now if air was also returned, then the matching gases were not calculated in calculate_sac(). To revert to the old behavior, pass in an invalid gasmix. Moreover, give names to the invalid and air gasmixes. Reported-by: tormento <turment@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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-25profilewidget: remove QSettingsGravatar jan Iversen
Update profilewidget to use qPrefDisplay (amended variable) Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25core/tests: merge Animations and add vars. to qPrefDisplayGravatar jan Iversen
Add class variable tooltip_position to qPrefDisplay Add class variable lastDir to qPrefDisplay qPrefDisplay is updated to use new qPrefPrivate functions Adjust test cases incl. qml tests qPrefAnimations only has 1 variable, that really is a display variable Merge the variable into qPrefDisplay, to simplify setup (and avoid loading extra page in qml). correct theme to save in correct place, and make it a static class variable Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-23Cleanup: const-ify functions taking pointers to eventsGravatar Berthold Stoeger
This is another entry in the series to make more things "const-clean" with the ultimate goal of merge_dive() take const pointers. This concerns functions taking pointers to events and the fallout from making these const. The somewhat debatable part of this commit might be that get_next_event() is split in a two distinct (const and non-const) versions with different names, since C doesn't allow overloading. The linker should recognize that these functions are identical and remove one of them. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23Cleanup: pass gasmix by valueGravatar Berthold Stoeger
In a previous commit, the get_gasmix_* functions were changed to return by value. For consistency, also pass gasmix by value. Note that on common 64-bit platforms struct gasmix is the size of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the same space on the stack. On 32-bit platforms, the stack use is probably doubled, but in return a dereference is avoided. Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an invasive change that going back to pointers is probably the least of our worries. This commit is a step in const-ifying input parameters (passing by value is the ultimate way of signaling that the input parameter will not be changed [unless there are references to said parameter]). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23Cleanup: unify get_gas_at_time() and get_gasmix()Gravatar Berthold Stoeger
There were two functions for getting gas-mixes at a certain timestamp: - get_gasmix() for repeated queries. - get_gas_at_time() for a single query. Since the latter is a special case of the former, simply call the former in the latter. Moreover, rename to get_gasmix_at_time() for consistency. Replace on get_gasmix() call, which was outside of a loop by the corresponding get_gasmix_at_time() call. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23Cleanup: return gasmix by valueGravatar Berthold Stoeger
Currently, get_gasmix_from_event() and get_gasmix() return pointers to either static or to (possibly changing) dive data. This seems like a dangerous practice and the returned data should be used immediately. Instead, return the gasmix by value. This is in preparation of const-ifying input parameters of a number of core functions, which will ultimately let the merge() function take const-arguments in preparation of undo of dive-merging. On common 64-bit systems gasmix (two "int"s) is the size of a pointer and can be returned in a register. On 32-bit systems a pointer to the struct to be filled out will be passed. Since get_gasmix() now returns a value, the first invocation is tested by a NULL-initialized "struct event *". Document this in a comment. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>