Skip to content

Commit 7ecdb1d

Browse files
author
jef
committed
fix #1935
git-svn-id: http://svn.osgeo.org/qgis/trunk@11704 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b950808 commit 7ecdb1d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/app/qgsvectorlayerproperties.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void QgsVectorLayerProperties::setRow( int row, int idx, const QgsField &field )
183183
for ( int i = 0; i < 6; i++ )
184184
tblAttributes->item( row, i )->setFlags( tblAttributes->item( row, i )->flags() & ~Qt::ItemIsEditable );
185185

186-
QPushButton * pb = new QPushButton( editTypeButtonText( layer->editType( idx ) ) );
186+
QPushButton *pb = new QPushButton( editTypeButtonText( layer->editType( idx ) ) );
187187
tblAttributes->setCellWidget( row, 6, pb );
188188
connect( pb, SIGNAL( pressed() ), this, SLOT( attributeTypeDialog( ) ) );
189189
mButtonMap.insert( idx, pb );
@@ -200,15 +200,13 @@ QgsVectorLayerProperties::~QgsVectorLayerProperties()
200200

201201
void QgsVectorLayerProperties::attributeTypeDialog( )
202202
{
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;
212210

213211
QgsAttributeTypeDialog attributeTypeDialog( layer );
214212

@@ -243,6 +241,7 @@ void QgsVectorLayerProperties::attributeTypeDialog( )
243241
return;
244242

245243
QgsVectorLayer::EditType editType = attributeTypeDialog.editType();
244+
246245
mEditTypeMap.insert( index, editType );
247246

248247
QString buttonText;
@@ -258,9 +257,8 @@ void QgsVectorLayerProperties::attributeTypeDialog( )
258257
default:
259258
break;
260259
}
261-
QPushButton *pb = dynamic_cast<QPushButton*>( tblAttributes->cellWidget( index, 6 ) );
262-
pb->setText( editTypeButtonText( editType ) );
263260

261+
pb->setText( editTypeButtonText( editType ) );
264262
}
265263

266264

0 commit comments

Comments
 (0)