Skip to content

Commit

Permalink
Merge pull request #4937 from m-kuhn/attributeTableCodeEnhancements$
Browse files Browse the repository at this point in the history
Attribute table code enhancements
  • Loading branch information
m-kuhn committed Jul 28, 2017
2 parents 4705c97 + f43df12 commit 7f1bb72
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
19 changes: 15 additions & 4 deletions src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -474,7 +474,11 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
continue;

QgsAttributeTableAction *a = new QgsAttributeTableAction( action.name(), this, action.id(), sourceIndex );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
menu->addAction( action.name(), a, SLOT( execute() ) );
#else
menu->addAction( action.name(), a, &QgsAttributeTableAction::execute );
#endif
}
}

Expand All @@ -485,17 +489,24 @@ void QgsDualView::viewWillShowContextMenu( QMenu *menu, const QModelIndex &atInd
//add a separator between user defined and standard actions
menu->addSeparator();

QList<QgsMapLayerAction *>::iterator actionIt;
for ( actionIt = registeredActions.begin(); actionIt != registeredActions.end(); ++actionIt )
Q_FOREACH ( QgsMapLayerAction *action, registeredActions )
{
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( ( *actionIt )->text(), this, ( *actionIt ), sourceIndex );
menu->addAction( ( *actionIt )->text(), a, SLOT( execute() ) );
QgsAttributeTableMapLayerAction *a = new QgsAttributeTableMapLayerAction( action->text(), this, action, sourceIndex );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
menu->addAction( action->text(), a, SLOT( execut() ) );
#else
menu->addAction( action->text(), a, &QgsAttributeTableMapLayerAction::execute );
#endif
}
}

menu->addSeparator();
QgsAttributeTableAction *a = new QgsAttributeTableAction( tr( "Open form" ), this, QString(), sourceIndex );
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
menu->addAction( tr( "Open form" ), a, SLOT( featureForm() ) );
#else
menu->addAction( tr( "Open form" ), a, &QgsAttributeTableAction::featureForm );
#endif
}

void QgsDualView::showViewHeaderMenu( QPoint point )
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmaplayeractionregistry.cpp
Expand Up @@ -108,12 +108,12 @@ void QgsMapLayerActionRegistry::addMapLayerAction( QgsMapLayerAction *action )
QList< QgsMapLayerAction * > QgsMapLayerActionRegistry::mapLayerActions( QgsMapLayer *layer, QgsMapLayerAction::Targets targets )
{
QList< QgsMapLayerAction * > validActions;
QList<QgsMapLayerAction *>::iterator actionIt;
for ( actionIt = mMapLayerActionList.begin(); actionIt != mMapLayerActionList.end(); ++actionIt )

Q_FOREACH ( QgsMapLayerAction *action, mMapLayerActionList )
{
if ( ( *actionIt )->canRunUsingLayer( layer ) && ( targets & ( *actionIt )->targets() ) )
if ( action->canRunUsingLayer( layer ) && ( targets & action->targets() ) )
{
validActions.append( ( *actionIt ) );
validActions.append( action );
}
}
return validActions;
Expand Down

0 comments on commit 7f1bb72

Please sign in to comment.