| 119 | } |
| 120 | |
| 121 | void 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 | |
| 145 | QRect ToolItemDelegate::drawItemIcon(QPainter *painter, |
| 146 | const QStyleOptionViewItem &option, |