@@ -55,8 +55,6 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
55
55
connect (mZoomMapToSelectedRowsButton , SIGNAL (clicked ()), this , SLOT (zoomMapToSelectedRows ()));
56
56
connect (mAddAttributeButton , SIGNAL (clicked ()), this , SLOT (addAttribute ()));
57
57
connect (mDeleteAttributeButton , SIGNAL (clicked ()), this , SLOT (deleteAttributes ()));
58
- connect (btnStartEditing, SIGNAL (clicked ()), this , SLOT (startEditing ()));
59
- connect (btnStopEditing, SIGNAL (clicked ()), this , SLOT (stopEditing ()));
60
58
connect (mSearchButton , SIGNAL (clicked ()), this , SLOT (search ()));
61
59
connect (mSearchShowResults , SIGNAL (activated (int )), this , SLOT (searchShowResultsChanged (int )));
62
60
connect (btnAdvancedSearch, SIGNAL (clicked ()), this , SLOT (advancedSearch ()));
@@ -69,17 +67,16 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
69
67
mAddAttributeButton ->setEnabled (false );
70
68
mDeleteAttributeButton ->setEnabled (false );
71
69
72
- btnStopEditing->setEnabled (false );
73
70
int cap=layer->getDataProvider ()->capabilities ();
74
71
if ((cap&QgsVectorDataProvider::ChangeAttributeValues)
75
72
||(cap&QgsVectorDataProvider::AddAttributes)
76
73
||(cap&QgsVectorDataProvider::DeleteAttributes))
77
74
{
78
- btnStartEditing ->setEnabled (true );
75
+ btnEdit ->setEnabled (true );
79
76
}
80
77
else
81
78
{
82
- btnStartEditing ->setEnabled (false );
79
+ btnEdit ->setEnabled (false );
83
80
}
84
81
85
82
// fill in mSearchColumns with available columns
@@ -175,8 +172,7 @@ void QgsAttributeTableDisplay::startEditing()
175
172
}
176
173
if (editing)
177
174
{
178
- btnStartEditing->setEnabled (false );
179
- btnStopEditing->setEnabled (true );
175
+ btnEdit->setText (tr (" Stop editing" ));
180
176
buttonBox->button (QDialogButtonBox::Close)->setEnabled (false );
181
177
// make the dialog modal when in editable
182
178
// otherwise map editing and table editing
@@ -185,6 +181,24 @@ void QgsAttributeTableDisplay::startEditing()
185
181
setModal (true );
186
182
show ();
187
183
}
184
+ else
185
+ {
186
+ // revert button
187
+ QMessageBox::information (this ,tr (" Editing not permitted" ),tr (" The data provider is read only, editing is not allowed." ));
188
+ btnEdit->setChecked (false );
189
+ }
190
+ }
191
+ }
192
+
193
+ void QgsAttributeTableDisplay::on_btnEdit_toggled (bool theFlag)
194
+ {
195
+ if (theFlag)
196
+ {
197
+ startEditing ();
198
+ }
199
+ else
200
+ {
201
+ stopEditing ();
188
202
}
189
203
}
190
204
@@ -213,8 +227,7 @@ void QgsAttributeTableDisplay::stopEditing()
213
227
return ;
214
228
}
215
229
}
216
- btnStartEditing->setEnabled (true );
217
- btnStopEditing->setEnabled (false );
230
+ btnEdit->setText (tr (" Start editing" ));
218
231
buttonBox->button (QDialogButtonBox::Close)->setEnabled (true );
219
232
mAddAttributeButton ->setEnabled (false );
220
233
mDeleteAttributeButton ->setEnabled (false );
0 commit comments