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

Method drawExpandArrow

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

Source from the content-addressed store, hash-verified

172}
173
174QRect 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
200QRect ToolItemDelegate::arrowRect(const QRect &itemRect) const
201{

Callers

nothing calls this directly

Calls 4

styleMethod · 0.80
restoreMethod · 0.80
saveMethod · 0.45
colorMethod · 0.45

Tested by

no test coverage detected