QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgstextwidgetwrapper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextwidgetwrapper.h
3
4 ---------------------
5 begin : 28.12.2022
6 copyright : (C) 2022 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 QGSTEXTWIDGETWRAPPER_H
17#define QGSTEXTWIDGETWRAPPER_H
18
19#include "qgis_gui.h"
20#include "qgswidgetwrapper.h"
21
22#include <QLabel>
23
29class GUI_EXPORT QgsTextWidgetWrapper : public QgsWidgetWrapper
30{
31 Q_OBJECT
32
33 public:
41 QgsTextWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
42
43 bool valid() const override;
44
45 QWidget *createWidget( QWidget *parent ) override;
46
47 void initWidget( QWidget *editor ) override;
48
50 void reinitWidget();
51
53 void setText( const QString &text );
54
58 bool needsGeometry() const;
59
60 private slots:
61
63 void updateTextContext();
64
65 public slots:
66 void setFeature( const QgsFeature &feature ) override;
67
68 private:
69 QString mText;
70 QLabel *mWidget = nullptr;
71 QgsFeature mFeature;
72 QgsFeature mFormFeature;
73 bool mRequiresFormScope = false;
74 QgsExpressionContext mTextContext;
75 bool mNeedsGeometry = false;
76
78};
79
80
81#endif // QGSTEXTWIDGETWRAPPER_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
bool needsGeometry() const
Returns true if the widget needs feature geometry.
friend class TestQgsTextWidgetWrapper
void setText(const QString &text)
Sets the text code to htmlCode.
QgsTextWidgetWrapper(QgsVectorLayer *layer, QWidget *editor, QWidget *parent)
Create a text widget wrapper.
void reinitWidget()
Clears the content and makes new initialization.
Represents a vector layer which manages a vector based dataset.
virtual void setFeature(const QgsFeature &feature)=0
Is called when the value of the widget needs to be changed.
virtual bool valid() const =0
Returns true if the widget has been properly initialized.
virtual void initWidget(QWidget *editor)
This method should initialize the editor widget with runtime data.
QgsWidgetWrapper(QgsVectorLayer *vl, QWidget *editor=nullptr, QWidget *parent=nullptr)
Create a new widget wrapper.
QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
virtual QWidget * createWidget(QWidget *parent)=0
This method should create a new widget with the provided parent.