Skip to content

Commit

Permalink
[Fix #7892] Fields properties: Fix sorting by id (numeric)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 24, 2013
1 parent 4363198 commit dcc72d2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent
connect( mAttributesTree, SIGNAL( itemSelectionChanged() ), this, SLOT( onAttributeSelectionChanged() ) );
connect( mAttributesList, SIGNAL( itemSelectionChanged() ), this, SLOT( onAttributeSelectionChanged() ) );

mAttributesList->sortByColumn( 0, Qt::AscendingOrder );
mAttributesTree->setHeaderLabels( QStringList() << tr( "Label" ) );

leEditForm->setText( layer->editForm() );
Expand Down Expand Up @@ -315,7 +316,7 @@ void QgsFieldsProperties::loadRows()

void QgsFieldsProperties::setRow( int row, int idx, const QgsField &field )
{
mAttributesList->setItem( row, attrIdCol, new QTableWidgetItem( QString::number( idx ) ) );
mAttributesList->setItem( row, attrIdCol, new QTableWidgetItem( idx ) );
mIndexedWidgets.insert( idx, mAttributesList->item( row, 0 ) );
mAttributesList->setItem( row, attrNameCol, new QTableWidgetItem( field.name() ) );
mAttributesList->setItem( row, attrTypeCol, new QTableWidgetItem( field.typeName() ) );
Expand Down Expand Up @@ -553,7 +554,7 @@ void QgsFieldsProperties::attributeAdded( int idx )

for ( int i = idx; i < mIndexedWidgets.count(); i++ )
{
mIndexedWidgets[i]->setText( QString::number( i ) );
mIndexedWidgets[i]->setData( Qt::DisplayRole, i );
}

mAttributesList->setCurrentCell( row, idx );
Expand All @@ -567,7 +568,7 @@ void QgsFieldsProperties::attributeDeleted( int idx )
mIndexedWidgets.removeAt( idx );
for ( int i = idx; i < mIndexedWidgets.count(); i++ )
{
mIndexedWidgets[i]->setText( QString::number( i ) );
mIndexedWidgets[i]->setData( Qt::DisplayRole, i );
}
}

Expand Down

0 comments on commit dcc72d2

Please sign in to comment.