29 mKeyColumn->setLayer( mLayerName->currentLayer() );
30 mValueColumn->setLayer( mLayerName->currentLayer() );
31 mGroupColumn->setLayer( mLayerName->currentLayer() );
32 mGroupColumn->setAllowEmptyFieldName(
true );
33 mDescriptionExpression->setLayer( mLayerName->currentLayer() );
34 mOrderByFieldName->setLayer( mLayerName->currentLayer() );
35 mOrderByFieldName->setAllowEmptyFieldName(
false );
42 connect( mOrderByField, &QAbstractButton::toggled, mOrderByFieldName, [ = ](
bool enabled )
44 mOrderByFieldName->setEnabled( enabled );
47 mOrderByGroupBox->setCollapsed(
true );
49 mNofColumns->setMinimum( 1 );
50 mNofColumns->setMaximum( 10 );
51 mNofColumns->setValue( 1 );
56 connect( mGroupColumn,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int index )
58 mDisplayGroupName->setEnabled( index != 0 );
67 connect( mAllowMulti, &QAbstractButton::toggled,
this, [ = ](
bool checked )
69 label_nofColumns->setEnabled( checked );
70 mNofColumns->setEnabled( checked );
73 connect( mUseCompleter, &QCheckBox::stateChanged,
this, [ = ](
int state )
75 mCompleterMatchFromStart->setEnabled(
static_cast<Qt::CheckState
>( state ) == Qt::CheckState::Checked );
78 mCompleterMatchFromStart->setEnabled( mUseCompleter->isChecked() );
89 cfg.insert( QStringLiteral(
"Layer" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->id() : QString() );
90 cfg.insert( QStringLiteral(
"LayerName" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->name() : QString() );
91 cfg.insert( QStringLiteral(
"LayerSource" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->publicSource() : QString() );
92 cfg.insert( QStringLiteral(
"LayerProviderName" ), ( mLayerName->currentLayer() && mLayerName->currentLayer()->dataProvider() ) ?
93 mLayerName->currentLayer()->providerType() :
95 cfg.insert( QStringLiteral(
"Key" ), mKeyColumn->currentField() );
96 cfg.insert( QStringLiteral(
"Value" ), mValueColumn->currentField() );
97 cfg.insert( QStringLiteral(
"Group" ), mGroupColumn->currentField() );
98 cfg.insert( QStringLiteral(
"DisplayGroupName" ), mDisplayGroupName->isChecked() );
99 cfg.insert( QStringLiteral(
"Description" ), mDescriptionExpression->expression() );
100 cfg.insert( QStringLiteral(
"AllowMulti" ), mAllowMulti->isChecked() );
101 cfg.insert( QStringLiteral(
"NofColumns" ), mNofColumns->value() );
102 cfg.insert( QStringLiteral(
"AllowNull" ), mAllowNull->isChecked() );
103 cfg.insert( QStringLiteral(
"OrderByValue" ), mOrderByValue->isChecked() );
104 cfg.insert( QStringLiteral(
"OrderByKey" ), mOrderByKey->isChecked() );
105 cfg.insert( QStringLiteral(
"OrderByField" ), mOrderByField->isChecked() );
106 cfg.insert( QStringLiteral(
"OrderByFieldName" ), mOrderByFieldName->currentField() );
107 cfg.insert( QStringLiteral(
"OrderByDescending" ), mOrderByDescending->isChecked() );
108 cfg.insert( QStringLiteral(
"FilterExpression" ), mFilterExpression->toPlainText() );
109 cfg.insert( QStringLiteral(
"UseCompleter" ), mUseCompleter->isChecked() );
110 const Qt::MatchFlags completerMatchFlags { mCompleterMatchFromStart->isChecked() ? Qt::MatchFlag::MatchStartsWith : Qt::MatchFlag::MatchContains };
111 cfg.insert( QStringLiteral(
"CompleterMatchFlags" ),
static_cast<int>( completerMatchFlags ) );
119 mLayerName->setLayer( lyr );
120 mOrderByFieldName->setLayer( lyr );
121 mKeyColumn->setField(
config.value( QStringLiteral(
"Key" ) ).toString() );
122 mValueColumn->setField(
config.value( QStringLiteral(
"Value" ) ).toString() );
123 mGroupColumn->setField(
config.value( QStringLiteral(
"Group" ) ).toString() );
124 mDisplayGroupName->setChecked(
config.value( QStringLiteral(
"DisplayGroupName" ) ).toBool() );
125 mDescriptionExpression->setField(
config.value( QStringLiteral(
"Description" ) ).toString() );
126 mAllowMulti->setChecked(
config.value( QStringLiteral(
"AllowMulti" ) ).toBool() );
127 mNofColumns->setValue(
config.value( QStringLiteral(
"NofColumns" ), 1 ).toInt() );
128 if ( !mAllowMulti->isChecked() )
130 label_nofColumns->setEnabled(
false );
131 mNofColumns->setEnabled(
false );
133 mAllowNull->setChecked(
config.value( QStringLiteral(
"AllowNull" ) ).toBool() );
134 mOrderByValue->setChecked(
config.value( QStringLiteral(
"OrderByValue" ) ).toBool() );
135 mOrderByField->setChecked(
config.value( QStringLiteral(
"OrderByField" ) ).toBool() );
136 mOrderByKey->setChecked(
config.value( QStringLiteral(
"OrderByKey" ) ).toBool() );
137 mOrderByFieldName->setField(
config.value( QStringLiteral(
"OrderByFieldName" ) ).toString() );
138 mOrderByDescending->setChecked(
config.value( QStringLiteral(
"OrderByDescending" ) ).toBool() );
140 if ( !mOrderByField->isChecked() && !mOrderByValue->isChecked() && !mOrderByKey->isChecked() )
142 mOrderByKey->setChecked(
true );
146 if ( !mOrderByKey->isChecked() )
148 mOrderByGroupBox->setCollapsed(
false );
151 mFilterExpression->setPlainText(
config.value( QStringLiteral(
"FilterExpression" ) ).toString() );
152 mUseCompleter->setChecked(
config.value( QStringLiteral(
"UseCompleter" ) ).toBool() );
154 const Qt::MatchFlags completerMatchFlags {
config.contains( QStringLiteral(
"CompleterMatchFlags" ) ) ?
static_cast<Qt::MatchFlags
>(
config.value( QStringLiteral(
"CompleterMatchFlags" ), Qt::MatchFlag::MatchStartsWith ).toInt( ) ) : Qt::MatchFlag::MatchStartsWith };
155 mCompleterMatchFromStart->setChecked( completerMatchFlags.testFlag( Qt::MatchFlag::MatchStartsWith ) );
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 setHighlightedFunctions(const QStringList &names)
Sets the list of function names intended to be highlighted to the user.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.