mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
Fix taking attribute values in merge attributes dialog (fix #13971)
Also fix handling of long feature ids in tool.
This commit is contained in:
parent
f93fce7390
commit
b23ddfe2b4
@ -170,7 +170,7 @@ 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() ), QString( "f%1" ).arg( f_it->id() ) );
|
||||
newComboBox->addItem( tr( "Feature %1" ).arg( f_it->id() ), QString( "f%1" ).arg( FID_TO_STRING( f_it->id() ) ) );
|
||||
}
|
||||
|
||||
if ( columnType == QVariant::Double || columnType == QVariant::Int )
|
||||
@ -223,7 +223,7 @@ void QgsMergeAttributesDialog::selectedRowChanged()
|
||||
{
|
||||
//find out selected row
|
||||
QList<QTableWidgetItem *> selectionList = mTableWidget->selectedItems();
|
||||
if ( selectionList.size() < 1 )
|
||||
if ( selectionList.isEmpty() )
|
||||
{
|
||||
delete mSelectionRubberBand;
|
||||
mSelectionRubberBand = 0;
|
||||
@ -245,7 +245,7 @@ void QgsMergeAttributesDialog::selectedRowChanged()
|
||||
}
|
||||
|
||||
bool conversionSuccess = false;
|
||||
int featureIdToSelect = idItem->text().toInt( &conversionSuccess );
|
||||
QgsFeatureId featureIdToSelect = idItem->text().toLongLong( &conversionSuccess );
|
||||
if ( !conversionSuccess )
|
||||
{
|
||||
//the merge result row was selected
|
||||
@ -275,10 +275,10 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
|
||||
{
|
||||
mergeResult = tr( "Skipped" );
|
||||
}
|
||||
else if ( mergeBehaviourString.startsWith( "f" ) )
|
||||
else if ( mergeBehaviourString.startsWith( 'f' ) )
|
||||
{
|
||||
//an existing feature value - TODO should be QgsFeatureId, not int
|
||||
int featureId = mergeBehaviourString.mid( 1 ).toInt();
|
||||
//an existing feature value
|
||||
QgsFeatureId featureId = STRING_TO_FID( mergeBehaviourString.mid( 1 ) );
|
||||
mergeResult = featureAttribute( featureId, col );
|
||||
}
|
||||
else
|
||||
@ -295,7 +295,7 @@ void QgsMergeAttributesDialog::refreshMergedValue( int col )
|
||||
mTableWidget->setItem( mTableWidget->rowCount() - 1, col, newTotalItem );
|
||||
}
|
||||
|
||||
QVariant QgsMergeAttributesDialog::featureAttribute( int featureId, int col )
|
||||
QVariant QgsMergeAttributesDialog::featureAttribute( QgsFeatureId featureId, int col )
|
||||
{
|
||||
int idx = mTableWidget->horizontalHeaderItem( col )->data( Qt::UserRole ).toInt();
|
||||
|
||||
@ -362,7 +362,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
|
||||
|
||||
//find out feature id of selected row
|
||||
QList<QTableWidgetItem *> selectionList = mTableWidget->selectedItems();
|
||||
if ( selectionList.size() < 1 )
|
||||
if ( selectionList.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -377,7 +377,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
|
||||
}
|
||||
|
||||
bool conversionSuccess;
|
||||
int featureId = selectedHeaderItem->text().toInt( &conversionSuccess );
|
||||
QgsFeatureId featureId = selectedHeaderItem->text().toLongLong( &conversionSuccess );
|
||||
if ( !conversionSuccess )
|
||||
{
|
||||
return;
|
||||
@ -393,7 +393,7 @@ void QgsMergeAttributesDialog::on_mFromSelectedPushButton_clicked()
|
||||
QComboBox* currentComboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, i ) );
|
||||
if ( currentComboBox )
|
||||
{
|
||||
currentComboBox->setCurrentIndex( currentComboBox->findData( QString::number( featureId ) ) );
|
||||
currentComboBox->setCurrentIndex( currentComboBox->findData( QString( "f%1" ).arg( FID_TO_STRING( featureId ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -407,7 +407,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
|
||||
|
||||
//find out feature id of selected row
|
||||
QList<QTableWidgetItem *> selectionList = mTableWidget->selectedItems();
|
||||
if ( selectionList.size() < 1 )
|
||||
if ( selectionList.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -422,7 +422,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
|
||||
}
|
||||
|
||||
bool conversionSuccess;
|
||||
int featureId = selectedHeaderItem->text().toInt( &conversionSuccess );
|
||||
QgsFeatureId featureId = selectedHeaderItem->text().toLongLong( &conversionSuccess );
|
||||
if ( !conversionSuccess )
|
||||
{
|
||||
selectedRowChanged();
|
||||
@ -446,7 +446,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
|
||||
continue;
|
||||
|
||||
currentComboBox->blockSignals( true );
|
||||
currentComboBox->removeItem( currentComboBox->findData( QString::number( featureId ) ) );
|
||||
currentComboBox->removeItem( currentComboBox->findData( QString( "f%1" ).arg( FID_TO_STRING( featureId ) ) ) );
|
||||
currentComboBox->blockSignals( false );
|
||||
}
|
||||
|
||||
@ -463,7 +463,7 @@ void QgsMergeAttributesDialog::on_mRemoveFeatureFromSelectionButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsMergeAttributesDialog::createRubberBandForFeature( int featureId )
|
||||
void QgsMergeAttributesDialog::createRubberBandForFeature( QgsFeatureId featureId )
|
||||
{
|
||||
//create rubber band to highlight the feature
|
||||
delete mSelectionRubberBand;
|
||||
|
@ -67,7 +67,7 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
|
||||
/** Calculates the merged value of a column (depending on the selected merge behaviour) and inserts the value in the corresponding cell*/
|
||||
void refreshMergedValue( int col );
|
||||
/** Inserts the attribute value of a specific feature into the row of merged attributes*/
|
||||
QVariant featureAttribute( int featureId, int col );
|
||||
QVariant featureAttribute( QgsFeatureId featureId, int col );
|
||||
/** Appends the values of the features for the final value*/
|
||||
QVariant concatenationAttribute( int col );
|
||||
|
||||
@ -77,7 +77,7 @@ class APP_EXPORT QgsMergeAttributesDialog: public QDialog, private Ui::QgsMergeA
|
||||
QVariant calcStatistic( int col, QgsStatisticalSummary::Statistic stat );
|
||||
|
||||
/** Sets mSelectionRubberBand to a new feature*/
|
||||
void createRubberBandForFeature( int featureId );
|
||||
void createRubberBandForFeature( QgsFeatureId featureId );
|
||||
|
||||
QgsFeatureList mFeatureList;
|
||||
QgsVectorLayer* mVectorLayer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user