Skip to content

Commit

Permalink
enable (or disable) "feature action" tool after adding (or removing) …
Browse files Browse the repository at this point in the history
…actions
  • Loading branch information
brushtyler committed Jan 11, 2012
1 parent acc1d55 commit 9ca05fe
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/qgisapp.cpp
Expand Up @@ -3300,15 +3300,12 @@ void QgisApp::doFeatureAction()

void QgisApp::updateDefaultFeatureAction( QAction *action )
{
foreach( QAction *a, mFeatureActionMenu->actions() )
{
a->setChecked( a == action );
}

QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( activeLayer() );
if ( !vlayer )
return;

mFeatureActionMenu->setActiveAction( action );

int index = mFeatureActionMenu->actions().indexOf( action );
vlayer->actions()->setDefaultAction( index );

Expand All @@ -3327,10 +3324,9 @@ void QgisApp::refreshFeatureActions()
for ( int i = 0; i < actions->size(); i++ )
{
QAction *action = mFeatureActionMenu->addAction( actions->at( i ).name() );
action->setCheckable( true );
if ( i == actions->defaultAction() )
{
action->setChecked( true );
mFeatureActionMenu->setActiveAction( action );
}
}
}
Expand Down Expand Up @@ -6123,6 +6119,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );
QgsVectorDataProvider* dprovider = vlayer->dataProvider();
bool layerHasSelection = vlayer->selectedFeatureCount() != 0;
bool layerHasActions = vlayer->actions()->size() > 0;

mActionLocalHistogramStretch->setEnabled( false );
mActionFullHistogramStretch->setEnabled( false );
Expand All @@ -6138,7 +6135,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionLayerSaveAs->setEnabled( true );
mActionLayerSelectionSaveAs->setEnabled( true );
mActionCopyFeatures->setEnabled( layerHasSelection );
mActionFeatureAction->setEnabled( vlayer->actions()->size() > 0 );
mActionFeatureAction->setEnabled( layerHasActions );

if ( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
{
Expand Down Expand Up @@ -6979,7 +6976,11 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
vlp = new QgsVectorLayerProperties( vlayer );
connect( vlp, SIGNAL( refreshLegend( QString, bool ) ), mMapLegend, SLOT( refreshLayerSymbology( QString, bool ) ) );
}
vlp->exec();

if ( vlp->exec() )
{
activateDeactivateLayerRelatedActions( ml );
}
delete vlp; // delete since dialog cannot be reused without updating code
}
else if ( ml->type() == QgsMapLayer::PluginLayer )
Expand Down

0 comments on commit 9ca05fe

Please sign in to comment.