Skip to content

Commit

Permalink
make merge attributes dialog translation agnostic (fixes #10681)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 23, 2014
1 parent 980b104 commit 13178fa
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -99,7 +99,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
QComboBox *cb = createMergeComboBox( fields[idx].type() );
if ( pkAttrList.contains( idx ) )
{
cb->setCurrentIndex( cb->findText( tr( "Skip attribute" ) ) );
cb->setCurrentIndex( cb->findData( "skip" ) );
}
mTableWidget->setCellWidget( 0, col, cb );

Expand Down Expand Up @@ -147,26 +147,26 @@ QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnT
QgsFeatureList::const_iterator f_it = mFeatureList.constBegin();
for ( ; f_it != mFeatureList.constEnd(); ++f_it )
{
newComboBox->addItem( tr( "Feature %1" ).arg( f_it->id() ) );
newComboBox->addItem( tr( "Feature %1" ).arg( f_it->id() ), QString::number( f_it->id() ) );
}

if ( columnType == QVariant::Double || columnType == QVariant::Int )
{
newComboBox->addItem( tr( "Minimum" ) );
newComboBox->addItem( tr( "Maximum" ) );
newComboBox->addItem( tr( "Median" ) );
newComboBox->addItem( tr( "Sum" ) );
newComboBox->addItem( tr( "Minimum" ), "minimum" );
newComboBox->addItem( tr( "Maximum" ), "maximum" );
newComboBox->addItem( tr( "Median" ), "median" );
newComboBox->addItem( tr( "Sum" ), "sum" );
}
else if ( columnType == QVariant::String )
{
newComboBox->addItem( tr( "Concatenation" ) );
newComboBox->addItem( tr( "Concatenation" ), "concat" );
}
else if ( columnType == QVariant::Double )
{
newComboBox->addItem( tr( "Mean" ) );
newComboBox->addItem( tr( "Mean" ), "mean" );
}

newComboBox->addItem( tr( "Skip attribute" ) );
newComboBox->addItem( tr( "Skip attribute" ), "skip" );

QObject::connect( newComboBox, SIGNAL( currentIndexChanged( const QString& ) ),
this, SLOT( comboValueChanged( const QString& ) ) );
Expand Down Expand Up @@ -243,39 +243,39 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
}

//evaluate behaviour (feature value or min / max / mean )
QString mergeBehaviourString = comboBox->currentText();
QString mergeBehaviourString = comboBox->itemData( comboBox->currentIndex() ).toString();
QVariant mergeResult; // result to show in the merge result field
if ( mergeBehaviourString == tr( "Minimum" ) )
if ( mergeBehaviourString == "minimum" )
{
mergeResult = minimumAttribute( col );
}
else if ( mergeBehaviourString == tr( "Maximum" ) )
else if ( mergeBehaviourString == "maximum" )
{
mergeResult = maximumAttribute( col );
}
else if ( mergeBehaviourString == tr( "Mean" ) )
else if ( mergeBehaviourString == "mean" )
{
mergeResult = meanAttribute( col );
}
else if ( mergeBehaviourString == tr( "Median" ) )
else if ( mergeBehaviourString == "median" )
{
mergeResult = medianAttribute( col );
}
else if ( mergeBehaviourString == tr( "Sum" ) )
else if ( mergeBehaviourString == "sum" )
{
mergeResult = sumAttribute( col );
}
else if ( mergeBehaviourString == tr( "Concatenation" ) )
else if ( mergeBehaviourString == "concat" )
{
mergeResult = concatenationAttribute( col );
}
else if ( mergeBehaviourString == tr( "Skip attribute" ) )
else if ( mergeBehaviourString == "skip" )
{
mergeResult = tr( "Skipped" );
}
else //an existing feature value
{
int featureId = mergeBehaviourString.split( " " ).value( 1 ).toInt(); //probably not very robust for translations...
int featureId = mergeBehaviourString.toInt();
mergeResult = featureAttribute( featureId, col );
}

Expand Down Expand Up @@ -494,7 +494,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
QComboBox* currentComboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
if ( currentComboBox )
{
currentComboBox->setCurrentIndex( currentComboBox->findText( tr( "Feature %1" ).arg( featureId ) ) );
currentComboBox->setCurrentIndex( currentComboBox->findData( QString::number( featureId ) ) );
}
}
}
Expand Down Expand Up @@ -547,7 +547,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
continue;

currentComboBox->blockSignals( true );
currentComboBox->removeItem( currentComboBox->findText( tr( "feature %1" ).arg( featureId ) ) );
currentComboBox->removeItem( currentComboBox->findData( QString::number( featureId ) ) );
currentComboBox->blockSignals( false );
}

Expand Down Expand Up @@ -600,7 +600,7 @@ QgsAttributes QgsMergeAttributesDialog::mergedAttributes() const
if ( idx >= results.count() )
results.resize( idx + 1 ); // make sure the results vector is long enough (maybe not necessary)

if ( comboBox->currentText() != tr( "Skip attribute" ) )
if ( comboBox->itemData( comboBox->currentIndex() ) != "skip" )
{
results[idx] = currentItem->data( Qt::DisplayRole );
}
Expand Down

0 comments on commit 13178fa

Please sign in to comment.