QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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 ];
void triggerForFeature(QgsMapLayer *layer, const QgsFeature &feature)
Triggers the action with the specified layer and feature.
QgsMapLayerAction(const QString &name, QObject *parent, Targets targets=AllActions, const QIcon &icon=QIcon(), QgsMapLayerAction::Flags flags=QgsMapLayerAction::Flags())
Action behavior flags.
void changed()
Triggered when an action is added or removed from the registry.
void triggeredForFeatures(QgsMapLayer *layer, const QList< QgsFeature > &featureList)
Triggered when action has been run for a specific list of features.
An action which can run on map layers.
QList< QgsMapLayerAction * > mMapLayerActionList
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
QgsMapLayerType
Types of layers that can be added to a map.
bool canRunUsingLayer(QgsMapLayer *layer) const
True if action can run using the specified layer.
void triggeredForLayer(QgsMapLayer *layer)
Triggered when action has been run for a specific layer.
QgsMapLayerAction * defaultActionForLayer(QgsMapLayer *layer)
Returns the default action for a layer.
bool removeMapLayerAction(QgsMapLayerAction *action)
Removes a map layer action from the registry.
void triggeredForFeature(QgsMapLayer *layer, const QgsFeature &feature)
Triggered when action has been run for a specific feature.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
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.
Base class for all map layer types.
@ EnabledOnlyWhenEditable
Action should be shown only for editable layers.
void triggerForLayer(QgsMapLayer *layer)
Triggers the action with the specified layer.
QgsMapLayerAction::Flags flags() const
Layer behavior flags.
void setDefaultActionForLayer(QgsMapLayer *layer, QgsMapLayerAction *action)
Sets the default action for a layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
~QgsMapLayerAction() override
QgsMapLayerActionRegistry(QObject *parent=nullptr)
Constructor for QgsMapLayerActionRegistry.
bool isEnabledOnlyWhenEditable() const
Returns true if the action is only enabled for layers in editable mode.