QGIS API Documentation 3.37.0-Master (df6056bf1be)
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
QgsExpressionFinder Class Reference

Helper methods to locate expressions within text editors. More...

#include <qgsexpressionfinder.h>

Static Public Member Functions

static QString findAndSelectActiveExpression (QgsCodeEditor *editor, const QString &pattern=QString())
 Find the expression under the cursor in the given editor and select it.
 
static QString findAndSelectActiveExpression (QPlainTextEdit *editor, const QString &pattern=QString())
 Find the expression under the cursor in the given editor and select it.
 
static QString findAndSelectActiveExpression (QTextEdit *editor, const QString &pattern=QString())
 Find the expression under the cursor in the given editor and select it.
 
static void findExpressionAtPos (const QString &text, int startSelectionPos, int endSelectionPos, int &start, int &end, QString &expression, const QString &pattern=QString())
 Find an expression at the given position in the given text.
 

Detailed Description

Helper methods to locate expressions within text editors.

Note
not available in Python bindings
Since
QGIS 3.36

Definition at line 36 of file qgsexpressionfinder.h.

Member Function Documentation

◆ findAndSelectActiveExpression() [1/3]

QString QgsExpressionFinder::findAndSelectActiveExpression ( QgsCodeEditor editor,
const QString &  pattern = QString() 
)
static

Find the expression under the cursor in the given editor and select it.

If an expression is found, it is returned (excluding the surrounding [% %] characters) Otherwise, the selection is kept unchanged and the selected text is returned

Definition at line 63 of file qgsexpressionfinder.cpp.

◆ findAndSelectActiveExpression() [2/3]

QString QgsExpressionFinder::findAndSelectActiveExpression ( QPlainTextEdit *  editor,
const QString &  pattern = QString() 
)
static

Find the expression under the cursor in the given editor and select it.

If an expression is found, it is returned (excluding the surrounding [% %] characters) Otherwise, the selection is kept unchanged and the selected text is returned

Definition at line 98 of file qgsexpressionfinder.cpp.

◆ findAndSelectActiveExpression() [3/3]

QString QgsExpressionFinder::findAndSelectActiveExpression ( QTextEdit *  editor,
const QString &  pattern = QString() 
)
static

Find the expression under the cursor in the given editor and select it.

If an expression is found, it is returned (excluding the surrounding [% %] characters) Otherwise, the selection is kept unchanged and the selected text is returned

Definition at line 79 of file qgsexpressionfinder.cpp.

◆ findExpressionAtPos()

void QgsExpressionFinder::findExpressionAtPos ( const QString &  text,
int  startSelectionPos,
int  endSelectionPos,
int &  start,
int &  end,
QString &  expression,
const QString &  pattern = QString() 
)
static

Find an expression at the given position in the given text.

If an expression is found, start and end are set to the position of the opening and closing brakets of the expression, and expression is set to the trimmed expression (excluding the surrounding [% %] characters)

Otherwise, start and end are set to startSelectionPos and endSelectionPos and expression is set to the selected text

Optionally, a custom regex pattern can be used to find the expression. This pattern must contain a capture group to extract the expression from the match.

Definition at line 26 of file qgsexpressionfinder.cpp.


The documentation for this class was generated from the following files: