| 1374 | } |
| 1375 | |
| 1376 | void |
| 1377 | ShortcutDelegate::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 | |
| 1430 | KeybindRecorder::KeybindRecorder(QWidget* parent) |
| 1431 | : LineEdit(parent) |