| 134 | } |
| 135 | |
| 136 | void TaskDelegate::paintItemBackground(QPainter *painter, const QStyleOptionViewItem &option, |
| 137 | const QModelIndex &index) const |
| 138 | { |
| 139 | painter->save(); |
| 140 | |
| 141 | if (option.widget) { |
| 142 | #ifdef DTKWIDGET_CLASS_DPaletteHelper |
| 143 | DPalette pl(DPaletteHelper::instance()->palette(option.widget)); |
| 144 | #else |
| 145 | DPalette pl = DGuiApplicationHelper::instance()->applicationPalette(); |
| 146 | #endif |
| 147 | QColor baseColor = pl.color(DPalette::ColorGroup::Active, DPalette::ColorType::ItemBackground); |
| 148 | QColor adjustColor = baseColor; |
| 149 | |
| 150 | bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected; |
| 151 | |
| 152 | if (isSelected) { |
| 153 | adjustColor = option.palette.color(DPalette::ColorGroup::Active, QPalette::Highlight); |
| 154 | } else if (option.state & QStyle::StateFlag::State_MouseOver) { |
| 155 | // hover color |
| 156 | adjustColor = DGuiApplicationHelper::adjustColor(baseColor, 0, 0, 0, 0, 0, 0, +10); |
| 157 | } else { |
| 158 | // alternately background color |
| 159 | painter->setOpacity(0); |
| 160 | if (index.row() % 2 == 0) { |
| 161 | adjustColor = DGuiApplicationHelper::adjustColor(baseColor, 0, 0, 0, 0, 0, 0, +5); |
| 162 | painter->setOpacity(1); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // set paint path |
| 167 | QPainterPath path; |
| 168 | path.addRoundedRect(option.rect, kRectRadius, kRectRadius); |
| 169 | painter->fillPath(path, adjustColor); |
| 170 | } |
| 171 | |
| 172 | painter->restore(); |
| 173 | } |
| 174 | |
| 175 | void TaskDelegate::paintItemColumn(QPainter *painter, const QStyleOptionViewItem &option, |
| 176 | const QModelIndex &index, const QRect &iconRect) const |
nothing calls this directly
no test coverage detected