17#include "moc_qgsactionwidgetwrapper.cpp"
28 const bool actionIsVisible {
33 mActionButton->setVisible( actionIsVisible );
63 return new QPushButton( parent );
69 mActionButton = qobject_cast<QPushButton *>( editor );
76 const QString shortTitle { mAction.
shortTitle() };
77 const QString description { mAction.
name() };
78 const QIcon icon { mAction.
icon() };
81 if ( ! icon.isNull() )
83 mActionButton->setIcon( icon );
84 mActionButton->setToolTip( description );
88 mActionButton->setText( shortTitle.isEmpty() ? description : shortTitle );
89 if ( ! shortTitle.isEmpty() )
91 mActionButton->setToolTip( description );
97 mActionButton->setEnabled(
false );
101 connect( mActionButton, &QPushButton::clicked,
this, [ & ]
109 if (
QgsAttributeForm *form = qobject_cast<QgsAttributeForm *>( parent() ) )
111 const QString formCode = QStringLiteral(
"locals()[\"form\"] = sip.wrapinstance( %1, qgis.gui.QgsAttributeForm )\n" )
112 .arg( ( quint64 ) form );
115 action.run(
layer(), mFeature, expressionContext );
120 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.
@ SingleEditMode
Single edit mode, for editing a single feature.
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...
bool isEditable() const FINAL
Returns true if the provider is in editing mode.