@@ -36,8 +36,7 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
36
36
populateFields ();
37
37
populateOutputFieldTypes ();
38
38
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 () ) );
41
40
42
41
// default values for field width and precision
43
42
mOuputFieldWidthSpinBox ->setValue ( 10 );
@@ -269,7 +268,19 @@ void QgsFieldCalculator::populateFields()
269
268
270
269
void QgsFieldCalculator::setOkButtonState ()
271
270
{
272
- bool okEnabled = ( !mOutputFieldNameLineEdit ->text ().isEmpty () || mUpdateExistingGroupBox ->isChecked () ) && builder->isExpressionValid ();
271
+ QPushButton* okButton = mButtonBox ->button ( QDialogButtonBox::Ok );
272
+ okButton->setToolTip (" " );
273
273
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 );
275
286
}
0 commit comments