File: qgsfieldexpressionwidget.sip.in

package info (click to toggle)
qgis 3.40.10%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,183,672 kB
  • sloc: cpp: 1,595,771; python: 372,544; xml: 23,474; sh: 3,761; perl: 3,664; ansic: 2,257; sql: 2,137; yacc: 1,068; lex: 577; javascript: 540; lisp: 411; makefile: 161
file content (341 lines) | stat: -rw-r--r-- 10,326 bytes parent folder | download | duplicates (12)
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/gui/qgsfieldexpressionwidget.h                                   *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/







class QgsFieldExpressionWidget : QWidget
{
%Docstring(signature="appended")
The :py:class:`QgsFieldExpressionWidget` class creates a widget to
choose fields and edit expressions It contains a combo box to display
the fields and expression and a button to open the expression dialog.
The combo box is editable, allowing expressions to be edited inline. The
validity of the expression is checked live on key press, invalid
expressions are displayed in red. The expression will be added to the
model (and the fieldChanged signals emitted) only when editing in the
line edit is finished (focus lost, enter key pressed).
%End

%TypeHeaderCode
#include "qgsfieldexpressionwidget.h"
%End
  public:
    explicit QgsFieldExpressionWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
QgsFieldExpressionWidget creates a widget with a combo box to display
the fields and expression and a button to open the expression dialog
%End

    void setExpressionDialogTitle( const QString &title );
%Docstring
define the title used in the expression dialog
%End

    void appendScope( QgsExpressionContextScope *scope /Transfer/ );
%Docstring
Appends a scope to the current expression context.

:param scope: The scope to add.

.. versionadded:: 3.2
%End

    const QString expressionDialogTitle();
%Docstring
Returns the title used for the expression dialog
%End

    void setFilters( QgsFieldProxyModel::Filters filters );
%Docstring
setFilters allows filtering according to the type of field
%End

    void setAllowEmptyFieldName( bool allowEmpty );
%Docstring
Sets whether an optional empty field ("not set") option is shown in the
combo box.

.. seealso:: :py:func:`allowEmptyFieldName`

.. versionadded:: 3.4.6
%End

    bool allowEmptyFieldName() const;
%Docstring
Returns ``True`` if the combo box allows the empty field ("not set")
choice.

.. seealso:: :py:func:`setAllowEmptyFieldName`

.. versionadded:: 3.4.6
%End

    void setLeftHandButtonStyle( bool isLeft );

    QgsFieldProxyModel::Filters filters() const;
%Docstring
currently used filter on list of fields
%End

    void setGeomCalculator( const QgsDistanceArea &da );
%Docstring
Sets the geometry calculator used in the expression dialog
%End

    QString currentField( bool *isExpression = 0, bool *isValid = 0 ) const;
%Docstring
currentField returns the currently selected field or expression if
allowed

:param isExpression: determines if the string returned is the name of a
                     field or an expression
:param isValid: determines if the expression (or field) returned is
                valid
%End

    bool isValidExpression( QString *expressionError = 0 ) const;
%Docstring
Returns ``True`` if the current expression is valid
%End

    bool isExpression() const;
%Docstring
If the content is not just a simple field this method will return
``True``.
%End

    QString currentText() const;
%Docstring
Returns the current text that is set in the expression area
%End

    QString asExpression() const;
%Docstring
Returns the currently selected field or expression. If a field is
currently selected, the returned value will be converted to a valid
expression referencing this field (ie enclosing the field name with
appropriate quotations).
%End

    QString expression() const;
%Docstring
Returns the currently selected field or expression. If a field is
currently selected, the returned value will be converted to a valid
expression referencing this field (ie enclosing the field name with
appropriate quotations).

Alias for :py:func:`~QgsFieldExpressionWidget.asExpression`
%End

    QgsVectorLayer *layer() const;
%Docstring
Returns the layer currently associated with the widget.

.. seealso:: :py:func:`setLayer`
%End

    void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
%Docstring
Register an expression context generator class that will be used to
retrieve an expression context for the widget.

:param generator: A :py:class:`QgsExpressionContextGenerator` class that
                  will be used to create an expression context when
                  required.
%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

    bool allowEvalErrors() const;
%Docstring
Allow accepting expressions with evaluation errors. This can be useful
when we are not able to provide an expression context of which we are
sure it's completely populated.
%End

    void setAllowEvalErrors( bool allowEvalErrors );
%Docstring
Allow accepting expressions with evaluation errors. This can be useful
when we are not able to provide an expression context of which we are
sure it's completely populated.
%End

    bool buttonVisible() const;
%Docstring
Returns the visibility of the button

If button is hidden, the widget essentially becomes an editable combo
box

.. versionadded:: 3.36
%End

    void setButtonVisible( bool visible );
%Docstring
Set the visibility of the button

If button is hidden, the widget essentially becomes an editable combo
box

.. versionadded:: 3.36
%End

  signals:
    void fieldChanged( const QString &fieldName );
%Docstring
Emitted when the currently selected field changes.
%End

    void fieldChanged( const QString &fieldName, bool isValid );
%Docstring
fieldChanged signal with indication of the validity of the expression
%End

    void allowEvalErrorsChanged();
%Docstring
Allow accepting expressions with evaluation errors. This can be useful
when we are not able to provide an expression context of which we are
sure it's completely populated.
%End

    void buttonVisibleChanged();
%Docstring
Emitted when the button visibility changes

.. versionadded:: 3.36
%End

  public slots:

    void setLayer( QgsMapLayer *layer );
%Docstring
Sets the layer used to display the fields and expression.

.. seealso:: :py:func:`layer`
%End

    void setRow( int row );
%Docstring
sets the current row in the widget
%End

    void setField( const QString &fieldName );
%Docstring
sets the current field or expression in the widget
%End

    void setFields( const QgsFields &fields );
%Docstring
Sets the fields used in the widget to ``fields``, this allows the widget
to work without a layer.

.. versionadded:: 3.14
%End

    void setExpression( const QString &expression );
%Docstring
Sets the current expression text and if applicable also the field. Alias
for setField.
%End

  protected slots:
    void editExpression();
%Docstring
open the expression dialog to edit the current or add a new expression
%End

    void expressionEdited( const QString &expression );
%Docstring
when expression is edited by the user in the line edit, it will be
checked for validity
%End

    void expressionEditingFinished();
%Docstring
when expression has been edited (finished) it will be added to the model
%End

    void currentFieldChanged();

    void updateLineEditStyle( const QString &expression = QString() );
%Docstring
updateLineEditStyle will re-style (color/font) the line edit depending
on content and status

:param expression: if expression is given it will be evaluated for the
                   given string, otherwise it takes current expression
                   from the model
%End

    bool isExpressionValid( const QString &expressionStr );

  protected:
    virtual void changeEvent( QEvent *event );


    virtual bool eventFilter( QObject *watched, QEvent *event );


};

/************************************************************************
 * This file has been generated automatically from                      *
 *                                                                      *
 * src/gui/qgsfieldexpressionwidget.h                                   *
 *                                                                      *
 * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 ************************************************************************/