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(
"audio" ), Qt::CaseInsensitive ) == 0 )
111 else if ( dvcString.compare( QLatin1String(
"video" ), Qt::CaseInsensitive ) == 0 )
115 else if ( dvcString.compare( QLatin1String(
"web" ), Qt::CaseInsensitive ) == 0 )
131 updateProperties( feature );
142 mForm = qobject_cast<QgsAttributeForm *>( parent );
152 mLineEdit = qobject_cast<QLineEdit *>( editor );
153 mLabel = qobject_cast<QLabel *>( editor );
154 mQgsWidget = qobject_cast<QgsExternalResourceWidget *>( editor );
165 mLineEdit = editor->findChild<QLineEdit *>();
173 const QVariantMap cfg =
config();
176 mQgsWidget->
setStorageType( cfg.value( QStringLiteral(
"StorageType" ) ).toString() );
185 if ( cfg.contains( QStringLiteral(
"UseLink" ) ) )
189 if ( cfg.contains( QStringLiteral(
"FullUrl" ) ) )
196 mQgsWidget->
setDefaultRoot( cfg.value( QStringLiteral(
"DefaultRoot" ) ).toString() );
198 if ( cfg.contains( QStringLiteral(
"StorageMode" ) ) )
202 if ( cfg.contains( QStringLiteral(
"RelativeStorage" ) ) )
206 if ( cfg.contains( QStringLiteral(
"FileWidget" ) ) )
210 if ( cfg.contains( QStringLiteral(
"FileWidgetButton" ) ) )
214 if ( cfg.contains( QStringLiteral(
"DocumentViewer" ) ) )
218 if ( cfg.contains( QStringLiteral(
"FileWidgetFilter" ) ) )
220 mQgsWidget->
fileWidget()->
setFilter( cfg.value( QStringLiteral(
"FileWidgetFilter" ) ).toString() );
222 if ( cfg.contains( QStringLiteral(
"DocumentViewerHeight" ) ) )
226 if ( cfg.contains( QStringLiteral(
"DocumentViewerWidth" ) ) )
233 connect( mLineEdit, &QLineEdit::textChanged,
this, [ = ](
const QString &
value )
243void QgsExternalResourceWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
253 mLineEdit->setText(
value.toString() );
259 mLabel->setText(
value.toString() );
282 mLineEdit->setReadOnly( !enabled );
290 Q_UNUSED( newValue );
291 if ( attributeChanged )
300 updateProperties( feature );
305void QgsExternalResourceWidgetWrapper::updateConstraintWidgetStatus()
311 widget()->setStyleSheet( QString() );
318 mLineEdit->setStyleSheet( QString() );
322 mLineEdit->setStyleSheet( QStringLiteral(
"QgsFilterLineEdit { background-color: #dd7777; }" ) );
326 mLineEdit->setStyleSheet( QStringLiteral(
"QgsFilterLineEdit { background-color: #ffd85d; }" ) );
335 if ( !mQgsWidget || !
layer() )
341 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.