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:
Lubomir I. Ivanov 2017-11-27 17:13:57 +02:00
parent 1d80b08a8f
commit 837ed67d86

View file

@ -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()