@@ -36,8 +36,7 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
3636 populateFields ();
3737 populateOutputFieldTypes ();
3838
39- QPushButton* okbutton = mButtonBox ->button ( QDialogButtonBox::Ok );
40- connect ( builder, SIGNAL ( expressionParsed ( bool ) ), okbutton, SLOT ( setEnabled ( bool ) ) );
39+ connect ( builder, SIGNAL ( expressionParsed ( bool ) ), this , SLOT ( setOkButtonState () ) );
4140
4241 // default values for field width and precision
4342 mOuputFieldWidthSpinBox ->setValue ( 10 );
@@ -269,7 +268,19 @@ void QgsFieldCalculator::populateFields()
269268
270269void QgsFieldCalculator::setOkButtonState ()
271270{
272- bool okEnabled = ( !mOutputFieldNameLineEdit ->text ().isEmpty () || mUpdateExistingGroupBox ->isChecked () ) && builder->isExpressionValid ();
271+ QPushButton* okButton = mButtonBox ->button ( QDialogButtonBox::Ok );
272+ okButton->setToolTip (" " );
273273
274- mButtonBox ->button ( QDialogButtonBox::Ok )->setEnabled ( okEnabled );
274+ bool emptyFieldName = mOutputFieldNameLineEdit ->text ().isEmpty ();
275+ bool expressionVaild = builder->isExpressionValid ();
276+
277+ if ( emptyFieldName )
278+ okButton->setToolTip ( tr (" Please enter a field name" ) );
279+
280+ if ( !expressionVaild )
281+ okButton->setToolTip ( okButton->toolTip () + tr (" \n The expression is invaild see (more info) for details" ) );
282+
283+ bool okEnabled = ( !emptyFieldName || mUpdateExistingGroupBox ->isChecked () ) && expressionVaild;
284+
285+ okButton->setEnabled ( okEnabled );
275286}
0 commit comments