Skip to content

Commit b23ddfe

Browse files
committedDec 10, 2015
Fix taking attribute values in merge attributes dialog (fix #13971)
Also fix handling of long feature ids in tool.
1 parent f93fce7 commit b23ddfe

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed
 

‎src/app/qgsmergeattributesdialog.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ QComboBox *QgsMergeAttributesDialog::createMergeComboBox( QVariant::Type columnT
170170
QgsFeatureList::const_iterator f_it = mFeatureList.constBegin();
171171
for ( ; f_it != mFeatureList.constEnd(); ++f_it )
172172
{
173-
newComboBox->addItem( tr( "Feature %1" ).arg( f_it->id() ), QString( "f%1" ).arg( f_it->id() ) );
173+
newComboBox->addItem( tr( "Feature %1" ).arg( f_it->id() ), QString( "f%1" ).arg( FID_TO_STRING( f_it->id() ) ) );
174174
}
175175

176176
if ( columnType == QVariant::Double || columnType == QVariant::Int )
@@ -223,7 +223,7 @@ void QgsMergeAttributesDialog::selectedRowChanged()
223223
{
224224
//find out selected row
225225
QList<QTableWidgetItem *> selectionList = mTableWidget->selectedItems();
226-
if ( selectionList.size() < 1 )
226+
if ( selectionList.isEmpty() )
227227
{
228228
delete mSelectionRubberBand;
229229
mSelectionRubberBand = 0;
@@ -245,7 +245,7 @@ void QgsMergeAttributesDialog::selectedRowChanged()
245245
}
246246

247247
bool conversionSuccess = false;
248-
int featureIdToSelect = idItem->text().toInt( &conversionSuccess );
248+
QgsFeatureId featureIdToSelect = idItem->text().toLongLong( &conversionSuccess );
249249
if ( !conversionSuccess )
250250
{
251251
//the merge result row was selected
@@ -275,10 +275,10 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
275275
{
276276
mergeResult = tr( "Skipped" );
277277
}
278-
else if ( mergeBehaviourString.startsWith( "f" ) )
278+
else if ( mergeBehaviourString.startsWith( 'f' ) )
279279
{
280-
//an existing feature value - TODO should be QgsFeatureId, not int
281-
int featureId = mergeBehaviourString.mid( 1 ).toInt();
280+
//an existing feature value
281+
QgsFeatureId featureId = STRING_TO_FID( mergeBehaviourString.mid( 1 ) );
282282
mergeResult = featureAttribute( featureId, col );
283283
}
284284
else
@@ -295,7 +295,7 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
295295
mTableWidget->setItem( mTableWidget->rowCount() - 1, col, newTotalItem );
296296
}
297297

298-
QVariant QgsMergeAttributesDialog::featureAttribute( int featureId, int col )
298+
QVariant QgsMergeAttributesDialog::featureAttribute( QgsFeatureId featureId, int col )
299299
{
300300
int idx = mTableWidget->horizontalHeaderItem( col )->data( Qt::UserRole ).toInt();
301301

@@ -362,7 +362,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
362362

363363
//find out feature id of selected row
364364
QList<QTableWidgetItem *> selectionList = mTableWidget->selectedItems();
365-
if ( selectionList.size() < 1 )
365+
if ( selectionList.isEmpty() )
366366
{
367367
return;
368368
}
@@ -377,7 +377,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
377377
}
378378

379379
bool conversionSuccess;
380-
int featureId = selectedHeaderItem->text().toInt( &conversionSuccess );
380+
QgsFeatureId featureId = selectedHeaderItem->text().toLongLong( &conversionSuccess );
381381
if ( !conversionSuccess )
382382
{
383383
return;
@@ -393,7 +393,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
393393
QComboBox* currentComboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
394394
if ( currentComboBox )
395395
{
396-
currentComboBox->setCurrentIndex( currentComboBox->findData( QString::number( featureId ) ) );
396+
currentComboBox->setCurrentIndex( currentComboBox->findData( QString( "f%1" ).arg( FID_TO_STRING( featureId ) ) ) );
397397
}
398398
}
399399
}
@@ -407,7 +407,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
407407

408408
//find out feature id of selected row
409409
QList<QTableWidgetItem *> selectionList = mTableWidget->selectedItems();
410-
if ( selectionList.size() < 1 )
410+
if ( selectionList.isEmpty() )
411411
{
412412
return;
413413
}
@@ -422,7 +422,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
422422
}
423423

424424
bool conversionSuccess;
425-
int featureId = selectedHeaderItem->text().toInt( &conversionSuccess );
425+
QgsFeatureId featureId = selectedHeaderItem->text().toLongLong( &conversionSuccess );
426426
if ( !conversionSuccess )
427427
{
428428
selectedRowChanged();
@@ -446,7 +446,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
446446
continue;
447447

448448
currentComboBox->blockSignals( true );
449-
currentComboBox->removeItem( currentComboBox->findData( QString::number( featureId ) ) );
449+
currentComboBox->removeItem( currentComboBox->findData( QString( "f%1" ).arg( FID_TO_STRING( featureId ) ) ) );
450450
currentComboBox->blockSignals( false );
451451
}
452452

@@ -463,7 +463,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
463463
}
464464
}
465465

466-
void QgsMergeAttributesDialog::createRubberBandForFeature( int featureId )
466+
void QgsMergeAttributesDialog::createRubberBandForFeature( QgsFeatureId featureId )
467467
{
468468
//create rubber band to highlight the feature
469469
delete mSelectionRubberBand;

‎src/app/qgsmergeattributesdialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
6767
/** Calculates the merged value of a column (depending on the selected merge behaviour) and inserts the value in the corresponding cell*/
6868
void refreshMergedValue( int col );
6969
/** Inserts the attribute value of a specific feature into the row of merged attributes*/
70-
QVariant featureAttribute( int featureId, int col );
70+
QVariant featureAttribute( QgsFeatureId featureId, int col );
7171
/** Appends the values of the features for the final value*/
7272
QVariant concatenationAttribute( int col );
7373

@@ -77,7 +77,7 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
7777
QVariant calcStatistic( int col, QgsStatisticalSummary::Statistic stat );
7878

7979
/** Sets mSelectionRubberBand to a new feature*/
80-
void createRubberBandForFeature( int featureId );
80+
void createRubberBandForFeature( QgsFeatureId featureId );
8181

8282
QgsFeatureList mFeatureList;
8383
QgsVectorLayer* mVectorLayer;

0 commit comments

Comments
 (0)
Please sign in to comment.