mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
1d80b08a8f
commit
837ed67d86
1 changed files with 59 additions and 59 deletions
|
@ -151,7 +151,8 @@ Item {
|
||||||
stopZoomAnimations()
|
stopZoomAnimations()
|
||||||
if (!coordIsValid(coord)) {
|
if (!coordIsValid(coord)) {
|
||||||
console.warn("MapWidget.qml: centerOnCoordinate(): !coordIsValid()")
|
console.warn("MapWidget.qml: centerOnCoordinate(): !coordIsValid()")
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
var newZoomOutFound = false
|
var newZoomOutFound = false
|
||||||
var zoomStored = zoomLevel
|
var zoomStored = zoomLevel
|
||||||
var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
|
var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
|
||||||
|
@ -174,13 +175,13 @@ Item {
|
||||||
newZoom = zoomStored
|
newZoom = zoomStored
|
||||||
mapAnimationZoomIn.restart()
|
mapAnimationZoomIn.restart()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function centerOnRectangle(topLeft, bottomRight, centerRect) {
|
function centerOnRectangle(topLeft, bottomRight, centerRect) {
|
||||||
stopZoomAnimations()
|
stopZoomAnimations()
|
||||||
if (newCenter.latitude === 0.0 && newCenter.longitude === 0.0) {
|
if (newCenter.latitude === 0.0 && newCenter.longitude === 0.0) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
|
var centerStored = QtPositioning.coordinate(center.latitude, center.longitude)
|
||||||
var zoomStored = zoomLevel
|
var zoomStored = zoomLevel
|
||||||
var newZoomOutFound = false
|
var newZoomOutFound = false
|
||||||
|
@ -218,7 +219,6 @@ Item {
|
||||||
center = centerStored
|
center = centerStored
|
||||||
mapAnimationZoomIn.restart()
|
mapAnimationZoomIn.restart()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function deselectMapLocation() {
|
function deselectMapLocation() {
|
||||||
stopZoomAnimations()
|
stopZoomAnimations()
|
||||||
|
|
Loading…
Reference in a new issue