Example #1
0
void QtPropertyItemDelegate::hideAllChildOptionalWidgets(QtPropertyData* data)
{
	for(int i = 0; i < data->ChildCount(); i++)
	{
		QPair<QString, QtPropertyData *> childPair = data->ChildGet(i);
		QtPropertyData *childData = childPair.second;

		for (int j = 0; j < childData->GetOWCount(); j++)
		{
			childData->GetOW(j)->widget->hide();
		}

		hideAllChildOptionalWidgets(childData);
	}
}
Example #2
0
void QtPropertyItemDelegate::recalcOptionalWidgets(const QModelIndex &index, QStyleOptionViewItem *option) const
{
	QtPropertyData* data = index.data(QtPropertyItem::PropertyDataRole).value<QtPropertyData*>();

	if(NULL != data)
	{
		QWidget *owViewport = data->GetOWViewport();

		int prevOWSpace = 0;
		int owSpacing = 1;
		int optionRectRight = option->rect.right();

		int dataCount = data->GetOWCount();
		for (int i = 0; i < dataCount; ++i)
		{

			const QtPropertyOW *ow = data->GetOW(i);
			if(NULL != ow && NULL != owViewport && NULL != ow->widget)
			{
				QWidget *owWidget = ow->widget;
				int owWidth = ow->size.width();

				if(0 != owWidth)
				{
					QRect owRect = option->rect;
					owRect.setLeft(optionRectRight - owWidth - prevOWSpace);
					owRect.setRight(owRect.left() + owWidth);
									
					owWidget->setGeometry(owRect);
					owWidget->show();

					// if this widget isn't overlayed we should modify rect for tree view cell to be drawn in.
					if(!ow->overlay)
					{
						option->rect.setRight(owRect.left());
					}

					prevOWSpace += (owWidth + owSpacing);
				}
				else
				{
					owWidget->hide();
				}
			}
		}
	}
}