void QtPropertyTreeView::mousePressEvent(QMouseEvent *event) { QTreeWidget::mousePressEvent(event); QTreeWidgetItem *item = itemAt(event->pos()); if (item) { QtProperty *property = editorPrivate_->itemToProperty(item); if ((item != editorPrivate_->getEditedItem()) && (event->button() == Qt::LeftButton) && (header()->logicalIndexAt(event->pos().x()) == 1) && isItemEditable(item->flags())) { editItem(item, 1); } else if (property && !property->hasValue() && editorPrivate_->markPropertiesWithoutValue() && !rootIsDecorated()) { if (event->pos().x() + header()->offset() < 20) item->setExpanded(!item->isExpanded()); } } }
void QtPropertyEditorView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionViewItemV3 opt = option; bool hasValue = true; if (m_editorPrivate) { QtProperty *property = m_editorPrivate->indexToProperty(index); if (property) hasValue = property->hasValue(); } if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { const QColor c = option.palette.color(QPalette::Dark); painter->fillRect(option.rect, c); opt.palette.setColor(QPalette::AlternateBase, c); } else { const QColor c = m_editorPrivate->calculatedBackgroundColor( m_editorPrivate->indexToBrowserItem(index)); if (c.isValid()) { painter->fillRect(option.rect, c); opt.palette.setColor(QPalette::AlternateBase, c.lighter(112)); } } QTreeWidget::drawRow(painter, opt, index); QColor color = static_cast<QRgb>( QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); painter->save(); painter->setPen(QPen(color)); painter->drawLine(opt.rect.x(), opt.rect.bottom(), opt.rect.right(), opt.rect.bottom()); painter->restore(); }