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

Method drawItemState

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

Source from the content-addressed store, hash-verified

207}
208
209QRect 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
259void ProjectItemDelegate::drawFileNameItem(QPainter *painter,
260 const QStyleOptionViewItem &option,

Callers

nothing calls this directly

Calls 7

hasChildrenMethod · 0.45
modelMethod · 0.45
valueMethod · 0.45
removeMethod · 0.45
dataMethod · 0.45
colorMethod · 0.45
paintMethod · 0.45

Tested by

no test coverage detected