27 const bool actionIsVisible {
32 mActionButton->setVisible( actionIsVisible );
62 return new QPushButton( parent );
68 mActionButton = qobject_cast<QPushButton *>( editor );
75 const QString shortTitle { mAction.
shortTitle() };
76 const QString description { mAction.
name() };
77 const QIcon icon { mAction.
icon() };
80 if ( ! icon.isNull() )
82 mActionButton->setIcon( icon );
83 mActionButton->setToolTip( description );
87 mActionButton->setText( shortTitle.isEmpty() ? description : shortTitle );
88 if ( ! shortTitle.isEmpty() )
90 mActionButton->setToolTip( description );
96 mActionButton->setEnabled(
false );
100 connect( mActionButton, &QPushButton::clicked,
this, [ & ]
108 if (
QgsAttributeForm *form = qobject_cast<QgsAttributeForm *>( parent() ) )
110 const QString formCode = QStringLiteral(
"locals()[\"form\"] = sip.wrapinstance( %1, qgis.gui.QgsAttributeForm )\n" )
111 .arg( ( quint64 ) form );
114 action.run(
layer(), mFeature, expressionContext );
119 mAction.
run(
layer(), mFeature, expressionContext );
Utility class that encapsulates an action based on vector attributes.
QString name() const
The name of the action. This may be a longer description.
Qgis::AttributeActionType type() const
The action type.
void run(QgsVectorLayer *layer, const QgsFeature &feature, const QgsExpressionContext &expressionContext) const
Run this action.
void setCommand(const QString &newCommand)
Sets the action command.
bool runable() const
Checks if the action is runable on the current platform.
QIcon icon() const
The icon.
bool isValid() const
Returns true if this action was a default constructed one.
QString command() const
Returns the command that is executed by this action.
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.
This class contains context information for attribute editor widgets.
QString attributeFormModeString() const
Returns given attributeFormMode as string.
Mode attributeFormMode() const
Returns current attributeFormMode.
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...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Represents a vector layer which manages a vector based data sets.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...