| 207 | } |
| 208 | |
| 209 | QRect ProjectItemDelegate::drawItemState(QPainter *painter, |
| 210 | const QStyleOptionViewItem &option, |
| 211 | const QModelIndex &index) const |
| 212 | { |
| 213 | if (index.model()->hasChildren(index)) |
| 214 | return {}; |
| 215 | |
| 216 | auto stopSpinner = [&] { |
| 217 | if (auto spinner = spinners.value(index)) { |
| 218 | delete spinner; |
| 219 | spinners.remove(index); |
| 220 | } |
| 221 | }; |
| 222 | |
| 223 | QRect stateRect = itemStateRect(option.rect); |
| 224 | auto state = static_cast<ItemState>(index.data(ItemStateRole).toInt()); |
| 225 | switch (state) { |
| 226 | case Generating: { |
| 227 | auto *spinner = findOrCreateSpinnerPainter(index); |
| 228 | QColor color = option.state & QStyle::State_Selected ? option.palette.color(QPalette::HighlightedText) |
| 229 | : option.palette.color(QPalette::Highlight); |
| 230 | |
| 231 | spinner->paint(*painter, color, stateRect); |
| 232 | return stateRect; |
| 233 | } |
| 234 | case Waiting: |
| 235 | stopSpinner(); |
| 236 | drawIcon(painter, option, QIcon::fromTheme("uc_wait"), stateRect); |
| 237 | return stateRect; |
| 238 | case Completed: |
| 239 | stopSpinner(); |
| 240 | drawIcon(painter, option, QIcon::fromTheme("uc_success"), stateRect); |
| 241 | return stateRect; |
| 242 | case Failed: |
| 243 | stopSpinner(); |
| 244 | drawIcon(painter, option, QIcon::fromTheme("uc_failure"), stateRect); |
| 245 | return stateRect; |
| 246 | case Ignored: |
| 247 | stopSpinner(); |
| 248 | drawIcon(painter, option, QIcon::fromTheme("uc_ignore"), stateRect); |
| 249 | return stateRect; |
| 250 | case None: |
| 251 | default: |
| 252 | break; |
| 253 | } |
| 254 | |
| 255 | stopSpinner(); |
| 256 | return {}; |
| 257 | } |
| 258 | |
| 259 | void ProjectItemDelegate::drawFileNameItem(QPainter *painter, |
| 260 | const QStyleOptionViewItem &option, |