Skip to content

Commit dda7ab3

Browse files
author
timlinux
committedJul 28, 2008

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed
 

‎src/app/qgsattributetabledisplay.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

‎src/app/qgsattributetabledisplay.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase
6060
protected slots:
6161
void deleteAttributes();
6262
void addAttribute();
63+
void on_btnEdit_toggled(bool theFlag);
6364
void startEditing();
6465
void stopEditing();
6566
void selectedToTop();

‎src/ui/qgsattributetablebase.ui

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,12 @@
162162
</spacer>
163163
</item>
164164
<item>
165-
<widget class="QPushButton" name="btnStartEditing" >
165+
<widget class="QPushButton" name="btnEdit" >
166166
<property name="text" >
167167
<string>Start editing</string>
168168
</property>
169-
</widget>
170-
</item>
171-
<item>
172-
<widget class="QPushButton" name="btnStopEditing" >
173-
<property name="text" >
174-
<string>Stop editin&amp;g</string>
175-
</property>
176-
<property name="shortcut" >
177-
<string>Alt+G</string>
169+
<property name="checkable" >
170+
<bool>true</bool>
178171
</property>
179172
</widget>
180173
</item>
@@ -272,8 +265,7 @@
272265
<tabstop>mZoomMapToSelectedRowsButton</tabstop>
273266
<tabstop>mAddAttributeButton</tabstop>
274267
<tabstop>mDeleteAttributeButton</tabstop>
275-
<tabstop>btnStartEditing</tabstop>
276-
<tabstop>btnStopEditing</tabstop>
268+
<tabstop>btnEdit</tabstop>
277269
<tabstop>mSearchText</tabstop>
278270
<tabstop>mSearchColumns</tabstop>
279271
<tabstop>mSearchButton</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.