| 257 | } |
| 258 | |
| 259 | void 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 | |
| 287 | void ProjectItemDelegate::drawIcon(QPainter *painter, const QStyleOptionViewItem &option, const QIcon &icon, const QRect &rect) const |
| 288 | { |