1 | #include <FileDiffEditor.h> |
---|---|
2 | |
3 | #include <GitQlientStyles.h> |
4 | #include <LineNumberArea.h> |
5 | |
6 | FileDiffEditor::FileDiffEditor(QWidget *parent) |
7 | : FileDiffView(parent) |
8 | { |
9 | setReadOnly(false); |
10 | |
11 | addNumberArea(new LineNumberArea(this)); |
12 | |
13 | connect(this, &FileDiffView::cursorPositionChanged, this, &FileDiffEditor::highlightCurrentLine); |
14 | |
15 | highlightCurrentLine(); |
16 | } |
17 | |
18 | void FileDiffEditor::highlightCurrentLine() |
19 | { |
20 | QList<QTextEdit::ExtraSelection> extraSelections; |
21 | |
22 | if (!isReadOnly()) |
23 | { |
24 | QTextEdit::ExtraSelection selection; |
25 | |
26 | selection.format.setBackground(GitQlientStyles::getGraphSelectionColor()); |
27 | selection.format.setProperty(QTextFormat::FullWidthSelection, true); |
28 | selection.cursor = textCursor(); |
29 | selection.cursor.clearSelection(); |
30 | extraSelections.append(selection); |
31 | } |
32 | |
33 | setExtraSelections(extraSelections); |
34 | } |
35 |