QWidget * PropertyDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const { AbstractProperty * property = retrieveProperty(index); if (property->isCollection()) return QStyledItemDelegate::createEditor(parent, option, index); return m_editorFactory->createEditor(*property, parent); }
void PropertyBrowser::expandAllGroups() { QAbstractItemModel * model = this->model(); QModelIndexList indexes = model->match(model->index(0,0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard|Qt::MatchRecursive); for (QModelIndex index : indexes) { if (!index.isValid()) continue; AbstractProperty * property = retrieveProperty(index); if (property->isGroup() && model->hasChildren(index)) expand(index); } }
void PropertyDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { QStyledItemDelegate::paint(painter, option, index); AbstractProperty * property = retrieveProperty(index); if (property->isCollection()) return; QStyleOptionViewItem opt = option; initStyleOption(&opt, index); m_propertyPainter->drawValue(painter, opt, *property); }
void PropertyBrowser::onRowsInserted(const QModelIndex & parentIndex, int first, int last) { QAbstractItemModel * model = this->model(); for (int i = first; i <= last; ++i) { QModelIndex index = model->index(i, 0, parentIndex); if (!index.isValid()) continue; AbstractProperty * property = retrieveProperty(index); if (property->isGroup() && model->hasChildren(index)) expand(index); } }