21 : QAction( icon, name, parent )
28 : QAction( icon, name, parent )
29 , mSingleLayer( true )
30 , mActionLayer( layer )
37 : QAction( icon, name, parent )
38 , mSpecificLayerType( true )
39 , mLayerType( layerType )
65 if ( !qobject_cast<QgsVectorLayer *>( layer )->isEditable() )
70 if ( !mSingleLayer && !mSpecificLayerType )
76 if ( mSingleLayer && layer == mActionLayer )
81 else if ( mSpecificLayerType && layer && layer->
type() == mLayerType )
127 QList< QgsMapLayerAction * > validActions;
132 if ( action->canRunUsingLayer( layer ) && ( targets & action->targets() ) )
134 validActions.append( action );
148 QMap<QgsMapLayer *, QgsMapLayerAction *>::iterator defaultIt;
149 for ( defaultIt = mDefaultLayerActionMap.begin(); defaultIt != mDefaultLayerActionMap.end(); ++defaultIt )
151 if ( defaultIt.value() == action )
153 defaultIt.value() =
nullptr;
165 mDefaultLayerActionMap[ layer ] = action;
170 if ( !mDefaultLayerActionMap.contains( layer ) )
175 return mDefaultLayerActionMap[ layer ];
QgsMapLayerAction * defaultActionForLayer(QgsMapLayer *layer)
Returns the default action for a layer.
Base class for all map layer types.
QList< QgsMapLayerAction *> mMapLayerActionList
QgsMapLayerActionRegistry(QObject *parent=nullptr)
Constructor for QgsMapLayerActionRegistry.
QgsMapLayerType type() const
Returns the type of the layer.
bool canRunUsingLayer(QgsMapLayer *layer) const
True if action can run using the specified layer.
bool isEnabledOnlyWhenEditable() const
Returns true if the action is only enabled for layers in editable mode.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void triggeredForFeature(QgsMapLayer *layer, const QgsFeature &feature)
Triggered when action has been run for a specific feature.
void triggeredForLayer(QgsMapLayer *layer)
Triggered when action has been run for a specific layer.
void setDefaultActionForLayer(QgsMapLayer *layer, QgsMapLayerAction *action)
Sets the default action for a layer.
Action should be shown only for editable layers.
QgsMapLayerAction(const QString &name, QObject *parent, Targets targets=AllActions, const QIcon &icon=QIcon(), QgsMapLayerAction::Flags flags=nullptr)
Action behavior flags.
void changed()
Triggered when an action is added or removed from the registry.
const Targets & targets() const
Returns availibity of action.
void triggerForFeatures(QgsMapLayer *layer, const QList< QgsFeature > &featureList)
Triggers the action with the specified layer and list of feature.
void addMapLayerAction(QgsMapLayerAction *action)
Adds a map layer action to the registry.
~QgsMapLayerAction() override
QgsMapLayerAction::Flags flags() const
Layer behavior flags.
bool removeMapLayerAction(QgsMapLayerAction *action)
Removes a map layer action from the registry.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
QgsMapLayerType
Types of layers that can be added to a map.
void triggeredForFeatures(QgsMapLayer *layer, const QList< QgsFeature > &featureList)
Triggered when action has been run for a specific list of features.
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
void triggerForLayer(QgsMapLayer *layer)
Triggers the action with the specified layer.
void triggerForFeature(QgsMapLayer *layer, const QgsFeature *feature)
Triggers the action with the specified layer and feature.
An action which can run on map layers.