Workspace 6.21.5
Public Member Functions | Protected Member Functions | List of all members
DifferenceHighlightingStyledItemDelegate Class Reference

Displays coloured highlights in the display text based on known differences between it and another string (ie that displayed in the cell next to it). Does not affect editing. More...

#include <Tools/Widgets/differencehighlightingstyleditemdelegate.h>

Inheritance diagram for DifferenceHighlightingStyledItemDelegate:
[legend]

Public Member Functions

 DifferenceHighlightingStyledItemDelegate (const QBrush &highlightBrush, const QColor &constrastColour, int stringHighlightRole, QObject *parent=nullptr)
 An styled item delegate that colours the display cell of an item to highlight differences between the text displayed and an alternative cell.
 
 DifferenceHighlightingStyledItemDelegate (int stringHighlightRole, QObject *parent=nullptr)
 An styled item delegate that colours the display cell of an item dark or light grey to highlight differences between the text displayed and an alternative cell.
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
 
void setColours (const QBrush &highlightBrush, const QColor &constrastColour)
 

Protected Member Functions

void drawVerticalLines (QPainter &painter, const int top, const int left, const int width, const QColor &color, const QVector< int > &columns) const
 

Detailed Description

The required highlights must have already been calculated and stored in the model data for the item as role stringHighlightRole

See also
TextDifferencer::compareLines

Constructor & Destructor Documentation

◆ DifferenceHighlightingStyledItemDelegate() [1/2]

DifferenceHighlightingStyledItemDelegate ( const QBrush &  highlightBrush,
const QColor &  contrastColour,
int  stringHighlightRole,
QObject *  parent = nullptr 
)

The differences should have already been calculated

See also
TextDifferencer::CompareLines and stored in the item model as role stringHighlightRole
Parameters
highlightBrushbrush to be used to highlight the backround of text in this cell but not the alternate
contrastColourcolour to be used for vertical lines showing where text exists in the alternate cell but not this
stringHighlightRoleQt::UserRole where the differences should be found
parentparent widget

◆ DifferenceHighlightingStyledItemDelegate() [2/2]

DifferenceHighlightingStyledItemDelegate ( int  stringHighlightRole,
QObject *  parent = nullptr 
)

Use this if you need to set up your column delegate before you have colours available

See also
TextDifferencer::CompareLines
setColours

Member Function Documentation

◆ drawVerticalLines()

void drawVerticalLines ( QPainter &  painter,
const int  top,
const int  left,
const int  width,
const QColor &  color,
const QVector< int > &  columns 
) const
protected

◆ paint()

void paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const

◆ setColours()

void setColours ( const QBrush &  highlightBrush,
const QColor &  constrastColour 
)