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 ) {
43 mOrderByFieldName->setEnabled( enabled );
46 mOrderByGroupBox->setCollapsed(
true );
48 mNofColumns->setMinimum( 1 );
49 mNofColumns->setMaximum( 10 );
50 mNofColumns->setValue( 1 );
55 connect( mGroupColumn,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [=](
int index ) {
56 mDisplayGroupName->setEnabled( index != 0 );
65 connect( mAllowMulti, &QAbstractButton::toggled,
this, [=](
bool checked ) {
66 label_nofColumns->setEnabled( checked );
67 mNofColumns->setEnabled( checked );
70 connect( mUseCompleter, &QCheckBox::stateChanged,
this, [=](
int state ) {
71 mCompleterMatchFromStart->setEnabled(
static_cast<Qt::CheckState
>( state ) == Qt::CheckState::Checked );
74 mCompleterMatchFromStart->setEnabled( mUseCompleter->isChecked() );
85 cfg.insert( QStringLiteral(
"Layer" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->id() : QString() );
86 cfg.insert( QStringLiteral(
"LayerName" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->name() : QString() );
87 cfg.insert( QStringLiteral(
"LayerSource" ), mLayerName->currentLayer() ? mLayerName->currentLayer()->publicSource() : QString() );
88 cfg.insert( QStringLiteral(
"LayerProviderName" ), ( mLayerName->currentLayer() && mLayerName->currentLayer()->dataProvider() ) ? mLayerName->currentLayer()->providerType() : QString() );
89 cfg.insert( QStringLiteral(
"Key" ), mKeyColumn->currentField() );
90 cfg.insert( QStringLiteral(
"Value" ), mValueColumn->currentField() );
91 cfg.insert( QStringLiteral(
"Group" ), mGroupColumn->currentField() );
92 cfg.insert( QStringLiteral(
"DisplayGroupName" ), mDisplayGroupName->isChecked() );
93 cfg.insert( QStringLiteral(
"Description" ), mDescriptionExpression->expression() );
94 cfg.insert( QStringLiteral(
"AllowMulti" ), mAllowMulti->isChecked() );
95 cfg.insert( QStringLiteral(
"NofColumns" ), mNofColumns->value() );
96 cfg.insert( QStringLiteral(
"AllowNull" ), mAllowNull->isChecked() );
97 cfg.insert( QStringLiteral(
"OrderByValue" ), mOrderByValue->isChecked() );
98 cfg.insert( QStringLiteral(
"OrderByKey" ), mOrderByKey->isChecked() );
99 cfg.insert( QStringLiteral(
"OrderByField" ), mOrderByField->isChecked() );
100 cfg.insert( QStringLiteral(
"OrderByFieldName" ), mOrderByFieldName->currentField() );
101 cfg.insert( QStringLiteral(
"OrderByDescending" ), mOrderByDescending->isChecked() );
102 cfg.insert( QStringLiteral(
"FilterExpression" ), mFilterExpression->toPlainText() );
103 cfg.insert( QStringLiteral(
"UseCompleter" ), mUseCompleter->isChecked() );
104 const Qt::MatchFlags completerMatchFlags { mCompleterMatchFromStart->isChecked() ? Qt::MatchFlag::MatchStartsWith : Qt::MatchFlag::MatchContains };
105 cfg.insert( QStringLiteral(
"CompleterMatchFlags" ),
static_cast<int>( completerMatchFlags ) );
113 mLayerName->setLayer( lyr );
114 mOrderByFieldName->setLayer( lyr );
115 mKeyColumn->setField(
config.value( QStringLiteral(
"Key" ) ).toString() );
116 mValueColumn->setField(
config.value( QStringLiteral(
"Value" ) ).toString() );
117 mGroupColumn->setField(
config.value( QStringLiteral(
"Group" ) ).toString() );
118 mDisplayGroupName->setChecked(
config.value( QStringLiteral(
"DisplayGroupName" ) ).toBool() );
119 mDescriptionExpression->setField(
config.value( QStringLiteral(
"Description" ) ).toString() );
120 mAllowMulti->setChecked(
config.value( QStringLiteral(
"AllowMulti" ) ).toBool() );
121 mNofColumns->setValue(
config.value( QStringLiteral(
"NofColumns" ), 1 ).toInt() );
122 if ( !mAllowMulti->isChecked() )
124 label_nofColumns->setEnabled(
false );
125 mNofColumns->setEnabled(
false );
127 mAllowNull->setChecked(
config.value( QStringLiteral(
"AllowNull" ) ).toBool() );
128 mOrderByValue->setChecked(
config.value( QStringLiteral(
"OrderByValue" ) ).toBool() );
129 mOrderByField->setChecked(
config.value( QStringLiteral(
"OrderByField" ) ).toBool() );
130 mOrderByKey->setChecked(
config.value( QStringLiteral(
"OrderByKey" ) ).toBool() );
131 mOrderByFieldName->setField(
config.value( QStringLiteral(
"OrderByFieldName" ) ).toString() );
132 mOrderByDescending->setChecked(
config.value( QStringLiteral(
"OrderByDescending" ) ).toBool() );
134 if ( !mOrderByField->isChecked() && !mOrderByValue->isChecked() && !mOrderByKey->isChecked() )
136 mOrderByKey->setChecked(
true );
140 if ( !mOrderByKey->isChecked() )
142 mOrderByGroupBox->setCollapsed(
false );
145 mFilterExpression->setPlainText(
config.value( QStringLiteral(
"FilterExpression" ) ).toString() );
146 mUseCompleter->setChecked(
config.value( QStringLiteral(
"UseCompleter" ) ).toBool() );
148 const Qt::MatchFlags completerMatchFlags {
config.contains( QStringLiteral(
"CompleterMatchFlags" ) ) ?
static_cast<Qt::MatchFlags
>(
config.value( QStringLiteral(
"CompleterMatchFlags" ), Qt::MatchFlag::MatchStartsWith ).toInt() ) : Qt::MatchFlag::MatchStartsWith };
149 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.