When changing the dive selection, we have to reload the map to show
the correctly highlighted flags. Do this directly by hooking into
the DiveListNotifier::divesChanged signal instead of indirectly
via the MainTab.
Moreover, on reload center on the highlighted dive sites.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This member variable was only used locally in functions.
Accordingly, make it a function-local variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
MapWidgetHelper::selectVisibleLocations() calls setSelection()
on a single dive. Firstly, this make no sense anymore, as
we now support multiple highlithed flags. Secondly, the
highlted dives are now derived from the selected dives.
Therefore, remove the call.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To detangle this code a little bit, let centerOnSelectedDiveSite()
just do what is says: center on the selected dive sites.
Don't update the selected dive site by calling
MapLocationModel::setSelected().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
If multiple dives are selected, highlight all corresponding sites.
For that, replace the MapLocationModel::m_selectedDs pointer by
a QVector<>. Fill the vector in MapLocationModel::reload() and
add a isSelected() member function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The map model keeps track of the dive site positions on the
map. Therefore, it seems more logical to have the code calculating
the map position in the model, not in the helper-class.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When on the dive site tab or editing a dive site, we want
to show all dive sites so that the user can related different
dive sites. Therefore export a "in dive site mode" flag from
the filter model and don't filter in that case in MapWidgetHelper.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
During edit mode, we could get spurious reload() requests owing
to tabs being hidden. This led to undefined behavior:
In some cases entering dive site edit mode would show all dive
sites, in some only the dive site of the currently edited dive.
Therefore, refuse to reload the map while in edit mode. The
corresponding flag already exists.
Partially fixes#2076
Reported-by: Doug Junkins <junkins@foghead.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On reload of the map, the map exits edit mode. Sounds logical
at first, but the whole map-mode code is very unpredictable.
What happened was that when switching from the dive site table
to dive site edit mode, the code would enter map edit mode first.
Then, the dive site tab got its hide-signal, which would reset the
filter. This would reload the map and thus exit mode. Hence the user
can't drag the flag on the map.
Partially fixes#2076
Reported-by: Doug Junkins <junkins@foghead.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This has been a feature people have asked for quite frequently. It is
taking up some valuable screen real estate - so the question could
become if there should be a switch to enable / disable it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Creates the dialog box to select which sites to import from the file
selected in mainwindow.cpp. The DivesiteImportModel is created as a
table to display and select which sites are to be imported. Once the
sites are selected, the Command::importDiveSites command is called to
add the sites to the core dive site table with undo/redo functions.
Signed-off-by: Doug Junkins <junkins@foghead.com>
Adds "Import->Import dive sites" menu to mainwindow.cpp and adds the
on_actionImportDiveSites_triggered() method to prompt for the filename
to import from. The files are parsed and then any dive and trip data is
cleared before opening a dialog box to select which sites are to be
imported.
Signed-off-by: Doug Junkins <junkins@foghead.com>
ImportDiveSites adds the provided dive sites to the core dive site table
and stores the source data so it can be undone.
Signed-off-by: Doug Junkins <junkins@foghead.com>
For some reason openSUSE 42.3 updates keep timing out, causing these builds to
fail. Having a Qt5.5 and a Qt5.7 build should be sufficient for our purposes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Include text about dive site management. 5 new figures
are introduced. Writing this enabled me to appreciate just how
much time must have gone into writing the code.
Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
An interesting crash:
1) On the dive site tab select a dive site such that only one
trip is shown.
2) Unselect all dives.
3) Press CTRL-A while the dive list has focus.
4) This will select a trip.
5) In MainTab::updateDiveInfo() this will switch to the previous
tab active when in trip mode.
6) This will reset the filter.
7) This will reset the currentTrip field which we just set.
8) Since we just set the currentTrip field, we don't expect
it to change and reference a null pointer.
To fix, don't switch tabs when on the dive site tab. This also
improves user experience as there seems to be no reason to switch
away from the dive site tab.
Currently the index of the dive site tab is hard-coded - this
should be changed!
Fixes#2077
Reported-by: Doug Junkins <junkins@foghead.com>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Fixed bug in the Haversine function in get_distance() based on algorithm
at https://www.movable-type.co.uk/scripts/latlong.html and added bounds
to the 'a' term to avoid floating point errors for antipodal points.
Signed-off-by: Doug Junkins <junkins@foghead.com>
A number of objects in this file were global. Yet they weren't
used anywhere else. Don't export these symbols by making them of
static linkage.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
A copy of a C-string was assigned to a QString. The copy was never
freed. Instead, assign the C-string directly. This does the right
thing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
- Use a beginResetModel()/endResetModel() pair instead of distinct
addRows / removeRows pairs.
- Reuse the update function in the constructor().
- Let "rows" be the number of rows, not the number of rows minus one.
- Remove updateInfo() function as it does the same as update().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
- Use a beginResetModel()/endResetModel() pair instead of distinct
addRows / removeRows pairs.
- Reuse the update function in the constructor().
- Let "rows" be the number of rows, not the number of rows minus one.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The TankInfoModel and WeightInfoModel had biggerString() functions
to determine the correct column widths for the tank- and weight-type
columns. The users were removed around 2013. Remove these functions
and the corresponding member variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
YearInfo is a trivial wrapper around "stats_t *". All the
constructor / destructor rigmarole seems completely unnecessary.
Remove it. Probably the whole class could be removed, but for
that I'd need more insight into Grantlee, which is low on my
list of priorities for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
For printing, DiveObjectHelpers are allocated and pointers to these
are stored in a QVariantList. The objects are never freed. To fix
this leak, keep the objects in a std::list<>.
std::list<> was chosen because
1) Pointers to elements stay valid during its lifetime.
2) Objects can be constructed directly in the list with emplace_back()
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We're quite inconsistent when it comes to variable naming.
The general usage is camelCase for Qt parts and snake_case
for core code. Virtually nowhere do we start variable names
with a capital letter. Therefore, turn this one weird case
into camelCase.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
TemplateLayout::m_engine is a Grantlee::Engine that is reallocated
for every function call. Instead of the archaic memory-management,
remove the member variable and make it a local variable of the
two functions that need it. There seems to be no point in keeping
the object alive beyond the function's scope.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The default QString constructor generates an empty string. No point
in assigning the empty string to such a thing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, the dive information tab was not updated when the user
edited fields. The fields were only updated when switching between
dives.
Therefore, hook into the "divesChanged" signal and update the fields
accordingly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The information tab used displayed_dive to fill out its field.
For consistency with the main tab and in a bigger effort to remove
displayed_dive, use current_dive instead.
Only clear the fields if no current_dive is set. The code used to
clear the fields and overwrite them later.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On the main-tab, when looking at a trip, the fields were filled
out with dive-data and then either hidden or overwritten with
trip data. Move the update of the fields into the corresponding
if-branch that is only active if on dive-mode.
This means removing the UPDATE_* macros, which updated or cleared
dive-fields depending on whether a current dive was set. These
operations are now performed explicitly in the corresponding
if-branches.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
I'm not sure this is actually relevant for anything any more, but this
adds the USB device ID's for the Scubapro G2 Console and HUD versions.
It also fixes things to use the proper vendor name (a bit too much
cut-and-paste, where the code said "Suunto" instead of "Scubapro").
The real device ID changes are in libdivecomputer, this is just the
Android xml list for recognized USB devices that likely nobody really
uses.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This adds ID entries for the Scubapro G2 HUD (but no GPS parsing support
yet) and the Aladin H Matrix.
Also fix ndl/deco parsing for for Aqualung i450T.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This didn't use to matter, because none of the BLE-using backends did
retry on timeout until recently.
But Jef started doing packet sending retry for the Mares Icon backend,
and now we should make sure to distinguish the "IO failed" from "IO
timed out" cases.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit adds an entry to the dive media context
menu which offers to write a subtitle file. This
creates an .ass file for the selected videos.
In an attempt to to clutter the screen too much, don't
show irrelevant entries (zero temperature or
NDL and show TTS only for dives with stops).
VLC is able to show these subtitles directly, they
can be integrated into the video file with ffmpeg.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
In the dive site selection widget there are two special entries
(add dive site with given name). Don't show this if the user didn't
enter a string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The dive site selection widget implements a lessThan() function, but
that was never called. Apparently in a QListView one has to start
sorting by hand? Do just that.
In any case, the lessThan function was erroneous as it would happily
sort away the first two special entries. Fix it with a special case
for these to.
Finally use case insensitive string comparison.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To reset the filter-model, LocationInformationWidget would extract
the model from the diveSiteListView and then downcasts it. Instead,
it can access it directly, because the filter-model is a subobject
of LocationInformationWidget.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
DiveLocationLineEdit stored a pointer to itself in a global variable
so that the DiveLocationModel can access it to access the filter text.
Instead, on change simply pass the filter text down from DiveLocationLineEdit
to DiveLocationModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Commit c69ca4df80 removed the roleNames
function, which is not needed according to the docs, as a default function
is provided. For unknown reasons this broke the QML combo box.
Reinstate the function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>