Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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);
    }
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
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);
    }
}