| 172 | } |
| 173 | |
| 174 | QRect ToolItemDelegate::drawExpandArrow(QPainter *painter, |
| 175 | const QStyleOptionViewItem &option, |
| 176 | const QModelIndex &index) const |
| 177 | { |
| 178 | QStyleOptionViewItem opt = option; |
| 179 | opt.rect = arrowRect(opt.rect).marginsRemoved(QMargins(5, 5, 5, 5)); |
| 180 | |
| 181 | painter->save(); |
| 182 | bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected; |
| 183 | if (isSelected) { |
| 184 | painter->setPen(option.palette.color(QPalette::Active, QPalette::HighlightedText)); |
| 185 | } else { |
| 186 | painter->setPen(option.palette.color(QPalette::Active, QPalette::Text)); |
| 187 | } |
| 188 | |
| 189 | auto style = option.widget->style(); |
| 190 | if (view()->isExpanded(index)) { |
| 191 | style->drawPrimitive(QStyle::PE_IndicatorArrowDown, &opt, painter, nullptr); |
| 192 | } else { |
| 193 | style->drawPrimitive(QStyle::PE_IndicatorArrowRight, &opt, painter, nullptr); |
| 194 | } |
| 195 | |
| 196 | painter->restore(); |
| 197 | return opt.rect; |
| 198 | } |
| 199 | |
| 200 | QRect ToolItemDelegate::arrowRect(const QRect &itemRect) const |
| 201 | { |