32 , mMessageBar( messageBar )
47 return QVariant(
field().type() );
51 return mLineEdit->text();
55 return QVariant(
field().type() );
78 return mLineEdit || mLabel || mQgsWidget;
81void QgsExternalResourceWidgetWrapper::updateProperties(
const QgsFeature &feature )
86 expressionContext.setFeature( feature );
103 if ( dvcString.compare( QLatin1String(
"image" ), Qt::CaseInsensitive ) == 0 )
107 else if ( dvcString.compare( QLatin1String(
"web" ), Qt::CaseInsensitive ) == 0 )
123 updateProperties( feature );
134 mForm = qobject_cast<QgsAttributeForm *>( parent );
144 mLineEdit = qobject_cast<QLineEdit *>( editor );
145 mLabel = qobject_cast<QLabel *>( editor );
146 mQgsWidget = qobject_cast<QgsExternalResourceWidget *>( editor );
157 mLineEdit = editor->findChild<QLineEdit *>();
165 const QVariantMap cfg =
config();
168 mQgsWidget->
setStorageType( cfg.value( QStringLiteral(
"StorageType" ) ).toString() );
177 if ( cfg.contains( QStringLiteral(
"UseLink" ) ) )
181 if ( cfg.contains( QStringLiteral(
"FullUrl" ) ) )
188 mQgsWidget->
setDefaultRoot( cfg.value( QStringLiteral(
"DefaultRoot" ) ).toString() );
190 if ( cfg.contains( QStringLiteral(
"StorageMode" ) ) )
194 if ( cfg.contains( QStringLiteral(
"RelativeStorage" ) ) )
198 if ( cfg.contains( QStringLiteral(
"FileWidget" ) ) )
202 if ( cfg.contains( QStringLiteral(
"FileWidgetButton" ) ) )
206 if ( cfg.contains( QStringLiteral(
"DocumentViewer" ) ) )
210 if ( cfg.contains( QStringLiteral(
"FileWidgetFilter" ) ) )
212 mQgsWidget->
fileWidget()->
setFilter( cfg.value( QStringLiteral(
"FileWidgetFilter" ) ).toString() );
214 if ( cfg.contains( QStringLiteral(
"DocumentViewerHeight" ) ) )
218 if ( cfg.contains( QStringLiteral(
"DocumentViewerWidth" ) ) )
225 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString &
value )
235void QgsExternalResourceWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
245 mLineEdit->setText(
value.toString() );
251 mLabel->setText(
value.toString() );
274 mLineEdit->setReadOnly( !enabled );
282 Q_UNUSED( newValue );
283 if ( attributeChanged )
292 updateProperties( feature );
297void QgsExternalResourceWidgetWrapper::updateConstraintWidgetStatus()
303 widget()->setStyleSheet( QString() );
310 mLineEdit->setStyleSheet( QString() );
314 mLineEdit->setStyleSheet( QStringLiteral(
"QgsFilterLineEdit { background-color: #dd7777; }" ) );
318 mLineEdit->setStyleSheet( QStringLiteral(
"QgsFilterLineEdit { background-color: #ffd85d; }" ) );
327 if ( !mQgsWidget || !
layer() )
333 if (
context().parentFormFeature().isValid() )
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string.
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
static QgsExpressionContextScope * parentFormScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current parent attribute form/tab...
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current attribute form/table form...
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
void setNullValue(const QString &nullValue)
Sets the string representation for null values in the widget.
A bar for displaying non-blocking messages to the user.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
bool loadVariant(const QVariant &configuration, const QgsPropertiesDefinition &definitions) override
Loads this property collection from a QVariantMap, wrapped in a QVariant.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QString expressionString() const
Returns the expression used for the property value.
static bool isNull(const QVariant &variant)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.