The QML map uses MapItemView. MapItemView needs a delagate
in the form of a MapQuickItem. The MapQuickItem needs a
'sourceItem' which would be used as the visual (e.g. marker)
on the map.
If the root sourceItem is of type Item, the marker becomes
non-clickable. If the root sourceItem is an Image, the clicks
work.
This patch removes the root Item, which makes the code
less organized, but at the same time it fixes the bug.
Bug reproduced on the following Qt versions on Ubuntu:
5.5.x, 5.7.x
Bug cannot be reproduced on Qt 5.9.x on Windows.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit implements possible switching BT on and off during a session,
so not needing a restart of the app when the user forgot to switch
it on when starting the app.
For this, the following needed to be done: 1) create a handler that
reacts on local BT device status changes. 2) repopulate the connection
list in the download screen when a BT status change is detected.
Notice the subtile change of the Q_INVOKABLE btEnabled() function
to a Q_PROPERTY. This gives a nice dynamic behaviour when
switching BT on/off with the app open.
Fixes: #556
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In certain places the '(int)' cast is used, while in other the
llrint() or lrint() functions. Make the conversation from degrees
in the 'double' form to the 'int' degrees_t consistent using lrint().
lrint() is the function which should give the best results,
because it accepts a 'double' and results in a 'long'
even if degrees_t is 'int'. If the truncation from 'long' to 'int'
is discarding some of the precision then the next step
would be to turn degrees_t into a 64bit signed integer type.
Possible fix for #625.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Commit cf8e87545f implemented a way to cancel pin setup,
and this also has effects on an exit from the app after pressing
the android exit. The change button started with clearing the
email and passwd in order to get the credentail page(s) active
again. While this worked ok, it confuses users that exit the
app from the credential pages, resulting in the need to enter
the credentials again after a restart. It appears that clearing
the credential state is sufficient to get the pages active.
Notice that the android exit is still not working (it seems
a no-op), but the interaction with the buttons in the app
preserves the email/passwd.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The old credential status should only be set when changing the
actual credential status using the setCredentialStatus function.
Setting it here is just wrong. It sets the old status to the
current, and than adds the current to the prefences,
obviously, resulting in old = current, which can not be right
and results in a wrong flow of control in the credential state
processing.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
If the QML modules for QtLocation and QtPositioning are
missing the QML in mapwidget.cpp will fail to load,
which can lead to crashes.
To solve the issue check if the QML has loaded and set
a flag 'isReady' to true. If the loading has failed
load another QML which is for showing a red error text
in the lines of `MapWidget.qml failed to load!`.
If the map QML has failed, use a macro in all relevant
MapWidget members to turn them into a NOP. This approach
leaves the rest of the codebase intact - e.g. no checks
in classes which connect to the MapWidget class.
Fixes#596
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is empty when shown with '-w' - it just updates the
indentation after commit c00804eff6 ("QML UI: always start edit at top
of page").
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When starting to edit / add a dive, the Flickable needs to be positioned
at the top of the page, not the last position shown.
For clarity I'll do the re-indentation in the next commit.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The hard switch was not ideal. This isn't perfect, yet, but a step in
the right direction. The 'transitions' to change the visibility
properties are a bit odd, but that's how it's done in the examples as
well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need a white path drawn on the dark action button, but a black path
drawn for the main menu.
(looks like a white space change snuck in here)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This addresses some review comment on whitespace and translated
string formatting.
In the string formatting, a tiny additional change is made.
I wanted the email address in the explanation text in a bold
font. Using the HTML <b> for this, removed the /n newline
characters in the output. Apparantly, mixing these two
formatting styles does not work. No problem, replaced the
/n to HTML style too.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit tries to implement most of issue #515. It reworks the
one credential page, which its dynamic PIN part, into two pages.
Main driver of selecting one of the two pages is the showPin
boolean. Page 1 contains the email/passwd field (and the
option to use a no cloud setup). Page 2 only contains the PIN
part (and the option to cancel the process).
The Kirigami central button does not seem very handy here. We
need, for example, a cancel, sign-in and register, only register,
etc. buttons, which are not easy to handle in specific icons.
Therefore, normal pushbuttons are chosen to deal with user
interaction, and the Kirigami button is removed from these
pages.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Previously, we could edit the cloud credentials in basically two
places. At startup of the app from a fresh install (and no previous
data on the device), and from the settings. Issue #515 proposes
only one way.
However, we need a way to access the new credential UI pages, so
that the pages at a fresh install of the app can be reused,
for example for account switching.
This commit replaces the settings cloud credentials block by
a simple (not editable) display of the current credentials, and
a button to access the initial pages, for all management tasks
on the credentials.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is just a precaution. It makes sure that the old
(aka previous) credential status is correctly set on all changes
of this status.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This is a very subtile bug. Testing/developing on the desktop for mobile,
with a normal logbook in a git repo, resulted in a surprising effect.
When swichting from a cloud account to a NOCLOUD situation, the no cloud
repo was (not always) reset to the NOCLOUD_LOCALSTORAGE, but to the
normal logbook. Resuling in commits in the wrong repo.
This can easily be solved by setting the filename to NOCLOUD_LOCALSTORAGE,
when switching to NOCLOUD mode.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In case the credential state is NOCLOUD, the saving of credentials
in the preferences was suppressed in case of invalid data in the
email/passwd fields.
There is no reason to check these fields for correct input, as they
are not used in case of NOCLOUD mode. A simple if statement is added.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
As written in 8d9ad3cfea7e4c0875, the user needs to be able
to exit the PIN entry UI, in case no PIN can be received due
to a wrong email address.
The simplest way seems to just clear the cloud credential data,
and let the user try again. Obviously, we could argue if the
exact previous state of the 1st credentials screen could
be restored, but as it is only 2 simple fields, of which
it is higly likely that the email adress is misspelled (and
the password hidden), it seems overly complex to implement.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Makes sure that the CS_NEED_TO_VERIFY status is carried forward
and sets the showPin flag that triggers the 2 different states
in de QML UI.
The new credential UI will have one page for username/passwd,
used for setting up an account or switchting to a different
account, and a second page to enter a PIN only.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
In case the credential status is UNKNOWN, and the cloud username
and password are empty, do not go automatically to NO_CLOUD status.
This is (again) preparation for future work on credential management.
For example, the user entered an email address with a spelling
error, so does not receive a PIN code email. This user needs a
way out, so there needs to be a <cancel> button on the PIN code
screen. And the most logic was of cancelling is emptying the
entered username/passwd and let the user try again.
Without this change, the user immediately gets into the (somewhat)
final NO_CLOUD state, which will result in (very) confused users.
With this change, there is exacly one way (left) to get into a
NO_CLOUD setup: hitting the proper button, so a deliberate user
action.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
It appears that the onCompleted of the StartPage item is triggered
before the onCompleted of the rootItem. This is logical as the
Startpage is a child of the rootItem. And, yes, this does matter.
As the divelist also contains the logic for initial cloud
registration (and is the default page shown in a state where
the cloud credentials are valid (CS_VERIFIED state)), we need to
know the correct credential state at start of the app.
The move of this one line of code makes sure of that, in addition
to setting the credential state from the preferences. Now, the
setupActions function can reference correct credential data.
This is further preparation for a better cloud creation
process from mobile.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
MapWidgetHelper::calculateSmallCircleRadius() uses
the second argument (boolean) of QDeclarativeGeoMap::toCoordinate()
and QDeclarativeGeoMap::fromCoordinate(), which isn't supported
in Qt 5.5.x and errors will be thrown on runtime.
This argument usage is redundant for the calculateSmallCircleRadius()
use case.
If the argument is set to "false" it tells the map to avoid
clipping the viewport and always return a valid QPointF/QGeoCoordinate.
Given that calculateSmallCircleRadius() only works with the
map center - i.e it's called like so in MapWidget.qml:
onZoomLevelChanged: mapHelper.calculateSmallCircleRadius(map.center)
The only way for the radius estimation to fail is if the map widget
width is smaller than SMALL_CIRCLE_RADIUS_PX * 2 = 52px, which is not
possible as the MainWindow splitter prevents it.
If the map widget becomes that small it would be hardly usable,
yet no errors should be thrown related to this change.
Tested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Following on beb0d5703a, the context menu seems to work fine
with a much older QtQuick import - version 2.0.
The 2.7 import is technically a development leftover
and a minimal version should have been considered earlier.
On older Qt setups (e.g. 5.5.x) this might throw a:
'module "QtQuick" version 2.6 is not installed'
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Having two different enums around with more or less the same
definition has lead to unclear code. After removing two not needed
states on the mobile end, the remaining step to one enum for the
credential state becomes almost is simple rename operation.
Unfortunately, I do not know a way to embed a plain C enum
from pref.h into the QMLManager object. So after this, there
are still 2 enums around, but now identical.
This commit is not changing any functionality.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
And here, the removal of a second superfluous state from QMLManager.
This is true no-brainer. While this state was set once troughout the
entire mobile code, it was never tested for this state. Testing shows
that it is safe to change to the UNKNOWN state.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This is a no-brainer removal of the VALID_EMAIL state used in QMLManager.
All current usage of this state is "if state is VALID or VALID_EMAIL",
so there is no distinction between the two states.
It is even a little different. The comment suggests "when we can open
a local cloud storage, tied to a cloud account (so explicitly not
the no-cloud status), we have at least a valid email". While this
is formally true, this implies that there is also a cloud account
on the cloud server (ie. the cloud account is in a VERIFIED state).
In other words: currently, there can't exist a valid local storage
that is tied to a valid email adress, without valid cloud account
on the server.
Notice that this touches the discussion on GitHub for commit
e76f527fe5 (pull request #520). Can we implement the creation
of a valid cloud account without data link to the cloud server?
Currently, we need the server to confirm the email address (for
example for uniqueness reasons on server side). Obviously, we could
hack our way out of this, but we have a perfect solution already
in place. Create a no-cloud account, and transfer that later to
a true and valid cloud account.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
When we want to go the NOCLOUD credential state, do not go the
incorrect INCOMPLETE state.
This is the first in a series of unraveling the preference parameter
prefs.cloud_verification_status and the data that is carried around
in the QMLManager::credentialStatus_t.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The default location which is used when the
PluginParemeter "googlemaps.cachefolder" is not specified
should be ~/.cache/googlemaps on Linux or
/user/<name>/appdata/local/cache/googlemaps on Windows.
This patch moves the cache to the default system location
where we store the printing templates, cloudstorage and the
default user XML file.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The googlemaps plugin is about to support tile language
via the PluginParameter 'googlemaps.maps.language'.
To be able to pass the subsurface UI language (obtained
from the uiLanguage() helper) the Plugin has to be created
dynamically, only *after* the MapWidgetHelper is created.
MapWidgetHelper::pluginObject() now provides a QString which
contains the Plugin object and also include the uiLanguage
ISO value.
This string is used in mapwidget.qml as:
map.plugin = Qt.createQmlObject(pluginObject, rootItem)
This creates the Plugin object dynamically with the proper
UI language string, but also requires a couple of small changes:
- move the declaration of map.mapType after the
Qt.createQmlObject() call
- assign map.activeMapType after map.mapType has a value
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Looking for already existing locations with
m_mapLocationModel->getMapLocationForUuid() will not cover dive
sites which are too close to each other and are skipped when
creating MapLocations. See reloadMapLocations() and the usage of
MIN_DISTANCE_BETWEEN_DIVE_SITES_M.
Constructing a new QGeoCoordinate for the already retrieved
dive site (ds) coordinates ensures that we are traversing
*all* dive sites at the backend and not only those visible on the map.
Fixes the issue where not all dives in the DiveList are selected,
even if a dive clearly happened on a location currently visible in
the map viewport (map -> context menu -> select visible dive
locations).
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The QML Map has a couple of methods - toCoordinate(someQPointF) and
fromCoordinate(someQGeoCoordinate). Ideally, if one passes a point to
toCoordinate() and then attempts to convert the resulted coordinates
back to the point, the same point in the Map view port with minimal error
should be retrieved. That's not always the case - e.g. near
47.400200 -123.142066, which means that the methods are not exactly
*reliable* and there might be Map class bugs at hand.
The new zoom-in and zoom-out improvements try to work around the above:
- for both centerOnRectangle() and centerOnCoordinate(), if no good
zoom-out level is found (newZoomOut), the zoom-out is set to the default
value of defaultZoomOut. In practice, this prevents the case where the map
does not zoom-out at all when going from one place to another
- centerOnRectangle() now uses rectangle diagonals to estimate a fit,
instead of checking if 2 points (top-left and bottom-right) are visible
in the viewport. The usage of fromCoordinate() was giving bad results
in this case and comparing distances (diagonals) is more reliable
but more expensive on the CPU.
Due to the inconsistencies of toCoordinate() and fromCoordinate()
the dynamic zoom-in and zoom-out are still not ideal, but the current
implementation is somewhat usable with decent accuracy.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This appears to fix the mystery crashes that can occur when deleting a dive
from the dive list.
Fixes: #497
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
This gets rid of TypeError messages, but does not appear to affect behaviour
qrc:///qml/DiveDetailsEdit.qml:254: TypeError: Cannot read property 'dive' of null
qrc:///qml/DiveDetailsEdit.qml:228: TypeError: Cannot read property 'dive' of null
qrc:///qml/DiveDetailsEdit.qml:216: TypeError: Cannot read property 'dive' of null
qrc:///qml/DiveDetailsEdit.qml:204: TypeError: Cannot read property 'dive' of null
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
MapWidgetContextMenu now has a new action (SELECT_VISIBLE_LOCATIONS),
that will invoke the MapWidgetHelper method selectVisibleLocations().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The new method selectVisibleLocations() contains a routine
to find all visible MapLocation objects in the Map viewport and
select the dives associated to said MapLocation objects.
This method is to be invoked from the QML context menu.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
First, this function calculates the zoom out effect until both the
current Map center and the target rectangle are visible - see the
"calculate zoom out" part.
Then it calculates a zoom level, so that the target rectangle
fits the viewport, but also so that the zoom is not too much (clamped).
see the "calculate zoom in" part.
NOTE: "centerStored" (the variable used to store the current map center)
is created using QtPositioning.coordinate(), because the code needs a new
object and not a reference of the map.center QGeoCoordinate object.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Add stopZoomAnimations(), which is really just a precaution
function to make sure we have stopped all animation of the
map before doing calculations! Since the animation *should*
be running in a separate thread, this would make sure the Map "center"
and "zoomLevel" properties do not change.
Add pointIsVisible(), which is a helper to determine
if a point created by map.fromCoordinate() method is inside
the viewport. fromCoordinate() has to be called without the
"false" (clip) flag for this to work.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
MapWidgetHelper::centerOnDiveSite() now checks if more than
one dive sites are selected and finds the most top-left and
bottom-right ones in the coordinate system to form
a rectangle.
It also supports the special cases where a selected dive site
does not have coordinates or the case where only a single dive site
with GPS coordinates are selected.
TODO: implement mapwidget.qml::centerOnRectangle()
This QML function will receive a QGeoCoordinate based rectangle which
has to be centered in the viewport with animation.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
For instance, if the 'googlemaps' geoservices plugin is missing
a new message is now shown:
"qml: MapWidget.qml: cannot find a plugin with the name 'googlemaps'"
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Do so until the following issue is resolved:
https://github.com/vladest/googlemaps/issues/9
With the satellite map ([1]), the black tiles at relatively high
zoom levels over the Red Sea cannot be seen. Instead it shows white
tiles at the ultra-maximum zoom level at places.
As a side note, the "satellite" map does not have the country labels
which the "hybrid" map has.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
No idea why this was restricted to be so narrow. Also, making
the font of the label smaller and lighter seems visually more
pleasing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This makes sure that the autocompleting comboboxes never displays the scroll list where the user can pick an entry, and as such forces the view of a autocompleting textfield from the users point of view. The reasoning is that when scrolling in the drop down list it it possible to scroll to far and thus abort the ongoing edit by flicking away the edit page.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Mobile devices hare rather limited when it comes to screen size,
there is no point in reducing the availabel space more than neccecary.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
This handles a cornercase where a user starts editing and then cances the divedit followed by a return to edit mode. The previously acive textfield would then be active again even though all changes are lost.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
For some reason the textfields on dive edit page did not loose focus when editing ended by press on the return key.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
When the user makes a selection using the autocomplete function while editing a dive the keyboard should close and the selection list should disappear.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Add star icons from the material repository.
https://material.io/icons/
The icons are under Apache License Version 2.0
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
This patch makes use of the geolocation plugin "googlemaps"
for Qt Location with source code from here:
https://github.com/vladest/googlemaps
The change from the ESRI plugin is that it requires new indexes
for the Hybrid ([3]) and Street ([0]) map types.
There are more zoom levels in this plugins, but our default zoom-in
settings seem to transition well to it.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
In commit e76f527fe5, the scenario of switching between 2 already
VERIFIED cloud accounts was identified, which was working poorly. It
needed a restart of the app to get the new account visible.
Reason for this, was the setting of the credentialStatus to the value
of an undefined (never set) old credentialStatus. This commit makes
sure we have a defined credentialStatus, just before changing it to
the new one.
A really mini step forward, as the behavior is still not perfect. Now,
the user has to select the dive list manually, after entering
credentials of the new clould account.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
The PIN (and cloud account creation) is not limited to the
desktop (any more). Correct the string accordingly.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
I thought we had this automated, but Lubomirs commits introduced a few
files with dos line endings. This is purely a change of line endings, no
other changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The C++ side for the desktop version already does that. Add a slot
for that in QML, for later use in the mobile version.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The editing support is added via dragging. It is handled via the
MouseArea's drag.target of the MapQuickItem. The drag target changes
with the model selectedUuid.
"mapAnimationZoomIn" now also does an initial zoom-out before moving
to a new location.
centerOnCoordinate() now pefroms calculations to determine how much
the animation needs to zoom out. What it does is it reduces the Map
zoomLevel util both the current and the new target coordinates are visible.
It then restores the zoomLevel and performs animation based on newZoomOut.
animateMapZoomIn() is now obsolete.
The patch also includes the following smaller changes:
- remove the setSelectedUuid() call in deselectMapLocation()
This is now handled in C++
- sets "defaultZoomIn" to 12.0
- use ">=" when determining if a mapItem text should be visible
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The MapWidgetHelper QML instance now has the slot onEditModeChanged()
which toggles the visiblity of a newly added message box that
notifies the user if editing mode is enabled.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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>
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>
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>
The MapItemView delegate now includes a white Text element.
It uses the MapLocation "name" property as text.
This text is only visible if the map zoom is above "textVisibleZoom".
For hundreds of dives, using the DropShadow effect for the text
makes it laggy. Instead, using a fake drop shadow (duplicate black
Text under the default text) makes it much better.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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>
The buttons are positioned bellow the "toggle map type" button
and increment / decrement the zoom by "zoomStep" (2 for now).
Also clamp the zoom-in level to "map.maximumZoomLevel".
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Double clicking a marker or the newly added MouseArea now performs
a +2 zoom-in over a period of 500ms and centers on that clicked
coordinate.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Different actions might be performed depending on the count of selected
dives - e.g. deep zoom only for a single selected dive.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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>
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>
The idea of this flag is to be able to only to emit the
selectedLocationChanged() signal when the user clicked on the map
(fromClick == true).
MapWidgetHelper::selectedLocationChanged() listens for this signal
and only then it will select nearby dives based on a "small-cicle".
If "fromClick" is false, it's the backend or the dive list that
updated the selection and MapWidgetHelper::selectedLocationChanged()
should no be called.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Each time the zoom changes MapWidgetHelper::calculateSmallCircleRadius()
is called, and the "small circle" radius is stored in both C++ and QML.
On the C++ side this radius will be used to select multiple nearby
dives.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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>
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>
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>
openLocationInGoogleMaps() now can be used to open a URL in an
external browser, triggered by the context menu. Use the same
Google Maps URL formating as in main.qml showMap().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The actionSelected() signal is now dispatched when the user selects
an action from the menu (see the "actions" object). Then the declaration
of the MapWidgetContextMenu object in mapwidget.qml can catch that
signal in the onActionSelected() slot and obtain the action via
switch() branching.
The actions enumeration is kept in QML for now, with the idea that
specific C++ methods from the mapwidgethelper class will be called
directly (if marked as Q_INVOCABLE), instead of a generic
onMapAction(action) C++ method in the helper. But if the actions
are possible from QML (like copying to clipboard) and are also
small and non-expensive, it might be better to keep them
in mapwidget.qml.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
- move the readonly properties near the top of the root Item
- move the rest of the properties bellow the readonly properties
- make the ListView Timer as a child of the ListView
- slight rename of the timer ID
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
NOTES:
- the ListView object uses lsitItemDelagate to display all elements from
the model listModel
- onCountChanged() is used to adjust the x position based on the
maxItemWidth property which is calculated when the items are populated
with text
- onVisibleChanged() is used to deselect the last selected item by
calling listModel.selectedIdx = -1
- onOpacityChanged() i sued to make sure that the View is hidden if the
opacity becomes 0.0
- inside the View there is a MouseAre which obtains the selected item via
indexAt(x,y)
- there is a Timer with id listViewVisibleTimer, which is called each
time the user selects an item from the list and the timer performs a
"delayed hide"
- a couple of State and a Transition objects are used to preform smooth
fade-in / out animation when the ListView is hidden or becomes visible
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This property would act like a state flag. If -1 (default) no QML State
animation will be pefromed, otherwise the ListView will either fade in
(1), or fade out (0) when the user clicks the context menu button
(Image) or selects an item from the list.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>