Skip to content
Permalink
Browse files

[FEATURE][multiedit] Add shortcut to modify attributes of selected

features to edit menu

Workflow:
- enter edit mode, select multiple features
- select Edit -> Modify Attributes of Selected Features
- edit attributes using feature form, click OK or Cancel
  • Loading branch information
nyalldawson committed May 3, 2016
1 parent 98e9ae1 commit 4335a77b7b8793a7f1d14c3e4771f4f4e2467b4e
Showing with 71 additions and 6 deletions.
  1. +43 −0 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgisapp.h
  3. +12 −5 src/gui/qgsattributeform.cpp
  4. +14 −1 src/ui/qgisapp.ui
@@ -1388,6 +1388,7 @@ void QgisApp::createActions()
connect( mActionDeletePart, SIGNAL( triggered() ), this, SLOT( deletePart() ) );
connect( mActionMergeFeatures, SIGNAL( triggered() ), this, SLOT( mergeSelectedFeatures() ) );
connect( mActionMergeFeatureAttributes, SIGNAL( triggered() ), this, SLOT( mergeAttributesOfSelectedFeatures() ) );
connect( mActionMultiEditAttributes, SIGNAL( triggered() ), this, SLOT( modifyAttributesOfSelectedFeatures() ) );
connect( mActionNodeTool, SIGNAL( triggered() ), this, SLOT( nodeTool() ) );
connect( mActionRotatePointSymbols, SIGNAL( triggered() ), this, SLOT( rotatePointSymbols() ) );
connect( mActionSnappingOptions, SIGNAL( triggered() ), this, SLOT( snappingOptions() ) );
@@ -6551,6 +6552,45 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
}
}

void QgisApp::modifyAttributesOfSelectedFeatures()
{
QgsMapLayer* activeMapLayer = activeLayer();
if ( !activeMapLayer )
{
messageBar()->pushMessage(
tr( "No active layer" ),
tr( "Please select a layer in the layer list" ),
QgsMessageBar::WARNING );
return;
}

QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( activeMapLayer );
if ( !vl )
{
messageBar()->pushMessage(
tr( "Invalid layer" ),
tr( "The merge features tool only works on vector layers." ),
QgsMessageBar::WARNING );
return;
}
if ( !vl->isEditable() )
{
messageBar()->pushMessage(
tr( "Layer not editable" ),
tr( "Modifying features can only be done for layers in editing mode." ),
QgsMessageBar::WARNING );

return;
}

//dummy feature
QgsFeature f;
QgsAttributeDialog* dialog = new QgsAttributeDialog( vl, &f, false, this );
dialog->setMode( QgsAttributeForm::MultiEditMode );
dialog->exec();

}

void QgisApp::mergeSelectedFeatures()
{
//get active layer (hopefully vector)
@@ -9998,6 +10038,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSplitParts->setEnabled( false );
mActionMergeFeatures->setEnabled( false );
mActionMergeFeatureAttributes->setEnabled( false );
mActionMultiEditAttributes->setEnabled( false );
mActionRotatePointSymbols->setEnabled( false );
mActionEnableTracing->setEnabled( false );

@@ -10109,11 +10150,13 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
mActionMergeFeatures->setEnabled( layerHasSelection && canDeleteFeatures && canAddFeatures );
mActionMergeFeatureAttributes->setEnabled( layerHasSelection );
mActionMultiEditAttributes->setEnabled( layerHasSelection );
}
else
{
mActionMergeFeatures->setEnabled( false );
mActionMergeFeatureAttributes->setEnabled( false );
mActionMultiEditAttributes->setEnabled( false );
}

bool isMultiPart = QGis::isMultiType( vlayer->wkbType() ) || !dprovider->doesStrictFeatureTypeCheck();
@@ -1034,6 +1034,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void mergeSelectedFeatures();
//! merges the attributes of selected features
void mergeAttributesOfSelectedFeatures();
//! Modifies the attributes of selected features via feature form
void modifyAttributesOfSelectedFeatures();
//! provides operations with nodes
void nodeTool();
//! activates the rotate points tool
@@ -186,6 +186,7 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )

case QgsAttributeForm::MultiEditMode:
resetMultiEdit( false );
synchronizeEnabledState();
break;
}

@@ -433,7 +434,8 @@ bool QgsAttributeForm::saveMultiEdits()
mMultiEditMessageBarItem = new QgsMessageBarItem( tr( "Changes could not be applied" ), QgsMessageBar::WARNING, messageTimeout() );
}

mMessageBar->pushItem( mMultiEditMessageBarItem );
if ( !mButtonBox->isVisible() )
mMessageBar->pushItem( mMultiEditMessageBarItem );
return success;
}

@@ -482,12 +484,14 @@ void QgsAttributeForm::clearMultiEditMessages()
{
if ( mMultiEditUnsavedMessageBarItem )
{
mMessageBar->popWidget( mMultiEditUnsavedMessageBarItem );
if ( !mButtonBox->isVisible() )
mMessageBar->popWidget( mMultiEditUnsavedMessageBarItem );
mMultiEditUnsavedMessageBarItem = nullptr;
}
if ( mMultiEditMessageBarItem )
{
mMessageBar->popWidget( mMultiEditMessageBarItem );
if ( !mButtonBox->isVisible() )
mMessageBar->popWidget( mMultiEditMessageBarItem );
mMultiEditMessageBarItem = nullptr;
}
}
@@ -523,7 +527,8 @@ void QgsAttributeForm::onAttributeChanged( const QVariant& value )
clearMultiEditMessages();

mMultiEditUnsavedMessageBarItem = new QgsMessageBarItem( msgLabel, QgsMessageBar::WARNING );
mMessageBar->pushItem( mMultiEditUnsavedMessageBarItem );
if ( !mButtonBox->isVisible() )
mMessageBar->pushItem( mMultiEditUnsavedMessageBarItem );
}
break;
}
@@ -608,7 +613,9 @@ void QgsAttributeForm::refreshFeature()

void QgsAttributeForm::synchronizeEnabledState()
{
bool isEditable = ( mFeature.isValid() || mMode == AddFeatureMode ) && mLayer->isEditable();
bool isEditable = ( mFeature.isValid()
|| mMode == AddFeatureMode
|| mMode == MultiEditMode ) && mLayer->isEditable();

Q_FOREACH ( QgsWidgetWrapper* ww, mWidgets )
{
@@ -17,7 +17,7 @@
<x>0</x>
<y>0</y>
<width>1050</width>
<height>19</height>
<height>25</height>
</rect>
</property>
<property name="toolTip">
@@ -271,6 +271,7 @@
<addaction name="mActionAddFeature"/>
<addaction name="mActionMoveFeature"/>
<addaction name="mActionDeleteSelected"/>
<addaction name="mActionMultiEditAttributes"/>
<addaction name="separator"/>
<addaction name="mActionRotateFeature"/>
<addaction name="mActionSimplifyFeature"/>
@@ -2479,6 +2480,18 @@ Acts on currently active editable layer</string>
<string>New GeoPackage Layer...</string>
</property>
</action>
<action name="mActionMultiEditAttributes">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionAllEdits.svg</normaloff>:/images/themes/default/mActionAllEdits.svg</iconset>
</property>
<property name="text">
<string>Modify Attributes of Selected Features</string>
</property>
<property name="toolTip">
<string>Modify the Attributes of all Selected Features Simultaneously</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>

0 comments on commit 4335a77

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