27using namespace Qt::StringLiterals;
43 return new QgsDummyConfigDlg( vl, fieldIdx, parent, QObject::tr(
"Key/Value field" ) );
50 if ( field.
typeName().compare( u
"json"_s, Qt::CaseInsensitive ) == 0 || field.
typeName().compare( u
"jsonb"_s, Qt::CaseInsensitive ) == 0 )
53 const int MAX_FEATURE_LIMIT { 20 };
62 bool foundNotNull =
false;
63 bool foundInvalidValue =
false;
67 if ( featureCount > MAX_FEATURE_LIMIT )
72 const QVariant value( f.
attribute( fieldIdx ) );
73 if ( !value.isNull() )
78 QJsonObject jsonObject;
79 bool validObject =
false;
80 if ( value.type() == QVariant::Type::Map )
83 jsonObject = QJsonObject::fromVariantMap( value.toMap() );
87 const QJsonDocument doc = QJsonDocument::fromJson( value.toString().toUtf8() );
91 jsonObject = doc.object();
98 for (
auto it = jsonObject.begin(); it != jsonObject.end(); ++it )
105 const QJsonValue childValue = it.value();
106 if ( childValue.isObject() || childValue.isArray() || childValue.isUndefined() )
109 foundInvalidValue =
true;
113 if ( foundInvalidValue )
121 foundInvalidValue =
true;
128 if ( !foundInvalidValue )
143 return field.
type() == QMetaType::Type::QVariantMap && field.
subType() != QMetaType::Type::UnknownType ? 20 : 0;
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Configuration widget for dummy widgets.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Encapsulate a field in an attribute table or data source.
QString typeName() const
Gets the field type.
QMetaType::Type subType() const
If the field is a collection, gets its element's type.
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
Represents a vector layer which manages a vector based dataset.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const final
Queries the layer for features specified in request.