28 setTitle( tr(
"Expression Editor" ) );
31 setAutoCompletionCaseSensitivity(
false );
40 for (
const QString &var : variableNames )
42 mVariables <<
'@' + var;
50 for (
int i = 0; i < count; i++ )
62 QString signature = func->
name();
63 if ( !signature.startsWith(
'$' ) )
67 QStringList paramNames;
71 paramNames << param.name();
75 if ( parameters.isEmpty() && func->
params() )
76 signature += QChar( 0x2026 );
78 signature += paramNames.join(
", " );
82 mFunctions << signature;
105 mSqlLexer =
new QgsLexerExpression(
this );
106 mSqlLexer->setDefaultFont( font );
109 mSqlLexer->setFont( font, -1 );
110 font.setBold(
true );
111 mSqlLexer->setFont( font, QsciLexerSQL::Keyword );
113 font.setBold(
false );
114 font.setItalic(
true );
115 mSqlLexer->setFont( font, QsciLexerSQL::Comment );
116 mSqlLexer->setFont( font, QsciLexerSQL::CommentLine );
118 mSqlLexer->setColor( Qt::darkYellow, QsciLexerSQL::DoubleQuotedString );
120 mSqlLexer->setColor(
defaultColor, QsciLexerSQL::Default );
132 setLexer( mSqlLexer );
136 void QgsCodeEditorExpression::updateApis()
138 mApis =
new QgsSciApisExpression( mSqlLexer );
140 for (
const QString &var : std::as_const( mVariables ) )
145 for (
const QString &
function : std::as_const( mContextFunctions ) )
147 mApis->add(
function );
150 for (
const QString &
function : std::as_const( mFunctions ) )
152 mApis->add(
function );
155 for (
const QString &fieldName : std::as_const( mFieldNames ) )
157 mApis->add( fieldName );
160 mApis->add( QString(
"NULL" ) );
162 mSqlLexer->setAPIs( mApis );
166 QgsLexerExpression::QgsLexerExpression( QObject *parent )
167 : QsciLexerSQL( parent )
169 setBackslashEscapes(
true );
172 const char *QgsLexerExpression::language()
const
174 return "QGIS Expression";
177 bool QgsLexerExpression::caseSensitive()
const
182 const char *QgsLexerExpression::wordCharacters()
const
184 return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@";
187 QgsSciApisExpression::QgsSciApisExpression( QsciLexer *lexer )
193 QStringList QgsSciApisExpression::callTips(
const QStringList &context,
int commas, QsciScintilla::CallTipsStyle style, QList<int> &shifts )
195 const QStringList originalTips = QsciAPIs::callTips( context, commas, style, shifts );
196 QStringList lowercaseTips;
197 for (
const QString &tip : originalTips )
198 lowercaseTips << tip.toLower();
200 return lowercaseTips;