Skip to content

Commit

Permalink
fix activateDeactivateLayerRelatedActions (fixes #8005)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 6, 2013
1 parent cbd335a commit 6b0ce08
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ void QgisApp::dropEvent( QDropEvent *event )
}
}
}
mMapCanvas->freeze(false);
mMapCanvas->freeze( false );
mMapCanvas->refresh();
event->acceptProposedAction();
}
Expand Down Expand Up @@ -6810,8 +6810,8 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
// Let the caller do it otherwise
if ( !wasfrozen )
{
mMapCanvas->freeze( false );
mMapCanvas->refresh();
mMapCanvas->freeze( false );
mMapCanvas->refresh();
}

// Let render() do its own cursor management
Expand Down Expand Up @@ -8008,8 +8008,9 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
{
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
QgsVectorDataProvider* dprovider = vlayer->dataProvider();

bool isEditable = vlayer->isEditable();
bool layerHasSelection = vlayer->selectedFeatureCount() != 0;
bool layerHasSelection = vlayer->selectedFeatureCount() > 0;
bool layerHasActions = vlayer->actions()->size() > 0;

bool canChangeAttributes = dprovider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
Expand Down Expand Up @@ -8045,7 +8046,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )

if ( dprovider )
{
mActionLayerSubsetString->setEnabled( dprovider->supportsSubsetString() && !isEditable );
mActionLayerSubsetString->setEnabled( !isEditable && dprovider->supportsSubsetString() );

mActionToggleEditing->setEnabled( canSupportEditing && !vlayer->isReadOnly() );
mActionToggleEditing->setChecked( canSupportEditing && isEditable );
Expand All @@ -8060,8 +8061,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
updateUndoActions();
}

mActionPasteFeatures->setEnabled( canAddAttributes && isEditable && !clipboard()->empty() );
mActionAddFeature->setEnabled( canAddAttributes && isEditable );
mActionPasteFeatures->setEnabled( isEditable && canAddFeatures && !clipboard()->empty() );
mActionAddFeature->setEnabled( isEditable && canAddFeatures );

//does provider allow deleting of features?
mActionDeleteSelected->setEnabled( isEditable && canDeleteFeatures && layerHasSelection );
Expand All @@ -8070,10 +8071,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
//merge tool needs editable layer and provider with the capability of adding and deleting features
if ( isEditable && canChangeAttributes )
{
mActionMergeFeatures->setEnabled( layerHasSelection &&
canDeleteFeatures &&
canAddAttributes );

mActionMergeFeatures->setEnabled( layerHasSelection && canDeleteFeatures && canAddFeatures );
mActionMergeFeatureAttributes->setEnabled( layerHasSelection );
}
else
Expand All @@ -8089,8 +8087,6 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionRotateFeature->setEnabled( isEditable && canChangeGeometry );
mActionNodeTool->setEnabled( isEditable && canChangeGeometry );

mActionOffsetCurve->setEnabled( false );

if ( vlayer->geometryType() == QGis::Point )
{
mActionAddFeature->setIcon( QgsApplication::getThemeIcon( "/mActionCapturePoint.png" ) );
Expand All @@ -8101,6 +8097,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSimplifyFeature->setEnabled( false );
mActionDeleteRing->setEnabled( false );
mActionRotatePointSymbols->setEnabled( false );
mActionOffsetCurve->setEnabled( false );

if ( isEditable && canChangeAttributes )
{
Expand All @@ -8109,6 +8106,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionRotatePointSymbols->setEnabled( true );
}
}

return;
}
else if ( vlayer->geometryType() == QGis::Line )
Expand All @@ -8132,9 +8130,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionSplitFeatures->setEnabled( isEditable && canAddFeatures );
mActionSimplifyFeature->setEnabled( isEditable && canAddFeatures );
mActionDeleteRing->setEnabled( isEditable && canAddFeatures );
mActionOffsetCurve->setEnabled( false );
}

mActionOpenFieldCalc->setEnabled(( canChangeAttributes || canAddAttributes ) && isEditable );
mActionOpenFieldCalc->setEnabled( isEditable && ( canChangeAttributes || canAddAttributes ) );

return;
}
Expand All @@ -8145,10 +8144,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionRedo->setEnabled( false );
}



mActionLayerSubsetString->setEnabled( false );
}//end vector layer block
} //end vector layer block
/*************Raster layers*************/
else if ( layer->type() == QgsMapLayer::RasterLayer )
{
Expand Down

0 comments on commit 6b0ce08

Please sign in to comment.