Skip to content

Commit 361fe1a

Browse files
authored
Merge pull request #6071 from opengisch/plugins_createfeature_context
Fix NFC tag capture not sending decoded signal & allow to pass on position and cloud user information scops when creating features using FeatureUtils.createFeature() function
2 parents e2dcb8e + 5681880 commit 361fe1a

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/core/utils/featureutils.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* *
1515
***************************************************************************/
1616

17+
#include "expressioncontextutils.h"
1718
#include "featureutils.h"
1819
#include "qgsquickmapsettings.h"
1920

@@ -35,11 +36,19 @@ QgsFeature FeatureUtils::createBlankFeature( const QgsFields &fields, const QgsG
3536
return feature;
3637
}
3738

38-
QgsFeature FeatureUtils::createFeature( QgsVectorLayer *layer, const QgsGeometry &geometry )
39+
QgsFeature FeatureUtils::createFeature( QgsVectorLayer *layer, const QgsGeometry &geometry, const GnssPositionInformation &positionInformation, const CloudUserInformation &cloudUserInformation )
3940
{
4041
QgsFeature feature;
4142
QgsAttributeMap attributes;
4243
QgsExpressionContext context = layer->createExpressionContext();
44+
if ( positionInformation.isValid() )
45+
{
46+
context << ExpressionContextUtils::positionScope( positionInformation, false );
47+
}
48+
if ( !cloudUserInformation.isEmpty() )
49+
{
50+
context << ExpressionContextUtils::cloudUserScope( cloudUserInformation );
51+
}
4352
feature = QgsVectorLayerUtils::createFeature( layer, geometry, attributes, &context );
4453
return feature;
4554
}

src/core/utils/featureutils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#ifndef FEATUREUTILS_H
1717
#define FEATUREUTILS_H
1818

19+
#include "gnsspositioninformation.h"
1920
#include "qfield_core_export.h"
21+
#include "qfieldcloudutils.h"
2022

2123
#include <QObject>
2224
#include <qgsfeature.h>
@@ -42,7 +44,7 @@ class QFIELD_CORE_EXPORT FeatureUtils : public QObject
4244
/**
4345
* Returns a new feature with its fields set to default values.
4446
*/
45-
static Q_INVOKABLE QgsFeature createFeature( QgsVectorLayer *layer, const QgsGeometry &geometry = QgsGeometry() );
47+
static Q_INVOKABLE QgsFeature createFeature( QgsVectorLayer *layer, const QgsGeometry &geometry = QgsGeometry(), const GnssPositionInformation &positionInformation = GnssPositionInformation(), const CloudUserInformation &cloudUserInformation = CloudUserInformation() );
4648

4749
/**
4850
* Returns the display name of a given feature.

src/qml/CodeReader.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ Popup {
5656
}
5757
}
5858

59+
onDecodedStringChanged: {
60+
if (decodedString != "") {
61+
decoded(decodedString);
62+
}
63+
}
64+
5965
QfCameraPermission {
6066
id: cameraPermission
6167
}
@@ -73,7 +79,6 @@ Popup {
7379
if (decodedString !== '') {
7480
codeReader.decodedString = decodedString;
7581
decodedFlashAnimation.start();
76-
decoded(decodedString);
7782
}
7883
}
7984
}

src/qml/qgismobileapp.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,6 +3902,7 @@ ApplicationWindow {
39023902

39033903
ProjectInfo {
39043904
id: projectInfo
3905+
objectName: "projectInfo"
39053906

39063907
mapSettings: mapCanvas.mapSettings
39073908
layerTree: dashBoard.layerTree

0 commit comments

Comments
 (0)