@@ -250,16 +250,19 @@ void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )
250250
251251void QgsAttributeTableDialog::columnBoxInit ()
252252{
253- QgsFieldMap fieldMap = mLayer ->dataProvider ()-> fields ();
253+ QgsFieldMap fieldMap = mLayer ->pendingFields ();
254254 QgsFieldMap::Iterator it = fieldMap.begin ();
255255
256256 for ( ; it != fieldMap.end (); ++it )
257- mColumnBox ->addItem ( it.value ().name () );
257+ if ( mLayer ->editType ( it.key () ) != QgsVectorLayer::Hidden )
258+ mColumnBox ->addItem ( it.value ().name () );
259+
260+ mColumnBox ->setCurrentIndex ( mColumnBox ->findText ( mLayer ->displayField () ) );
258261}
259262
260263int QgsAttributeTableDialog::columnBoxColumnId ()
261264{
262- QgsFieldMap fieldMap = mLayer ->dataProvider ()-> fields ();
265+ QgsFieldMap fieldMap = mLayer ->pendingFields ();
263266 QgsFieldMap::Iterator it = fieldMap.begin ();
264267
265268 for ( ; it != fieldMap.end (); ++it )
@@ -594,8 +597,8 @@ void QgsAttributeTableDialog::search()
594597
595598 QString str = mColumnBox ->currentText ();
596599
597- const QgsFieldMap& flds = mLayer ->dataProvider ()-> fields ();
598- int fldIndex = mLayer ->dataProvider ()-> fieldNameIndex ( str );
600+ const QgsFieldMap& flds = mLayer ->pendingFields ();
601+ int fldIndex = mLayer ->fieldNameIndex ( str );
599602 QVariant::Type fldType = flds[fldIndex].type ();
600603 bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double );
601604
@@ -604,7 +607,7 @@ void QgsAttributeTableDialog::search()
604607 else
605608 str += " ~ '" ;
606609
607- str += mQuery ->displayText ().replace (" '" , " ''" ); // escape quotes
610+ str += mQuery ->displayText ().replace ( " '" , " ''" ); // escape quotes
608611 str += " '" ;
609612
610613 doSearch ( str );
@@ -673,7 +676,7 @@ void QgsAttributeTableDialog::on_mAddAttribute_clicked()
673676 return ;
674677 }
675678
676- QgsAddAttrDialog dialog ( mLayer -> dataProvider () , this );
679+ QgsAddAttrDialog dialog ( mLayer , this );
677680 if ( dialog.exec () == QDialog::Accepted )
678681 {
679682 mLayer ->beginEditCommand ( tr ( " Attribute added" ) );
0 commit comments