26 : QToolButton( parent )
29 mMenu =
new QMenu(
this );
30 mSetExpressionAction =
new QAction( tr(
"Edit Filter Expression…" ), mMenu );
31 connect( mSetExpressionAction, &QAction::triggered,
this, &QgsLegendFilterButton::onSetLegendFilterExpression );
33 mClearExpressionAction =
new QAction( tr(
"Clear Filter Expression" ), mMenu );
34 connect( mClearExpressionAction, &QAction::triggered,
this, &QgsLegendFilterButton::onClearFilterExpression );
35 mClearExpressionAction->setEnabled(
false );
37 mMenu->addAction( mSetExpressionAction );
38 mMenu->addAction( mClearExpressionAction );
42 setPopupMode( QToolButton::MenuButtonPopup );
46 connect(
this, &QAbstractButton::toggled,
this, &QgsLegendFilterButton::onToggle );
49void QgsLegendFilterButton::onToggle(
bool checked )
55 onSetLegendFilterExpression();
56 blockSignals(
false );
60void QgsLegendFilterButton::onSetLegendFilterExpression()
63 if ( mExpressionContextGenerator )
74 bool emitSignal =
false;
77 emitSignal = isChecked();
82 emitSignal = !isChecked();
86 emit toggled( isChecked() );
92 mExpressionContextGenerator = generator;
95void QgsLegendFilterButton::onClearFilterExpression()
97 mClearExpressionAction->setEnabled(
false );
103void QgsLegendFilterButton::updateMenu()
105 if ( !mExpression.isEmpty() )
107 mClearExpressionAction->setEnabled(
true );
108 mSetExpressionAction->setText( tr(
"Edit Filter Expression (current: %1)" ).arg( mExpression ) );
112 mClearExpressionAction->setEnabled(
false );
113 mSetExpressionAction->setText( tr(
"Edit Filter Expression" ) );
124 mExpression = expression;
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
A generic dialog for building expression strings.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
Represents a vector layer which manages a vector based data sets.