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

Method drawFileNameItem

src/plugins/smartut/common/projectitemdelegate.cpp:259–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259void ProjectItemDelegate::drawFileNameItem(QPainter *painter,
260 const QStyleOptionViewItem &option,
261 const QModelIndex &index,
262 const QRect &iconRect) const
263{
264 QStyleOptionViewItem opt = option;
265 painter->setFont(opt.font);
266
267 QRect stateRect;
268 if (view->viewType() == ProjectTreeView::UnitTest)
269 stateRect = drawItemState(painter, opt, index);
270
271 QRect nameRect = opt.rect;
272 nameRect.setLeft(iconRect.right() + kPadding);
273 if (stateRect.isValid())
274 nameRect.setRight(stateRect.left() - kPadding);
275
276 QString fileName = index.data(Qt::DisplayRole).toString();
277 if (opt.state & QStyle::State_Selected) {
278 painter->setPen(opt.palette.color(QPalette::Normal, QPalette::HighlightedText));
279 } else {
280 painter->setPen(opt.palette.color(QPalette::Normal, QPalette::Text));
281 }
282
283 QString displayText = opt.fontMetrics.elidedText(fileName, Qt::ElideRight, nameRect.width());
284 painter->drawText(nameRect, displayText);
285}
286
287void ProjectItemDelegate::drawIcon(QPainter *painter, const QStyleOptionViewItem &option, const QIcon &icon, const QRect &rect) const
288{

Callers

nothing calls this directly

Calls 10

viewTypeMethod · 0.80
rightMethod · 0.80
leftMethod · 0.80
widthMethod · 0.80
setFontMethod · 0.45
isValidMethod · 0.45
toStringMethod · 0.45
dataMethod · 0.45
colorMethod · 0.45
drawTextMethod · 0.45

Tested by

no test coverage detected