17 #include <QPushButton>
22 , mExistingLabels( existingLabels )
27 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QgsExpressionStoreDialog::accept );
28 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QgsExpressionStoreDialog::reject );
29 mValidationError->hide();
30 mValidationError->setStyleSheet( QStringLiteral(
"QLabel { color : red; }" ) );
31 QPushButton *saveBtn { buttonBox->button( QDialogButtonBox::StandardButton::Save ) };
32 saveBtn->setEnabled(
false );
33 connect( mLabel, &QLineEdit::textChanged,
this, [ = ](
const QString & text )
36 if ( mExistingLabels.contains( text ) )
38 errorMessage = tr(
"A stored expression with this name already exists" );
40 else if ( text.contains(
'/' ) || text.contains(
'\\' ) )
42 errorMessage = tr(
"Labels cannot contain slashes (/ or \\)" );
44 if ( ! errorMessage.isEmpty() )
46 mValidationError->show();
47 mValidationError->setText( errorMessage );
48 saveBtn->setEnabled( false );
52 mValidationError->hide();
53 saveBtn->setEnabled( true );
57 QString labelFixed {
label };
58 labelFixed.remove(
'/' ).remove(
'\\' );
59 mLabel->setText( labelFixed );
67 return mHelpText->toHtml().replace(
"<meta name=\"qrichtext\" content=\"1\" />", QString() );