@@ -88,8 +88,8 @@ BeataModel::BeataModel( QgsVectorLayer *theLayer, QObject *parent )
88
88
mLastRow = NULL ;
89
89
mLayer = theLayer;
90
90
mFeatureCount = mLayer ->pendingFeatureCount ();
91
- mFieldCount = mLayer ->dataProvider ()-> fieldCount ();
92
- mAttributes = mLayer ->dataProvider ()-> attributeIndexes ();
91
+ mFieldCount = mLayer ->pendingFields (). size ();
92
+ mAttributes = mLayer ->pendingAllAttributesList ();
93
93
94
94
connect ( mLayer , SIGNAL ( layerModified ( bool ) ), this , SLOT ( layerModified ( bool ) ) );
95
95
// connect(mLayer, SIGNAL(attributeAdded(int)), this, SLOT( attributeAdded(int)));
@@ -233,7 +233,7 @@ void BeataModel::loadLayer()
233
233
234
234
// not needed when we have featureAdded signal
235
235
mFeatureCount = mLayer ->pendingFeatureCount ();
236
- mFieldCount = mLayer ->dataProvider ()-> fieldCount ();
236
+ mFieldCount = mLayer ->pendingFields (). size ();
237
237
238
238
if ( ins )
239
239
{
@@ -324,7 +324,7 @@ QVariant BeataModel::headerData( int section, Qt::Orientation orientation, int r
324
324
}
325
325
else
326
326
{
327
- QgsField field = mLayer ->dataProvider ()-> fields ()[ section]; // column
327
+ QgsField field = mLayer ->pendingFields ()[ mAttributes [ section] ]; // column
328
328
return QVariant ( field.name () );
329
329
}
330
330
}
@@ -350,7 +350,7 @@ void BeataModel::sort( int column, Qt::SortOrder order )
350
350
row = f.attributeMap ();
351
351
352
352
pair.id = f.id ();
353
- pair.columnItem = row[column];
353
+ pair.columnItem = row[ mAttributes [ column] ];
354
354
355
355
mSortList .append ( pair );
356
356
}
@@ -383,7 +383,7 @@ QVariant BeataModel::data( const QModelIndex &index, int role ) const
383
383
if ( !index .isValid () || ( role != Qt::TextAlignmentRole && role != Qt::DisplayRole && role != Qt::EditRole ) )
384
384
return QVariant ();
385
385
386
- QVariant::Type fldType = mLayer ->dataProvider ()-> fields ()[ index .column ()].type ();
386
+ QVariant::Type fldType = mLayer ->pendingFields ()[ mAttributes [ index .column ()] ].type ();
387
387
bool fldNumeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
388
388
389
389
if ( role == Qt::TextAlignmentRole )
@@ -403,10 +403,10 @@ QVariant BeataModel::data( const QModelIndex &index, int role ) const
403
403
return QVariant ( " ERROR" );
404
404
405
405
mLastRowId = rowToId ( index .row () );
406
- mLastRow = ( QgsAttributeMap * )( &( mFeat .attributeMap () ) );
406
+ mLastRow = ( QgsAttributeMap * ) & mFeat .attributeMap ();
407
407
}
408
408
409
- QVariant& val = ( *mLastRow )[index .column ()];
409
+ QVariant& val = ( *mLastRow )[ mAttributes [ index .column ()] ];
410
410
411
411
if ( val.isNull () )
412
412
{
@@ -512,7 +512,7 @@ QVariant BeataMemModel::data( const QModelIndex &index, int role ) const
512
512
if ( !index .isValid () || ( role != Qt::TextAlignmentRole && role != Qt::DisplayRole && role != Qt::EditRole ) )
513
513
return QVariant ();
514
514
515
- QVariant::Type fldType = mLayer ->dataProvider ()-> fields ()[ index .column ()].type ();
515
+ QVariant::Type fldType = mLayer ->pendingFields ()[ mAttributes [ index .column ()] ].type ();
516
516
bool fldNumeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
517
517
518
518
if ( role == Qt::TextAlignmentRole )
@@ -534,10 +534,10 @@ QVariant BeataMemModel::data( const QModelIndex &index, int role ) const
534
534
535
535
mLastRowId = rowToId ( index .row () );
536
536
mFeat = mFeatureMap [rowToId ( index .row () )];
537
- mLastRow = ( QgsAttributeMap * )( &( mFeat .attributeMap () ) );
537
+ mLastRow = ( QgsAttributeMap * ) & mFeat .attributeMap ();
538
538
}
539
539
540
- QVariant& val = ( *mLastRow )[index .column ()];
540
+ QVariant & val = ( *mLastRow )[ mAttributes [ index .column ()] ];
541
541
542
542
if ( val.isNull () )
543
543
{
0 commit comments