QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgscodeeditorexpression.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscodeeditorsql.h - A SQL editor based on QScintilla
3  --------------------------------------
4  Date : 06-Oct-2013
5  Copyright : (C) 2013 by Salvatore Larosa
6  Email : lrssvtml (at) gmail (dot) com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSCODEEDITOREXPRESSION_H
17 #define QGSCODEEDITOREXPRESSION_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_gui.h"
21 #include "qgscodeeditor.h"
22 #include "qgsexpressioncontext.h"
23 
24 #include <Qsci/qscilexersql.h>
25 
26 SIP_IF_MODULE( HAVE_QSCI_SIP )
27 
28 
36 class GUI_EXPORT QgsCodeEditorExpression : public QgsCodeEditor
37 {
38  Q_OBJECT
39 
40  public:
42  QgsCodeEditorExpression( QWidget *parent SIP_TRANSFERTHIS = nullptr );
43 
49  void setExpressionContext( const QgsExpressionContext &context );
50 
54  void setFields( const QgsFields &fields );
55 
56  protected:
57 
58  void initializeLexer() override;
59 
60  private:
61  void updateApis();
62  QsciAPIs *mApis = nullptr;
63  QsciLexerSQL *mSqlLexer = nullptr;
64 
65  QStringList mVariables;
66  QStringList mContextFunctions;
67  QStringList mFunctions;
68  QStringList mFieldNames;
69 };
70 
71 #ifndef SIP_RUN
72 
83 class QgsLexerExpression : public QsciLexerSQL
84 {
85  Q_OBJECT
86 
87  public:
89  explicit QgsLexerExpression( QObject *parent = nullptr );
90 
91  const char *language() const override;
92 
93  bool caseSensitive() const override;
94 
95  const char *wordCharacters() const override;
96 };
97 
98 class QgsSciApisExpression : public QsciAPIs
99 {
100  Q_OBJECT
101  public:
102  QgsSciApisExpression( QsciLexer *lexer );
103 
104  QStringList callTips( const QStringList &context, int commas, QsciScintilla::CallTipsStyle style, QList<int> &shifts ) override;
105 };
107 #endif
108 
109 #endif
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
QgsCodeEditor
A text editor based on QScintilla2.
Definition: qgscodeeditor.h:42
qgsexpressioncontext.h
qgis_sip.h
QgsCodeEditorExpression
A QGIS expression editor based on QScintilla2.
Definition: qgscodeeditorexpression.h:37
qgscodeeditor.h
SIP_IF_MODULE
#define SIP_IF_MODULE(condition)
Definition: qgis_sip.h:28
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53