21 : QAction( icon, name, parent )
22 , mSingleLayer( false )
23 , mSpecificLayerType( false )
31 : QAction( icon, name, parent )
32 , mSingleLayer( true )
33 , mActionLayer( layer )
34 , mSpecificLayerType( false )
42 : QAction( icon, name, parent )
43 , mSingleLayer( false )
44 , mSpecificLayerType( true )
45 , mLayerType( layerType )
71 if ( !qobject_cast<QgsVectorLayer *>( layer )->isEditable() )
76 if ( !mSingleLayer && !mSpecificLayerType )
82 if ( mSingleLayer && layer == mActionLayer )
87 else if ( mSpecificLayerType && layer && layer->
type() == mLayerType )
133 QList< QgsMapLayerAction * > validActions;
139 validActions.append( action );
153 QMap<QgsMapLayer *, QgsMapLayerAction *>::iterator defaultIt;
154 for ( defaultIt = mDefaultLayerActionMap.begin(); defaultIt != mDefaultLayerActionMap.end(); ++defaultIt )
156 if ( defaultIt.value() == action )
158 defaultIt.value() =
nullptr;
170 mDefaultLayerActionMap[ layer ] = action;
175 if ( !mDefaultLayerActionMap.contains( layer ) )
180 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.
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...
QgsMapLayer::LayerType type() const
Returns the type of the layer.
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.
LayerType
Types of layers that can be added to a map.
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
Return 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.
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.