Skip to content

Commit 55860e8

Browse files
committed
sipify QgsFieldExpressionWidget
1 parent daa3c2a commit 55860e8

File tree

3 files changed

+161
-91
lines changed

3 files changed

+161
-91
lines changed

python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ gui/qgsextentgroupbox.sip
364364
gui/qgsexternalresourcewidget.sip
365365
gui/qgsfeatureselectiondlg.sip
366366
gui/qgsfieldcombobox.sip
367-
gui/qgsfieldexpressionwidget.sip
368367
gui/qgsfieldmodel.sip
369368
gui/qgsfieldproxymodel.sip
370369
gui/qgsfieldvalidator.sip
Lines changed: 152 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,206 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/qgsfieldexpressionwidget.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
114

215
class QgsFieldExpressionWidget : QWidget
316
{
17+
%Docstring
18+
The QgsFieldExpressionWidget class reates a widget to choose fields and edit expressions
19+
It contains a combo boxto display the fields and expression and a button to open the expression dialog.
20+
The combo box is editable, allowing expressions to be edited inline.
21+
The validity of the expression is checked live on key press, invalid expressions are displayed in red.
22+
The expression will be added to the model (and the fieldChanged signals emitted)
23+
only when editing in the line edit is finished (focus lost, enter key pressed).
24+
%End
25+
426
%TypeHeaderCode
527
#include "qgsfieldexpressionwidget.h"
628
%End
7-
829
public:
9-
/**
10-
* @brief QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a button to open the expression dialog
11-
*/
30+
1231
explicit QgsFieldExpressionWidget( QWidget *parent /TransferThis/ = 0 );
32+
%Docstring
33+
QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a button to open the expression dialog
34+
%End
1335

14-
//! define the title used in the expression dialog
15-
void setExpressionDialogTitle( const QString& title );
36+
void setExpressionDialogTitle( const QString &title );
37+
%Docstring
38+
define the title used in the expression dialog
39+
%End
1640

17-
//! return the title used for the expression dialog
1841
const QString expressionDialogTitle();
42+
%Docstring
43+
return the title used for the expression dialog
44+
:rtype: str
45+
%End
1946

20-
//! setFilters allows fitering according to the type of field
2147
void setFilters( QgsFieldProxyModel::Filters filters );
48+
%Docstring
49+
setFilters allows fitering according to the type of field
50+
%End
2251

2352
void setLeftHandButtonStyle( bool isLeft );
2453

25-
//! currently used filter on list of fields
2654
QgsFieldProxyModel::Filters filters() const;
55+
%Docstring
56+
currently used filter on list of fields
57+
:rtype: QgsFieldProxyModel.Filters
58+
%End
2759

28-
//! set the geometry calculator used in the expression dialog
2960
void setGeomCalculator( const QgsDistanceArea &da );
61+
%Docstring
62+
set the geometry calculator used in the expression dialog
63+
%End
3064

31-
/**
32-
* @brief currentField returns the currently selected field or expression if allowed
33-
* @param isExpression determines if the string returned is the name of a field or an expression
34-
* @param isValid determines if the expression (or field) returned is valid
35-
*/
3665
QString currentField( bool *isExpression = 0, bool *isValid = 0 ) const;
66+
%Docstring
67+
currentField returns the currently selected field or expression if allowed
68+
\param isExpression determines if the string returned is the name of a field or an expression
69+
\param isValid determines if the expression (or field) returned is valid
70+
:rtype: str
71+
%End
3772

38-
/**
39-
* Return true if the current expression is valid
40-
*/
4173
bool isValidExpression( QString *expressionError = 0 ) const;
74+
%Docstring
75+
Return true if the current expression is valid
76+
:rtype: bool
77+
%End
4278

4379
bool isExpression() const;
44-
/**
45-
* Return the current text that is set in the expression area
46-
*/
80+
%Docstring
81+
If the content is not just a simple field this method will return true.
82+
:rtype: bool
83+
%End
84+
4785
QString currentText() const;
86+
%Docstring
87+
Return the current text that is set in the expression area
88+
:rtype: str
89+
%End
4890

49-
/** Returns the currently selected field or expression. If a field is currently selected, the returned
50-
* value will be converted to a valid expression referencing this field (ie enclosing the field name with
51-
* appropriate quotations).
52-
* @note added in QGIS 2.14
53-
*/
5491
QString asExpression() const;
92+
%Docstring
93+
Returns the currently selected field or expression. If a field is currently selected, the returned
94+
value will be converted to a valid expression referencing this field (ie enclosing the field name with
95+
appropriate quotations).
96+
.. versionadded:: 2.14
97+
:rtype: str
98+
%End
5599

56-
/**
57-
* Returns the currently selected field or expression. If a field is currently selected, the returned
58-
* value will be converted to a valid expression referencing this field (ie enclosing the field name with
59-
* appropriate quotations).
60-
*
61-
* Alias for asExpression()
62-
*
63-
* @note added in QGIS 3.0
64-
*/
65100
QString expression() const;
101+
%Docstring
102+
Returns the currently selected field or expression. If a field is currently selected, the returned
103+
value will be converted to a valid expression referencing this field (ie enclosing the field name with
104+
appropriate quotations).
66105

67-
/**
68-
* Returns the layer currently associated with the widget.
69-
* @see setLayer()
70-
*/
71-
QgsVectorLayer* layer() const;
72-
73-
/**
74-
* Register an expression context generator class that will be used to retrieve
75-
* an expression context for the widget.
76-
* @param generator A QgsExpressionContextGenerator class that will be used to
77-
* create an expression context when required.
78-
* @note added in QGIS 3.0
79-
*/
80-
void registerExpressionContextGenerator( QgsExpressionContextGenerator* generator );
106+
Alias for asExpression()
81107

82-
signals:
83-
//! the signal is emitted when the currently selected field changes
84-
void fieldChanged( const QString& fieldName );
108+
.. versionadded:: 3.0
109+
:rtype: str
110+
%End
85111

86-
//! fieldChanged signal with indication of the validity of the expression
87-
void fieldChanged( const QString& fieldName, bool isValid );
112+
QgsVectorLayer *layer() const;
113+
%Docstring
114+
Returns the layer currently associated with the widget.
115+
\see setLayer()
116+
:rtype: QgsVectorLayer
117+
%End
88118

89-
// void returnPressed();
119+
void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
120+
%Docstring
121+
Register an expression context generator class that will be used to retrieve
122+
an expression context for the widget.
123+
\param generator A QgsExpressionContextGenerator class that will be used to
124+
create an expression context when required.
125+
.. versionadded:: 3.0
126+
%End
127+
128+
signals:
129+
void fieldChanged( const QString &fieldName );
130+
%Docstring
131+
the signal is emitted when the currently selected field changes
132+
%End
133+
134+
void fieldChanged( const QString &fieldName, bool isValid );
135+
%Docstring
136+
fieldChanged signal with indication of the validity of the expression
137+
%End
90138

91139
public slots:
92-
/**
93-
* Sets the layer used to display the fields and expression.
94-
* @see layer()
95-
*/
96-
void setLayer( QgsMapLayer* layer );
97140

98-
//! sets the current row in the widget
141+
void setLayer( QgsMapLayer *layer );
142+
%Docstring
143+
Sets the layer used to display the fields and expression.
144+
\see layer()
145+
%End
146+
99147
void setRow( int row );
148+
%Docstring
149+
sets the current row in the widget
150+
%End
100151

101-
//! sets the current field or expression in the widget
102152
void setField( const QString &fieldName );
153+
%Docstring
154+
sets the current field or expression in the widget
155+
%End
156+
157+
void setExpression( const QString &expression );
158+
%Docstring
159+
Sets the current expression text and if applicable also the field.
160+
Alias for setField.
103161

104-
/**
105-
* Sets the current expression text and if applicable also the field.
106-
* Alias for setField.
107-
*
108-
* @note Added in QGIS 3.0
109-
*/
110-
void setExpression( const QString& expression );
162+
.. versionadded:: 3.0
163+
%End
111164

112165
protected slots:
113-
//! open the expression dialog to edit the current or add a new expression
114166
void editExpression();
167+
%Docstring
168+
open the expression dialog to edit the current or add a new expression
169+
%End
115170

116-
//! when expression is edited by the user in the line edit, it will be checked for validity
117-
void expressionEdited( const QString& expression );
171+
void expressionEdited( const QString &expression );
172+
%Docstring
173+
when expression is edited by the user in the line edit, it will be checked for validity
174+
%End
118175

119-
//! when expression has been edited (finished) it will be added to the model
120176
void expressionEditingFinished();
177+
%Docstring
178+
when expression has been edited (finished) it will be added to the model
179+
%End
121180

122181
void currentFieldChanged();
123182

124-
/**
125-
* @brief updateLineEditStyle will re-style (color/font) the line edit depending on content and status
126-
* @param expression if expression is given it will be evaluated for the given string, otherwise it takes
127-
* current expression from the model
128-
*/
129-
void updateLineEditStyle( const QString& expression = QString() );
183+
void updateLineEditStyle( const QString &expression = QString() );
184+
%Docstring
185+
updateLineEditStyle will re-style (color/font) the line edit depending on content and status
186+
\param expression if expression is given it will be evaluated for the given string, otherwise it takes
187+
current expression from the model
188+
%End
130189

131-
bool isExpressionValid( const QString& expressionStr );
190+
bool isExpressionValid( const QString &expressionStr );
191+
%Docstring
192+
:rtype: bool
193+
%End
132194

133195
protected:
134-
void changeEvent( QEvent* event );
196+
virtual void changeEvent( QEvent *event );
197+
135198
};
199+
200+
/************************************************************************
201+
* This file has been generated automatically from *
202+
* *
203+
* src/gui/qgsfieldexpressionwidget.h *
204+
* *
205+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
206+
************************************************************************/

