22 , mExistingLabels( existingLabels )
23 , mOriginalLabel( label )
28 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QgsExpressionStoreDialog::accept );
29 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QgsExpressionStoreDialog::reject );
30 mValidationError->hide();
31 mValidationError->setStyleSheet( QStringLiteral(
"QLabel { color : red; }" ) );
32 QPushButton *saveBtn { buttonBox->button( QDialogButtonBox::StandardButton::Save ) };
33 saveBtn->setEnabled(
false );
34 connect( mLabel, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
37 if ( mOriginalLabel.simplified() != text.simplified() &&
38 mExistingLabels.contains( text.simplified() ) )
40 errorMessage = tr(
"A stored expression with this name already exists" );
42 else if ( text.contains(
'/' ) || text.contains(
'\\' ) )
44 errorMessage = tr(
"Labels cannot contain slashes (/ or \\)" );
46 if ( ! errorMessage.isEmpty() )
48 mValidationError->show();
49 mValidationError->setText( errorMessage );
50 saveBtn->setEnabled( false );
54 mValidationError->hide();
55 saveBtn->setEnabled( true );
59 QString labelFixed {
label };
60 labelFixed.remove(
'/' ).remove(
'\\' );
61 mLabel->setText( labelFixed.simplified() );
QgsExpressionStoreDialog(const QString &label, const QString &expression, const QString &helpText, const QStringList &existingLabels=QStringList(), QWidget *parent=nullptr)
Creates a QgsExpressionStoreDialog with given label, expression and helpText.