Commit graph

41 commits

Author SHA1 Message Date
Berthold Stoeger
cedc23f487 Dive site: Pass dive-site pointer to MapWidgetHelper::enterEditMode()
Replace the uuid argument to MapWidgetHelper::enterEditMode() by a
pointer. Likewise, adapt the only caller prepareForGetDiveCoordinates().
This is a small step in a bigger effort to replace dive-site UUIDs
by pointers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Linus Torvalds
28e3413ff6 Add 'location_t' data structure
Instead of having people treat latitude and longitude as separate
things, just add a 'location_t' data structure that contains both.

Almost all cases want to always act on them together.

This is really just prep-work for adding a few more locations that we
track: I want to add a entry/exit location to each dive (independent of
the dive site) because of how the Garmin Descent gives us the
information (and hopefully, some day, other dive computers too).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-21 19:55:09 +03:00
Berthold Stoeger
0416e54049 Dive site: select dive site when entering edit mode
Commit 0aef04352a made it impossible
to move new dive sites on the map. When entering dive-site-edit mode,
the filter would be instructed to show only dives of the corresponding
dive site [which didn't yet exist] and therefore all dive sites
on the map were deselected.

Fix this by explicitly centering on the dive site to be edited in
MapWidgetHelper::enterEditMode().

Fixes #1809

Reported-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-19 06:20:07 -04:00
Berthold Stoeger
ac02854a8a Map: don't access displayed_dive_site in reloadMapLocations()
MapWidgetHelper::reloadMapLocations() reloads all dive flags
of the non-hidden dives plus the one of the currently edited
dive. Use the current_dive macro to determine whether this
is the current dive site instead of the global displayed_dive_site
object.

This is part of a series of commits, which makes the map-code
independent of the global displayed_dive_site object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:32 -07:00
Berthold Stoeger
dd44dc4ab8 Map: pass down dive site in prepareForGetDiveCoordinates()
Instead of reading out the global object "displayed_dive_site",
pass the dive site to be edited in arguments to
prepareForGetDiveCoordinates() and enter edit mode.

Simplify the code in LocationInformationWidget by not using
signals to call the prepareForGetDiveCoordinates() function.
While doing this, collect common code in accept() and reject()
in the already existing resetState() function.

This is another entry in a series of commits that makes
data-flow more clear by removing access to the global
"displayed_dive_site" object.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:32 -07:00
Berthold Stoeger
8091497745 Map: split void MapWidget::setEditMode()
The setEditMode(bool) function behaves very differently, when
entering and exiting edit mode. Therefore, split it in two
versions. This will allow to pass arguments that make sense
only when entering the edit mode.

Since setEditMode() doesn't exist anymore, turn the editMode
Q_PROPERTY line to the MEMBER version. Accordingly, remove
the reader function. If QML wants to enter edit mode, it
should invoke the appropriate function and not simply set
the flag.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:32 -07:00
Berthold Stoeger
754160d625 Map: pass changed coordinates via signal
The coordinates of a "dragged flag" were passed out-of-bound via
the global "displayed_dive_site" object and then a signal was sent
to notify of the changed coordinates.

Instead, pass the coordinates directly via the signal. This makes
the data- and control-flow more clear.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:32 -07:00
Berthold Stoeger
66c5c5f72b Map: remove LocationInformationWidget::coordinatesChanged signal
This was used by LocationInformationWidget to instruct the map
that the coordinates of the current dive site has changed.
There is no reason why this couldn't be a function call, as no
other object ever connect()s to this signal. In fact, such a
function already exists viz. updateLocationOnMap.

Therefore, replace the signal by a simple function call.

Moreover, the uuid and coordinates of the dive site were transported
via the global "displayed_dive_site" object. Instead, pass this
information in the parameters of the function. This makes it
easier to reason about data- and control-flow.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:32 -07:00
Berthold Stoeger
0aef04352a Map: zoom on dive sites when flipping through dive site list
The dive site list was connected to centerOnDiveSite(). Apparently,
the currently selected dive site should have been shown in the map.
Yet, this never worked, because the actual dive site of the selected
dive had precedence in centerOnDiveSite().

It seems that centerOnDiveSite() had actually to purposes:
1) center on the passed in dive site
2) center on the dive sites of the selected dives

Therefore, split this function in two separate functions for
each of these use-cases. This allows us to remove some pre-processor
magic (mobile vs. desktop) and to remove a parameter from the
MainTab::diveSiteChanged() signal.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-08 13:29:51 -07:00
Lubomir I. Ivanov
b4f10553cc map-widget: add support for filtering of map locations
If the dive list is filtered the map should hide dive locations
that do not match the dive list filter.

To achieve that, loop over dives instead of dive sites in
MapWidgetHelper::reloadMapLocations() and discard
dives that are hidden by the filter. Then check if a dive
has a dive site attached to it and re-use the old functionality.

