@@ -183,7 +183,7 @@ void QgsVectorLayerProperties::setRow( int row, int idx, const QgsField &field )
183
183
for ( int i = 0 ; i < 6 ; i++ )
184
184
tblAttributes->item ( row, i )->setFlags ( tblAttributes->item ( row, i )->flags () & ~Qt::ItemIsEditable );
185
185
186
- QPushButton * pb = new QPushButton ( editTypeButtonText ( layer->editType ( idx ) ) );
186
+ QPushButton *pb = new QPushButton ( editTypeButtonText ( layer->editType ( idx ) ) );
187
187
tblAttributes->setCellWidget ( row, 6 , pb );
188
188
connect ( pb, SIGNAL ( pressed () ), this , SLOT ( attributeTypeDialog ( ) ) );
189
189
mButtonMap .insert ( idx, pb );
@@ -200,15 +200,13 @@ QgsVectorLayerProperties::~QgsVectorLayerProperties()
200
200
201
201
void QgsVectorLayerProperties::attributeTypeDialog ( )
202
202
{
203
- int index = -1 ;
204
- QMap<int , QPushButton*>::iterator it = mButtonMap .begin ();
205
- for ( ; it != mButtonMap .end () ; it++ )
206
- {
207
- if ( it.value ()->isDown () )
208
- {
209
- index = it.key ();
210
- }
211
- }
203
+ QPushButton *pb = dynamic_cast <QPushButton *>( sender () );
204
+ if ( !pb )
205
+ return ;
206
+
207
+ int index = mButtonMap .key ( pb, -1 );
208
+ if ( index == -1 )
209
+ return ;
212
210
213
211
QgsAttributeTypeDialog attributeTypeDialog ( layer );
214
212
@@ -243,6 +241,7 @@ void QgsVectorLayerProperties::attributeTypeDialog( )
243
241
return ;
244
242
245
243
QgsVectorLayer::EditType editType = attributeTypeDialog.editType ();
244
+
246
245
mEditTypeMap .insert ( index , editType );
247
246
248
247
QString buttonText;
@@ -258,9 +257,8 @@ void QgsVectorLayerProperties::attributeTypeDialog( )
258
257
default :
259
258
break ;
260
259
}
261
- QPushButton *pb = dynamic_cast <QPushButton*>( tblAttributes->cellWidget ( index , 6 ) );
262
- pb->setText ( editTypeButtonText ( editType ) );
263
260
261
+ pb->setText ( editTypeButtonText ( editType ) );
264
262
}
265
263
266
264
0 commit comments