[QGIS Commit] r13310 - trunk/qgis/src/app/attributetable

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Apr 14 12:47:16 EDT 2010


Author: jef
Date: 2010-04-14 12:47:16 -0400 (Wed, 14 Apr 2010)
New Revision: 13310

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
Log:
fix #2549

Modified: trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp	2010-04-14 13:44:14 UTC (rev 13309)
+++ trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp	2010-04-14 16:47:16 UTC (rev 13310)
@@ -137,23 +137,8 @@
   }
 
   bool ins = false, rm = false;
-  int pendingFieldCount = mLayer->pendingFields().size();
 
-  if ( mFieldCount < pendingFieldCount )
-  {
-    ins = true;
-    beginInsertColumns( QModelIndex(), mFieldCount, pendingFieldCount - 1 );
-  }
-  else if ( pendingFieldCount < mFieldCount )
-  {
-    rm = true;
-    beginRemoveColumns( QModelIndex(), pendingFieldCount, mFieldCount - 1 );
-  }
-
-  mFieldCount = 0;
-  mAttributes.clear();
-  mValueMaps.clear();
-
+  QgsAttributeList attributes;
   for ( QgsFieldMap::const_iterator it = mLayer->pendingFields().constBegin(); it != mLayer->pendingFields().end(); it++ )
   {
     switch ( mLayer->editType( it.key() ) )
@@ -169,10 +154,24 @@
         break;
     }
 
-    mFieldCount++;
-    mAttributes << it.key();
+    attributes << it.key();
   }
 
+  if ( mFieldCount < attributes.size() )
+  {
+    ins = true;
+    beginInsertColumns( QModelIndex(), mFieldCount, attributes.size() - 1 );
+  }
+  else if ( attributes.size() < mFieldCount )
+  {
+    rm = true;
+    beginRemoveColumns( QModelIndex(), attributes.size(), mFieldCount - 1 );
+  }
+
+  mFieldCount = attributes.size();
+  mAttributes = attributes;
+  mValueMaps.clear();
+
   if ( ins )
   {
     endInsertColumns();



More information about the QGIS-commit mailing list