[QGIS Commit] r14037 -
branches/threading-branch/src/app/attributetable
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Aug 9 10:09:04 EDT 2010
Author: wonder
Date: 2010-08-09 14:09:03 +0000 (Mon, 09 Aug 2010)
New Revision: 14037
Modified:
branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp
Log:
Speed improvements for loading of attribute table
Modified: branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp 2010-08-09 14:08:05 UTC (rev 14036)
+++ branches/threading-branch/src/app/attributetable/qgsattributetablemodel.cpp 2010-08-09 14:09:03 UTC (rev 14037)
@@ -201,12 +201,14 @@
if ( behaviour == 1 )
{
- const QgsFeatureList &features = mLayer->selectedFeatures();
+ int i = 0;
+ const QgsFeatureIds& fids = mLayer->selectedFeaturesIds();
+ for ( QgsFeatureIds::const_iterator it = fids.constBegin(); it != fids.constEnd(); ++it, ++i )
+ {
+ mLayer->featureAtId( *it, f, false, false );
- for ( int i = 0; i < features.size(); ++i )
- {
- mRowIdMap.insert( i, features[i].id() );
- mIdRowMap.insert( features[i].id(), i );
+ mRowIdMap.insert( i, f.id() );
+ mIdRowMap.insert( f.id(), i );
}
}
else
@@ -291,14 +293,15 @@
int QgsAttributeTableModel::rowToId( const int id ) const
{
- if ( !mRowIdMap.contains( id ) )
+ const QHash<int, int>::const_iterator it = mRowIdMap.constFind( id );
+ if ( it == mRowIdMap.constEnd() )
{
QgsDebugMsg( QString( "rowToId: row %1 not in the map" ).arg( id ) );
// return negative infinite (to avoid collision with newly added features)
return std::numeric_limits<int>::min();
}
- return mRowIdMap[id];
+ return *it;
}
int QgsAttributeTableModel::fieldIdx( int col ) const
@@ -412,7 +415,7 @@
if ( mFeat.id() != rowId )
return QVariant( "ERROR" );
- const QVariant &val = mFeat.attributeMap()[ fieldId ];
+ const QVariant &val = mFeat.attributeVector()[ fieldId ];
if ( val.isNull() )
{
More information about the QGIS-commit
mailing list