11#include "sqltextedit.h"
2+ #include "PreferencesDialog.h"
23
34#include <QKeyEvent>
45#include <QAbstractItemView>
@@ -16,8 +17,10 @@ SqlTextEdit::SqlTextEdit(QWidget* parent) :
1617 m_Completer->setWrapAround(false);
1718 m_Completer->setWidget(this);
1819
19- QObject::connect(m_Completer, SIGNAL(activated(QString)),
20- this, SLOT(insertCompletion(QString)));
20+ connect(m_Completer, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)));
21+ connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
22+
23+ highlightCurrentLine();
2124}
2225
2326SqlTextEdit::~SqlTextEdit()
@@ -91,6 +94,23 @@ void SqlTextEdit::insertCompletion(const QString& completion)
9194 setTextCursor(tc);
9295}
9396
97+ void SqlTextEdit::highlightCurrentLine()
98+ {
99+ QList<QTextEdit::ExtraSelection> extra_selections;
100+
101+ QTextEdit::ExtraSelection selection;
102+ selection.format.setBackground(QColor(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_colour").toString()));
103+ selection.format.setFontWeight(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_bold").toBool() ? QFont::Bold : QFont::Normal);
104+ selection.format.setFontItalic(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_italic").toBool());
105+ selection.format.setFontUnderline(PreferencesDialog::getSettingsValue("syntaxhighlighter", "currentline_underline").toBool());
106+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
107+ selection.cursor = textCursor();
108+ selection.cursor.clearSelection();
109+ extra_selections.append(selection);
110+
111+ setExtraSelections(extra_selections);
112+ }
113+
94114namespace {
95115bool isSqliteIdentifierChar(QChar c) {
96116 return c.isLetterOrNumber() || c == '.' || c == '_';
0 commit comments