Skip to content
Permalink
Browse files

Merge pull request #4937 from m-kuhn/attributeTableCodeEnhancements$

Attribute table code enhancements
  • Loading branch information
m-kuhn committed Jul 28, 2017
2 parents 4705c97 + f43df12 commit 7f1bb72872a61765fb8a4fac01b11135d0e68c58
Showing with 19 additions and 8 deletions.
  1. +15 −4 src/gui/attributetable/qgsdualview.cpp
  2. +4 −4 src/gui/qgsmaplayeractionregistry.cpp
@@ -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
}
}

@@ -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 )
@@ -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;

0 comments on commit 7f1bb72

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