@@ -55,8 +55,6 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
5555 connect (mZoomMapToSelectedRowsButton , SIGNAL (clicked ()), this , SLOT (zoomMapToSelectedRows ()));
5656 connect (mAddAttributeButton , SIGNAL (clicked ()), this , SLOT (addAttribute ()));
5757 connect (mDeleteAttributeButton , SIGNAL (clicked ()), this , SLOT (deleteAttributes ()));
58- connect (btnStartEditing, SIGNAL (clicked ()), this , SLOT (startEditing ()));
59- connect (btnStopEditing, SIGNAL (clicked ()), this , SLOT (stopEditing ()));
6058 connect (mSearchButton , SIGNAL (clicked ()), this , SLOT (search ()));
6159 connect (mSearchShowResults , SIGNAL (activated (int )), this , SLOT (searchShowResultsChanged (int )));
6260 connect (btnAdvancedSearch, SIGNAL (clicked ()), this , SLOT (advancedSearch ()));
@@ -69,17 +67,16 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
6967 mAddAttributeButton ->setEnabled (false );
7068 mDeleteAttributeButton ->setEnabled (false );
7169
72- btnStopEditing->setEnabled (false );
7370 int cap=layer->getDataProvider ()->capabilities ();
7471 if ((cap&QgsVectorDataProvider::ChangeAttributeValues)
7572 ||(cap&QgsVectorDataProvider::AddAttributes)
7673 ||(cap&QgsVectorDataProvider::DeleteAttributes))
7774 {
78- btnStartEditing ->setEnabled (true );
75+ btnEdit ->setEnabled (true );
7976 }
8077 else
8178 {
82- btnStartEditing ->setEnabled (false );
79+ btnEdit ->setEnabled (false );
8380 }
8481
8582 // fill in mSearchColumns with available columns
@@ -175,8 +172,7 @@ void QgsAttributeTableDisplay::startEditing()
175172 }
176173 if (editing)
177174 {
178- btnStartEditing->setEnabled (false );
179- btnStopEditing->setEnabled (true );
175+ btnEdit->setText (tr (" Stop editing" ));
180176 buttonBox->button (QDialogButtonBox::Close)->setEnabled (false );
181177 // make the dialog modal when in editable
182178 // otherwise map editing and table editing
@@ -185,6 +181,24 @@ void QgsAttributeTableDisplay::startEditing()
185181 setModal (true );
186182 show ();
187183 }
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 ();
188202 }
189203}
190204
@@ -213,8 +227,7 @@ void QgsAttributeTableDisplay::stopEditing()
213227 return ;
214228 }
215229 }
216- btnStartEditing->setEnabled (true );
217- btnStopEditing->setEnabled (false );
230+ btnEdit->setText (tr (" Start editing" ));
218231 buttonBox->button (QDialogButtonBox::Close)->setEnabled (true );
219232 mAddAttributeButton ->setEnabled (false );
220233 mDeleteAttributeButton ->setEnabled (false );
0 commit comments