Skip to content

Commit

Permalink
Fix ticket #982 - combine start / stop editing into one button
Browse files Browse the repository at this point in the history
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 8b24e29
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
31 changes: 22 additions & 9 deletions src/app/qgsattributetabledisplay.cpp
Expand Up @@ -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()));
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
}

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsattributetabledisplay.h
Expand Up @@ -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();
Expand Down
16 changes: 4 additions & 12 deletions src/ui/qgsattributetablebase.ui
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 8b24e29

Please sign in to comment.