27 , mFeatureId( feature.id() )
28 , mActionScope( actionScope )
37 , mActionScope( actionScope )
42 void QgsActionMenu::init()
44 setTitle( tr(
"&Actions" ) );
76 void QgsActionMenu::triggerAction()
78 if ( !feature().isValid() )
81 QAction *action = qobject_cast<QAction *>( sender() );
85 if ( !action->data().isValid() || !action->data().canConvert<
ActionData>() )
106 context << actionScope;
112 void QgsActionMenu::reloadActions()
118 Q_FOREACH (
const QgsAction &action, mActions )
129 QAction *qAction =
new QAction( action.
icon(), action.
name(), this );
130 qAction->setData( QVariant::fromValue<ActionData>(
ActionData( act, mFeatureId, mLayer ) ) );
131 qAction->setIcon( action.
icon() );
136 qAction->setEnabled(
false );
137 qAction->setToolTip( tr(
"Not supported on your platform" ) );
141 qAction->setToolTip( action.
command() );
143 connect( qAction, &QAction::triggered,
this, &QgsActionMenu::triggerAction );
144 addAction( qAction );
149 if ( !mapLayerActions.isEmpty() )
154 for (
int i = 0; i < mapLayerActions.size(); ++i )
161 QAction *qAction =
new QAction( qaction->icon(), qaction->text(), this );
162 qAction->setData( QVariant::fromValue<ActionData>(
ActionData( qaction, mFeatureId, mLayer ) ) );
163 addAction( qAction );
164 connect( qAction, &QAction::triggered,
this, &QgsActionMenu::triggerAction );
171 void QgsActionMenu::layerWillBeDeleted()
184 , featureId( featureId )
185 , mapLayer( mapLayer )
192 , featureId( featureId )
193 , mapLayer( mapLayer )
199 mExpressionContextScope = scope;
205 return mExpressionContextScope;
QgsActionManager * actions()
Returns all layer actions defined on this layer.
Single variable definition for use within a QgsExpressionContextScope.
Base class for all map layer types.
bool isValid() const
Returns the validity of this feature.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void run(QgsVectorLayer *layer, const QgsFeature &feature, const QgsExpressionContext &expressionContext) const
Run this action.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
void readOnlyChanged()
Emitted when the read only state of this layer is changed.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QString name() const
The name of the action. This may be a longer description.
QList< QgsMapLayerAction * > mapLayerActions(QgsMapLayer *layer, QgsMapLayerAction::Targets targets=QgsMapLayerAction::AllActions)
Returns the map layer actions which can run on the specified layer.
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)...
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.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QString command() const
Returns the command that is executed by this action.
bool isEnabledOnlyWhenEditable() const
Returns true if the action is only enabled for layers in editable mode.
bool runable() const
Checks if the action is runable on the current platform.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
bool nextFeature(QgsFeature &f)
QList< QgsAction > actions(const QString &actionScope=QString()) const
Returns a list of actions that are available in the given action scope.
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.
bool isEnabledOnlyWhenEditable() const
Returns whether only enabled in editable mode.
An action which can run on map layers.
QIcon icon() const
The icon.