@@ -88,8 +88,8 @@ BeataModel::BeataModel( QgsVectorLayer *theLayer, QObject *parent )
8888 mLastRow = NULL ;
8989 mLayer = theLayer;
9090 mFeatureCount = mLayer ->pendingFeatureCount ();
91- mFieldCount = mLayer ->dataProvider ()-> fieldCount ();
92- mAttributes = mLayer ->dataProvider ()-> attributeIndexes ();
91+ mFieldCount = mLayer ->pendingFields (). size ();
92+ mAttributes = mLayer ->pendingAllAttributesList ();
9393
9494 connect ( mLayer , SIGNAL ( layerModified ( bool ) ), this , SLOT ( layerModified ( bool ) ) );
9595 // connect(mLayer, SIGNAL(attributeAdded(int)), this, SLOT( attributeAdded(int)));
@@ -233,7 +233,7 @@ void BeataModel::loadLayer()
233233
234234 // not needed when we have featureAdded signal
235235 mFeatureCount = mLayer ->pendingFeatureCount ();
236- mFieldCount = mLayer ->dataProvider ()-> fieldCount ();
236+ mFieldCount = mLayer ->pendingFields (). size ();
237237
238238 if ( ins )
239239 {
@@ -324,7 +324,7 @@ QVariant BeataModel::headerData( int section, Qt::Orientation orientation, int r
324324 }
325325 else
326326 {
327- QgsField field = mLayer ->dataProvider ()-> fields ()[ section]; // column
327+ QgsField field = mLayer ->pendingFields ()[ mAttributes [ section] ]; // column
328328 return QVariant ( field.name () );
329329 }
330330 }
@@ -350,7 +350,7 @@ void BeataModel::sort( int column, Qt::SortOrder order )
350350 row = f.attributeMap ();
351351
352352 pair.id = f.id ();
353- pair.columnItem = row[column];
353+ pair.columnItem = row[ mAttributes [ column] ];
354354
355355 mSortList .append ( pair );
356356 }
@@ -383,7 +383,7 @@ QVariant BeataModel::data( const QModelIndex &index, int role ) const
383383 if ( !index.isValid () || ( role != Qt::TextAlignmentRole && role != Qt::DisplayRole && role != Qt::EditRole ) )
384384 return QVariant ();
385385
386- QVariant::Type fldType = mLayer ->dataProvider ()-> fields ()[ index.column ()].type ();
386+ QVariant::Type fldType = mLayer ->pendingFields ()[ mAttributes [ index.column ()] ].type ();
387387 bool fldNumeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
388388
389389 if ( role == Qt::TextAlignmentRole )
@@ -403,10 +403,10 @@ QVariant BeataModel::data( const QModelIndex &index, int role ) const
403403 return QVariant ( " ERROR" );
404404
405405 mLastRowId = rowToId ( index.row () );
406- mLastRow = ( QgsAttributeMap * )( &( mFeat .attributeMap () ) );
406+ mLastRow = ( QgsAttributeMap * ) & mFeat .attributeMap ();
407407 }
408408
409- QVariant& val = ( *mLastRow )[index.column ()];
409+ QVariant& val = ( *mLastRow )[ mAttributes [ index.column ()] ];
410410
411411 if ( val.isNull () )
412412 {
@@ -512,7 +512,7 @@ QVariant BeataMemModel::data( const QModelIndex &index, int role ) const
512512 if ( !index.isValid () || ( role != Qt::TextAlignmentRole && role != Qt::DisplayRole && role != Qt::EditRole ) )
513513 return QVariant ();
514514
515- QVariant::Type fldType = mLayer ->dataProvider ()-> fields ()[ index.column ()].type ();
515+ QVariant::Type fldType = mLayer ->pendingFields ()[ mAttributes [ index.column ()] ].type ();
516516 bool fldNumeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
517517
518518 if ( role == Qt::TextAlignmentRole )
@@ -534,10 +534,10 @@ QVariant BeataMemModel::data( const QModelIndex &index, int role ) const
534534
535535 mLastRowId = rowToId ( index.row () );
536536 mFeat = mFeatureMap [rowToId ( index.row () )];
537- mLastRow = ( QgsAttributeMap * )( &( mFeat .attributeMap () ) );
537+ mLastRow = ( QgsAttributeMap * ) & mFeat .attributeMap ();
538538 }
539539
540- QVariant& val = ( *mLastRow )[index.column ()];
540+ QVariant & val = ( *mLastRow )[ mAttributes [ index.column ()] ];
541541
542542 if ( val.isNull () )
543543 {
0 commit comments