| 180 | } |
| 181 | |
| 182 | void 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 | |
| 209 | QRect ProjectItemDelegate::drawItemState(QPainter *painter, |
| 210 | const QStyleOptionViewItem &option, |