Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fieldcalculator buttons tooltips test #227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/gui/vector/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer *vl, QWidget *parent )
connect( mCreateVirtualFieldCheckbox, &QCheckBox::stateChanged, this, &QgsFieldCalculator::mCreateVirtualFieldCheckbox_stateChanged );
connect( mOutputFieldNameLineEdit, &QLineEdit::textChanged, this, &QgsFieldCalculator::mOutputFieldNameLineEdit_textChanged );
connect( mOutputFieldTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::activated ), this, &QgsFieldCalculator::mOutputFieldTypeComboBox_activated );
connect( mExistingFieldComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFieldCalculator::mExistingFieldComboBox_currentIndexChanged );

QgsGui::enableAutoGeometryRestore( this );

Expand Down Expand Up @@ -502,6 +503,12 @@ void QgsFieldCalculator::mOutputFieldTypeComboBox_activated( int index )
setPrecisionMinMax();
}

void QgsFieldCalculator::mExistingFieldComboBox_currentIndexChanged( const int index )
{
Q_UNUSED( index )
setDialogButtonState();
}

void QgsFieldCalculator::populateFields()
{
if ( !mVectorLayer )
Expand Down Expand Up @@ -574,9 +581,20 @@ void QgsFieldCalculator::setDialogButtonState()
tooltip = tr( "Please enter a field name" );
enableButtons = false;
}
else if ( ( mUpdateExistingGroupBox->isChecked() || !mNewFieldGroupBox->isEnabled() )
&& mExistingFieldComboBox->currentIndex() == -1 )
{
tooltip = tr( "Please select a field" );
enableButtons = false;
}
else if ( builder->expressionText().isEmpty() )
{
tooltip = tr( "Please insert an expression" );
enableButtons = false;
}
else if ( !builder->isExpressionValid() )
{
tooltip = tr( "The expression is invalid see \"(more info)\" for details" );
tooltip = tr( "The expression is invalid. See \"(more info)\" for details" );
enableButtons = false;
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/vector/qgsfieldcalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class GUI_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalcula
void mCreateVirtualFieldCheckbox_stateChanged( int state );
void mOutputFieldNameLineEdit_textChanged( const QString &text );
void mOutputFieldTypeComboBox_activated( int index );
void mExistingFieldComboBox_currentIndexChanged( const int index );

//! Sets the dialog buttons (Ok and Apply) enabled / disabled
void setDialogButtonState();
Expand Down
Loading