DiffEditor: Use settings' foreground color for highlights

Simplify drawing highlights by passing selections
into a drawing function.
Reduce selections which are covered completely by
other selections.

Task-number: QTCREATORBUG-12844
Change-Id: If282d5c881d25cac1b8db4ac8dfc45d47b0b8580
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
jkobus
2014-09-25 15:48:21 +02:00
committed by Orgad Shaneh
parent cb4f04f416
commit 5c6b1373c4
4 changed files with 116 additions and 66 deletions

View File

@@ -54,21 +54,19 @@ class DIFFEDITOR_EXPORT SelectableTextEditorWidget
public:
SelectableTextEditorWidget(Core::Id id, QWidget *parent = 0);
~SelectableTextEditorWidget();
void setSelections(const QMap<int, QList<DiffSelection> > &selections) {
m_selections = selections;
}
void setSelections(const QMap<int, QList<DiffSelection> > &selections);
private:
void innerPaintEvent(QPaintEvent *e);
void paintSelections(QPainter &painter,
const QList<DiffSelection> &selections,
const QTextBlock &block,
int top);
void paintBlock(QPainter *painter,
const QTextBlock &block,
const QPointF &offset,
const QVector<QTextLayout::FormatRange> &selections,
const QRect &clipRect) const;
// block number, list of ranges
// DiffSelection.start - can be -1 (continues from the previous line)
// DiffSelection.end - can be -1 (spans to the end of line, even after the last character in line)
QMap<int, QList<DiffSelection> > m_selections;
QMap<int, QList<DiffSelection> > m_diffSelections;
};
} // namespace DiffEditor