27 , mFeatureId( feature.id() )
28 , mActionScope( actionScope )
37 , mActionScope( actionScope )
42 void QgsActionMenu::init()
44 setTitle( tr(
"&Actions" ) );
75 void QgsActionMenu::triggerAction()
77 if ( !feature().isValid() )
80 QAction *action = qobject_cast<QAction *>( sender() );
84 if ( !action->data().isValid() || !action->data().canConvert<
ActionData>() )
105 context << actionScope;
111 void QgsActionMenu::reloadActions()
117 Q_FOREACH (
const QgsAction &action, mActions )
128 QAction *qAction =
new QAction( action.
icon(), action.
name(), this );
129 qAction->setData( QVariant::fromValue<ActionData>(
ActionData( act, mFeatureId, mLayer ) ) );
130 qAction->setIcon( action.
icon() );
135 qAction->setEnabled(
false );
136 qAction->setToolTip( tr(
"Not supported on your platform" ) );
140 qAction->setToolTip( action.
command() );
142 connect( qAction, &QAction::triggered,
this, &QgsActionMenu::triggerAction );
143 addAction( qAction );
148 if ( !mapLayerActions.isEmpty() )
153 for (
int i = 0; i < mapLayerActions.size(); ++i )
160 QAction *qAction =
new QAction( qaction->icon(), qaction->text(), this );
161 qAction->setData( QVariant::fromValue<ActionData>(
ActionData( qaction, mFeatureId, mLayer ) ) );
162 addAction( qAction );
163 connect( qAction, &QAction::triggered,
this, &QgsActionMenu::triggerAction );
174 , featureId( featureId )
175 , mapLayer( mapLayer )
182 , featureId( featureId )
183 , mapLayer( mapLayer )
189 mExpressionContextScope = scope;
195 return mExpressionContextScope;
bool isValid() const
Returns the validity of this feature.
QgsActionManager * actions()
Get all layer actions defined on this layer.
Single variable definition for use within a QgsExpressionContextScope.
Base class for all map layer types.
bool isEnabledOnlyWhenEditable() const
Returns true if the action is only enabled for layers in editable mode.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void readOnlyChanged()
Emitted when the read only state of this layer is changed.
bool isEnabledOnlyWhenEditable() const
Return whether only enabled in editable mode.
QList< QgsAction > actions(const QString &actionScope=QString()) const
Return a list of actions that are available in the given action scope.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool isEditable() const override
Returns true if the provider is in editing mode.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
void run(QgsVectorLayer *layer, const QgsFeature &feature, const QgsExpressionContext &expressionContext) const
Run this action.
Utility class that encapsulates an action based on vector attributes.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void editingStopped()
Is emitted, when edited changes successfully have been written to the data provider.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
bool runable() const
Checks if the action is runable on the current platform.
QIcon icon() const
The icon.
QString name() const
The name of the action. This may be a longer description.
void changed()
Triggered when an action is added or removed from the registry.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void editingStarted()
Is emitted, when editing on this layer has started.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
bool nextFeature(QgsFeature &f)
void setExpressionContextScope(const QgsExpressionContextScope &scope)
Sets an expression context scope to use for running the action.
Represents a vector layer which manages a vector based data sets.
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
void triggerForFeature(QgsMapLayer *layer, const QgsFeature *feature)
Triggers the action with the specified layer and feature.
QString command() const
Returns the command that is executed by this action.
An action which can run on map layers.