aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qmlmapwidgethelper.cpp
AgeCommit message (Collapse)Author
2017-07-28mapwidgethelper: add methods for editing MapLocationsGravatar Lubomir I. Ivanov
updateCurrentDiveSiteCoordinates() should be called from QML when a marker changed it's location. it emits the coordinatesChanged() signal, which should be tracked in the MapWidget class. The MapWidget class should emit the same signal to the MainWindow (Marble does that). editMode is now a boolean property, which should put the QML map into editing mode. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: add the same logic for markers as in globe.cppGravatar Lubomir I. Ivanov
The marble globe tracks dive sites with the same name and discards such that are less than 50 meters apart. We already store names in MapLocation objects, but using a QMap<QString, MapLocation *> to check the names is probably faster with the expense of using more memory. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: change centerOnDiveSite()Gravatar Lubomir I. Ivanov
Call setSelectedUuid() from C++ also center on coodinates instead on a MapLocation, as there is no point to pass the MapLocation object back to QML. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28maplocationmodel: add the "namer" propertyGravatar Lubomir I. Ivanov
The MapLocation QObject now has a QString property "name", which is translating the dive_site->name member. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: emit a selectedDivesChanged() signalGravatar Lubomir I. Ivanov
The signal emits a QList<int> filled with dive idexes from the main backend dive table. The MapWidgetHelper QML instance handles that in onSelectedDivesChanged(). This will only be needed for the mobile version, as the desktop version should connect it's own slot in MapWidget.cpp. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: obtain a list of nearby divesGravatar Lubomir I. Ivanov
Based on a current location (MapLocation), iterate the dive list and add nearby dives (distance smaller than m_smallCircleRadius) to a local QList property (m_selectedDiveIds). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: add means to obtain a small circle radiusGravatar Lubomir I. Ivanov
Based on a QGeoCoordinate, calculateSmallCircleRadius() calls some QML Map methods to obtain how big a circle is in meters if a circle is drawn over the Map widget with radius SMALL_CIRCLE_RADIUS_PX pixels. This is called a "small circle" of a sphere: https://en.wikipedia.org/wiki/Circle_of_a_sphere This "small circle" radius becomes huge if the map is zoomed out, while quite small if the map is really zoomed in. The idea behind this circle is to be able to select multiple nearby dives, when clicking on the map (TODO). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: skip dive sites which are near each otherGravatar Lubomir I. Ivanov
Use QGeoCoordinate::distanceTo() to skip dive sites which are too close (50m) to dives sites which are already added as MapLocations. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: add the method copyToClipboardCoordinates()Gravatar Lubomir I. Ivanov
This method uses the helper printGPSCoords() to format the coordinates of a location into either decimal or sexagesimal. The selection is handled by the boolean flag "formatTraditional" and the user preferences flag - prefs.coordinates_traditional. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper.cpp: call deselectMapLocation() in QMLGravatar Lubomir I. Ivanov
If a divesite doesn't have a GPS location we want to deselect the currently selected markers and zoom out the map. In the Map QML object the function deselectMapLocation will handle that. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: pass a MapLocation object to QML in centerOnDiveSite()Gravatar Lubomir I. Ivanov
The function in QML centerOnCoordinate() is now renamed centerOnMapLocation() and accepts a MapLocation object, so that a marker is selected (based on UUID). In MapWidgetHelper::centerOnDiveSite(), the pointer to a MapLocation is retrieved via MapLocationModel::getMapLocationForUuid(). Added in the previous commit. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: add a slot to handle marker selection from the modelGravatar Lubomir I. Ivanov
When MapLocationModel updates the selected marker, MapWidgetHelper now receives a signal. The slot is named selectedLocationChanged(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28maplocationmodel: add a "uuid" property to MapLocationGravatar Lubomir I. Ivanov
The "uuid" property will be the one from the dive_site. At first it will also be used to track the active marker/flag selection. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: pass a QGeoCoordinate to the QML mapGravatar Lubomir I. Ivanov
Rename the QML function "centerOnCoordinates" to "centerOnCoordinate" and pass a QGeoCoordinate to it in ::centerOnDiveSite(). This will prevent the creation of a QGeoCoordinate object on the QML side and instead it will be created in C++. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28maplocationmodel: use QVector for the MapLocation storageGravatar Lubomir I. Ivanov
QVector is faster, use it for "m_mapLocations" instead of QList. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28maplocationmodel: add the addList() methodGravatar Lubomir I. Ivanov
This method should be used if many markers are added at once. It's main purpose is to reduces the number of beingInsertRows() calls. Make MapWidgetHelper::reloadMapLocations() use it. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidgethelper: add the reloadMapLocations() methodGravatar Lubomir I. Ivanov
reloadMapLocations() is the method which is called when the list of markers (model) should be cleared and re-populated with new MapLocation objects. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28qmlmapwidgethelper: maintain an instance of MapLocationModelGravatar Lubomir I. Ivanov
The idea here is that the QML code should be able to fetch a model from the MapWidgetHelper instance which is instantiated inside the QML code; fetch it in the lines of "mapHelper.model". This way, updates at the backend would be reflected on the Map QML widget. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28add the SPDX-License-Identifier to new source filesGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mapwidget.qml: add the function centerOnCoordinates()Gravatar Lubomir I. Ivanov
This function can be called to center the map on a specific coordinates. For the C++ version call it via QMetaObject::invokeMethod() in centerOnDiveSite(). TODO: add QML property animations. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28qmlmapwidgethelper: add the centerOnDiveSite() methodGravatar Lubomir I. Ivanov
MapWidget sould not handle any of the map backend. Instead it should just pass calls to MapWidgetHelper. Do that for centerOnDiveSite(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28qmlmapwidgethelper: remove stray test() methodGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-07-28mobile-widgets: add the helper class MapWidgetHelperGravatar Lubomir I. Ivanov
The idea with this class is that it should be used by both the mobile and desktop version. TODO STEPS: 1) the class should be registered in both the mobile and desktop version with qmlRegisterType<MapWidgetHelper>... 2) the MapWidget.qml should create an instance of this class. 3) this way the helper will be part of the QML and both the desktop and mobile version can have access to it. 4) the desktop version as a first implementation can just use findChild() in desktop-widgets/mapwidget.cpp. 5) desktop-widgets/mapwidget.cpp on the desktop should just translate calls from the rest of the desktop-widgets to this helper class. 6) the mobile version access to this object would be easy but is off the scope for now. 7) the idea, when implementing the desktop support is to make it so that when implementing the mobile version later, no or only minimal changes would be required to the MapWidgetHelper class. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>