QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsactionwidgetwrapper.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsactionwidgetwrapper.h - QgsActionWidgetWrapper
3 
4  ---------------------
5  begin : 14.8.2021
6  copyright : (C) 2021 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #ifndef QGSACTIONWIDGETWRAPPER_H
17 #define QGSACTIONWIDGETWRAPPER_H
18 
19 #include <qgswidgetwrapper.h>
20 #include <qgsaction.h>
21 #include "qgis_sip.h"
22 #include "qgis_gui.h"
23 
24 #include <QPushButton>
25 
31 class GUI_EXPORT QgsActionWidgetWrapper : public QgsWidgetWrapper
32 {
33  Q_OBJECT
34 
35  public:
36 
44  QgsActionWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
45 
46  public:
47 
51  void setAction( const QgsAction &action );
52 
53  // QgsWidgetWrapper interface
54  bool valid() const override;
55  QWidget *createWidget( QWidget *parent ) override;
56  void initWidget( QWidget *editor ) override;
57 
58  public slots:
59 
60  void setFeature( const QgsFeature &feature ) override;
61  void setEnabled( bool enabled ) override;
62 
63  private:
64 
65  QPushButton *mActionButton = nullptr;
66  QgsAction mAction;
67  QgsFeature mFeature;
68 
69 };
70 
71 #endif // QGSACTIONWIDGETWRAPPER_H
QgsWidgetWrapper::initWidget
virtual void initWidget(QWidget *editor)
This method should initialize the editor widget with runtime data.
Definition: qgswidgetwrapper.cpp:107
QgsWidgetWrapper::valid
virtual bool valid() const =0
Returns true if the widget has been properly initialized.
QgsWidgetWrapper
Manages an editor widget Widget and wrapper share the same parent.
Definition: qgswidgetwrapper.h:52
QgsWidgetWrapper::setEnabled
virtual void setEnabled(bool enabled)
Is used to enable or disable the edit functionality of the managed widget.
Definition: qgswidgetwrapper.cpp:112
QgsActionWidgetWrapper
Wraps a button widget to launch a layer action.
Definition: qgsactionwidgetwrapper.h:31
qgis_sip.h
qgsaction.h
QgsAction
Utility class that encapsulates an action based on vector attributes.
Definition: qgsaction.h:34
QgsWidgetWrapper::setFeature
virtual void setFeature(const QgsFeature &feature)=0
Is called when the value of the widget needs to be changed.
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
qgswidgetwrapper.h
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsWidgetWrapper::createWidget
virtual QWidget * createWidget(QWidget *parent)=0
This method should create a new widget with the provided parent.