34 setAutoCompletionCaseSensitivity(
false );
39 void QgsCodeEditorSQL::initializeLexer()
41 QHash< QString, QColor > colors;
45 for (
const auto &key : ini.allKeys() )
52 QColor defaultColor = colors.value( QStringLiteral(
"sql/defaultFontColor" ), Qt::black );
54 mSqlLexer =
new QgsCaseInsensitiveLexerSQL(
this );
55 mSqlLexer->setDefaultFont( font );
56 mSqlLexer->setDefaultColor( defaultColor );
57 mSqlLexer->setDefaultPaper( colors.value( QStringLiteral(
"sql/paperBackgroundColor" ), Qt::white ) );
58 mSqlLexer->setFont( font, -1 );
60 mSqlLexer->setFont( font, QsciLexerSQL::Keyword );
62 mSqlLexer->setColor( defaultColor, QsciLexerSQL::Default );
63 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/commentFontColor" ), QColor( 142, 144, 140 ) ), QsciLexerSQL::Comment );
64 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/commentLineFontColor" ), QColor( 142, 144, 140 ) ), QsciLexerSQL::CommentLine );
65 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/numberFontColor" ), QColor( 200, 40, 41 ) ), QsciLexerSQL::Number );
66 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/keywordFontColor" ), QColor( 137, 89, 168 ) ), QsciLexerSQL::Keyword );
67 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/singleQuoteFontColor" ), QColor( 113, 140, 0 ) ), QsciLexerSQL::SingleQuotedString );
68 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/doubleQuoteFontColor" ), QColor( 234, 183, 0 ) ), QsciLexerSQL::DoubleQuotedString );
69 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/operatorFontColor" ), QColor( 66, 113, 174 ) ), QsciLexerSQL::Operator );
70 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/identifierFontColor" ), QColor( 62, 153, 159 ) ), QsciLexerSQL::Identifier );
71 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/QuotedIdentifierFontColor" ), Qt::black ), QsciLexerSQL::QuotedIdentifier );
72 mSqlLexer->setColor( colors.value( QStringLiteral(
"sql/QuotedOperatorFontColor" ), Qt::black ), QsciLexerSQL::QuotedOperator );
74 setLexer( mSqlLexer );
81 for (
const QgsField &field : fields )
83 mFieldNames << field.name();
89 void QgsCodeEditorSQL::updateApis()
91 mApis =
new QsciAPIs( mSqlLexer );
93 for (
const QString &fieldName : qgis::as_const( mFieldNames ) )
95 mApis->add( fieldName );
99 mSqlLexer->setAPIs( mApis );