QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
18 #include <QPushButton>
32 , mMessageBar( messageBar )
47 return QVariant(
field().type() );
51 return mLineEdit->text();
55 return QVariant(
field().type() );
78 return mLineEdit || mLabel || mQgsWidget;
81 void 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 )
235 void QgsExternalResourceWidgetWrapper::updateValues(
const QVariant &value,
const QVariantList & )
239 if (
value.isNull() )
245 mLineEdit->setText(
value.toString() );
251 mLabel->setText(
value.toString() );
260 if (
value.isNull() )
274 mLineEdit->setReadOnly( !enabled );
282 Q_UNUSED( newValue );
283 if ( attributeChanged )
292 updateProperties( feature );
297 void 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() )
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
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...
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
bool loadVariant(const QVariant &configuration, const QgsPropertiesDefinition &definitions) override
Loads this property collection from a QVariantMap, wrapped in a QVariant.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
QString expressionString() const
Returns the expression used for the property value.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
#define Q_NOWARN_DEPRECATED_POP
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
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...
A bar for displaying non-blocking messages to the user.
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.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Represents a vector layer which manages a vector based data sets.
void setNullValue(const QString &nullValue)
Sets the string representation for null values in the widget.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Class for parsing and evaluation of expressions (formerly called "search strings")....
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
#define Q_NOWARN_DEPRECATED_PUSH
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.