Commit graph

26 commits

Author SHA1 Message Date
Berthold Stoeger
1d01fff006 Map: export isSelected as attribute from MapLocationModel
Recently we changed the MapLocationModel-items to store whether
they are selected. Thus, we can directly export an isSelected
flag instead of calling a function taking a dive-site argument.

1) This makes the QML easier to read.
2) This avoids passing pointers through QML which has caused
   us lots of pain.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
652b78657e Map: calculate the z value in the model
Since not fully reloading the map on selection change,
the selected sites were not moved to the top. Not calculating
the z-value in QML, but making it a simple model property
helps.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
488eb15423 Desktop: show all selected dive sites on click
When clicking a dive site on the map, the QML code would set
the selected dive site, but then all dives of dive sites in
the vicinity were set. But still only the clicked-on dive site
was shown.

Therefore, don't set the list of selected dive sites in QML,
but later in DiveListView::selectDives(), where we know all
the dives that were selected.

This, again, gives nasty entanglement of diverse widgets and
models.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
bce31ab862 Map: generate pixmap name in model
Experimentation has shown that the image of a flag will
only be changed after dataChanged() if it is a simple
property. The old code had a complex QML expression and
then - for some reason - it didn't work.

To give us better control over the flags and avoid full
reloads of the map therefore introduce a model-property
pixmap name. The name depends on whether the site is
selected and if not, whether we are in divesite-edit mode.
This makes the code rather convoluted. Firstly, we have
to save whether the site is selected in the map-item.
Secondly we have to access the global map-widget, which
in turn has to go to the map-widget helper (layering
violation!).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
28cb75b73d Map: explicitly reload selected map on click
When clicking on a flag
 1) The QML would call MapLocationModel::setSelected() with
    fromClick = true
 2) MapLocationModel::setSelected() would emit a signal
    selectedLocationChanged()
 3) MapWidgetHelper would catch that signal and do the actual
    processing.
Other functions would call MapLocationModel::setSelected() with
fromClick = false, which would not emit the selectedLocationChanged()
signal.

Detangle this a bit by calling the selectedLocationChanged() function
directly from QML and remove the fromClick parameter.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-06 11:48:47 -07:00
Berthold Stoeger
b3fd824d18 Map: catch null divesites in map widget selection code
Just to be sure, refuse to add null divesites to the selection.

Moreover, refuse to call the setSelected function on a null-divesite.
I got an unfriendly Qt-Warning there:

"Passing incompatible arguments to C++ functions from JavaScript is
dangerous and deprecated."
"This will throw a JavaScript TypeError in future releases of Qt!"

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-08-28 07:12:01 -07:00
Berthold Stoeger
a35d1bd0e7 Map: show multiple selected dive sites
If multiple dives are selected, highlight all corresponding sites.
For that, replace the MapLocationModel::m_selectedDs pointer by
a QVector<>. Fill the vector in MapLocationModel::reload() and
add a isSelected() member function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-05-11 12:06:19 -07:00
Berthold Stoeger
724055f0af Dive site: replace dive->dive_site_uuid by dive_site
Replace the UUID reference of struct dive by a pointer to dive_site.
This commit is rather large in lines, but nevertheless quite simple
since most of the UUID->pointer work was done in previous commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00: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
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
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
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
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