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

Method paint

plugins/modelinspector/modelcontentdelegate.cpp:30–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28ModelContentDelegate::~ModelContentDelegate() = default;
29
30void ModelContentDelegate::paint(QPainter *painter, const QStyleOptionViewItem &origOption, const QModelIndex &index) const
31{
32 Q_ASSERT(index.isValid());
33 auto option = origOption;
34 initStyleOption(&option, index);
35 if (index.data(ModelContentProxyModel::DisabledRole).toBool())
36 option.state = option.state & ~QStyle::State_Enabled;
37
38 if (index.data(ModelContentProxyModel::SelectedRole).toBool()) {
39 // for non-selected cells
40 option.backgroundBrush = option.palette.highlight();
41 option.backgroundBrush.setStyle(Qt::BDiagPattern);
42
43 // TODO also render selection for currently selected cells
44 }
45
46 if (index.data(ModelContentProxyModel::IsDisplayStringEmptyRole).toBool()) {
47 option.palette.setColor(QPalette::Text, option.palette.color(QPalette::Disabled, QPalette::Text));
48 option.text = tr("<unnamed: row %1, column %2>").arg(index.row()).arg(index.column());
49 }
50
51 QStyle *style = QApplication::style();
52 style->drawControl(QStyle::CE_ItemViewItem, &option, painter, nullptr);
53}

Callers

nothing calls this directly

Calls 5

setStyleMethod · 0.80
rowMethod · 0.80
columnMethod · 0.80
isValidMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected