30#include "moc_qgsexternalresourcewidgetwrapper.cpp"
32using namespace Qt::StringLiterals;
36 , mMessageBar( messageBar )
44 return mQgsWidget->documentPath(
field().type() );
55 return mLineEdit->text();
82 return mLineEdit || mLabel || mQgsWidget;
85void QgsExternalResourceWidgetWrapper::updateProperties(
const QgsFeature &feature )
90 expressionContext.setFeature( feature );
107 if ( dvcString.compare(
"image"_L1, Qt::CaseInsensitive ) == 0 )
111 else if ( dvcString.compare(
"audio"_L1, Qt::CaseInsensitive ) == 0 )
115 else if ( dvcString.compare(
"video"_L1, Qt::CaseInsensitive ) == 0 )
119 else if ( dvcString.compare(
"web"_L1, Qt::CaseInsensitive ) == 0 )
127 mQgsWidget->setDocumentViewerContent( dvc );
135 updateProperties( feature );
146 mForm = qobject_cast<QgsAttributeForm *>( parent );
156 mLineEdit = qobject_cast<QLineEdit *>( editor );
157 mLabel = qobject_cast<QLabel *>( editor );
158 mQgsWidget = qobject_cast<QgsExternalResourceWidget *>( editor );
169 mLineEdit = editor->findChild<QLineEdit *>();
173 mQgsWidget->setMessageBar( mMessageBar );
177 const QVariantMap cfg =
config();
180 mQgsWidget->setStorageType( cfg.value( u
"StorageType"_s ).toString() );
181 mQgsWidget->setStorageAuthConfigId( cfg.value( u
"StorageAuthConfigId"_s ).toString() );
187 if ( cfg.contains( u
"UseLink"_s ) )
189 mQgsWidget->fileWidget()->setUseLink( cfg.value( u
"UseLink"_s ).toBool() );
191 if ( cfg.contains( u
"FullUrl"_s ) )
193 mQgsWidget->fileWidget()->setFullUrl( cfg.value( u
"FullUrl"_s ).toBool() );
198 mQgsWidget->setDefaultRoot( cfg.value( u
"DefaultRoot"_s ).toString() );
200 if ( cfg.contains( u
"StorageMode"_s ) )
204 if ( cfg.contains( u
"RelativeStorage"_s ) )
208 if ( cfg.contains( u
"FileWidget"_s ) )
210 mQgsWidget->setFileWidgetVisible( cfg.value( u
"FileWidget"_s ).toBool() );
212 if ( cfg.contains( u
"FileWidgetButton"_s ) )
214 mQgsWidget->fileWidget()->setFileWidgetButtonVisible( cfg.value( u
"FileWidgetButton"_s ).toBool() );
216 if ( cfg.contains( u
"DocumentViewer"_s ) )
220 if ( cfg.contains( u
"FileWidgetFilter"_s ) )
222 mQgsWidget->fileWidget()->setFilter( cfg.value( u
"FileWidgetFilter"_s ).toString() );
224 if ( cfg.contains( u
"DocumentViewerHeight"_s ) )
226 mQgsWidget->setDocumentViewerHeight( cfg.value( u
"DocumentViewerHeight"_s ).toInt() );
228 if ( cfg.contains( u
"DocumentViewerWidth"_s ) )
230 mQgsWidget->setDocumentViewerWidth( cfg.value( u
"DocumentViewerWidth"_s ).toInt() );
235 connect( mLineEdit, &QLineEdit::textChanged,
this, [
this](
const QString &
value ) {
243void QgsExternalResourceWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
253 mLineEdit->setText(
value.toString() );
259 mLabel->setText(
value.toString() );
274 mQgsWidget->setDocumentPath(
value.toString() );
282 mLineEdit->setReadOnly( !enabled );
285 mQgsWidget->setReadOnly( !enabled );
290 Q_UNUSED( newValue );
291 if ( attributeChanged )
298 const QgsFeature feature = mForm->currentFormFeature();
299 updateProperties( feature );
310 widget()->setStyleSheet( QString() );
317 mLineEdit->setStyleSheet( QString() );
321 mLineEdit->setStyleSheet( u
"QgsFilterLineEdit { background-color: #dd7777; }"_s );
325 mLineEdit->setStyleSheet( u
"QgsFilterLineEdit { background-color: #ffd85d; }"_s );
334 if ( !mQgsWidget || !
layer() )
340 if (
context().parentFormFeature().isValid() )
345 mQgsWidget->fileWidget()->setExpressionContext( expressionContext );
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.
Handles 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 hasActiveProperties() const final
Returns true if the collection has any active properties, or false if all properties within the colle...
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 dataset.
#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.