17#include "moc_qgslegendfilterbutton.cpp"
27 : QToolButton( parent )
30 mMenu =
new QMenu(
this );
31 mSetExpressionAction =
new QAction( tr(
"Edit Filter Expression…" ), mMenu );
32 connect( mSetExpressionAction, &QAction::triggered,
this, &QgsLegendFilterButton::onSetLegendFilterExpression );
34 mClearExpressionAction =
new QAction( tr(
"Clear Filter Expression" ), mMenu );
35 connect( mClearExpressionAction, &QAction::triggered,
this, &QgsLegendFilterButton::onClearFilterExpression );
36 mClearExpressionAction->setEnabled(
false );
38 mMenu->addAction( mSetExpressionAction );
39 mMenu->addAction( mClearExpressionAction );
43 setPopupMode( QToolButton::MenuButtonPopup );
47 connect(
this, &QAbstractButton::toggled,
this, &QgsLegendFilterButton::onToggle );
50void QgsLegendFilterButton::onToggle(
bool checked )
56 onSetLegendFilterExpression();
57 blockSignals(
false );
61void QgsLegendFilterButton::onSetLegendFilterExpression()
64 if ( mExpressionContextGenerator )
75 bool emitSignal =
false;
78 emitSignal = isChecked();
83 emitSignal = !isChecked();
87 emit toggled( isChecked() );
93 mExpressionContextGenerator = generator;
96void QgsLegendFilterButton::onClearFilterExpression()
98 mClearExpressionAction->setEnabled(
false );
104void QgsLegendFilterButton::updateMenu()
106 if ( !mExpression.isEmpty() )
108 mClearExpressionAction->setEnabled(
true );
109 mSetExpressionAction->setText( tr(
"Edit Filter Expression (current: %1)" ).arg( mExpression ) );
113 mClearExpressionAction->setEnabled(
false );
114 mSetExpressionAction->setText( tr(
"Edit Filter Expression" ) );
125 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.