Workout Editor Fix QT4 plus highlighting

.. QT code supplied was QT5 only, fixed up to compile
   on QT4 by including relevant headers

.. moved the responsibility for code highlighting back
   to the editor as it is the sensible place to do it.
This commit is contained in:
Mark Liversedge
2016-01-19 08:52:49 +00:00
parent d39caf1c05
commit 2dadafc8f5
2 changed files with 8 additions and 21 deletions

View File

@@ -38,7 +38,10 @@
**
****************************************************************************/
#include <QtWidgets>
#include <QWidget>
#include <QPlainTextEdit>
#include <QTextBlock>
#include <QPainter>
#include "codeeditor.h"
@@ -50,10 +53,10 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent)
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
//we manage highlighting within GC, this is not required.
//connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
updateLineNumberAreaWidth(0);
//highlightCurrentLine();
highlightCurrentLine();
lineAreaColor=QColor(Qt::darkGray);
lineAreaText=QColor(Qt::white);
@@ -114,9 +117,7 @@ void CodeEditor::highlightCurrentLine()
if (!isReadOnly()) {
QTextEdit::ExtraSelection selection;
QColor lineColor = QColor(Qt::yellow).lighter(160);
selection.format.setBackground(lineColor);
selection.format.setBackground(lineAreaColor);
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = textCursor();
selection.cursor.clearSelection();