25#include "moc_qgstextwidgetwrapper.cpp"
46 if ( attributeChanged )
48 if ( mRequiresFormScope )
50 mFormFeature.setAttribute( attribute, newValue );
56 QLabel *
widget =
new QLabel( parent );
63 mWidget = qobject_cast<QLabel *>( editor );
69 mWidget->setOpenExternalLinks(
true );
71 const thread_local QRegularExpression sRegEx { QStringLiteral(
"\\[%(.*?)%\\]" ), QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption };
73 mNeedsGeometry =
false;
74 QRegularExpressionMatchIterator matchIt { sRegEx.globalMatch( mText ) };
75 while ( !mNeedsGeometry && matchIt.hasNext() )
77 const QRegularExpressionMatch match { matchIt.next() };
97 const thread_local QRegularExpression sRegEx( QStringLiteral(
"\\[%(.*?)%\\]" ), QRegularExpression::MultilineOption | QRegularExpression::DotMatchesEverythingOption );
98 QRegularExpressionMatchIterator matchIt = sRegEx.globalMatch( mText );
99 while ( !ok && matchIt.hasNext() )
101 const QRegularExpressionMatch match = matchIt.next();
105 mRequiresFormScope = ok;
112 return mNeedsGeometry;
115void QgsTextWidgetWrapper::updateTextContext()
127 mTextContext.setFeature( mFeature );
137 mFormFeature = feature;
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...
Handles 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...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
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 dataset.
QgsExpressionContext createExpressionContext() const final
This method needs to be reimplemented in all classes which implement this interface and return an exp...