28 mKeyColumn->setLayer( mLayerName->currentLayer() );
29 mValueColumn->setLayer( mLayerName->currentLayer() );
35 mNofColumns->setMinimum( 1 );
36 mNofColumns->setMaximum( 10 );
37 mNofColumns->setValue( 1 );
47 connect( mAllowMulti, &QAbstractButton::toggled,
this, [ = ](
bool checked )
49 label_nofColumns->setEnabled( checked );
50 mNofColumns->setEnabled( checked );
63 cfg.insert( QStringLiteral(
"Layer" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->id() : QString() );
64 cfg.insert( QStringLiteral(
"LayerName" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->name() : QString() );
65 cfg.insert( QStringLiteral(
"LayerSource" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->publicSource() : QString() );
66 cfg.insert( QStringLiteral(
"LayerProviderName" ), ( mLayerName->currentLayer() && mLayerName->currentLayer()->dataProvider() ) ?
67 mLayerName->currentLayer()->providerType() :
69 cfg.insert( QStringLiteral(
"Key" ), mKeyColumn->currentField() );
70 cfg.insert( QStringLiteral(
"Value" ), mValueColumn->currentField() );
71 cfg.insert( QStringLiteral(
"AllowMulti" ), mAllowMulti->isChecked() );
72 cfg.insert( QStringLiteral(
"NofColumns" ), mNofColumns->value() );
73 cfg.insert( QStringLiteral(
"AllowNull" ), mAllowNull->isChecked() );
74 cfg.insert( QStringLiteral(
"OrderByValue" ), mOrderByValue->isChecked() );
75 cfg.insert( QStringLiteral(
"FilterExpression" ), mFilterExpression->toPlainText() );
76 cfg.insert( QStringLiteral(
"UseCompleter" ), mUseCompleter->isChecked() );
84 mLayerName->setLayer( lyr );
85 mKeyColumn->setField( config.value( QStringLiteral(
"Key" ) ).toString() );
86 mValueColumn->setField( config.value( QStringLiteral(
"Value" ) ).toString() );
87 mAllowMulti->setChecked( config.value( QStringLiteral(
"AllowMulti" ) ).toBool() );
88 mNofColumns->setValue( config.value( QStringLiteral(
"NofColumns" ), 1 ).toInt() );
89 if ( !mAllowMulti->isChecked() )
91 label_nofColumns->setEnabled(
false );
92 mNofColumns->setEnabled(
false );
94 mAllowNull->setChecked( config.value( QStringLiteral(
"AllowNull" ) ).toBool() );
95 mOrderByValue->setChecked( config.value( QStringLiteral(
"OrderByValue" ) ).toBool() );
96 mFilterExpression->setPlainText( config.value( QStringLiteral(
"FilterExpression" ) ).toString() );
97 mUseCompleter->setChecked( config.value( QStringLiteral(
"UseCompleter" ) ).toBool() );
100 void QgsValueRelationConfigDlg::layerChanged()
102 mFilterExpression->setEnabled( qobject_cast<QgsVectorLayer *>( mLayerName->currentLayer() ) );
103 mEditExpression->setEnabled( qobject_cast<QgsVectorLayer *>( mLayerName->currentLayer() ) );
117 << QStringLiteral(
"current_feature" )
118 << QStringLiteral(
"form_mode" ) );
121 dlg.setWindowTitle( tr(
"Edit Filter Expression" ) );
123 if ( dlg.exec() == QDialog::Accepted )
125 mFilterExpression->setText( dlg.expressionBuilder()->expressionText() );
QVariantMap config() override
Create a configuration from the current GUI state.
void setConfig(const QVariantMap &config) override
Update the configuration widget to represent the given configuration.
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 feat...
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
void setHighlightedFunctions(const QStringList &names)
Sets the list of function names intended to be highlighted to the user.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
void setLayer(QgsMapLayer *layer)
Sets the layer for which fields are listed in the combobox.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
QgsValueRelationConfigDlg(QgsVectorLayer *vl, int fieldIdx, QWidget *parent=nullptr)
Represents a vector layer which manages a vector based data sets.
A generic dialog for building expression strings.