Logo Search packages:      
Sourcecode: kdbg version File versions

void KTreeViewItem::paintTree ( QPainter *  p,
int  indent,
int  cellHeight,
const QColorGroup &  cg 
) const [protected, virtual]

paints the item's tree part.

Definition at line 381 of file ktreeview.cpp.

References getChild(), getParent(), hasSibling(), KTreeView::indentation(), KTreeView::itemIndent, owner, and parent.

Referenced by paint().

{
    int parentLeaderX = indent - (owner->itemIndent / 2);
    int cellCenterY = cellHeight / 2;
    int cellBottomY = cellHeight - 1;
    int itemLeaderX = indent - 1;

    p->setPen(cg.background());

    /*
     * If this is not the first item in the tree draw the line up
     * towards parent or sibling.
     */
    if (parent->parent != 0 || parent->getChild() != this)
      p->drawLine(parentLeaderX, 0, parentLeaderX, cellCenterY);

    // draw the line down towards sibling
    if (sibling) 
      p->drawLine(parentLeaderX, cellCenterY, parentLeaderX, cellBottomY);

    /*
     * If this item has children or siblings in the tree or is a child of
     * an item other than the root item then draw the little line from the
     * item out to the left.
     */
    if (sibling || (doExpandButton && (child || delayedExpanding)) ||
      parent->parent != 0 ||
      /*
       * The following handles the case of an item at the end of the
       * topmost level which doesn't have children.
       */
      parent->getChild() != this)
    {
      p->drawLine(parentLeaderX, cellCenterY, itemLeaderX, cellCenterY);
    }

    /*
     * If there are siblings of ancestors below, draw our portion of the
     * branches that extend through this cell.
     */
    KTreeViewItem* prevRoot = parent;
    while (prevRoot->getParent() != 0) {  /* while not root item */
      assert(prevRoot->owner == owner);
      if (prevRoot->hasSibling()) {
          int sibLeaderX = owner->indentation(prevRoot) - (owner->itemIndent / 2);
          p->drawLine(sibLeaderX, 0, sibLeaderX, cellBottomY);
      }
      prevRoot = prevRoot->getParent();
    }
}


Generated by  Doxygen 1.6.0   Back to index