Skip to content

Commit 13178fa

Browse files
committed
make merge attributes dialog translation agnostic (fixes #10681)
1 parent 980b104 commit 13178fa

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/app/qgsmergeattributesdialog.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
9999
QComboBox *cb = createMergeComboBox( fields[idx].type() );
100100
if ( pkAttrList.contains( idx ) )
101101
{
102-
cb->setCurrentIndex( cb->findText( tr( "Skip attribute" ) ) );
102+
cb->setCurrentIndex( cb->findData( "skip" ) );
103103
}
104104
mTableWidget->setCellWidget( 0, col, cb );
105105

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

153153
if ( columnType == QVariant::Double || columnType == QVariant::Int )
154154
{
155-
newComboBox->addItem( tr( "Minimum" ) );
156-
newComboBox->addItem( tr( "Maximum" ) );
157-
newComboBox->addItem( tr( "Median" ) );
158-
newComboBox->addItem( tr( "Sum" ) );
155+
newComboBox->addItem( tr( "Minimum" ), "minimum" );
156+
newComboBox->addItem( tr( "Maximum" ), "maximum" );
157+
newComboBox->addItem( tr( "Median" ), "median" );
158+
newComboBox->addItem( tr( "Sum" ), "sum" );
159159
}
160160
else if ( columnType == QVariant::String )
161161
{
162-
newComboBox->addItem( tr( "Concatenation" ) );
162+
newComboBox->addItem( tr( "Concatenation" ), "concat" );
163163
}
164164
else if ( columnType == QVariant::Double )
165165
{
166-
newComboBox->addItem( tr( "Mean" ) );
166+
newComboBox->addItem( tr( "Mean" ), "mean" );
167167
}
168168

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

171171
QObject::connect( newComboBox, SIGNAL( currentIndexChanged( const QString& ) ),
172172
this, SLOT( comboValueChanged( const QString& ) ) );
@@ -243,39 +243,39 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
243243
}
244244

245245
//evaluate behaviour (feature value or min / max / mean )
246-
QString mergeBehaviourString = comboBox->currentText();
246+
QString mergeBehaviourString = comboBox->itemData( comboBox->currentIndex() ).toString();
247247
QVariant mergeResult; // result to show in the merge result field
248-
if ( mergeBehaviourString == tr( "Minimum" ) )
248+
if ( mergeBehaviourString == "minimum" )
249249
{
250250
mergeResult = minimumAttribute( col );
251251
}
252-
else if ( mergeBehaviourString == tr( "Maximum" ) )
252+
else if ( mergeBehaviourString == "maximum" )
253253
{
254254
mergeResult = maximumAttribute( col );
255255
}
256-
else if ( mergeBehaviourString == tr( "Mean" ) )
256+
else if ( mergeBehaviourString == "mean" )
257257
{
258258
mergeResult = meanAttribute( col );
259259
}
260-
else if ( mergeBehaviourString == tr( "Median" ) )
260+
else if ( mergeBehaviourString == "median" )
261261
{
262262
mergeResult = medianAttribute( col );
263263
}
264-
else if ( mergeBehaviourString == tr( "Sum" ) )
264+
else if ( mergeBehaviourString == "sum" )
265265
{
266266
mergeResult = sumAttribute( col );
267267
}
268-
else if ( mergeBehaviourString == tr( "Concatenation" ) )
268+
else if ( mergeBehaviourString == "concat" )
269269
{
270270
mergeResult = concatenationAttribute( col );
271271
}
272-
else if ( mergeBehaviourString == tr( "Skip attribute" ) )
272+
else if ( mergeBehaviourString == "skip" )
273273
{
274274
mergeResult = tr( "Skipped" );
275275
}
276276
else //an existing feature value
277277
{
278-
int featureId = mergeBehaviourString.split( " " ).value( 1 ).toInt(); //probably not very robust for translations...
278+
int featureId = mergeBehaviourString.toInt();
279279
mergeResult = featureAttribute( featureId, col );
280280
}
281281

@@ -494,7 +494,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
494494
QComboBox* currentComboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
495495
if ( currentComboBox )
496496
{
497-
currentComboBox->setCurrentIndex( currentComboBox->findText( tr( "Feature %1" ).arg( featureId ) ) );
497+
currentComboBox->setCurrentIndex( currentComboBox->findData( QString::number( featureId ) ) );
498498
}
499499
}
500500
}
@@ -547,7 +547,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
547547
continue;
548548

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

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

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

0 commit comments

Comments
 (0)