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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Nov 23 18:02:56 EST 2010


Author: jef
Date: 2010-11-23 15:02:56 -0800 (Tue, 23 Nov 2010)
New Revision: 14754

Modified:
   trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.cpp
   trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.h
   trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
Log:
fix #3248

Modified: trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.cpp	2010-11-23 18:40:03 UTC (rev 14753)
+++ trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.cpp	2010-11-23 23:02:56 UTC (rev 14754)
@@ -89,3 +89,13 @@
   mFeatureMap[fid].changeAttribute( idx, value );
   QgsAttributeTableModel::attributeValueChanged( fid, idx, value );
 }
+
+bool QgsAttributeTableMemoryModel::removeRows( int row, int count, const QModelIndex &parent )
+{
+  QgsDebugMsg( "entered." );
+  for ( int i = row; i < row + count; i++ )
+  {
+    mFeatureMap.remove( mRowIdMap[ i ] );
+  }
+  return QgsAttributeTableModel::removeRows( row, count, parent );
+}

Modified: trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.h
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.h	2010-11-23 18:40:03 UTC (rev 14753)
+++ trunk/qgis/src/app/attributetable/qgsattributetablememorymodel.h	2010-11-23 23:02:56 UTC (rev 14754)
@@ -39,6 +39,11 @@
      */
     QgsAttributeTableMemoryModel( QgsVectorLayer *theLayer );
 
+    /**
+     * Remove rows
+     */
+    bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );
+
   protected slots:
     /**
      * Launched when a feature has been deleted

Modified: trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp	2010-11-23 18:40:03 UTC (rev 14753)
+++ trunk/qgis/src/app/attributetable/qgsattributetablemodel.cpp	2010-11-23 23:02:56 UTC (rev 14754)
@@ -66,13 +66,13 @@
 
 bool QgsAttributeTableModel::removeRows( int row, int count, const QModelIndex &parent )
 {
-  QgsDebugMsgLevel( QString( "remove %2 rows at %1" ).arg( row ).arg( count ), 3 );
+  QgsDebugMsgLevel( QString( "remove %2 rows at %1 (rows %3, ids %4)" ).arg( row ).arg( count ).arg( mRowIdMap.size() ).arg( mIdRowMap.size() ), 3 );
 
   // clean old references
   for ( int i = row; i < row + count; i++ )
   {
-    mIdRowMap.remove( mRowIdMap[ row ] );
-    mRowIdMap.remove( row );
+    mIdRowMap.remove( mRowIdMap[ i ] );
+    mRowIdMap.remove( i );
   }
 
   // update maps
@@ -86,16 +86,20 @@
   }
 
 #ifdef QGISDEBUG
-  QgsDebugMsgLevel( "id->row", 4 );
   QHash<int, int>::iterator it;
+
+  QgsDebugMsgLevel( QString( "after removal rows %1, ids %2" ).arg( mRowIdMap.size() ).arg( mIdRowMap.size() ), 4 );
+  QgsDebugMsgLevel( "id->row", 4 );
   for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
-    QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
+    QgsDebugMsgLevel( QString( "%1->%2" ).arg( it.key() ).arg( *it ), 4 );
 
   QgsDebugMsgLevel( "row->id", 4 );
   for ( it = mRowIdMap.begin(); it != mRowIdMap.end(); ++it )
-    QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
+    QgsDebugMsgLevel( QString( "%1->%2" ).arg( it.key() ).arg( *it ), 4 );
 #endif
 
+  Q_ASSERT( mRowIdMap.size() == mIdRowMap.size() );
+
   return true;
 }
 
@@ -201,14 +205,10 @@
 {
   QgsDebugMsg( "entered." );
 
-  Q_ASSERT( mRowIdMap.size() == mIdRowMap.size() );
-
   beginRemoveRows( QModelIndex(), 0, rowCount() - 1 );
   removeRows( 0, rowCount() );
   endRemoveRows();
 
-  Q_ASSERT( mRowIdMap.size() == mIdRowMap.size() );
-
   QSettings settings;
   int behaviour = settings.value( "/qgis/attributeTableBehaviour", 0 ).toInt();
 
@@ -239,8 +239,6 @@
     }
   }
 
-  Q_ASSERT( mRowIdMap.size() == mIdRowMap.size() );
-
   mFieldCount = mAttributes.size();
 }
 



More information about the QGIS-commit mailing list