17#include "moc_qgsactionwidgetwrapper.cpp"
27 const bool actionIsVisible {
32 mActionButton->setVisible( actionIsVisible );
62 return new QPushButton( parent );
67 mActionButton = qobject_cast<QPushButton *>( editor );
74 const QString shortTitle { mAction.
shortTitle() };
75 const QString description { mAction.
name() };
76 const QIcon icon { mAction.
icon() };
81 mActionButton->setIcon( icon );
82 mActionButton->setToolTip( description );
86 mActionButton->setText( shortTitle.isEmpty() ? description : shortTitle );
87 if ( !shortTitle.isEmpty() )
89 mActionButton->setToolTip( description );
95 mActionButton->setEnabled(
false );
99 connect( mActionButton, &QPushButton::clicked,
this, [&] {
106 if (
QgsAttributeForm *form = qobject_cast<QgsAttributeForm *>( parent() ) )
108 const QString formCode = QStringLiteral(
"locals()[\"form\"] = sip.wrapinstance( %1, qgis.gui.QgsAttributeForm )\n" )
109 .arg( ( quint64 ) form );
112 action.run(
layer(), mFeature, expressionContext );
117 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.