Suggested-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-08-18 18:50:26 +02:00
jan Iversen
2b7b7ad8f5 map-widget: add qrc file for widget
Make map-widget self contained, with its own qrc file.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-06-21 20:27:58 -07:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
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-04 08:50:10 -07:00
Dirk Hohndel
ea83b5ed37 Core: remove dive.h from files that don't need it
Of course, quite a few of them indirectly get it through other header
files.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Murillo Bernardes
ef5d4a123e ios: manually import google maps plugin
qmlimportscanner for some reason does not include
the googlemaps plugin in the generated file.

Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
2018-04-06 10:31:07 -07:00
Lubomir I. Ivanov
48c032bb8e mapwidget-mobile: do not animate the first selection
centerOnLocationHard() is added in MapPage.qml so that
on `firstRun` the map is hard panned to the desired location
without animation.

This affects the selection of a new "Dive details" -> "Map it" or
when opening a GPS location in the map.

The idea behind this change is to avoid starting the map animation
from an arbitrary location such as [0,0] or London. Also, to not
start the map zoomed out completely and then zoom in on a selected
dive.

For this change to work, add the helper getCoordinatesForUUID()
to qmlmapwidgethelper.cpp/.h and use it to obtain the
QGeoCoordinates for a dive site UUID.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-04-02 13:47:43 -07:00
Lubomir I. Ivanov
e1c81560b9 MapWidgetContextMenu.qml: improve the action text
The first 3 actions in the map widget context menu
are about the current map widget center and not about the
selected dive site / marker.

Avoid using the word "location" for these, use "coordinates"
for the second and third entry.

Suggested-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-15 23:27:18 +02:00
Lubomir I. Ivanov
64e2247aa7 MapWidget.qml: try to preserve zoom when opening Google Maps
Extend openLocationInGoogleMaps() so that the current
map widget zoom level is roughly mapped to the Google Maps
zoom level.

The two zoom scales are quite different. Google Maps uses meters
directly, while the QML map uses a scale from ~1 - 21.

The approximation is done via exponential regression over
a small data set gathered from experiment.

Add a console.log() call so that the URL is logged.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-15 23:27:18 +02:00
Lubomir I. Ivanov
16b3892f22 MapWidget.qml: use a new URL format for Google Maps
Make the map widget use a new URL format for Google Maps
in openLocationInGoogleMaps(). The new URL format does
not show a marker once the location is open in Google Maps
as this might confuse some users.

Suggested-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-15 23:27:18 +02:00
Lubomir I. Ivanov
8b43633c7d mapwidget.qml: emit a signal when the marker changed
The signal to emit is selectedDivesChanged() and it accepts
a list if diveIds. The 'nSelectedDives' counter is redundant.

Also expose the 'map' and 'mapHelper' objects as aliases.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-11 11:40:12 -07:00
Lubomir I. Ivanov
fbbb6ba4fb qmapwidgethelper: make adjustmets for the mobile version
The mobile version is limited as it does not support dive list
selection of multiple dives and editing multiple dives.

Also the dive list on mobile does not follow the same indexing as
the desktop version dive list.

Use the SUBSURFACE_MOBILE macro and for:
- centerOnDiveSite() either deselect map markers or center on
a single one (never on a rectangle like the desktop version)
- selectedLocationChanged() and selectVisibleLocations() return
a list of single dive ID

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-11 11:40:12 -07:00
Lubomir I. Ivanov
8fa2295a61 qmapwidgethelper: add centerOnDiveSiteUUID()
centerOnDiveSiteUUID() is a helper to center the map on a dive_site
UUID instead of a dive_site pointer.
Make it call centerOnDiveSite().

Make both this function and reloadMapLocations() Q_INVOKABLE
as these are going to be called from QML.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-11 11:40:12 -07:00
Lubomir I. Ivanov
eb8772d967 qmapwidgethelper: move includes to the header
Add the following includes in the header -
<QVariant> and <QGeoCoordinate> otherwise the
mobile build fails.

It is unclear how the desktop build does not complain
about this.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2018-03-11 11:40:12 -07:00
Berthold Stoeger
cd5e17cf79 Cleanup: Unify qthelper.h and qthelperfromc.h
Since all qt-helpers are defined in qthelper.cpp, there seems to be
no reason to have two include files. By unifying the two files,
duplication and inconsistencies are removed. The C++-only part is
simply compiled away with #ifdefs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 19:06:02 +02:00
Jan Mulder
92a5e0644e cleanup: Uninitialized pointer field
CID: 208335

Mainly to silence Coverity, as I do not believe this caused
any problem.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-28 17:30:25 +01:00
Jan Mulder
36c8a7e4ca mapwidget: QtQuick really to 2.5
It shall match the Qt version ... according to Dirk.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-24 11:33:46 -08:00
Jan Mulder
4c4222d611 mapwidget: revert QtQuick version to 2.0
In commit f3d978b8a5 the QtQuick version was upgraded
to 2.6 (from 2.0 for the mapwidget). This is, apparently,
too agressive, as there are still mainstream distributions
that are still on Qt 5.5.1 for which 2.6 of QtQuick is too
new. And as a sidenote: Qt 5.5.1 was released in October
2015.

So partially revert commit f3d978b8a5.

Fixes: #978

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-24 10:56:00 -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
Lubomir I. Ivanov
837ed67d86 mapwidget.qml: return early instead of doing branching
The centerOn*() functions can just return early
for invalid input, instead of branching the conditions.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
1d80b08a8f mapwidget.qml: more minor improvements
- Add the helper coordIsValid() and use it in centerOnCoordinate().
This checks for NaN coordinates and prevents an infinite while() loop.
- Use '-= 1.0' instead of '--' to be more clear that the decremented
variable is a float
- Store the current center with 'centerStored' in
centerOnCoordinate(). Fixes a possible zoom out glitch.
- use Math.floor() to convert 'zoomLevel' to integer when estimating
zoomOut in centerOn*()

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
449c92801b mapwidget.qml: remove unused zoom-out function
The zoom out function is no longer used as we don't zoom
out when a dive doesn't have dive site coordinates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
1bc91bfb67 mapwidget.qml: make pan and zoom-in have the same duration
There was a problem with the current different duration
for pan and zoom. Ideally the pan should before the zoom:
Map zooms out -> pan to new center starts -> zoom in

The problem with this is that if the map pans out too much it
loses it's center and the above scheme would not work.

To solve the problem, make the duration of pan and zoom
the same this is not idea, but prevents the case where
the map would not zoom-in at the correct center.

Also remove the easing function.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
fe69b304b2 map-widget: interrupt map animations on new interactions
When the map is performing zoom/pan animation and the
user performs an action that would trigger a new zoom/pan
animation, but some glitches can occurs. An example
would be when one clicks a dive in the dive list -
the zoom/pan animation will trigger, so that the map
is centered on the dive site, but if the user clicks the
[+] button to zoom-in, while the animation is running
the map will glitch.

This patch prevents such glitches by stopping
all running animations in progress when the user:
- single clicks the map
- uses the mouse-wheel to zoom
- presses the [+] / [-] buttons

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
8bc61f42cb map-widget: use 'getter' function coordinate() for MapLocation
Avoid using qvariant_cast() with getRole() in favor of
MapLocation::coordinate() in MapWidgetHelper::reloadMapLocations().

This makes the code more readble.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
b564debe21 map-widget: start dive site editing with coords pre-entered
Once the user starts editing a dive site, make sure to pass
coordinates of either the current map center (if a new MapLocation
is being added) or the coordinates of the existing MapLocation.

The "Dive site management" coordinates text field would receive
these new coordinates after the displayed_dive_site struct
is updated and the coordinatesChanged() signal is emitted.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Lubomir I. Ivanov
d9cfcae88b map-widget: move the map with the edited dive site
Once the user starts editing the coordinates by hand
(from the "Dive site management" UI) make sure to
update the map to center on those user entered
coordinates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-27 22:59:22 +01:00
Jan Mulder
f3d978b8a5 QML UI: QtQuick to 2.6
Upgrade QtQuick to 2.6. Seeing a small artifact in the application
header, lets see what happens when upgrading more includes.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-11-19 12:20:43 -08:00
Lubomir I. Ivanov
746874a78e map-widget: allow real-time updates of edited markers
This patch allows updating the location of map markers
while editing a dive site and updating the text in the
LocationInformationWidget in real-time.

Currently it is only possible to see the marker changes by
clicking 'Apply'.

The modification required the following changes:
- add the MapWidget::updateCurrentDiveSiteCoordinatesToMap() slot
and call it each time the GPS text updates
- separate the updateCurrentDiveSiteCoordinates(FromMap/ToMap) logic
by having the FromMap/ToMap suffix to method names
- make MapWidgetHelper::updateCurrentDiveSiteCoordinatesToMap()
call a new MapLocationModel::updateMapLocationCoordinates()
method, which updates selected location coordinates and the model
- add MapLocation::setCoordinateNoEmit() that does not emit
a signal when updating a coordinate

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-09 12:40:25 -08:00
Lubomir I. Ivanov
89ccdc3178 map-widget: use current center when editing new markers
When starting to edit a new dive location, create
a marker at the current map center instead of zooming
out and centering on the 0,0 coordinate.

This will help (and speed up) a lot the edition,
if the user needs to add numerous dive markers
at a specific location close to each other.

refs #754

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-09 12:40:25 -08:00
Lubomir I. Ivanov
956b45ddfd map-widget: move the widget and its resources to 'map-widget'
Move all the map widget platform agnostic files to the
<subsurface-root>/map-widget folder.

This avoids the confusion about the desktop version of subsurface
using mobile components. The map widget is planned as a shared
component between the mobile and desktop versions.

desktop-widgets/mapwidget[.h/.cpp] still remain as those are specific
to the desktop version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-05 14:48:56 -08:00