[QGIS Commit] r11136 - trunk/qgis/src/app/attributetable
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Jul 21 09:19:11 EDT 2009
Author: wonder
Date: 2009-07-21 09:19:10 -0400 (Tue, 21 Jul 2009)
New Revision: 11136
Modified:
trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
Log:
Replace multiple calls to featureCount() with just one when loading attribute table.
Can speed up loading of attribute table with providers not caching the feature count.
By Vita Cizek.
Modified: trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp 2009-07-21 13:07:02 UTC (rev 11135)
+++ trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp 2009-07-21 13:19:10 UTC (rev 11136)
@@ -157,18 +157,19 @@
mRowIdMap.clear();
mIdRowMap.clear();
- if ( mFeatureCount < mLayer->pendingFeatureCount() )
+ int pendingFeatureCount = mLayer->pendingFeatureCount();
+ if ( mFeatureCount < pendingFeatureCount)
{
QgsDebugMsg( "ins" );
ins = true;
- beginInsertRows( QModelIndex(), mFeatureCount, mLayer->pendingFeatureCount() - 1 );
+ beginInsertRows( QModelIndex(), mFeatureCount, pendingFeatureCount - 1 );
// QgsDebugMsg(QString("%1, %2").arg(mFeatureCount).arg(mLayer->pendingFeatureCount() - 1));
}
- else if ( mFeatureCount > mLayer->pendingFeatureCount() )
+ else if ( mFeatureCount > pendingFeatureCount )
{
QgsDebugMsg( "rm" );
rm = true;
- beginRemoveRows( QModelIndex(), mLayer->pendingFeatureCount(), mFeatureCount - 1 );
+ beginRemoveRows( QModelIndex(), pendingFeatureCount, mFeatureCount - 1 );
// QgsDebugMsg(QString("%1, %2").arg(mFeatureCount).arg(mLayer->pendingFeatureCount() -1));
}
@@ -181,7 +182,7 @@
}
// not needed when we have featureAdded signal
- mFeatureCount = mLayer->pendingFeatureCount();
+ mFeatureCount = pendingFeatureCount;
mFieldCount = mLayer->pendingFields().size();
if ( ins )
@@ -235,7 +236,7 @@
{
if ( !mIdRowMap.contains( id ) )
{
- QgsDebugMsg( QString( "idToRow: id %1 not in map" ).arg( id ) );
+ QgsDebugMsg( QString( "idToRow: id %1 not in the map" ).arg( id ) );
return -1;
}
@@ -246,7 +247,7 @@
{
if ( !mRowIdMap.contains( id ) )
{
- QgsDebugMsg( QString( "rowToId: row %1 not in map" ).arg( id ) );
+ QgsDebugMsg( QString( "rowToId: row %1 not in the map" ).arg( id ) );
return -1;
}
More information about the QGIS-commit
mailing list