QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgslegendfilterbutton.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslegendfilterbutton.h - QToolButton for legend filter by map content
3  --------------------------------------
4  Date : June 2015
5  Copyright : (C) 2015 by Hugo Mercier at Oslandia
6  Email : hugo dot mercier at oslandia dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGS_LEGEND_FILTER_BUTTON_H
16 #define QGS_LEGEND_FILTER_BUTTON_H
17 
18 #include <QToolButton>
19 #include "qgis_gui.h"
20 
21 class QgsVectorLayer;
22 
31 class GUI_EXPORT QgsLegendFilterButton: public QToolButton
32 {
33  Q_OBJECT
34 
35  public:
36 
42  QgsLegendFilterButton( QWidget *parent = nullptr );
43 
47  QString expressionText() const;
48 
53  void setExpressionText( const QString &expression );
54 
59  QgsVectorLayer *vectorLayer() const;
60 
65  void setVectorLayer( QgsVectorLayer *layer );
66 
67  signals:
68 
72  void expressionTextChanged();
73 
74  private:
75  QMenu *mMenu = nullptr;
76  QAction *mSetExpressionAction = nullptr;
77  QAction *mClearExpressionAction = nullptr;
78  QString mExpression;
79 
80  void updateMenu();
81 
82  QgsVectorLayer *mLayer = nullptr;
83  private slots:
84  void onSetLegendFilterExpression();
85  void onClearFilterExpression();
86  void onToggle( bool );
87 };
88 
89 #endif // QGS_FILTER_LEGEND_BUTTON_H
A tool button that allows enabling or disabling legend filter by contents of the map.
Represents a vector layer which manages a vector based data sets.