MCPcopy Create free account
hub / github.com/baldurk/renderdoc / paint

Method paint

qrenderdoc/Windows/Dialogs/ConfigEditor.cpp:395–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395void SettingDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
396 const QModelIndex &index) const
397{
398 if(index.column() == SettingModel::Column_ResetButton)
399 {
400 SDObject *o = (SDObject *)index.data(Qt::UserRole).toULongLong();
401
402 SDObject *def = o->FindChild("default");
403 SDObject *val = o->FindChild("value");
404
405 if(val && def && !val->HasEqualValue(def))
406 {
407 // draw the item without text, so we get the proper background/selection/etc.
408 // we'd like to be able to use the parent delegate's paint here, but either it calls to
409 // QStyledItemDelegate which will re-fetch the text (bleh), or it calls to the manual
410 // delegate which could do anything. So for this case we just use the style and skip the
411 // delegate and hope it works out.
412 QStyleOptionViewItem opt = option;
413 QStyledItemDelegate::initStyleOption(&opt, index);
414 opt.text.clear();
415 m_Editor->style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, m_Editor);
416
417 QStyleOptionToolButton buttonOpt;
418
419 int size = m_Editor->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, m_Editor);
420
421 buttonOpt.iconSize = QSize(size, size);
422 buttonOpt.subControls = 0;
423 buttonOpt.activeSubControls = 0;
424 buttonOpt.features = QStyleOptionToolButton::None;
425 buttonOpt.arrowType = Qt::NoArrow;
426 buttonOpt.state = QStyle::State_Active | QStyle::State_Enabled | QStyle::State_AutoRaise;
427
428 buttonOpt.rect = option.rect.adjusted(0, 0, -1, -1);
429 buttonOpt.icon = Icons::arrow_undo();
430
431 if(m_View->currentHoverIndex() == index)
432 buttonOpt.state |= QStyle::State_MouseOver;
433
434 m_Editor->style()->drawComplexControl(QStyle::CC_ToolButton, &buttonOpt, painter, m_Editor);
435 return;
436 }
437 }
438
439 return QStyledItemDelegate::paint(painter, option, index);
440}
441
442QSize SettingDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
443{

Callers

nothing calls this directly

Calls 10

currentHoverIndexMethod · 0.80
QSizeClass · 0.50
paintFunction · 0.50
columnMethod · 0.45
dataMethod · 0.45
clearMethod · 0.45
drawControlMethod · 0.45
styleMethod · 0.45
pixelMetricMethod · 0.45
drawComplexControlMethod · 0.45

Tested by

no test coverage detected