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

Method drawCheckBox

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

Source from the content-addressed store, hash-verified

180}
181
182void ProjectItemDelegate::drawCheckBox(int depth,
183 QPainter *painter,
184 const QStyleOptionViewItem &option,
185 const QModelIndex &index) const
186{
187 QStyleOptionButton opt;
188 opt.rect = checkBoxRect(depth, option.rect);
189 opt.state = option.state;
190
191 bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected;
192 if (isSelected) {
193 opt.palette.setColor(QPalette::Foreground, option.palette.color(QPalette::HighlightedText));
194 opt.palette.setColor(QPalette::Highlight, option.palette.color(QPalette::HighlightedText));
195 }
196
197 Qt::CheckState checkState = static_cast<Qt::CheckState>(index.data(Qt::CheckStateRole).toInt());
198 if (checkState == Qt::Checked)
199 opt.state |= QStyle::State_On;
200 else if (checkState == Qt::PartiallyChecked)
201 opt.state |= QStyle::State_NoChange;
202 else
203 opt.state |= QStyle::State_Off;
204
205 // Draw the checkbox using the widget's style
206 option.widget->style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, painter, option.widget);
207}
208
209QRect ProjectItemDelegate::drawItemState(QPainter *painter,
210 const QStyleOptionViewItem &option,

Callers

nothing calls this directly

Calls 4

styleMethod · 0.80
setColorMethod · 0.45
colorMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected