QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
29 const bool actionIsVisible {
34 mActionButton->setVisible( actionIsVisible );
64 return new QPushButton( parent );
70 mActionButton = qobject_cast<QPushButton *>( editor );
77 const QString shortTitle { mAction.
shortTitle() };
78 const QString description { mAction.
name() };
79 const QIcon icon { mAction.
icon() };
82 if ( ! icon.isNull() )
84 mActionButton->setIcon( icon );
85 mActionButton->setToolTip( description );
89 mActionButton->setText( shortTitle.isEmpty() ? description : shortTitle );
90 if ( ! shortTitle.isEmpty() )
92 mActionButton->setToolTip( description );
98 mActionButton->setEnabled(
false );
102 connect( mActionButton, &QPushButton::clicked,
this, [ & ]
108 if ( mAction.
type() == QgsAction::ActionType::GenericPython )
110 if (
QgsAttributeForm *form = qobject_cast<QgsAttributeForm *>( parent() ) )
112 const QString formCode = QStringLiteral(
"locals()[\"form\"] = sip.wrapinstance( %1, qgis.gui.QgsAttributeForm )\n" )
113 .arg( ( quint64 ) form );
116 action.run(
layer(), mFeature, expressionContext );
121 mAction.
run(
layer(), mFeature, expressionContext );
void run(QgsVectorLayer *layer, const QgsFeature &feature, const QgsExpressionContext &expressionContext) const
Run this action.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString name() const
The name of the action. This may be a longer description.
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current attribute form/table form...
QString shortTitle() const
The short title is used to label user interface elements like buttons.
bool isEnabledOnlyWhenEditable() const
Returns whether only enabled in editable mode.
bool isValid() const
Returns true if this action was a default constructed one.
ActionType type() const
The action type.
Mode attributeFormMode() const
Returns current attributeFormMode.
QIcon icon() const
The icon.
Utility class that encapsulates an action based on vector attributes.
bool runable() const
Checks if the action is runable on the current platform.
void setCommand(const QString &newCommand)
Sets the action command.
Represents a vector layer which manages a vector based data sets.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QString command() const
Returns the command that is executed by this action.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
This class contains context information for attribute editor widgets. It will be passed to embedded w...
QString attributeFormModeString() const
Returns given attributeFormMode as string.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.