mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix ticket #982 - combine start / stop editing into one button
git-svn-id: http://svn.osgeo.org/qgis/trunk@8945 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
cf69dee256
commit
8b24e2961e
@ -55,8 +55,6 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
|
||||
connect(mZoomMapToSelectedRowsButton, SIGNAL(clicked()), this, SLOT(zoomMapToSelectedRows()));
|
||||
connect(mAddAttributeButton, SIGNAL(clicked()), this, SLOT(addAttribute()));
|
||||
connect(mDeleteAttributeButton, SIGNAL(clicked()), this, SLOT(deleteAttributes()));
|
||||
connect(btnStartEditing, SIGNAL(clicked()), this, SLOT(startEditing()));
|
||||
connect(btnStopEditing, SIGNAL(clicked()), this, SLOT(stopEditing()));
|
||||
connect(mSearchButton, SIGNAL(clicked()), this, SLOT(search()));
|
||||
connect(mSearchShowResults, SIGNAL(activated(int)), this, SLOT(searchShowResultsChanged(int)));
|
||||
connect(btnAdvancedSearch, SIGNAL(clicked()), this, SLOT(advancedSearch()));
|
||||
@ -69,17 +67,16 @@ QgsAttributeTableDisplay::QgsAttributeTableDisplay(QgsVectorLayer* layer, QgisAp
|
||||
mAddAttributeButton->setEnabled(false);
|
||||
mDeleteAttributeButton->setEnabled(false);
|
||||
|
||||
btnStopEditing->setEnabled(false);
|
||||
int cap=layer->getDataProvider()->capabilities();
|
||||
if((cap&QgsVectorDataProvider::ChangeAttributeValues)
|
||||
||(cap&QgsVectorDataProvider::AddAttributes)
|
||||
||(cap&QgsVectorDataProvider::DeleteAttributes))
|
||||
{
|
||||
btnStartEditing->setEnabled(true);
|
||||
btnEdit->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
btnStartEditing->setEnabled(false);
|
||||
btnEdit->setEnabled(false);
|
||||
}
|
||||
|
||||
// fill in mSearchColumns with available columns
|
||||
@ -175,8 +172,7 @@ void QgsAttributeTableDisplay::startEditing()
|
||||
}
|
||||
if(editing)
|
||||
{
|
||||
btnStartEditing->setEnabled(false);
|
||||
btnStopEditing->setEnabled(true);
|
||||
btnEdit->setText(tr("Stop editing"));
|
||||
buttonBox->button(QDialogButtonBox::Close)->setEnabled(false);
|
||||
//make the dialog modal when in editable
|
||||
//otherwise map editing and table editing
|
||||
@ -185,6 +181,24 @@ void QgsAttributeTableDisplay::startEditing()
|
||||
setModal(true);
|
||||
show();
|
||||
}
|
||||
else
|
||||
{
|
||||
//revert button
|
||||
QMessageBox::information(this,tr("Editing not permitted"),tr("The data provider is read only, editing is not allowed."));
|
||||
btnEdit->setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAttributeTableDisplay::on_btnEdit_toggled(bool theFlag)
|
||||
{
|
||||
if (theFlag)
|
||||
{
|
||||
startEditing();
|
||||
}
|
||||
else
|
||||
{
|
||||
stopEditing();
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,8 +227,7 @@ void QgsAttributeTableDisplay::stopEditing()
|
||||
return;
|
||||
}
|
||||
}
|
||||
btnStartEditing->setEnabled(true);
|
||||
btnStopEditing->setEnabled(false);
|
||||
btnEdit->setText(tr("Start editing"));
|
||||
buttonBox->button(QDialogButtonBox::Close)->setEnabled(true);
|
||||
mAddAttributeButton->setEnabled(false);
|
||||
mDeleteAttributeButton->setEnabled(false);
|
||||
|
@ -60,6 +60,7 @@ class QgsAttributeTableDisplay:public QDialog, private Ui::QgsAttributeTableBase
|
||||
protected slots:
|
||||
void deleteAttributes();
|
||||
void addAttribute();
|
||||
void on_btnEdit_toggled(bool theFlag);
|
||||
void startEditing();
|
||||
void stopEditing();
|
||||
void selectedToTop();
|
||||
|
@ -162,19 +162,12 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnStartEditing" >
|
||||
<widget class="QPushButton" name="btnEdit" >
|
||||
<property name="text" >
|
||||
<string>Start editing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnStopEditing" >
|
||||
<property name="text" >
|
||||
<string>Stop editin&g</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Alt+G</string>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -272,8 +265,7 @@
|
||||
<tabstop>mZoomMapToSelectedRowsButton</tabstop>
|
||||
<tabstop>mAddAttributeButton</tabstop>
|
||||
<tabstop>mDeleteAttributeButton</tabstop>
|
||||
<tabstop>btnStartEditing</tabstop>
|
||||
<tabstop>btnStopEditing</tabstop>
|
||||
<tabstop>btnEdit</tabstop>
|
||||
<tabstop>mSearchText</tabstop>
|
||||
<tabstop>mSearchColumns</tabstop>
|
||||
<tabstop>mSearchButton</tabstop>
|
||||
|
Loading…
x
Reference in New Issue
Block a user