1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsexpressionpreviewwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsExpressionPreviewWidget : QWidget
{
%Docstring(signature="appended")
:py:class:`QgsExpressionPreviewWidget` is a widget to preview an
expression result. If the layer is set, one can browse across features
to see the different outputs.
.. versionadded:: 3.14
%End
%TypeHeaderCode
#include "qgsexpressionpreviewwidget.h"
%End
public:
explicit QgsExpressionPreviewWidget( QWidget *parent = 0 );
%Docstring
Constructor
%End
void setLayer( QgsVectorLayer *layer );
%Docstring
Sets the layer used in the preview
%End
void setCustomPreviewGenerator( const QString &label, const QList<QPair<QString, QVariant>> &choices, SIP_PYCALLABLE );
%Docstring
Sets the widget to run using a custom preview generator.
In this mode, the widget will call a callback function to generate a new
:py:class:`QgsExpressionContext` as the previewed object changes. This
can be used to provide custom preview values for different objects (i.e.
for objects which aren't vector layer features).
:param label: The label to display for the combo box presenting choices
of objects. This should be a representative name, eg
"Band" if the widget is showing choices of raster layer
bands
:param choices: A list of choices to present to the user. Each choice is
a pair of a human-readable label and a QVariant
representing the object to preview.
:param previewContextGenerator: A function which takes a QVariant
representing the object to preview, and
returns a
:py:class:`QgsExpressionContext` to use
for previewing the object.
.. versionadded:: 3.38
%End
%MethodCode
Py_XINCREF( a2 );
Py_BEGIN_ALLOW_THREADS
sipCpp->setCustomPreviewGenerator( *a0, *a1, [a2]( const QVariant &value ) -> QgsExpressionContext {
QgsExpressionContext res;
SIP_BLOCK_THREADS
PyObject *s = sipCallMethod( NULL, a2, "D", &value, sipType_QVariant, NULL );
int state;
int sipIsError = 0;
QgsExpressionContext *t1 = reinterpret_cast<QgsExpressionContext *>( sipConvertToType( s, sipType_QgsExpressionContext, 0, SIP_NOT_NONE, &state, &sipIsError ) );
if ( sipIsError == 0 )
{
res = QgsExpressionContext( *t1 );
}
sipReleaseType( t1, sipType_QgsExpressionContext, state );
SIP_UNBLOCK_THREADS
return res;
} );
Py_END_ALLOW_THREADS
%End
void setExpressionText( const QString &expression );
%Docstring
Sets the expression
%End
QgsExpressionContext expressionContext() const;
%Docstring
Returns the expression context for the widget. The context is used for
the expression preview result and for populating the list of available
functions and variables.
.. seealso:: :py:func:`setExpressionContext`
%End
void setExpressionContext( const QgsExpressionContext &context );
%Docstring
Sets the expression context for the widget. The context is used for the
expression preview result and to populate the list of available
functions and variables.
:param context: expression context
%End
void setGeomCalculator( const QgsDistanceArea &da );
%Docstring
Sets geometry calculator used in distance/area calculations.
%End
bool evalError() const;
%Docstring
Will be set to ``True`` if the current expression text reported an eval
error with the context.
%End
bool parserError() const;
%Docstring
Will be set to ``True`` if the current expression text reports a parser
error with the context.
%End
const QgsExpressionNode *rootNode() const;
%Docstring
Returns the root node of the expression
%End
QList<QgsExpression::ParserError> parserErrors() const;
%Docstring
Returns the expression parser errors
%End
QString currentPreviewText() const;
%Docstring
Returns the current expression result preview text.
.. versionadded:: 3.38
%End
signals:
void expressionParsed( bool isValid );
%Docstring
Emitted when the user changes the expression in the widget. Users of
this widget should connect to this signal to decide if to let the user
continue.
:param isValid: Is ``True`` if the expression the user has typed is
valid.
%End
void evalErrorChanged();
%Docstring
Will be set to ``True`` if the current expression text reported an eval
error with the context.
%End
void parserErrorChanged();
%Docstring
Will be set to ``True`` if the current expression text reported a parser
error with the context.
%End
void toolTipChanged( const QString &toolTip );
%Docstring
Emitted whenever the tool tip changed
%End
public slots:
void setCurrentFeature( const QgsFeature &feature );
%Docstring
sets the current feature used
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsexpressionpreviewwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|