17#include "moc_qgscodeeditorsql.cpp"
31 setAutoCompletionCaseSensitivity(
false );
44 mApis->cancelPreparation();
53 mSqlLexer =
new QgsCaseInsensitiveLexerSQL(
this );
54 mSqlLexer->setDefaultFont( font );
57 mSqlLexer->setFont( font, -1 );
59 mSqlLexer->setFont( font, QsciLexerSQL::Keyword );
61 font.setBold(
false );
62 font.setItalic(
true );
63 mSqlLexer->setFont( font, QsciLexerSQL::Comment );
64 mSqlLexer->setFont( font, QsciLexerSQL::CommentLine );
66 mSqlLexer->setColor(
defaultColor, QsciLexerSQL::Default );
78 setLexer( mSqlLexer );
87 for (
const QgsField &field : std::as_const( fields ) )
95void QgsCodeEditorSQL::updateApis()
97 mApis =
new QsciAPIs( mSqlLexer );
99 for (
const QString &fieldName : std::as_const( mFieldNames ) )
101 mApis->add( fieldName );
104 for (
const QString &keyword : std::as_const( mExtraKeywords ) )
106 mApis->add( keyword );
110 mSqlLexer->setAPIs( mApis );
115 return mExtraKeywords.values();
126 return mFieldNames.values();
ScriptLanguage
Scripting languages.
@ QuotedOperator
Quoted operator color.
@ Identifier
Identifier color.
@ DoubleQuote
Double quote color.
@ QuotedIdentifier
Quoted identifier color.
@ CommentLine
Line comment color.
@ Default
Default text color.
@ Background
Background color.
@ SingleQuote
Single quote color.
@ Operator
Operator color.
QStringList extraKeywords() const
Returns the extra keywords.
Qgis::ScriptLanguage language() const override
Returns the associated scripting language.
void setExtraKeywords(const QStringList &extraKeywords)
Set extra keywords to extraKeywords.
QStringList fieldNames() const
Returns field names from the lexer API.
virtual ~QgsCodeEditorSQL()
QgsCodeEditorSQL(QWidget *parent=nullptr)
Constructor for QgsCodeEditorSQL.
void setFieldNames(const QStringList &fieldNames)
Set field names to fieldNames to be added to the lexer API.
void initializeLexer() override
Called when the dialect specific code lexer needs to be initialized (or reinitialized).
void setFields(const QgsFields &fields)
Set field names to be added to the lexer API.
A text editor based on QScintilla2.
void runPostLexerConfigurationTasks()
Performs tasks which must be run after a lexer has been set for the widget.
void setTitle(const QString &title)
Set the widget title.
QFont lexerFont() const
Returns the font to use in the lexer.
QColor lexerColor(QgsCodeEditorColorScheme::ColorRole role) const
Returns the color to use in the lexer for the specified role.
static QColor defaultColor(QgsCodeEditorColorScheme::ColorRole role, const QString &theme=QString())
Returns the default color for the specified role.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.