21 , mSingleLayer( false )
22 , mActionLayer( nullptr )
23 , mSpecificLayerType( false )
32 , mSingleLayer( true )
33 , mActionLayer( layer )
34 , mSpecificLayerType( false )
43 , mSingleLayer( false )
44 , mActionLayer( nullptr )
45 , mSpecificLayerType( true )
46 , mLayerType( layerType )
60 if ( !mSingleLayer && !mSpecificLayerType )
66 if ( mSingleLayer && layer == mActionLayer )
71 else if ( mSpecificLayerType && layer->
type() == mLayerType )
134 if (( *actionIt )->canRunUsingLayer( layer ) && ( targets & ( *actionIt )->targets() ) )
136 validActions.
append(( *actionIt ) );
151 for ( defaultIt = mDefaultLayerActionMap.
begin(); defaultIt != mDefaultLayerActionMap.
end(); ++defaultIt )
153 if ( defaultIt.
value() == action )
155 defaultIt.
value() =
nullptr;
167 mDefaultLayerActionMap[ layer ] = action;
172 if ( !mDefaultLayerActionMap.
contains( layer ) )
177 return mDefaultLayerActionMap[ layer ];
QgsMapLayerAction * defaultActionForLayer(QgsMapLayer *layer)
Returns the default action for a layer.
Base class for all map layer types.
bool contains(const Key &key) const
QgsMapLayerActionRegistry(QObject *parent=nullptr)
protected constructor
bool canRunUsingLayer(QgsMapLayer *layer) const
True if action can run using the specified layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
~QgsMapLayerActionRegistry()
QgsMapLayer::LayerType type() const
Get the type of the layer.
int indexOf(const T &value, int from) const
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.
const char * name() const
void append(const T &value)
LayerType
Layers enum defining the types of layers that can be added to a map.
int removeAll(const T &value)
void setDefaultActionForLayer(QgsMapLayer *layer, QgsMapLayerAction *action)
Sets the default action for a layer.
QList< QgsMapLayerAction *> mMapLayerActionList
void changed()
Triggered when an action is added or removed from the registry.
This class tracks map layer actions.
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.
static QgsMapLayerActionRegistry * instance()
Returns the instance pointer, creating the object on the first call.
bool removeMapLayerAction(QgsMapLayerAction *action)
Removes a map layer action from the registry.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, const QgsMapLayerAction::Targets &targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
QgsMapLayerAction(const QString &name, QObject *parent, const Targets &targets=AllActions, const QIcon &icon=QIcon())
Creates a map layer action which can run on any layer.
void triggeredForFeatures(QgsMapLayer *layer, const QList< QgsFeature > &featureList)
Triggered when action has been run for a specific list of features.
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.
const T value(const Key &key) const