Commit graph

364 commits

Author SHA1 Message Date
Jan Mulder
04626b0891 Fix small memory leak
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>
2018-01-07 13:02:27 +01:00
Jan Mulder
75142b0a63 cleanup: less than operators shall not use equal
See also commit c032006d91. 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-29 13:16:58 -08:00
Jan Mulder
57e701f10e cleanup: Uninitialized scalar field
CID 45184

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28 17:30:25 +01:00
Jan Mulder
803759efea cleanup: Uninitialized scalar field
CID 208317
CID 208325

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28 17:30:25 +01:00
Jan Mulder
1ce9b5bb9a cleanup: Logically dead code
CID 208318

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28 17:30:25 +01:00
Jan Mulder
6fa23f74f7 cleanup: Argument cannot be negative
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-28 17:30:25 +01:00
Jan Mulder
2a58be6649 filter: fix trip header bug
With commit 5962f00679, 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-28 17:30:13 +01:00
Jan Mulder
522b922d2a filter: setStringList() at end of every change
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 5962f00679, but this calling at the end just feels
better.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28 17:30:13 +01:00
Jan Mulder
97d564e920 filter: prevent assert trap on exit filters
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-28 17:30:13 +01:00
Berthold Stoeger
c3b1c64183 Remove unnecessary dynamic_cast<>s in filter code
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-28 09:11:12 +01:00
Dirk Hohndel
652e382e68 Cleanup: avoid a few memory leaks
Coverity CID 215199
Coverity CID 215195
Coverity CID 215196
Coverity CID 215198

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26 13:41:58 -08:00
Berthold Stoeger
b6bf57a13b Introduce negate-toggle buttons to filter lists
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-26 13:08:49 -08:00
Berthold Stoeger
130f109442 Remove superfluous QScopedPointer<>s in singletons
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-24 11:04:10 -08:00
Dirk Hohndel
eec69de7ab Small whitespace updates
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-24 09:10:12 -08:00
Jan Mulder
dbcf044b93 beginInsertRows requires last >= first
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-24 08:25:21 -08:00
Berthold Stoeger
7451517e4a Add select-all, deselect-all and invert-selection options to filters
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-24 08:24:11 -08:00
Berthold Stoeger
668635e98e Move *FilterModel functions into base class
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-24 08:24:11 -08:00
Berthold Stoeger
7eed752ba1 Fold MultiFilterInterface into FilterModelBase
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-24 08:24:11 -08:00
Stefan Fuchs
603e43f46e Use function emitDataChanged in diveplannermodel consistently
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Stefan Fuchs
d703ba99c1 Simplify update of gflow and gfhigh values in the code
The more complex handling is no longer needed because:
- Keyboard tracking for gfhigh/low UI fields was switched off here:
  030c094854
- GFhigh was limited to 40 here:
  53fffe0ce3

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Stefan Fuchs
4db9f5dbbd Correcty typo ghflow -> gflow in diveplannermodel.cpp
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-24 00:01:39 +01:00
Berthold Stoeger
935fb3c3df Fix BuddyFilterModel
Commit 6343515fed 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-21 21:09:35 +01:00
Berthold Stoeger
05a1626c7e Implement different zoom levels for dive photos tab
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-18 12:07:10 -08:00
Berthold Stoeger
0d01c70f3a Make protected DivePictureModel members private
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-18 12:07:10 -08:00
Berthold Stoeger
2f5f1e036e Make scaleImages() a static function
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-18 12:07:10 -08:00
Stefan Fuchs
2890be9256 divepicturemodel: Reset start and end row for displayed_dive correctly
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-15 09:11:28 -08:00
Jan Mulder
dd87350cb7 mobile: stay on same dive after edit
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-14 08:53:06 -08:00
Stefan Fuchs
82170579ad Enable removal of pictures from different dives at the same moment
Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13 05:48:20 -08:00
Stefan Fuchs
5b7e4c57f7 Dive pictures show pictures of all selected dives
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-13 05:48:20 -08:00
Stefan Fuchs
a11622623a Remove unused divesitepicturemodel from qt-models
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-13 05:48:20 -08:00
Berthold Stoeger
c3c5256dc4 Remove outdated comment
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-10 15:00:53 +01:00
Berthold Stoeger
92ad7865d0 Make thumbnail code threadsafe
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-10 15:00:53 +01:00
Berthold Stoeger
c73828d605 Simplify DivePictureModel
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-10 15:00:53 +01:00
Berthold Stoeger
a07d3b7bfe Whitespace fixes in qt-models/divepicturemodel.cpp
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>
2017-12-10 15:00:53 +01:00
Dirk Hohndel
03b02c9352 Cleanup: mark parameter as potentially unused
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-08 16:29:49 +01:00
Stefan Fuchs
de26a50ba3 In planner variations use variables for delta values
Plus a small layout change: Add a colon behind "Stop time".

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-02 20:48:02 +01:00
Stefan Fuchs
1bd2f3fe3e Planner variations stop time calculation cover all stops
Simplify the sum up of the deco stop times for analysis of
the planner variations.

