23 , mExistingLabels( existingLabels )
24 , mOriginalLabel( label )
29 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QgsExpressionStoreDialog::accept );
30 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QgsExpressionStoreDialog::reject );
31 mValidationError->hide();
32 mValidationError->setStyleSheet( QStringLiteral(
"QLabel { color : red; }" ) );
33 QPushButton *saveBtn { buttonBox->button( QDialogButtonBox::StandardButton::Save ) };
34 saveBtn->setEnabled(
false );
35 connect( mLabel, &QLineEdit::textChanged,
this, [=](
const QString &text ) {
37 if ( mOriginalLabel.simplified() != text.simplified() && mExistingLabels.contains( text.simplified() ) )
39 errorMessage = tr(
"A stored expression with this name already exists" );
41 else if ( text.contains(
'/' ) || text.contains(
'\\' ) )
43 errorMessage = tr(
"Labels cannot contain slashes (/ or \\)" );
45 if ( !errorMessage.isEmpty() )
47 mValidationError->show();
48 mValidationError->setText( errorMessage );
49 saveBtn->setEnabled( false );
53 mValidationError->hide();
54 saveBtn->setEnabled( true );
58 QString labelFixed {
label };
59 labelFixed.remove(
'/' ).remove(
'\\' );
60 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.