| 31 | } |
| 32 | |
| 33 | void CheckListItemProxyStyle::drawCheckBox(QPainter* painter, const QStyleOptionViewItem* option) const |
| 34 | { |
| 35 | QString iconName; |
| 36 | const auto checkState = option->checkState; |
| 37 | if (checkState == Qt::PartiallyChecked) { |
| 38 | const int effectiveEnabledState = option->index.data(CheckListModel::EffectiveEnabledStateRole).toInt(); |
| 39 | if (effectiveEnabledState != CheckGroup::Enabled) { |
| 40 | return; |
| 41 | } |
| 42 | iconName = QStringLiteral("dialog-ok"); |
| 43 | } else { |
| 44 | iconName = (checkState == Qt::Unchecked) ? QStringLiteral("emblem-remove") : QStringLiteral("emblem-added"); |
| 45 | } |
| 46 | |
| 47 | const auto icon = QIcon::fromTheme(iconName); |
| 48 | |
| 49 | const QIcon::Mode iconMode = (option->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; |
| 50 | |
| 51 | icon.paint(painter, option->rect, option->decorationAlignment, iconMode, QIcon::On); |
| 52 | } |
| 53 | |
| 54 | } |
| 55 | |