Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/CaptureModeDelegate.cpp
- This file was added.
1 | #include "CaptureModeDelegate.h" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | #include <QPainter> | ||||
4 | #include <QDebug> | ||||
5 | | ||||
6 | void CaptureModeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { | ||||
7 | QStyledItemDelegate::paint(painter, option, index.sibling(index.row(), 2)); | ||||
8 | QStyleOptionViewItem opt = option; | ||||
9 | | ||||
10 | /*QVariant value = index.data(Qt::FontRole); | ||||
11 | if (value.isValid() && !value.isNull()) { | ||||
12 | opt.font = qvariant_cast<QFont>(value).resolve(opt.font); | ||||
13 | opt.fontMetrics = QFontMetrics(opt.font); | ||||
14 | } | ||||
15 | | ||||
16 | value = index.data(Qt::ForegroundRole); | ||||
17 | if(value.canConvert<QBrush>()) | ||||
18 | opt.palette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));*/ | ||||
19 | | ||||
20 | | ||||
21 | painter->setFont(opt.font); | ||||
22 | painter->setBrush(opt.backgroundBrush); | ||||
23 | QString leftText = index.data(Qt::DisplayRole).toString(); | ||||
24 | QRect bounds; | ||||
25 | bounds.setWidth(option.rect.width() - 10); | ||||
26 | bounds.setHeight(option.rect.height()); | ||||
27 | bounds.moveCenter(option.rect.center()); | ||||
28 | painter->drawText(bounds, Qt::AlignLeft | Qt::AlignVCenter, leftText); | ||||
29 | QString text = index.sibling(index.row(), 1).data(Qt::DisplayRole).toString(); | ||||
30 | painter->drawText(bounds, Qt::AlignRight | Qt::AlignVCenter, text); | ||||
31 | } |