MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / paint

Method paint

Gui/PreferencesPanel.cpp:1376–1428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1374}
1375
1376void
1377ShortcutDelegate::paint(QPainter * painter,
1378 const QStyleOptionViewItem & option,
1379 const QModelIndex & index) const
1380{
1381 QTreeWidgetItem* item = tree->itemFromIndex_natron(index);
1382
1383 if (!item) {
1384 QStyledItemDelegate::paint(painter, option, index);
1385
1386 return;
1387 }
1388
1389 ///Determine whether the item is top level or not
1390 bool isTopLevel = false;
1391 int topLvlCount = tree->topLevelItemCount();
1392 for (int i = 0; i < topLvlCount; ++i) {
1393 if (tree->topLevelItem(i) == item) {
1394 isTopLevel = true;
1395 break;
1396 }
1397 }
1398
1399 QFont font = painter->font();
1400 QPen pen;
1401
1402 if (isTopLevel) {
1403 font.setBold(true);
1404 font.setPointSize(13);
1405 pen.setColor(Qt::gray);
1406 } else {
1407 font.setBold(false);
1408 font.setPointSize(11);
1409 if ( item->isDisabled() ) {
1410 pen.setColor(Qt::gray);
1411 } else {
1412 pen.setColor(Qt::lightGray);
1413 }
1414 }
1415 painter->setFont(font);
1416 painter->setPen(pen);
1417
1418 // get the proper subrect from the style
1419 QStyle *style = QApplication::style();
1420 QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &option);
1421
1422 ///Draw the item name column
1423 if (option.state & QStyle::State_Selected) {
1424 painter->fillRect( geom, option.palette.highlight() );
1425 }
1426 QRect r;
1427 painter->drawText(geom, Qt::TextSingleLine, item->data(index.column(), Qt::DisplayRole).toString(), &r);
1428} // paint
1429
1430KeybindRecorder::KeybindRecorder(QWidget* parent)
1431 : LineEdit(parent)

Callers

nothing calls this directly

Calls 6

itemFromIndex_natronMethod · 0.80
setBoldMethod · 0.80
setFontMethod · 0.80
columnMethod · 0.80
setColorMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected