Commit graph

12 commits

Author SHA1 Message Date
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