Skip to content

Commit

Permalink
fix attribute table for new vector api
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 30, 2013
1 parent 445c6e2 commit b4a6a83
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -334,7 +334,10 @@ void QgsAttributeTableModel::loadLayer()
}
}

QgsFeatureIterator fit = mLayer->getFeatures( QgsFeatureRequest().setFilterRect( rect ).setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( attributeList ) );
QgsFeatureRequest req;
if ( !rect.isEmpty() )
req.setFilterRect( rect );
QgsFeatureIterator fit = mLayer->getFeatures( req.setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( attributeList ) );

QgsFeature f;
for ( i = 0; fit.nextFeature( f ); ++i )
Expand Down Expand Up @@ -485,7 +488,10 @@ void QgsAttributeTableModel::sort( int column, Qt::SortOrder order )

int idx = fieldIdx( column );

QgsFeatureIterator fit = mLayer->getFeatures( QgsFeatureRequest().setFilterRect( rect ).setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( QgsAttributeList() << idx ) );
QgsFeatureRequest req;
if ( !rect.isEmpty() )
req.setFilterRect( rect );
QgsFeatureIterator fit = mLayer->getFeatures( req.setFlags( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes( QgsAttributeList() << idx ) );
QgsFeature f;
while ( fit.nextFeature( f ) )
{
Expand Down Expand Up @@ -585,11 +591,16 @@ bool QgsAttributeTableModel::setData( const QModelIndex &index, const QVariant &

if ( mFeatureMap.contains( fid ) )
{
mFeatureMap[ fid ].setAttribute( idx, value );
QgsFeature &f = mFeatureMap[ fid ];
if( idx >= f.attributes().size() )
f.attributes().resize( mFieldCount );
f.setAttribute( idx, value );
}

if ( mFeat.id() == fid || featureAtId( fid ) )
{
if( idx >= mFeat.attributes().size() )
mFeat.attributes().resize( mFieldCount );
mFeat.setAttribute( idx, value );
}

Expand Down

0 comments on commit b4a6a83

Please sign in to comment.