diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 623e0523..81410640 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -735,9 +735,7 @@ void MainWindow::executeQuery()
db.setRestorePoint();
// Remove any error indicators
- sqlWidget->getEditor()->clearIndicatorRange(0, 0,
- sqlWidget->getEditor()->lines(), sqlWidget->getEditor()->lineLength(sqlWidget->getEditor()->lines()),
- sqlWidget->getEditor()->getErrorIndicatorNumber());
+ sqlWidget->getEditor()->clearErrorIndicators();
//Accept multi-line queries, by looping until the tail is empty
QElapsedTimer timer;
@@ -805,8 +803,7 @@ void MainWindow::executeQuery()
} else {
statusMessage = QString::fromUtf8((const char*)sqlite3_errmsg(db._db)) +
": " + queryPart;
- sqlWidget->getEditor()->fillIndicatorRange(execution_start_line, execution_start_index, execution_start_line, execution_end_index,
- sqlWidget->getEditor()->getErrorIndicatorNumber());
+ sqlWidget->getEditor()->setErrorIndicator(execution_start_line, execution_start_index, execution_start_line, execution_end_index);
}
execution_start_index = execution_end_index;
diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp
index 4a27915b..c5a81a95 100644
--- a/src/PreferencesDialog.cpp
+++ b/src/PreferencesDialog.cpp
@@ -88,6 +88,7 @@ void PreferencesDialog::loadSettings()
ui->spinEditorFontSize->setValue(getSettingsValue("editor", "fontsize").toInt());
ui->spinTabSize->setValue(getSettingsValue("editor", "tabsize").toInt());
ui->spinLogFontSize->setValue(getSettingsValue("log", "fontsize").toInt());
+ ui->checkErrorIndicators->setChecked(getSettingsValue("editor", "error_indicators").toBool());
ui->listExtensions->addItems(getSettingsValue("extensions", "list").toStringList());
ui->checkRegexDisabled->setChecked(getSettingsValue("extensions", "disableregex").toBool());
@@ -123,6 +124,7 @@ void PreferencesDialog::saveSettings()
setSettingsValue("editor", "fontsize", ui->spinEditorFontSize->value());
setSettingsValue("editor", "tabsize", ui->spinTabSize->value());
setSettingsValue("log", "fontsize", ui->spinLogFontSize->value());
+ setSettingsValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());
QStringList extList;
foreach(QListWidgetItem* item, ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
@@ -292,6 +294,10 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
}
}
+ // editor/error_indicators?
+ if(group == "editor" && name == "error_indicators")
+ return true;
+
// extensions/list?
if(group == "extensions" && name == "list")
return QStringList();
diff --git a/src/PreferencesDialog.ui b/src/PreferencesDialog.ui
index b33d0c36..0144cf37 100644
--- a/src/PreferencesDialog.ui
+++ b/src/PreferencesDialog.ui
@@ -661,6 +661,26 @@ QGroupBox::title {
-
+ -
+
+
+ Error indicators
+
+
+ checkErrorIndicators
+
+
+
+ -
+
+
+ Enabling error indicators highlights the SQL code lines that caused errors during the last execution
+
+
+ enabled
+
+
+
@@ -775,6 +795,7 @@ QGroupBox::title {
spinEditorFontSize
spinLogFontSize
spinTabSize
+ checkErrorIndicators
listExtensions
buttonAddExtension
buttonRemoveExtension
@@ -823,8 +844,8 @@ QGroupBox::title {
addExtension()
- 119
- 79
+ 567
+ 88
245
@@ -839,8 +860,8 @@ QGroupBox::title {
removeExtension()
- 119
- 79
+ 567
+ 117
245
diff --git a/src/sqltextedit.cpp b/src/sqltextedit.cpp
index 86dc6785..b8dcc2a2 100644
--- a/src/sqltextedit.cpp
+++ b/src/sqltextedit.cpp
@@ -141,4 +141,22 @@ void SqlTextEdit::reloadSettings()
// Set tab width
setTabWidth(PreferencesDialog::getSettingsValue("editor", "tabsize").toInt());
+
+ // Check if error indicators are enabled and clear them if they just got disabled
+ showErrorIndicators = PreferencesDialog::getSettingsValue("editor", "error_indicators").toBool();
+ if(!showErrorIndicators)
+ clearErrorIndicators();
+}
+
+void SqlTextEdit::clearErrorIndicators()
+{
+ // Clear any error indicators from position (0,0) to the last column of the last line
+ clearIndicatorRange(0, 0, lines(), lineLength(lines()), errorIndicatorNumber);
+}
+
+void SqlTextEdit::setErrorIndicator(int fromRow, int fromIndex, int toRow, int toIndex)
+{
+ // Set error indicator for the specified range but only if they're enabled
+ if(showErrorIndicators)
+ fillIndicatorRange(fromRow, fromIndex, toRow, toIndex, errorIndicatorNumber);
}
diff --git a/src/sqltextedit.h b/src/sqltextedit.h
index 4950fc5c..4948b448 100644
--- a/src/sqltextedit.h
+++ b/src/sqltextedit.h
@@ -17,13 +17,13 @@ public:
explicit SqlTextEdit(QWidget *parent = 0);
virtual ~SqlTextEdit();
- int getErrorIndicatorNumber() const { return errorIndicatorNumber; }
-
static SqlUiLexer* sqlLexer;
public slots:
void reloadKeywords();
void reloadSettings();
+ void clearErrorIndicators();
+ void setErrorIndicator(int fromRow, int fromIndex, int toRow, int toIndex);
protected:
void dropEvent(QDropEvent* e);
@@ -32,6 +32,7 @@ private:
void setupSyntaxHighlightingFormat(const QString& settings_name, int style);
int errorIndicatorNumber;
+ bool showErrorIndicators;
private slots:
void updateLineNumberAreaWidth();