Skip to content
Permalink
Browse files

[needs-docs][attribute table] UX improvements to cut/copy/paste actions

  • Loading branch information
nirvn committed Jan 31, 2018
1 parent ad5a869 commit 28ff28a22363368bd38186be364efe3381b188d3
Showing with 45 additions and 9 deletions.
  1. +20 −5 src/app/qgsattributetabledialog.cpp
  2. +5 −0 src/app/qgsattributetabledialog.h
  3. +20 −4 src/ui/qgsattributetabledialog.ui
@@ -87,6 +87,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
{
setObjectName( QStringLiteral( "QgsAttributeTableDialog/" ) + layer->id() );
setupUi( this );
connect( mActionCutSelectedRows, &QAction::triggered, this, &QgsAttributeTableDialog::mActionCutSelectedRows_triggered );
connect( mActionCopySelectedRows, &QAction::triggered, this, &QgsAttributeTableDialog::mActionCopySelectedRows_triggered );
connect( mActionPasteFeatures, &QAction::triggered, this, &QgsAttributeTableDialog::mActionPasteFeatures_triggered );
connect( mActionToggleEditing, &QAction::toggled, this, &QgsAttributeTableDialog::mActionToggleEditing_toggled );
@@ -264,15 +265,18 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
mActionReload->setEnabled( ! mLayer->isEditable() );
mActionAddAttribute->setEnabled( ( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() );
if ( !canDeleteFeatures )
{
mToolbar->removeAction( mActionDeleteSelected );
mToolbar->removeAction( mActionCutSelectedRows );
}
mActionAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
mActionPasteFeatures->setEnabled( canAddFeatures && mLayer->isEditable() );
if ( !canAddFeatures )
{
mToolbar->removeAction( mActionAddFeature );

if ( canDeleteFeatures || canAddFeatures )
mToolbar->insertSeparator( mActionExpressionSelect );
mToolbar->removeAction( mActionPasteFeatures );
}

mMainViewButtonGroup->setId( mTableViewButton, QgsDualView::AttributeTable );
mMainViewButtonGroup->setId( mAttributeViewButton, QgsDualView::AttributeEditor );
@@ -382,8 +386,12 @@ void QgsAttributeTableDialog::updateTitle()
else
mRunFieldCalc->setText( tr( "Update Filtered" ) );

bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
bool enabled = mLayer->selectedFeatureCount() > 0;
mRunFieldCalcSelected->setEnabled( enabled );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() && enabled );
mActionCutSelectedRows->setEnabled( canDeleteFeatures && mLayer->isEditable() && enabled );
mActionCopySelectedRows->setEnabled( enabled );
}

void QgsAttributeTableDialog::updateButtonStatus( const QString &fieldName, bool isValid )
@@ -739,6 +747,11 @@ void QgsAttributeTableDialog::mActionExpressionSelect_triggered()
dlg->show();
}

void QgsAttributeTableDialog::mActionCutSelectedRows_triggered()
{
QgisApp::instance()->cutSelectionToClipboard( mLayer );
}

void QgsAttributeTableDialog::mActionCopySelectedRows_triggered()
{
QgisApp::instance()->copySelectionToClipboard( mLayer );
@@ -823,8 +836,10 @@ void QgsAttributeTableDialog::editingToggled()
bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;
mActionAddAttribute->setEnabled( ( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() && mLayer->selectedFeatureCount() > 0 );
mActionCutSelectedRows->setEnabled( canDeleteFeatures && mLayer->isEditable() && mLayer->selectedFeatureCount() > 0 );
mActionAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
mActionPasteFeatures->setEnabled( canAddFeatures && mLayer->isEditable() );
mActionToggleEditing->setEnabled( ( canChangeAttributes || canDeleteFeatures || canAddAttributes || canDeleteAttributes || canAddFeatures ) && !mLayer->readOnly() );

mUpdateExpressionBox->setVisible( mLayer->isEditable() );
@@ -74,6 +74,11 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib

private slots:

/**
* Cut selected rows to the clipboard
*/
void mActionCutSelectedRows_triggered();

/**
* Copies selected rows to the clipboard
*/
@@ -170,6 +170,10 @@
<addaction name="separator"/>
<addaction name="mActionAddFeature"/>
<addaction name="mActionDeleteSelected"/>
<addaction name="mActionCutSelectedRows"/>
<addaction name="mActionCopySelectedRows"/>
<addaction name="mActionPasteFeatures"/>
<addaction name="separator"/>
<addaction name="mActionExpressionSelect"/>
<addaction name="mActionSelectAll"/>
<addaction name="mActionInvertSelection"/>
@@ -179,9 +183,6 @@
<addaction name="mActionPanMapToSelectedRows"/>
<addaction name="mActionZoomMapToSelectedRows"/>
<addaction name="separator"/>
<addaction name="mActionCopySelectedRows"/>
<addaction name="mActionPasteFeatures"/>
<addaction name="separator"/>
<addaction name="mActionAddAttribute"/>
<addaction name="mActionRemoveAttribute"/>
<addaction name="mActionOpenFieldCalculator"/>
@@ -528,13 +529,28 @@
<string>Ctrl+J</string>
</property>
</action>
<action name="mActionCutSelectedRows">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionEditCut.svg</normaloff>:/images/themes/default/mActionEditCut.svg</iconset>
</property>
<property name="text">
<string>Cut selected rows to clipboard</string>
</property>
<property name="toolTip">
<string>Cut selected rows to clipboard (Ctrl+X)</string>
</property>
<property name="shortcut">
<string>Ctrl+X</string>
</property>
</action>
<action name="mActionCopySelectedRows">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionEditCopy.svg</normaloff>:/images/themes/default/mActionEditCopy.svg</iconset>
</property>
<property name="text">
<string>Copy selected rows to clipboard (Ctrl+C)</string>
<string>Copy selected rows to clipboard</string>
</property>
<property name="toolTip">
<string>Copy selected rows to clipboard (Ctrl+C)</string>

0 comments on commit 28ff28a

Please sign in to comment.
You can’t perform that action at this time.