-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QML locator filter framework for QField plugin #5841
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m-kuhn
reviewed
Nov 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
🎉 Ta-daaa, freshly created APKs are available for 04cd153: arm64-android |
nirvn
force-pushed
the
qfield_locator_filters
branch
from
November 22, 2024 03:25
e941716
to
2787284
Compare
nirvn
force-pushed
the
qfield_locator_filters
branch
from
November 23, 2024 04:49
2787284
to
4701c89
Compare
…to access the bool parameter
…centroid(), boundingBox(), and reprojectRectangle()
m-kuhn
reviewed
Nov 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Much wisdom gained from these lines of code.
The PR adds a framework that allows for plugin authors to integrate into the search bar through a QML-driven locator filter.
Here's a sample plugin registering a QML locator filter being declared:
The QFieldLocatorFilter item lives in the same thread and context as QField's mainWindow, and therefore can access the map canvas et al within the
triggerResult
function.Notice the source property of QFieldLocatorFilter. This is a sidecar QML component file that lives next to the main plugin QML (i.e. main.qml for app-wide plugins and my_project_file_name.qml for project plugins). That component must be declared in its own file as everything in there will be happening in a separate QML engine altogether, in a separate thread.
Also notice the use of a new property namedNote the use Qt.resolveUrl('my_file.qml') to resolve relative paths against the source file of the QML being loaded for the source property.pluginFolder
. This was added so plugins can load extra resource from their folder. To make use of it, simply declare a property var pluginFolder at the root of your plugin root Item {}.Moving on, here's a sample example of the source file (named testlocator.qml in the example above):
The use of the Timer here is merely to demonstrate how asynchronous result gathering happens. First, the function fetchResults(string, context) will be called. If the results can be computed right away, simply emit prepareResult(details) as many time as you want, and end the function by emitting fetchResultEnded(). However, it the very likely scenario the result fetching is waiting for some data (e.g. waiting for the response of an xmlhttprequest), the locator filter itself will wait until the fetchResultEnded() is emitted.
When all is done and understood, you'll get a beautiful integration:
0001-0208.webm
Here's a sample plugin that adds a GeoMapFish service into the search bar:
qfield-geomapfish-locator-v1.1.zip
Another sample plugin that adds OSM nominatim service into the search bar:
qfield-nominatim-locator-v1.1.zip
The framework also allows for plugins to add secondary actions to results. For example here, the search result has a secondary option to use the result geometry as destination:
0001-0220.webm