| 21 | } |
| 22 | |
| 23 | void QmitkLabelColorItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, |
| 24 | const QModelIndex &index) const |
| 25 | { |
| 26 | QVariant data = index.data(Qt::EditRole); |
| 27 | |
| 28 | if (data.canConvert<QColor>()) |
| 29 | { |
| 30 | QColor color = data.value<QColor>(); |
| 31 | |
| 32 | painter->fillRect(option.rect, color); |
| 33 | } |
| 34 | else |
| 35 | { |
| 36 | QStyledItemDelegate::paint(painter, option, index); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | bool QmitkLabelColorItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &, |
| 41 | const QModelIndex &index) |