Skip to content

Commit

Permalink
[attrtable] No checks when the model is not based on a request
Browse files Browse the repository at this point in the history
Huge speedup
Fix #9315
  • Loading branch information
m-kuhn committed Jan 30, 2014
1 parent 3ba33d7 commit d378f94
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/app/qgsfieldcalculator.cpp
Expand Up @@ -194,7 +194,6 @@ void QgsFieldCalculator::accept()
rownum++;
}


if ( !calculationSuccess )
{
QMessageBox::critical( 0, tr( "Error" ), tr( "An error occured while evaluating the calculation string:\n%1" ).arg( error ) );
Expand Down
44 changes: 26 additions & 18 deletions src/gui/attributetable/qgsattributetablemodel.cpp
Expand Up @@ -199,31 +199,39 @@ void QgsAttributeTableModel::layerDeleted()
void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
{
QgsDebugMsgLevel( QString( "(%4) fid: %1, idx: %2, value: %3" ).arg( fid ).arg( idx ).arg( value.toString() ).arg( mFeatureRequest.filterType() ), 3 );
if ( loadFeatureAtId( fid ) )
// No filter request: skip all possibly heavy checks
if ( mFeatureRequest.filterType() == QgsFeatureRequest::FilterNone )
{
if ( mFeatureRequest.acceptFeature( mFeat ) )
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}
else
{
if ( loadFeatureAtId( fid ) )
{
if ( !mIdRowMap.contains( fid ) )
if ( mFeatureRequest.acceptFeature( mFeat ) )
{
// Feature changed in such a way, it will be shown now
featureAdded( fid );
if ( !mIdRowMap.contains( fid ) )
{
// Feature changed in such a way, it will be shown now
featureAdded( fid );
}
else
{
if ( idx == mCachedField )
mFieldCache[ fid ] = value;
// Update representation
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}
}
else
{
if ( idx == mCachedField )
mFieldCache[ fid ] = value;
// Update representation
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
}
}
else
{
if ( mIdRowMap.contains( fid ) )
{
// Feature changed such, that it is no longer shown
featureDeleted( fid );
if ( mIdRowMap.contains( fid ) )
{
// Feature changed such, that it is no longer shown
featureDeleted( fid );
}
// else: we don't care
}
// else: we don't care
}
}
}
Expand Down

0 comments on commit d378f94

Please sign in to comment.