MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / drawToolItem

Method drawToolItem

src/plugins/binarytools/models/toolitemdelegate.cpp:121–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121void ToolItemDelegate::drawToolItem(QPainter *painter,
122 const QStyleOptionViewItem &option,
123 const QModelIndex &index) const
124{
125 QRect extraRect;
126 if (!index.parent().isValid())
127 extraRect = drawExpandArrow(painter, option, index);
128 else
129 extraRect = drawItemIcon(painter, option, index);
130
131 QRect itemRect = option.rect;
132 itemRect.setLeft(extraRect.right() + 6);
133
134 QString toolName = index.data(Qt::DisplayRole).toString();
135 if (option.state & QStyle::State_Selected) {
136 painter->setPen(option.palette.color(QPalette::Normal, QPalette::HighlightedText));
137 } else {
138 painter->setPen(option.palette.color(QPalette::Normal, QPalette::Text));
139 }
140
141 QString displayText = option.fontMetrics.elidedText(toolName, Qt::ElideRight, itemRect.width());
142 painter->drawText(itemRect, displayText);
143}
144
145QRect ToolItemDelegate::drawItemIcon(QPainter *painter,
146 const QStyleOptionViewItem &option,

Callers

nothing calls this directly

Calls 8

rightMethod · 0.80
widthMethod · 0.80
isValidMethod · 0.45
parentMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
colorMethod · 0.45
drawTextMethod · 0.45

Tested by

no test coverage detected