QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgshtmlwidgetwrapper.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshtmlwidgetwrapper.h
3
4 ---------------------
5 begin : 23.03.2019
6 copyright : (C) 2019 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 QGSHTMLWIDGETWRAPPER_H
17#define QGSHTMLWIDGETWRAPPER_H
18
19#include "qgswidgetwrapper.h"
20#include "qgswebview.h"
21#include "qgis_sip.h"
22#include "qgis_gui.h"
23
29class GUI_EXPORT QgsHtmlWidgetWrapper : public QgsWidgetWrapper
30{
31 Q_OBJECT
32
33 public:
41 QgsHtmlWidgetWrapper( 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 setHtmlCode( const QString &htmlCode );
54
59 bool needsGeometry() const;
60
61 public slots:
62 void setFeature( const QgsFeature &feature ) override;
63
64 private slots:
66 void setHtmlContext();
67#ifdef WITH_QTWEBKIT
68 void fixHeight();
69#endif
70
71 private:
73 void checkGeometryNeeds();
74
75 QString mHtmlCode;
76 QgsWebView *mWidget = nullptr;
77 QgsFeature mFeature;
78 bool mNeedsGeometry = false;
79 QgsFeature mFormFeature;
80 bool mRequiresFormScope = false;
81
82 friend class TestQgsHtmlWidgetWrapper;
83};
84
85
86#ifndef SIP_RUN
88
94class HtmlExpression : public QObject
95{
96 Q_OBJECT
97
98 public:
100 void setExpressionContext( const QgsExpressionContext &context );
101
102 public:
104 Q_INVOKABLE QString evaluate( const QString &expression ) const;
105
106 private:
107 QgsExpressionContext mExpressionContext;
108};
109
116class NeedsGeometryEvaluator : public QObject
117{
118 Q_OBJECT
119
120 public:
122 bool needsGeometry() const { return mNeedsGeometry; }
123
125 void setExpressionContext( const QgsExpressionContext &context );
126
128 Q_INVOKABLE void evaluate( const QString &expression );
129
130 private:
131 bool mNeedsGeometry = false;
132 QgsExpressionContext mExpressionContext;
133};
134
135
137#endif //SIP_RUN
138
139#endif // QGSHTMLWIDGETWRAPPER_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
Wraps a QQuickWidget to display HTML code.
Represents a vector layer which manages a vector based data sets.
The QgsWebView class is a collection of stubs to mimic the API of QWebView on systems where the real ...
Definition qgswebview.h:66
Manages an editor widget Widget and wrapper share the same parent.
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.
virtual QWidget * createWidget(QWidget *parent)=0
This method should create a new widget with the provided parent.