Skip to content

Commit 7f06712

Browse files
author
jef
committed
fix #1773
git-svn-id: http://svn.osgeo.org/qgis/trunk@12555 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5b89247 commit 7f06712

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

src/app/attributetable/qgsattributetablemodel.cpp

+6-44
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,6 @@ void QgsAttributeTableModel::featureDeleted( int fid )
6262
QgsDebugMsg( fid );
6363
#endif
6464

65-
#if 0
66-
--mFeatureCount;
67-
mIdRowMap.remove( fid );
68-
mRowIdMap.remove( idx );
69-
70-
// fill the hole in the view
71-
if ( idx != mFeatureCount )
72-
{
73-
QgsDebugMsg( "jo" );
74-
//mRowIdMap[idx] = mRowIdMap[mFeatureCount];
75-
//mIdRowMap[mRowIdMap[idx]] = idx;
76-
int movedId = mRowIdMap[mFeatureCount];
77-
mRowIdMap.remove( mFeatureCount );
78-
mRowIdMap.insert( idx, movedId );
79-
mIdRowMap[movedId] = idx;
80-
//mIdRowMap.remove(mRowIdMap[idx]);
81-
//mIdRowMap.insert(mRowIdMap[idx], idx);
82-
}
83-
84-
QgsDebugMsg( QString( "map sizes:%1, %2" ).arg( mRowIdMap.size() ).arg( mIdRowMap.size() ) );
85-
emit layoutChanged();
86-
//reload(index(0,0), index(rowCount(), columnCount()));
87-
#endif
88-
8965
QgsDebugMsg( "id->row" );
9066
QHash<int, int>::iterator it;
9167
for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
@@ -259,18 +235,6 @@ void QgsAttributeTableModel::loadLayer()
259235
endRemoveRows();
260236
QgsDebugMsg( "end rm" );
261237
}
262-
263-
#if 0
264-
QgsDebugMsg( "id->row" );
265-
QHash<int, int>::iterator it;
266-
for ( it = mIdRowMap.begin(); it != mIdRowMap.end(); ++it )
267-
QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
268-
269-
QgsDebugMsg( "row->id" );
270-
271-
for ( it = mRowIdMap.begin(); it != mRowIdMap.end(); ++it )
272-
QgsDebugMsg( QString( "%1->%2" ).arg( it.key() ).arg( *it ) );
273-
#endif
274238
}
275239

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

457-
// force also numeric data for EditRole to be strings
458-
// otherwise it creates spinboxes instead of line edits
459-
// (probably not what we do want)
460-
if ( fldNumeric && role == Qt::EditRole )
461-
return val.toString();
462-
463-
// convert to QString from some other representation
464-
// this prevents displaying greater numbers in exponential format
465421
return val.toString();
466422
}
467423

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

439+
disconnect( mLayer, SIGNAL( layerModified( bool ) ), this, SLOT( layerModified( bool ) ) );
440+
483441
mLayer->beginEditCommand( tr( "Attribute changed" ) );
484442
mLayer->changeAttributeValue( rowToId( index.row() ), mAttributes[ index.column()], value, true );
485443
mLayer->endEditCommand();
444+
445+
( *mLastRow )[ mAttributes[index.column()] ] = value;
446+
447+
connect( mLayer, SIGNAL( layerModified( bool ) ), this, SLOT( layerModified( bool ) ) );
486448
}
487449

488450
if ( !mLayer->isModified() )

0 commit comments

Comments
 (0)