@@ -62,30 +62,6 @@ void QgsAttributeTableModel::featureDeleted( int fid )
62
62
QgsDebugMsg ( fid );
63
63
#endif
64
64
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
-
89
65
QgsDebugMsg ( " id->row" );
90
66
QHash<int , int >::iterator it;
91
67
for ( it = mIdRowMap .begin (); it != mIdRowMap .end (); ++it )
@@ -259,18 +235,6 @@ void QgsAttributeTableModel::loadLayer()
259
235
endRemoveRows ();
260
236
QgsDebugMsg ( " end rm" );
261
237
}
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
274
238
}
275
239
276
240
void QgsAttributeTableModel::swapRows ( int a, int b )
@@ -454,14 +418,6 @@ QVariant QgsAttributeTableModel::data( const QModelIndex &index, int role )
454
418
return mValueMaps [ index .column ()]->key ( val.toString (), QString ( " (%1)" ).arg ( val.toString () ) );
455
419
}
456
420
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
465
421
return val.toString ();
466
422
}
467
423
@@ -480,9 +436,15 @@ bool QgsAttributeTableModel::setData( const QModelIndex &index, const QVariant &
480
436
mLastRowId = rowToId ( index .row () );
481
437
mLastRow = ( QgsAttributeMap * ) & mFeat .attributeMap ();
482
438
439
+ disconnect ( mLayer , SIGNAL ( layerModified ( bool ) ), this , SLOT ( layerModified ( bool ) ) );
440
+
483
441
mLayer ->beginEditCommand ( tr ( " Attribute changed" ) );
484
442
mLayer ->changeAttributeValue ( rowToId ( index .row () ), mAttributes [ index .column ()], value, true );
485
443
mLayer ->endEditCommand ();
444
+
445
+ ( *mLastRow )[ mAttributes [index .column ()] ] = value;
446
+
447
+ connect ( mLayer , SIGNAL ( layerModified ( bool ) ), this , SLOT ( layerModified ( bool ) ) );
486
448
}
487
449
488
450
if ( !mLayer ->isModified () )
0 commit comments