summaryrefslogtreecommitdiffstats
path: root/qt-models
AgeCommit message (Collapse)Author
2018-02-17Coding-style: remove superfluous parenthesesGravatar Berthold Stoeger
Mostly replace "return (expression);" by "return expression;" and one case of "function((parameter))" by "function(parameter)". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Bugfix in plannermodel for very short dive durationsGravatar Oliver Schwaneberg
When adding a dive manually, you might clear the "duration" field and fill in your value by hand. Unfortunately, commit #1052 produced a bug that practically limited the dive duration to 6 minutes once the field was cleared. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
2018-01-31mobile cleanup: restyle construction of locationlistGravatar Jan Mulder
See also e6e1473e6. The construction of the locationlist was not the same as the 3 previous lists, and it needs the inclusion of a new model file (divelocationmodel.cpp) in the mobile app. In addition, as the mobile app is mainly interested in a simple stringList (model) to populate a HintsText field (or maybe later a combobox), this stringlist is added to the model, to easy interfacing with QML. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31mobile cleanup: unduplicate code and do not loop over dives (1)Gravatar Jan Mulder
This is the first of a set of commits that are (very) similar. It appeared that a number of more or less static lists, which are constructed by a loop over all dives in the logbook, were executed when changing focus to a next dive. For example, the in this commit addressed list of used dive suits. What was wrong was that the suitList was linked to a dive. There is only a need to construct the list of used suits when data is changed (and obviously, once on startup of the app). Further, it appeared that a lot of code was duplicated and that we can use (in this case) the same code from the desktop completionmodels.cpp. Basically, this commit involves the following changes: - include completionmodels.cpp in mobile and desktop (so move it from the desktop only category to the generic category). - remove double code from DiveObjectHelper.cpp - Do not differentiate in the init phase and the normal refresh of the list - the per dive logic is now only the getting of a previously constructed list (in init or update of the divelist). There are no visible changes in the UI, other than a better performance when scrolling over dive details. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-26Initialise cylinder start pressure with working pressureGravatar Robert C. Helling
In the planner, this is the natural assumption. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-19Improve profile display in plannerGravatar Willem Ferguson
This patch allows the planner to save the last manually-entered dive planner point of a dive plan. When the plan has been saved and re-opened for edit, the time of the last-entered dive planner point is used to ensure that dive planning continues from the same point in the profile as was when the original dive plan was saved. Mechanism: 1) In dive.h, create a new dc attribute dc->last_manual_time with data type of duration_t. 2) In diveplanner.c, ensure that the last manually-entered dive planner point is saved in dc->last_manual_time. 3) In save-xml.c, create a new XML attribute for the <divecomputer> element, named last-manual-time. For dive plans, the element would now look like: <divecomputer model='planned dive' last-manual-time='31:17 min'> 4) In parse-xml.c, insert code that recognises the last-manual-time XML attribute, reads the time value and assigns this time to dc->last_manual_time. 5) In diveplannermodel.cpp, method DiveplannerPointModel::loadfromdive, insert code that sets the appropriate boolean value to dp->entered by comparing newtime (i.e. time of dp) with dc->last_manual_time. 6) Diveplannermodel.cpp also accepts profile data from normal dives in the dive log, whether hand-entered or loaded from dive computer. It looks like the reduction of dive points for dives with >100 points continues to work ok. The result is that when a dive plan is saved with manually entered points up to e.g. 10 minutes into the dive, it can be re-opened for edit in the dive planner and the planner re-creates the plan with manually entered points up to 10 minutes. The rest of the points are "soft" points, shaped by the deco calculations of the planner. Improvements: Improve code for profile display in dive planner This responds to #1052. Change load-git.c and save-git.c so that the last-manual-time is also saved in the git-format dive log. Several stylistic changes in text for consistent C source code. Improvement of dive planner profile display: Do some simplification of my alterations to diveplannermodel.cpp Two small style changes in planner.c and diveplannermodel.cpp as requested ny @neolit123 Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-11Use helper function empty_string() instead of manual checksGravatar Berthold Stoeger
For code consistency, substitute boolean expressions: s && *s -> !empty_string(s) s && s[0] -> !empty_string(s) !s || !*s -> empty_string(s) !s || !s[0] -> empty_string(s) Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-11Introduce helper function empty_string()Gravatar Berthold Stoeger
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). 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-10Un-tie plannner model from profile on mobileGravatar Jan Mulder
Do not pull in the DivePlannerPointsModel::instance as this is not used in the called function. We (currently) do not support deco computations on mobile, so trying to pull in any deco state from the planner is futile anyway. With this uncoupling, 6 more model files are not needed in mobile any more. 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-10mobile: fix crash on delete dive from divelistGravatar Jan Mulder
This is a somewhat hacky commit. For a very long time, the delete from the divelist on mobile crashed. That is, not always for anyone, but for me almost consistently. This commit tries to solve it. I found that trying to save the delete immediately after removing data from the underlying model seemed to cause the crash. Hacking around, I found that a simple beginResetModel/endResetModel between the delete of the underlying model data and actual save is sufficient to solve the crash. The big question is, why does this all work? I suspect some of race condition between deleting model data, and giving the QML engine the opportunity to do its thing. This is also related to issue #311, but that is not implemented here. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10Unused code: GpsListModel::addGpsFix()Gravatar Jan Mulder
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10Unused code: remove CCRMax() and used macroGravatar Jan Mulder
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10build system: split qt-models into partsGravatar Jan Mulder
For a long time, I did not realize that a lot of qt-models are only used in the mobile app, or only used in the desktop application. This commit splits the qt-models in 3 parts. Used in both mobile and desktop, used in desktop only, used in mobile only. There is no other code change in here, other than cmake changes. To me, this gives at least developers more insight where code is actually used, and there is a small benefit in footpoint. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-10Move function to proper placeGravatar Jan Mulder
Instead of writing TODO comment blocks, just do the work, and move the function to the proper class. Further, after review from Berthold, cleanup the function. There is no reason that getGasList() is member of any class. It is just a non-class helper, and as it is only used here, a static helper. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-07Fix small memory leakGravatar Jan Mulder
When deleting a dive from the divelist model, also free the pointed to DiveObjectHelper data. There seems no harm done (other than a memory leak) by this missing free. Found while (again) investigating the infamous crash occuring when deleting a dive from the mobile app when deleting a dive from the dive list. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-29cleanup: less than operators shall not use equalGravatar Jan Mulder
See also commit c032006d91ee3c. Compare functions passed to sort functions need to compare for less-than and not less-or-equal. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28cleanup: Uninitialized scalar fieldGravatar Jan Mulder
CID 45184 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28cleanup: Uninitialized scalar fieldGravatar Jan Mulder
CID 208317 CID 208325 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28cleanup: Logically dead codeGravatar Jan Mulder
CID 208318 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28cleanup: Argument cannot be negativeGravatar Jan Mulder
CID 208296. IndexOf can return -1 when not found, which will not happen in this context, so just to silence Coverity. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28filter: fix trip header bugGravatar Jan Mulder
With commit 5962f00679fae555, a well known problem was introduced. Incorrect width setting for the spanning trip lines. And as there is even a specific functon for that, just call this. The reason the mentioned commit introduces this, is that invalidate() causes layoutChanged signals, and invalidateFilter() does not. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28filter: setStringList() at end of every changeGravatar Jan Mulder
This is mainly code maintenance. Instead of emitting explicit dataChanged signals, we can make sure that setStringList() is called after all model data manipulation is ready. Accoording to the Qt docs: "The model will notify any attached views that its underlying data has changed". In itself, this does not solve the tripped assert mentioned in commit 5962f00679fae5, but this calling at the end just feels better. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28filter: prevent assert trap on exit filtersGravatar Jan Mulder
This "bug" is found using Qt 5.10 compiled in developer mode. Access the filers, click a little around here, close the filters. Almost every time the following assert is triggered: ASSERT failure in QPersistentModelIndex::~QPersistentModelIndex: "persistent model indexes corrupted", file itemmodels/qabstractitemmodel.cpp, line 643 This is relatively deep down in Qt, and it is triggered by clearing the filters. Trying to force a crash when using the same scenario in Qt 5.10 compiled for production (so no active asserts) did not result in a crash. So, upto this time, it is unclear if the Qt assert points out a real problem, or it is some false alarm (for whatever reason). Further investigation shows that the assert can be solved by changing the invalidate() to an invalidateFilter(). Indeed, the last variant is a little more lightweigt, and does seem to do the same job from a functional point of view (in this case). Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28Remove unnecessary dynamic_cast<>s in filter codeGravatar Berthold Stoeger
FilterModelBase is a direct subclass of QAbstractItemModel. Therefore, dynamic_cast<>ing the former to the latter is unnecessary. Probably an artifact of previous code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-26Cleanup: avoid a few memory leaksGravatar Dirk Hohndel
Coverity CID 215199 Coverity CID 215195 Coverity CID 215196 Coverity CID 215198 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26Introduce negate-toggle buttons to filter listsGravatar Berthold Stoeger
Introduce toggle buttons which mean "filter all dives except those fulfilling the selected criteria". The old code used to check for rowCount() == 0. This should never happen, because there is always a row "empty field". This check was moved into the preamble of the functions to seperate it from the actual logic. Fixes #435 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Remove superfluous QScopedPointer<>s in singletonsGravatar Berthold Stoeger
There was a curious pattern of singletons being implemented based on QScopedPointer<>s. This is an unnecessary level of indirection: The lifetime of the smart pointer is the same as that of the pointed-to object. Therefore, replace these pointers by the respective objects. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Small whitespace updatesGravatar Dirk Hohndel
We aren't really consistent. And I don't do this often enough. But based on a few things that I saw in a recent commit, I wanted to at least fix those. And then of course fixed everything in those two files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-24beginInsertRows requires last >= firstGravatar Jan Mulder
Found while compiled against Qt 5.10 build from source. The assert Q_ASSERT(last >= first) is trapped by this beginInsertRows in case there are no pictures. Just do not call this when there are no pictures. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-24Add select-all, deselect-all and invert-selection options to filtersGravatar Berthold Stoeger
To every filter list add a menu button that allows selection of all, selection of none or inversion of selection. Implements #435. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Move *FilterModel functions into base classGravatar Berthold Stoeger
The *FilterModels had a number of of virtual functions, which only accessed members of the base class. Moreover, these functions were identical and generated with macros. Therefore, move these functions to the base class. The one excption is data(), which uses different count functions (passed as a macro parameter). Thus, introduce a virtual countDives() function and likewise move data() to the base class. A function pointer might be even more clear, but since the rest of the code/Qt relies heavily on runtime polymorphism, let's do the same here. The only macros left are those creating the singleton accessors. This could be more clearly realized by templates, but let's likewise keep it the way is. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Fold MultiFilterInterface into FilterModelBaseGravatar Berthold Stoeger
There were two classes, MultiFilterInterface and FiterModelBase. The latter derives from the former and from QStringListModel. The former was not used anywhere else. Moreover, in contradiction to its name, MultiFilterInterface is not an interface (in the Java sense), because it actually has (non-virtual) data members. All in all, the data model is very weird. Merge these two classes, since there seems to be no gain whatsoever from keeping MultiFilterInterface separate. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-24Use function emitDataChanged in diveplannermodel consistentlyGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24Simplify update of gflow and gfhigh values in the codeGravatar Stefan Fuchs
The more complex handling is no longer needed because: - Keyboard tracking for gfhigh/low UI fields was switched off here: 030c094854aeab4aaade523d7126728d9ce98a5b - GFhigh was limited to 40 here: 53fffe0ce3696de33ce4657e20d295e4a43e0fd9 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24Correcty typo ghflow -> gflow in diveplannermodel.cppGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-21Fix BuddyFilterModelGravatar Berthold Stoeger
Commit 6343515fedbc43be4fd2cb3f1b3fea384e362c59 introduced equality instead of substring comparison for filters. This broke the buddy filter in the case of more than one buddy, because in such a case the buddy list is a comma-separated string. Fix this by splitting the buddy string, trimming the individual strings and search in the list. Fixes #969 Reported-by: <yrevawerd@gmail.com> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18Implement different zoom levels for dive photos tabGravatar Berthold Stoeger
This implements different zoom levels for the dive photos tab as suggested by Stefan Fuchs <sfuchs@gmx.de> in #898. The zoom level can be changed using a slider or CTRL+mousewheel. Zoom levels range from a third of the standard thumbnail size to thrice the standard thumbnail size. Thumbnails are cached in maximum resolution and scaled down on the fly. Because the profile widget took its pictures from the photo list model, an extra picture copy with a fixed size had to be introduced. The UI is still a bit crude. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18Make protected DivePictureModel members privateGravatar Berthold Stoeger
The constructor and the list of pictures was protected, but the class neither had friends nor subclasses (a subclass was removed in a recent commit). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-18Make scaleImages() a static functionGravatar Berthold Stoeger
It was only used by the DivePictureModel class, no need to export it. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-15divepicturemodel: Reset start and end row for displayed_dive correctlyGravatar Stefan Fuchs
Correct way of using indices for rowDDstart and rowDDend. Reset rowDDstart and rowDDend at beginning of updating dive pictures. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-14mobile: stay on same dive after editGravatar Jan Mulder
See issue #875. In hindsight the reason for this bug is easy to understand. When updating a dive, the dive was first removed from the model, and added in its new state again. This does seems resonable, but the delete in the model causes the internal (QML) state to be changed, and the previous state (like the currentIndex that was pointing to the just deleted row, so that one is changed to something valid internally) is not restored at recreation of the edited dive. The QML engine has no way to understand that the remove and subsequent add are in fact one atomic operation. This can be solved by simply updating the underlying data in place, and notifying the change using a dataChanged emitted signal. The dataChanged signal takes care of the repaint of the screen, and there is no need for removeRow/insertRow pairs. Fixes: #875 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-13Enable removal of pictures from different dives at the same momentGravatar Stefan Fuchs
Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13Dive pictures show pictures of all selected divesGravatar Stefan Fuchs
In the dive picture tab show pictures of all selected dive. But at the same moment take care that in the profile only pictures from displayed_dive are displayed. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13Remove unused divesitepicturemodel from qt-modelsGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-10Remove outdated commentGravatar Berthold Stoeger
The removed comment in qt-models/divepicturemodel.h described todo items which were already implemented. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-10Make thumbnail code threadsafeGravatar Berthold Stoeger
The thumbnailing in qt-models/divepicturemodel.cpp was performed concurrently, but the thumbnailCache was not protected from races. Resolve this by guarding the thumbnalCache accesses with mutexes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-10Simplify DivePictureModelGravatar Berthold Stoeger
The code of DivePictureModel used a QHash to keep track of thumbnails. Not only was the code rather complex - it also had the consequence that pictures are sorted according to the hash function, i.e. seemingly random. This commit replaces the QHash by a simple QList which keeps track of thumbnails and some meta-data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-12-10Whitespace fixes in qt-models/divepicturemodel.cppGravatar Berthold Stoeger
Note that constructs like QList<QFuture<void>> is incompatible with pre-C++11 compilers. But the code base is so full of C++11isms that we may just as well remove asymmetric eye-sores of the kind "QList<QFuture<void> >". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>