Example #1
0
Handle<Shape *>
Shape::nextSibling() const
{
    WH_ASSERT(hasNextSibling());
    return nextSibling_;
}
Example #2
0
void KTreeItem::drawBranch( QPainter *p )
{
	KTreeWidget::TreeStyles styles = m_treeWidget->treeStyle();
	if(!(styles & KTreeWidget::HasBranch))
	{
		return;
	}
	int ndepth = m_treeWidget->nodeDepth(m_nodeid);
	QColor clr = branchColor();
	int wdepth = m_treeWidget->indentation();
	QMargins m = margins();
	QRectF winRt = rect();
	QBrush brush(clr, Qt::Dense4Pattern);
	int xbegin = m.left() - wdepth;
	int ymid = winRt.center().y();
	if(hasChildren())
	{
		p->fillRect(xbegin + 4, winRt.top(), 1, ymid - 4 - winRt.top(), brush);
		QPen penold = p->pen();
		p->setPen(clr);
		if(hasExpanded())
		{
			p->drawLine(xbegin+2, ymid, xbegin + 6, ymid);
		}
		else
		{
			p->drawLine(xbegin+2, ymid, xbegin + 6, ymid);
			p->drawLine(xbegin + 4, ymid - 2, xbegin + 4, ymid + 2);
		}
		p->setPen(penold);
		QRect rt(xbegin, ymid-4, 8, 8);
		p->drawRect(rt);
		p->fillRect(xbegin + 8, ymid, wdepth - 8, 1, brush);
		if(hasNextSibling(m_nodeid))
		{
			p->fillRect(xbegin + 4, ymid + 4, 1, winRt.bottom() - ymid - 4, brush);
		}
	}
	else
	{
		p->fillRect(xbegin + 4, winRt.top(), 1, ymid - winRt.top(), brush);
		p->fillRect(xbegin + 4, ymid, wdepth - 8, 1, brush);
		if(hasNextSibling(m_nodeid))
		{
			p->fillRect(xbegin + 4, ymid, 1, winRt.bottom() - ymid, brush);
		}
	}
	xbegin -= wdepth;
	KAbstractTreeModel *model = m_treeWidget->model();
	qint64 nodeid = m_nodeid;
	for(int i = 0; i < ndepth - 1; i++)
	{
		int x = xbegin + 4;
		int y = winRt.top();
		nodeid = model->parent(nodeid);
		if(model->hasNextSibling(nodeid))
		{
			p->fillRect(x, y, 1, winRt.height(), brush);
		}
		xbegin -= wdepth;
	}
}