Skip to content

Commit d378f94

Browse files
committedJan 30, 2014
[attrtable] No checks when the model is not based on a request
Huge speedup Fix #9315
1 parent 3ba33d7 commit d378f94

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed
 

‎src/app/qgsfieldcalculator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ void QgsFieldCalculator::accept()
194194
rownum++;
195195
}
196196

197-
198197
if ( !calculationSuccess )
199198
{
200199
QMessageBox::critical( 0, tr( "Error" ), tr( "An error occured while evaluating the calculation string:\n%1" ).arg( error ) );

‎src/gui/attributetable/qgsattributetablemodel.cpp

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,31 +199,39 @@ void QgsAttributeTableModel::layerDeleted()
199199
void QgsAttributeTableModel::attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value )
200200
{
201201
QgsDebugMsgLevel( QString( "(%4) fid: %1, idx: %2, value: %3" ).arg( fid ).arg( idx ).arg( value.toString() ).arg( mFeatureRequest.filterType() ), 3 );
202-
if ( loadFeatureAtId( fid ) )
202+
// No filter request: skip all possibly heavy checks
203+
if ( mFeatureRequest.filterType() == QgsFeatureRequest::FilterNone )
203204
{
204-
if ( mFeatureRequest.acceptFeature( mFeat ) )
205+
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
206+
}
207+
else
208+
{
209+
if ( loadFeatureAtId( fid ) )
205210
{
206-
if ( !mIdRowMap.contains( fid ) )
211+
if ( mFeatureRequest.acceptFeature( mFeat ) )
207212
{
208-
// Feature changed in such a way, it will be shown now
209-
featureAdded( fid );
213+
if ( !mIdRowMap.contains( fid ) )
214+
{
215+
// Feature changed in such a way, it will be shown now
216+
featureAdded( fid );
217+
}
218+
else
219+
{
220+
if ( idx == mCachedField )
221+
mFieldCache[ fid ] = value;
222+
// Update representation
223+
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
224+
}
210225
}
211226
else
212227
{
213-
if ( idx == mCachedField )
214-
mFieldCache[ fid ] = value;
215-
// Update representation
216-
setData( index( idToRow( fid ), fieldCol( idx ) ), value, Qt::EditRole );
217-
}
218-
}
219-
else
220-
{
221-
if ( mIdRowMap.contains( fid ) )
222-
{
223-
// Feature changed such, that it is no longer shown
224-
featureDeleted( fid );
228+
if ( mIdRowMap.contains( fid ) )
229+
{
230+
// Feature changed such, that it is no longer shown
231+
featureDeleted( fid );
232+
}
233+
// else: we don't care
225234
}
226-
// else: we don't care
227235
}
228236
}
229237
}

0 commit comments

Comments
 (0)
Please sign in to comment.