@@ -148,6 +148,44 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
148
148
txtExpressionString->setCallTipsVisible ( 0 );
149
149
150
150
setExpectedOutputFormat ( QString () );
151
+ mFunctionBuilderHelp ->setMarginVisible ( false );
152
+ mFunctionBuilderHelp ->setEdgeMode ( QsciScintilla::EdgeNone );
153
+ mFunctionBuilderHelp ->setEdgeColumn ( 0 );
154
+ mFunctionBuilderHelp ->setReadOnly ( true );
155
+ mFunctionBuilderHelp ->setText ( tr ( R"( """Define a new function using the @qgsfunction decorator.
156
+
157
+ The function accepts the following parameters
158
+
159
+
160
+ : param [any]: Define any parameters you want to pass to your function before
161
+ the following arguments.
162
+ : param feature: The current feature
163
+ : param parent: The QgsExpression object
164
+ : param context: If there is an argument called ``context`` found at the last
165
+ position, this variable will contain a ``QgsExpressionContext``
166
+ object, that gives access to various additional information like
167
+ expression variables. E.g. ``context.variable( 'layer_id' )``
168
+ : returns: The result of the expression.
169
+
170
+
171
+
172
+ The @qgsfunction decorator accepts the following arguments:
173
+
174
+
175
+ : param args: Defines the number of arguments. With ``args = 'auto'`` the number of
176
+ arguments will automatically be extracted from the signature.
177
+ With ``args = -1``, any number of arguments are accepted.
178
+ : param group: The name of the group under which this expression function will
179
+ be listed.
180
+ : param handlesnull: Set this to True if your function has custom handling for NULL values.
181
+ If False, the result will always be NULL as soon as any parameter is NULL.
182
+ Defaults to False.
183
+ : param usesgeometry : Set this to False if your function does not access
184
+ feature.geometry(). Defaults to True.
185
+ : param referenced_columns: An array of attribute names that are required to run
186
+ this function. Defaults to
187
+ [QgsFeatureRequest.ALL_ATTRIBUTES].
188
+ """")" ) );
151
189
}
152
190
153
191
@@ -826,72 +864,72 @@ void QgsExpressionBuilderWidget::createMarkers( const QgsExpressionNode *inNode
826
864
switch ( inNode->nodeType () )
827
865
{
828
866
case QgsExpressionNode::NodeType::ntFunction:
829
- {
830
- const QgsExpressionNodeFunction *node = static_cast <const QgsExpressionNodeFunction *>( inNode );
831
- txtExpressionString->SendScintilla ( QsciScintilla::SCI_SETINDICATORCURRENT, FUNCTION_MARKER_ID );
832
- txtExpressionString->SendScintilla ( QsciScintilla::SCI_SETINDICATORVALUE, node->fnIndex () );
833
- int start = inNode->parserFirstColumn - 1 ;
834
- int end = inNode->parserLastColumn - 1 ;
835
- int start_pos = txtExpressionString->positionFromLineIndex ( inNode->parserFirstLine - 1 , start );
836
- txtExpressionString->SendScintilla ( QsciScintilla::SCI_INDICATORFILLRANGE, start_pos, end - start );
837
- if ( node->args () )
838
867
{
839
- const QList< QgsExpressionNode * > nodeList = node->args ()->list ();
840
- for ( QgsExpressionNode *n : nodeList )
868
+ const QgsExpressionNodeFunction *node = static_cast <const QgsExpressionNodeFunction *>( inNode );
869
+ txtExpressionString->SendScintilla ( QsciScintilla::SCI_SETINDICATORCURRENT, FUNCTION_MARKER_ID );
870
+ txtExpressionString->SendScintilla ( QsciScintilla::SCI_SETINDICATORVALUE, node->fnIndex () );
871
+ int start = inNode->parserFirstColumn - 1 ;
872
+ int end = inNode->parserLastColumn - 1 ;
873
+ int start_pos = txtExpressionString->positionFromLineIndex ( inNode->parserFirstLine - 1 , start );
874
+ txtExpressionString->SendScintilla ( QsciScintilla::SCI_INDICATORFILLRANGE, start_pos, end - start );
875
+ if ( node->args () )
841
876
{
842
- createMarkers ( n );
877
+ const QList< QgsExpressionNode * > nodeList = node->args ()->list ();
878
+ for ( QgsExpressionNode *n : nodeList )
879
+ {
880
+ createMarkers ( n );
881
+ }
843
882
}
883
+ break ;
844
884
}
845
- break ;
846
- }
847
885
case QgsExpressionNode::NodeType::ntLiteral:
848
- {
849
- break ;
850
- }
886
+ {
887
+ break ;
888
+ }
851
889
case QgsExpressionNode::NodeType::ntUnaryOperator:
852
- {
853
- const QgsExpressionNodeUnaryOperator *node = static_cast <const QgsExpressionNodeUnaryOperator *>( inNode );
854
- createMarkers ( node->operand () );
855
- break ;
856
- }
890
+ {
891
+ const QgsExpressionNodeUnaryOperator *node = static_cast <const QgsExpressionNodeUnaryOperator *>( inNode );
892
+ createMarkers ( node->operand () );
893
+ break ;
894
+ }
857
895
case QgsExpressionNode::NodeType::ntBinaryOperator:
858
- {
859
- const QgsExpressionNodeBinaryOperator *node = static_cast <const QgsExpressionNodeBinaryOperator *>( inNode );
860
- createMarkers ( node->opLeft () );
861
- createMarkers ( node->opRight () );
862
- break ;
863
- }
896
+ {
897
+ const QgsExpressionNodeBinaryOperator *node = static_cast <const QgsExpressionNodeBinaryOperator *>( inNode );
898
+ createMarkers ( node->opLeft () );
899
+ createMarkers ( node->opRight () );
900
+ break ;
901
+ }
864
902
case QgsExpressionNode::NodeType::ntColumnRef:
865
- {
866
- break ;
867
- }
903
+ {
904
+ break ;
905
+ }
868
906
case QgsExpressionNode::NodeType::ntInOperator:
869
- {
870
- const QgsExpressionNodeInOperator *node = static_cast <const QgsExpressionNodeInOperator *>( inNode );
871
- if ( node->list () )
872
907
{
873
- const QList< QgsExpressionNode * > nodeList = node-> list ()-> list ( );
874
- for ( QgsExpressionNode *n : nodeList )
908
+ const QgsExpressionNodeInOperator *node = static_cast < const QgsExpressionNodeInOperator *>( inNode );
909
+ if ( node-> list () )
875
910
{
876
- createMarkers ( n );
911
+ const QList< QgsExpressionNode * > nodeList = node->list ()->list ();
912
+ for ( QgsExpressionNode *n : nodeList )
913
+ {
914
+ createMarkers ( n );
915
+ }
877
916
}
917
+ break ;
878
918
}
879
- break ;
880
- }
881
919
case QgsExpressionNode::NodeType::ntCondition:
882
- {
883
- const QgsExpressionNodeCondition *node = static_cast <const QgsExpressionNodeCondition *>( inNode );
884
- for ( QgsExpressionNodeCondition::WhenThen *cond : node->conditions () )
885
920
{
886
- createMarkers ( cond->whenExp () );
887
- createMarkers ( cond->thenExp () );
888
- }
889
- if ( node->elseExp () )
890
- {
891
- createMarkers ( node->elseExp () );
921
+ const QgsExpressionNodeCondition *node = static_cast <const QgsExpressionNodeCondition *>( inNode );
922
+ for ( QgsExpressionNodeCondition::WhenThen *cond : node->conditions () )
923
+ {
924
+ createMarkers ( cond->whenExp () );
925
+ createMarkers ( cond->thenExp () );
926
+ }
927
+ if ( node->elseExp () )
928
+ {
929
+ createMarkers ( node->elseExp () );
930
+ }
931
+ break ;
892
932
}
893
- break ;
894
- }
895
933
}
896
934
}
897
935
0 commit comments