MCPcopy Create free account
hub / github.com/KDAB/GammaRay / paint

Method paint

plugins/sysinfo/standardpathswidget.cpp:56–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 }
55
56 void paint(QPainter *painter, const QStyleOptionViewItem &option,
57 const QModelIndex &index) const override
58 {
59 if (index.column() == 2) {
60 QStyleOptionViewItem opt = option;
61 initStyleOption(&opt, index);
62
63 const QWidget *widget = opt.widget;
64 QStyle *style = widget ? widget->style() : QApplication::style();
65 style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
66
67 const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
68 const QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget)
69 .adjusted(textMargin, 1, -textMargin, -1);
70 painter->setPen(((opt.state
71 & QStyle::State_Selected)
72 ? opt.palette.highlightedText()
73 : opt.palette.text())
74 .color());
75 painter->drawText(textRect, Qt::AlignBottom | Qt::AlignLeft,
76 index.sibling(index.row(), 3).data().toString());
77 } else {
78 QStyledItemDelegate::paint(painter, option, index);
79 }
80 }
81
82 QSize sizeHint(const QStyleOptionViewItem &option,
83 const QModelIndex &index) const override

Callers

nothing calls this directly

Calls 6

columnMethod · 0.80
styleMethod · 0.80
pixelMetricMethod · 0.80
textMethod · 0.80
rowMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected