Skip to content

Commit 4571b1d

Browse files
committed
fix #6803
1 parent 32ca040 commit 4571b1d

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/app/qgsfieldsproperties.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ QgsFieldsProperties::QgsFieldsProperties( QgsVectorLayer *layer, QWidget* parent
193193
mToggleEditingButton->setIcon( QgsApplication::getThemeIcon( "/mActionToggleEditing.png" ) );
194194
mCalculateFieldButton->setIcon( QgsApplication::getThemeIcon( "/mActionCalculateField.png" ) );
195195

196-
connect( mToggleEditingButton, SIGNAL( clicked() ), this, SLOT( toggleEditing() ) );
196+
connect( mToggleEditingButton, SIGNAL( clicked() ), this, SIGNAL( toggleEditing() ) );
197197
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
198198
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );
199199
connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( attributeAdded( int ) ) );
@@ -242,11 +242,6 @@ void QgsFieldsProperties::onAttributeSelectionChanged()
242242
mAddItemButton->setEnabled( isAddPossible );
243243
}
244244

245-
void QgsFieldsProperties::toggleEditing()
246-
{
247-
emit toggleEditing( mLayer );
248-
}
249-
250245
QTreeWidgetItem *QgsFieldsProperties::loadAttributeEditorTreeItem( QgsAttributeEditorElement* const widgetDef, QTreeWidgetItem* parent )
251246
{
252247
QTreeWidgetItem* newWidget = 0;
@@ -303,7 +298,7 @@ void QgsFieldsProperties::loadAttributeEditorTree()
303298

304299
void QgsFieldsProperties::loadRows()
305300
{
306-
disconnect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( on_mAttributesList_cellChanged( int, int ) ) );
301+
disconnect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( attributesListCellChanged( int, int ) ) );
307302
const QgsFieldMap &fields = mLayer->pendingFields();
308303

309304
mAttributesList->clear();
@@ -334,7 +329,7 @@ void QgsFieldsProperties::loadRows()
334329
setRow( row, it.key(), it.value() );
335330

336331
mAttributesList->resizeColumnsToContents();
337-
connect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( on_mAttributesList_cellChanged( int, int ) ) );
332+
connect( mAttributesList, SIGNAL( cellChanged( int, int ) ), this, SLOT( attributesListCellChanged( int, int ) ) );
338333
}
339334

340335
void QgsFieldsProperties::setRow( int row, int idx, const QgsField &field )
@@ -474,7 +469,7 @@ void QgsFieldsProperties::on_mMoveUpItem_clicked()
474469
}
475470
}
476471

477-
void QgsFieldsProperties::attributeTypeDialog( )
472+
void QgsFieldsProperties::attributeTypeDialog()
478473
{
479474
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
480475
if ( !pb )
@@ -657,9 +652,12 @@ void QgsFieldsProperties::on_mDeleteAttributeButton_clicked()
657652

658653
void QgsFieldsProperties::updateButtons()
659654
{
655+
int cap = mLayer->dataProvider()->capabilities();
656+
657+
mToggleEditingButton->setEnabled(( cap & QgsVectorDataProvider::ChangeAttributeValues ) && !mLayer->isReadOnly() );
658+
660659
if ( mLayer->isEditable() )
661660
{
662-
int cap = mLayer->dataProvider()->capabilities();
663661
mAddAttributeButton->setEnabled( cap & QgsVectorDataProvider::AddAttributes );
664662
mDeleteAttributeButton->setEnabled( cap & QgsVectorDataProvider::DeleteAttributes );
665663
mCalculateFieldButton->setEnabled( cap & ( QgsVectorDataProvider::ChangeAttributeValues | QgsVectorDataProvider::AddAttributes ) );
@@ -670,13 +668,12 @@ void QgsFieldsProperties::updateButtons()
670668
mAddAttributeButton->setEnabled( false );
671669
mDeleteAttributeButton->setEnabled( false );
672670
mToggleEditingButton->setChecked( false );
673-
mToggleEditingButton->setEnabled( false );
674671
mCalculateFieldButton->setEnabled( false );
675672
}
676673
}
677674

678675

679-
void QgsFieldsProperties::on_mAttributesList_cellChanged( int row, int column )
676+
void QgsFieldsProperties::attributesListCellChanged( int row, int column )
680677
{
681678
if ( column == attrAliasCol && mLayer ) //only consider attribute aliases in this function
682679
{

src/app/qgsfieldsproperties.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,13 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
9090
QTreeWidgetItem *loadAttributeEditorTreeItem( QgsAttributeEditorElement* const widgetDef, QTreeWidgetItem* parent );
9191

9292
signals:
93-
void toggleEditing( QgsMapLayer * );
93+
void toggleEditing();
9494

9595
public slots:
9696
void on_mAddAttributeButton_clicked();
9797
void on_mDeleteAttributeButton_clicked();
9898
void on_mCalculateFieldButton_clicked();
9999
void onAttributeSelectionChanged();
100-
void on_mAttributesList_cellChanged( int row, int column );
101100
void on_pbnSelectEditForm_clicked();
102101
void on_mEditorLayoutComboBox_currentIndexChanged( int index );
103102

@@ -113,10 +112,9 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
113112
void on_mMoveDownItem_clicked();
114113
void on_mMoveUpItem_clicked();
115114

116-
protected slots:
117-
/** toggle editing of layer */
118-
void toggleEditing();
115+
void attributesListCellChanged( int row, int column );
119116

117+
protected slots:
120118
/** editing of layer was toggled */
121119
void editingToggled();
122120

src/app/qgsvectorlayerproperties.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,15 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
137137
mFieldsFrame->setLayout( new QVBoxLayout( mFieldsFrame ) );
138138
mFieldsFrame->layout()->addWidget( mFieldsPropertiesDialog );
139139

140+
connect( mFieldsPropertiesDialog, SIGNAL( toggleEditing() ), this, SLOT( toggleEditing() ) );
141+
connect( this, SIGNAL( toggleEditing( QgsMapLayer* ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer* ) ) );
142+
140143
reset();
141144

142145
if ( layer->dataProvider() )//enable spatial index button group if supported by provider
143146
{
144147
int capabilities = layer->dataProvider()->capabilities();
145-
if ( !( capabilities&QgsVectorDataProvider::CreateSpatialIndex ) )
148+
if ( !( capabilities & QgsVectorDataProvider::CreateSpatialIndex ) )
146149
{
147150
pbnIndex->setEnabled( false );
148151
}

0 commit comments

Comments
 (0)