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 : qgis::as_const( mVariables ) )
145 for (
const QString &
function : qgis::as_const( mContextFunctions ) )
147 mApis->add(
function );
150 for (
const QString &
function : qgis::as_const( mFunctions ) )
152 mApis->add(
function );
155 for (
const QString &fieldName : qgis::as_const( mFieldNames ) )
157 mApis->add( fieldName );
161 mSqlLexer->setAPIs( mApis );
165 QgsLexerExpression::QgsLexerExpression( QObject *parent )
166 : QsciLexerSQL( parent )
170 const char *QgsLexerExpression::language()
const
172 return "QGIS Expression";
175 bool QgsLexerExpression::caseSensitive()
const
180 const char *QgsLexerExpression::wordCharacters()
const
182 return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@";
185 QgsSciApisExpression::QgsSciApisExpression( QsciLexer *lexer )
191 QStringList QgsSciApisExpression::callTips(
const QStringList &context,
int commas, QsciScintilla::CallTipsStyle style, QList<int> &shifts )
193 const QStringList originalTips = QsciAPIs::callTips( context, commas, style, shifts );
194 QStringList lowercaseTips;
195 for (
const QString &tip : originalTips )
196 lowercaseTips << tip.toLower();
198 return lowercaseTips;