Plus rename define for deco stop variations debug output

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-02 20:48:02 +01:00
Robert C. Helling
c38e0f225f Remove unnecessary #include and correct whitespace
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Robert C. Helling
511ee9ddeb Change #include line to make Linux builds happy
Let's see if this helps the Linux build on TravisCI.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Robert C. Helling
d8350ef238 Document background computation of variations
Update changelog, update user manual, clarify
meaning in dive notes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Robert C. Helling
4d605ce51f Prevent redundant replanning
Planning dives is heavy on CPU, so better be sure we only
do it when needed. In particular, when moving around dive
points, we only want a new plan once per move and not three
times (triggered at various points in the chain of events).

This should significantly improve planner snappiness.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Rick Walsh
1985bcb29e Disable plan variation in recreational mode
Calculating variations when in recreational mode doesn't make sense, and can
prevent variations from being calculated when switching back to Buhlmann or
VPM-B modes.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-12-01 15:47:51 -08:00
Robert C. Helling
41b4e4a19a Add imperial units to variations computation
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Robert C. Helling
0839342d33 Don't block profile updates in variations computation
We needed to prevent updates when we messed with the
diveplannerpointsmodel as those would trigger
starting planning from scratch causing infinite loops.

Now, the variations calculation operates on a copy of
the diveplan, so the model is no longer involved and
we should not block recalculations (as those might be
triggered by the UI).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Robert C. Helling
1e678d52b2 Make background calculation optional
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Robert C. Helling
a9703628c4 Actually compute variations in background
This reenables the computation of plan variations but now in a separate
thread. Once finieshed, a signal is sent to update the notes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Martin Měřinský
8ef87e618a Use better aliases for icons.
Icon aliases were complete mess.
Some icons had alias some didn't.
Named with underscores vs. hyphens vs. camelCase.
Lower vs. upper case.
"ICON" prefix vs. suffix vs. nothing.
With vs. without filename suffix.
Some didn't make sence. Eg. mapwidget-marker-gray
(I can see, it's grey, but what does it represent?)
Some were duplicated, eg warning vs. warning-icon.
Some were name after widget, which is wrong.

Do not reinvent wheel. Use widely used naming scheme
close to Freedesktop Icon Naming Specification. This
will enable usage of common icons from current set in
the future. Thus Subsurface will fit nicely to GUI.

This changes icon aliases to one, easy grep-able style.

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-30 23:14:46 -08:00
Dirk Hohndel
2747056889 Revert "Use consistent aliases for all icons."
This reverts commit 92e9c6606f.
2017-11-29 14:05:07 -08:00
Martin Měřinský
92e9c6606f Use consistent aliases for all icons.
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase.
With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs.
prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some
icons didn't have alias at all.

This changes all icon aliases to one, easy grep-able style which complies
to Freedesktop Icon Naming Specification (Guidelines).

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29 11:46:35 +01:00
Stefan Fuchs
8a92484b0c Add debug function dump_cylinders
This function can be used to dump print all cylinder data.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-27 22:40:16 +01:00