Skip to content

Commit

Permalink
fix #1650
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12378 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 8, 2009
1 parent 1002f8e commit eef0367
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 51 deletions.
10 changes: 10 additions & 0 deletions src/app/attributetable/qgsattributetabledialog.cpp
Expand Up @@ -89,18 +89,21 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mZoomMapToSelectedRowsButton->setIcon( getThemeIcon( "/mActionZoomToSelected.png" ) );
mInvertSelectionButton->setIcon( getThemeIcon( "/mActionInvertSelection.png" ) );
mToggleEditingButton->setIcon( getThemeIcon( "/mActionToggleEditing.png" ) );
mDeleteSelectedButton->setIcon( getThemeIcon( "/mActionDeleteSelected.png" ) );
mOpenFieldCalculator->setIcon( getThemeIcon( "/mActionCalculateField.png" ) );
mAddAttribute->setIcon( getThemeIcon( "/mActionNewAttribute.png" ) );
mRemoveAttribute->setIcon( getThemeIcon( "/mActionDeleteAttribute.png" ) );

// toggle editing
bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
mToggleEditingButton->setCheckable( true );
mToggleEditingButton->setChecked( mLayer->isEditable() );
mToggleEditingButton->setEnabled( canChangeAttributes );
mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mAddAttribute->setEnabled( canAddAttributes && mLayer->isEditable() );
mRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );

Expand Down Expand Up @@ -230,6 +233,11 @@ void QgsAttributeTableDialog::on_mRemoveSelectionButton_clicked()
mLayer->removeSelection();
}

void QgsAttributeTableDialog::on_mDeleteSelectedButton_clicked()
{
mLayer->deleteSelectedFeatures();
}

void QgsAttributeTableDialog::on_cbxShowSelectedOnly_toggled( bool theFlag )
{
mFilterModel->setHideUnselected( theFlag );
Expand Down Expand Up @@ -615,9 +623,11 @@ void QgsAttributeTableDialog::editingToggled()
mToggleEditingButton->blockSignals( false );

bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
mOpenFieldCalculator->setEnabled( canChangeAttributes && mLayer->isEditable() );
mDeleteSelectedButton->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mAddAttribute->setEnabled( canAddAttributes && mLayer->isEditable() );
mRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );

Expand Down
5 changes: 5 additions & 0 deletions src/app/attributetable/qgsattributetabledialog.h
Expand Up @@ -145,6 +145,11 @@ class QgsAttributeTableDialog : public QDialog, private Ui::QgsAttributeTableDia
*/
void on_mOpenFieldCalculator_clicked();

/**
* deletes the selected features
*/
void on_mDeleteSelectedButton_clicked();

signals:
/**
* Informs that editing mode ha been toggled
Expand Down
113 changes: 62 additions & 51 deletions src/ui/qgsattributetabledialog.ui
Expand Up @@ -21,6 +21,57 @@
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="cbxShowSelectedOnly">
<property name="text">
<string>Show selected records only</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxSearchSelectedOnly">
<property name="text">
<string>Search selected records only</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Advanced search</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mAdvancedSearchButton">
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
Expand Down Expand Up @@ -170,6 +221,17 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mDeleteSelectedButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normaloff>../../images/themes/default/mActionDeleteSelected.png</normaloff>../../images/themes/default/mActionDeleteSelected.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mAddAttribute">
<property name="toolTip">
Expand Down Expand Up @@ -259,57 +321,6 @@
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="cbxShowSelectedOnly">
<property name="text">
<string>Show selected records only</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxSearchSelectedOnly">
<property name="text">
<string>Search selected records only</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Advanced search</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mAdvancedSearchButton">
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
Expand Down

0 comments on commit eef0367

Please sign in to comment.