OGS
ColorTableViewDelegate Class Reference

Detailed Description

A delegate class to manage properties of ColorTableView.

Definition at line 34 of file ColorTableView.h.

#include <ColorTableView.h>

Inheritance diagram for ColorTableViewDelegate:
[legend]
Collaboration diagram for ColorTableViewDelegate:
[legend]

Public Member Functions

 ColorTableViewDelegate (QWidget *parent=nullptr)
 Constructor.
 
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
 Overwrites the paint-method to set user-defined properties instead of the default properties.
 
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const override
 

Constructor & Destructor Documentation

◆ ColorTableViewDelegate()

ColorTableViewDelegate::ColorTableViewDelegate ( QWidget * parent = nullptr)
inlineexplicit

Constructor.

Definition at line 40 of file ColorTableView.h.

41 : QItemDelegate(parent)
42 {
43 }

Member Function Documentation

◆ paint()

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

Overwrites the paint-method to set user-defined properties instead of the default properties.

Definition at line 29 of file ColorTableView.cpp.

32{
33 QColor val;
34 if (index.column() == 1)
35 {
36 if (index.data().canConvert(QMetaType::QColor))
37 {
38 val = index.data().value<QColor>();
39 QBrush brush(val);
40 painter->fillRect(option.rect, brush);
41 }
42 }
43 else
44 {
45 QItemDelegate::paint(painter, option, index);
46 }
47}

◆ sizeHint()

QSize ColorTableViewDelegate::sizeHint ( const QStyleOptionViewItem & option,
const QModelIndex & index ) const
override

Definition at line 49 of file ColorTableView.cpp.

51{
52 QSize s = QItemDelegate::sizeHint(option, index);
53 if (s.isValid())
54 {
55 s.setHeight(static_cast<int>(0.5 * s.height()));
56 }
57 return s;
58}

The documentation for this class was generated from the following files: