Skip to content
Permalink
Browse files

fix #3248

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14754 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Nov 23, 2010
1 parent 52f38ed commit 79b3e6ae5a808365b50df6edd7ad369cf3f9b8bd
@@ -89,3 +89,13 @@ void QgsAttributeTableMemoryModel::attributeValueChanged( int fid, int idx, cons
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 );
}
@@ -39,6 +39,11 @@ class QgsAttributeTableMemoryModel : public QgsAttributeTableModel
*/
QgsAttributeTableMemoryModel( QgsVectorLayer *theLayer );

/**
* Remove rows
*/
bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() );

protected slots:
/**
* Launched when a feature has been deleted
@@ -66,13 +66,13 @@ void QgsAttributeTableModel::featureDeleted( int fid )

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 @@ bool QgsAttributeTableModel::removeRows( int row, int count, const QModelIndex &
}

#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 @@ void QgsAttributeTableModel::loadLayer()
{
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 @@ void QgsAttributeTableModel::loadLayer()
}
}

Q_ASSERT( mRowIdMap.size() == mIdRowMap.size() );

mFieldCount = mAttributes.size();
}

0 comments on commit 79b3e6a

Please sign in to comment.
You can’t perform that action at this time.