Skip to content

Commit

Permalink
fix #2549
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13310 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Apr 14, 2010
1 parent 8056c91 commit 58acc85
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/app/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,8 @@ void QgsAttributeTableModel::loadAttributes()
}

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() ) )
Expand All @@ -169,10 +154,24 @@ void QgsAttributeTableModel::loadAttributes()
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();
Expand Down

0 comments on commit 58acc85

Please sign in to comment.