Skip to content

Commit

Permalink
Merge pull request #5991 from opengisch/bins_followup
Browse files Browse the repository at this point in the history
Additonal functionalities surrounding the code reader and geometry highlighter for plugins
  • Loading branch information
nirvn authored Feb 10, 2025
2 parents c9f12a5 + e0bd703 commit 4418868
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/core/locator/activelayerfeatureslocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ void ActiveLayerFeaturesLocatorFilter::triggerResultFromAction( const QgsLocator
mLocatorBridge->mapSettings()->setExtent( r, true );
}

mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom );
mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", layer->crs() );
mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom );
mLocatorBridge->geometryHighlighter()->setProperty( "crs", layer->crs() );
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/locator/bookmarklocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ void BookmarkLocatorFilter::triggerResultFromAction( const QgsLocatorResult &res
mLocatorBridge->bookmarks()->setExtentFromBookmark( mLocatorBridge->bookmarks()->index( row, 0 ) );

QgsGeometry geom( mLocatorBridge->bookmarks()->data( mLocatorBridge->bookmarks()->index( row, 0 ), BookmarkModel::BookmarkPoint ).value<QgsGeometry>() );
mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom );
mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() );
mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom );
mLocatorBridge->geometryHighlighter()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() );
}
4 changes: 2 additions & 2 deletions src/core/locator/featureslocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void FeaturesLocatorFilter::triggerResultFromAction( const QgsLocatorResult &res
mLocatorBridge->mapSettings()->setExtent( r, true );


mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom );
mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", layer->crs() );
mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom );
mLocatorBridge->geometryHighlighter()->setProperty( "crs", layer->crs() );
}
}
4 changes: 2 additions & 2 deletions src/core/locator/finlandlocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ void FinlandLocatorFilter::handleGeocodeResult( const QgsGeocoderResult &result

mLocatorBridge->mapSettings()->setCenter( transformedGeometry.centroid().vertexAt( 0 ), true );

mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", result.geometry() );
mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", result.crs() );
mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", result.geometry() );
mLocatorBridge->geometryHighlighter()->setProperty( "crs", result.crs() );
}
4 changes: 2 additions & 2 deletions src/core/locator/gotolocatorfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void GotoLocatorFilter::triggerResultFromAction( const QgsLocatorResult &result,
{
mLocatorBridge->mapSettings()->setCenter( geom.vertexAt( 0 ), true );

mLocatorBridge->locatorHighlightGeometry()->setProperty( "qgsGeometry", geom );
mLocatorBridge->locatorHighlightGeometry()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() );
mLocatorBridge->geometryHighlighter()->setProperty( "qgsGeometry", geom );
mLocatorBridge->geometryHighlighter()->setProperty( "crs", mLocatorBridge->mapSettings()->mapSettings().destinationCrs() );
}
}
12 changes: 6 additions & 6 deletions src/core/locator/locatormodelsuperbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ void LocatorModelSuperBridge::setMapSettings( QgsQuickMapSettings *mapSettings )
emit mapSettingsChanged();
}

QObject *LocatorModelSuperBridge::locatorHighlightGeometry() const
QObject *LocatorModelSuperBridge::geometryHighlighter() const
{
return mLocatorHighlightGeometry;
return mGeometryHighlighter;
}

void LocatorModelSuperBridge::setLocatorHighlightGeometry( QObject *locatorHighlightGeometry )
void LocatorModelSuperBridge::setGeometryHighlighter( QObject *geometryHighlighter )
{
if ( locatorHighlightGeometry == mLocatorHighlightGeometry )
if ( mGeometryHighlighter == geometryHighlighter )
return;

mLocatorHighlightGeometry = locatorHighlightGeometry;
emit locatorHighlightGeometryChanged();
mGeometryHighlighter = geometryHighlighter;
emit geometryHighlighterChanged();
}

FeatureListExtentController *LocatorModelSuperBridge::featureListController() const
Expand Down
14 changes: 7 additions & 7 deletions src/core/locator/locatormodelsuperbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge
//! The current project's map settings
Q_PROPERTY( QgsQuickMapSettings *mapSettings READ mapSettings WRITE setMapSettings NOTIFY mapSettingsChanged )
//! The locator highlight geometry object through which locator actions can highhlight features
Q_PROPERTY( QObject *locatorHighlightGeometry READ locatorHighlightGeometry WRITE setLocatorHighlightGeometry NOTIFY locatorHighlightGeometryChanged )
Q_PROPERTY( QObject *geometryHighlighter READ geometryHighlighter WRITE setGeometryHighlighter NOTIFY geometryHighlighterChanged )
//! The feature list extent controller
Q_PROPERTY( FeatureListExtentController *featureListController READ featureListController WRITE setFeatureListController NOTIFY featureListControllerChanged )
//! The current project's active layer
Expand Down Expand Up @@ -94,10 +94,10 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge
//! \copydoc LocatorModelSuperBridge::navigation
void setNavigation( Navigation *navigation );

//! \copydoc LocatorModelSuperBridge::locatorHighlightGeometry
QObject *locatorHighlightGeometry() const;
//! \copydoc LocatorModelSuperBridge::locatorHighlightGeometry
void setLocatorHighlightGeometry( QObject *locatorHighlightGeometry );
//! \copydoc LocatorModelSuperBridge::geometryHighlighter
QObject *geometryHighlighter() const;
//! \copydoc LocatorModelSuperBridge::geometryHighlighter
void setGeometryHighlighter( QObject *geometryHighlighter );

//! \copydoc LocatorModelSuperBridge::featureListController
FeatureListExtentController *featureListController() const;
Expand Down Expand Up @@ -158,7 +158,7 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge
void mapSettingsChanged();
void bookmarksChanged();
void navigationChanged();
void locatorHighlightGeometryChanged();
void geometryHighlighterChanged();
void featureListControllerChanged();
void activeLayerChanged();
void messageEmitted( const QString &text );
Expand All @@ -172,7 +172,7 @@ class LocatorModelSuperBridge : public QgsLocatorModelBridge

private:
QgsQuickMapSettings *mMapSettings = nullptr;
QObject *mLocatorHighlightGeometry = nullptr;
QObject *mGeometryHighlighter = nullptr;
FeatureListExtentController *mFeatureListController = nullptr;
QPointer<QgsMapLayer> mActiveLayer;
bool mKeepScale = false;
Expand Down
6 changes: 5 additions & 1 deletion src/qml/CodeReader.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import Theme
Popup {
id: codeReader

//! Emitted when a QR code or NFC tag has been decoded/received
signal decoded(var string)
//! Emitted when a QR code or NFC tag has been accepted
signal accepted(var string)

property string decodedString: ''
property var barcodeRequestedItem: undefined //<! when a feature form is requesting a bardcode, this will be set to attribute editor widget which triggered the request
Expand Down Expand Up @@ -70,6 +73,7 @@ Popup {
if (decodedString !== '') {
codeReader.decodedString = decodedString;
decodedFlashAnimation.start();
decoded(decodedString);
}
}
}
Expand Down Expand Up @@ -525,7 +529,7 @@ Popup {
codeReader.barcodeRequestedItem.requestedBarcodeReceived(codeReader.decodedString);
codeReader.barcodeRequestedItem = undefined;
} else {
codeReader.decoded(codeReader.decodedString);
codeReader.accepted(codeReader.decodedString);
}
codeReader.close();
}
Expand Down
2 changes: 1 addition & 1 deletion src/qml/LocatorItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Item {
target: codeReader
enabled: false

function onDecoded(string) {
function onAccepted(string) {
var prefix = locatorBridge.getPrefixFromSearchString(searchField.text);
searchField.text = prefix !== '' ? prefix + ' ' + string : string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/qml/editorwidgets/RelationReference.qml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ EditorWidgetBase {
onClicked: {
if (listModel.currentLayer !== undefined) {
var feature = listModel.getFeatureFromKeyValue(relationReference.currentKeyValue);
locatorHighlightItem.geometryWrapper.qgsGeometry = feature.geometry;
locatorHighlightItem.geometryWrapper.crs = listModel.currentLayer.crs;
geometryHighlighter.geometryWrapper.qgsGeometry = feature.geometry;
geometryHighlighter.geometryWrapper.crs = listModel.currentLayer.crs;
mapCanvas.mapSettings.extent = FeatureUtils.extent(mapCanvas.mapSettings, listModel.currentLayer, feature);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ EditorWidgetBase {

onClicked: {
if (orderedRelationModel.relation.referencingLayer !== undefined) {
locatorHighlightItem.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry;
locatorHighlightItem.geometryWrapper.crs = orderedRelationModel.relation.referencingLayer.crs;
geometryHighlighter.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry;
geometryHighlighter.geometryWrapper.crs = orderedRelationModel.relation.referencingLayer.crs;
mapCanvas.mapSettings.extent = FeatureUtils.extent(mapCanvas.mapSettings, orderedRelationModel.relation.referencingLayer, nmRelationId ? model.nmReferencingFeature : model.referencingFeature);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/qml/editorwidgets/relationeditors/relation_editor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ EditorWidgetBase {

onClicked: {
if (relationEditorModel.relation.referencingLayer !== undefined) {
locatorHighlightItem.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry;
locatorHighlightItem.geometryWrapper.crs = relationEditorModel.relation.referencingLayer.crs;
geometryHighlighter.geometryWrapper.qgsGeometry = nmRelationId ? model.nmReferencingFeature.geometry : model.referencingFeature.geometry;
geometryHighlighter.geometryWrapper.crs = relationEditorModel.relation.referencingLayer.crs;
mapCanvas.mapSettings.extent = FeatureUtils.extent(mapCanvas.mapSettings, relationEditorModel.relation.referencingLayer, nmRelationId ? model.nmReferencingFeature : model.referencingFeature);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ApplicationWindow {
featureListController: featureForm.extentController
mapSettings: mapCanvas.mapSettings
navigation: navigation
locatorHighlightGeometry: locatorHighlightItem.geometryWrapper
geometryHighlighter: geometryHighlighter.geometryWrapper
keepScale: qfieldSettings.locatorKeepScale

onMessageEmitted: {
Expand Down Expand Up @@ -987,7 +987,8 @@ ApplicationWindow {

/* Highlight features identified by locator or relation editor widgets */
GeometryHighlighter {
id: locatorHighlightItem
id: geometryHighlighter
objectName: "geometryHighlighter"
}

MapToScreen {
Expand Down

0 comments on commit 4418868

Please sign in to comment.