18#include "moc_qgstextwidgetwrapper.cpp"
43 if ( attributeChanged )
45 if ( mRequiresFormScope )
53 return new QLabel( parent );
58 mWidget = qobject_cast<QLabel *>( editor );
64 mWidget->setOpenExternalLinks(
true );
66 const thread_local QRegularExpression sRegEx { QStringLiteral(
"\\[%(.*?)%\\]" ), QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption };
68 mNeedsGeometry =
false;
69 QRegularExpressionMatchIterator matchIt { sRegEx.globalMatch( mText ) };
70 while ( !mNeedsGeometry && matchIt.hasNext() )
72 const QRegularExpressionMatch match { matchIt.next() };
74 mNeedsGeometry = exp.needsGeometry();
92 const thread_local QRegularExpression sRegEx( QStringLiteral(
"\\[%(.*?)%\\]" ), QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption );
93 QRegularExpressionMatchIterator matchIt = sRegEx.globalMatch( mText );
94 while ( !ok && matchIt.hasNext() )
96 const QRegularExpressionMatch match = matchIt.next();
100 mRequiresFormScope = ok;
107 return mNeedsGeometry;
110void QgsTextWidgetWrapper::updateTextContext()
132 mFormFeature = feature;
This class contains context information for attribute editor widgets.
QString attributeFormModeString() const
Returns given attributeFormMode as string.
QgsFeature parentFormFeature() const
Returns the feature of the currently edited parent form in its actual state.
static QgsExpressionContextScope * parentFormScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current parent attribute form/tab...
static QgsExpressionContextScope * formScope(const QgsFeature &formFeature=QgsFeature(), const QString &formMode=QString())
Creates a new scope which contains functions and variables from the current attribute form/table form...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
static QString replaceExpressionText(const QString &action, const QgsExpressionContext *context, const QgsDistanceArea *distanceArea=nullptr)
This function replaces each expression between [% and %] in the string with the result of its evaluat...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
bool isValid() const
Returns the validity of this feature.
bool needsGeometry() const
Returns true if the widget needs feature geometry.
bool valid() const override
Returns true if the widget has been properly initialized.
QWidget * createWidget(QWidget *parent) override
This method should create a new widget with the provided parent.
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.
void setFeature(const QgsFeature &feature) override
void initWidget(QWidget *editor) override
This method should initialize the editor widget with runtime data.
Represents a vector layer which manages a vector based data sets.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...