src/gui/qgsfieldexpressionwidget.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616
#ifndef QGSFIELDEXPRESSIONWIDGET_H
1717
#define QGSFIELDEXPRESSIONWIDGET_H
1818

19-
#include <QWidget>
20-
#include <QToolButton>
21-
#include <QComboBox>
2219
#include <QColor>
20+
#include <QComboBox>
21+
#include <QToolButton>
22+
#include <QWidget>
2323
#include <memory>
2424

25+
#include "qgis_gui.h"
26+
#include "qgis.h"
2527
#include "qgsdistancearea.h"
26-
#include "qgsfieldproxymodel.h"
27-
#include "qgsexpressioncontext.h"
2828
#include "qgsexpressioncontextgenerator.h"
29-
#include "qgis_gui.h"
29+
#include "qgsexpressioncontext.h"
30+
#include "qgsfieldproxymodel.h"
31+
3032

3133
class QgsMapLayer;
3234
class QgsVectorLayer;
@@ -52,7 +54,7 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
5254
/**
5355
* \brief QgsFieldExpressionWidget creates a widget with a combo box to display the fields and expression and a button to open the expression dialog
5456
*/
55-
explicit QgsFieldExpressionWidget( QWidget *parent = nullptr );
57+
explicit QgsFieldExpressionWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
5658

5759
//! define the title used in the expression dialog
5860
void setExpressionDialogTitle( const QString &title );
@@ -134,8 +136,6 @@ class GUI_EXPORT QgsFieldExpressionWidget : public QWidget
134136
//! fieldChanged signal with indication of the validity of the expression
135137
void fieldChanged( const QString &fieldName, bool isValid );
136138

137-
// void returnPressed();
138-
139139
public slots:
140140

141141
/**

0 commit comments

Comments
 (0)