Skip to content

Commit

Permalink
Fix #17412 Sorting fixed, no troubles when editing after sorting
Browse files Browse the repository at this point in the history
Issue was, that the cellchange is triggered at re-sorting or renaming something in re-sorted table - so there was a bug that referenced to the row instead of the index
  • Loading branch information
signedav authored and m-kuhn committed Nov 8, 2017
1 parent 3780223 commit 9339615
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/qgsfieldsproperties.cpp
Expand Up @@ -776,15 +776,17 @@ void QgsFieldsProperties::attributesListCellChanged( int row, int column )
}
else if ( column == attrNameCol && mLayer && mLayer->isEditable() )
{
int idx = mIndexedWidgets.indexOf( mFieldsList->item( row, attrIdCol ) );

QTableWidgetItem *nameItem = mFieldsList->item( row, column );
if ( !nameItem ||
nameItem->text().isEmpty() ||
!mLayer->fields().exists( row ) ||
mLayer->fields().at( row ).name() == nameItem->text() )
!mLayer->fields().exists( idx ) ||
mLayer->fields().at( idx ).name() == nameItem->text() )
return;

mLayer->beginEditCommand( tr( "Rename attribute" ) );
if ( mLayer->renameAttribute( row, nameItem->text() ) )
if ( mLayer->renameAttribute( idx, nameItem->text() ) )
{
mLayer->endEditCommand();
}
Expand Down

0 comments on commit 9339615

Please sign in to comment.