Skip to content

Commit

Permalink
fix #1773
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12555 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 20, 2009
1 parent ad64e04 commit 09fe9a5
Showing 1 changed file with 6 additions and 44 deletions.
50 changes: 6 additions & 44 deletions src/app/attributetable/qgsattributetablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,6 @@ void QgsAttributeTableModel::featureDeleted( int fid )
QgsDebugMsg( fid );
#endif

#if 0
--mFeatureCount;
mIdRowMap.remove( fid );
mRowIdMap.remove( idx );

// fill the hole in the view
if ( idx != mFeatureCount )
{
QgsDebugMsg( "jo" );
//mRowIdMap[idx] = mRowIdMap[mFeatureCount];
//mIdRowMap[mRowIdMap[idx]] = idx;
int movedId = mRowIdMap[mFeatureCount];
mRowIdMap.remove( mFeatureCount );
mRowIdMap.insert( idx, movedId );
mIdRowMap[movedId] = idx;
//mIdRowMap.remove(mRowIdMap[idx]);
//mIdRowMap.insert(mRowIdMap[idx], idx);
}

QgsDebugMsg( QString( "map sizes:%1, %2" ).arg( mRowIdMap.size() ).arg( mIdRowMap.size() ) );
emit layoutChanged();
//reload(index(0,0), index(rowCount(), columnCount()));
#endif

QgsDebugMsg( "id->row" );
QHash<int, int>::iterator it;
for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
Expand Down Expand Up @@ -259,18 +235,6 @@ void QgsAttributeTableModel::loadLayer()
endRemoveRows();
QgsDebugMsg( "end rm" );
}

#if 0
QgsDebugMsg( "id->row" );
QHash<int, int>::iterator it;
for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );

QgsDebugMsg( "row->id" );

for ( it = mRowIdMap.begin(); it != mRowIdMap.end(); ++it )
QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
#endif
}

void QgsAttributeTableModel::swapRows( int a, int b )
Expand Down Expand Up @@ -454,14 +418,6 @@ QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role )
return mValueMaps[ index.column()]->key( val.toString(), QString( "(%1)" ).arg( val.toString() ) );
}

// force also numeric data for EditRole to be strings
// otherwise it creates spinboxes instead of line edits
// (probably not what we do want)
if ( fldNumeric && role == Qt::EditRole )
return val.toString();

// convert to QString from some other representation
// this prevents displaying greater numbers in exponential format
return val.toString();
}

Expand All @@ -480,9 +436,15 @@ bool QgsAttributeTableModel::setData( const QModelIndex &index, const QVariant &
mLastRowId = rowToId( index.row() );
mLastRow = ( QgsAttributeMap * ) & mFeat.attributeMap();

disconnect( mLayer, SIGNAL( layerModified( bool ) ), this, SLOT( layerModified( bool ) ) );

mLayer->beginEditCommand( tr( "Attribute changed" ) );
mLayer->changeAttributeValue( rowToId( index.row() ), mAttributes[ index.column()], value, true );
mLayer->endEditCommand();

( *mLastRow )[ mAttributes[index.column()] ] = value;

connect( mLayer, SIGNAL( layerModified( bool ) ), this, SLOT( layerModified( bool ) ) );
}

if ( !mLayer->isModified() )
Expand Down

0 comments on commit 09fe9a5

Please sign in to comment.