17#include "moc_qgsexternalresourcewidgetwrapper.cpp"
33 , mMessageBar( messageBar )
52 return mLineEdit->text();
79 return mLineEdit || mLabel || mQgsWidget;
82void QgsExternalResourceWidgetWrapper::updateProperties(
const QgsFeature &feature )
87 expressionContext.setFeature( feature );
104 if ( dvcString.compare( QLatin1String(
"image" ), Qt::CaseInsensitive ) == 0 )
108 else if ( dvcString.compare( QLatin1String(
"audio" ), Qt::CaseInsensitive ) == 0 )
112 else if ( dvcString.compare( QLatin1String(
"video" ), Qt::CaseInsensitive ) == 0 )
116 else if ( dvcString.compare( QLatin1String(
"web" ), Qt::CaseInsensitive ) == 0 )
132 updateProperties( feature );
143 mForm = qobject_cast<QgsAttributeForm *>( parent );
153 mLineEdit = qobject_cast<QLineEdit *>( editor );
154 mLabel = qobject_cast<QLabel *>( editor );
155 mQgsWidget = qobject_cast<QgsExternalResourceWidget *>( editor );
166 mLineEdit = editor->findChild<QLineEdit *>();
174 const QVariantMap cfg =
config();
177 mQgsWidget->
setStorageType( cfg.value( QStringLiteral(
"StorageType" ) ).toString() );
184 if ( cfg.contains( QStringLiteral(
"UseLink" ) ) )
188 if ( cfg.contains( QStringLiteral(
"FullUrl" ) ) )
195 mQgsWidget->
setDefaultRoot( cfg.value( QStringLiteral(
"DefaultRoot" ) ).toString() );
197 if ( cfg.contains( QStringLiteral(
"StorageMode" ) ) )
201 if ( cfg.contains( QStringLiteral(
"RelativeStorage" ) ) )
205 if ( cfg.contains( QStringLiteral(
"FileWidget" ) ) )
209 if ( cfg.contains( QStringLiteral(
"FileWidgetButton" ) ) )
213 if ( cfg.contains( QStringLiteral(
"DocumentViewer" ) ) )
217 if ( cfg.contains( QStringLiteral(
"FileWidgetFilter" ) ) )
219 mQgsWidget->
fileWidget()->
setFilter( cfg.value( QStringLiteral(
"FileWidgetFilter" ) ).toString() );
221 if ( cfg.contains( QStringLiteral(
"DocumentViewerHeight" ) ) )
225 if ( cfg.contains( QStringLiteral(
"DocumentViewerWidth" ) ) )
232 connect( mLineEdit, &QLineEdit::textChanged,
this, [=](
const QString &
value ) {
240void QgsExternalResourceWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
250 mLineEdit->setText(
value.toString() );
256 mLabel->setText(
value.toString() );
279 mLineEdit->setReadOnly( !enabled );
287 Q_UNUSED( newValue );
288 if ( attributeChanged )
296 updateProperties( feature );
301void QgsExternalResourceWidgetWrapper::updateConstraintWidgetStatus()
307 widget()->setStyleSheet( QString() );
314 mLineEdit->setStyleSheet( QString() );
318 mLineEdit->setStyleSheet( QStringLiteral(
"QgsFilterLineEdit { background-color: #dd7777; }" ) );
322 mLineEdit->setStyleSheet( QStringLiteral(
"QgsFilterLineEdit { background-color: #ffd85d; }" ) );
331 if ( !mQgsWidget || !
layer() )
337 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()
Returns the string 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.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
bool loadVariant(const QVariant &configuration, const QgsPropertiesDefinition &definitions) final
Loads this property collection from a QVariantMap, wrapped in a QVariant.
bool hasActiveProperties() const final
Returns true if the collection has any active properties, or false if all properties within the colle...
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
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, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static QVariant createNullVariant(QMetaType::Type metaType)
Helper method to properly create a null QVariant from a metaType Returns the created QVariant.
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.