Skip to content
Permalink
Browse files
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
  • Loading branch information
timlinux committed Jul 28, 2008
1 parent cf69dee commit 8b24e2961e2e1223ccf03d063fba139eae16b2e3
Showing with 27 additions and 21 deletions.
  1. +22 −9 src/app/qgsattributetabledisplay.cpp
  2. +1 −0 src/app/qgsattributetabledisplay.h
  3. +4 −12 src/ui/qgsattributetablebase.ui
@@ -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&amp;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>

0 comments on commit 8b24e29

Please sign in to comment.