Source Code (Use browser search to find items of interest.)

Class Index

kdat'KTreeViewItem (./kdeadmin/kdat/ktreeview.h:40)

class KTreeViewItem
{
    friend class KTreeView;
public:
    /**
     * Item constructor. While text defaults to a null string, and the
     * item can be constructed this way, the text has to be non-null when
     * the item is added to the tree, or it will not be inserted.
     * 
     * The constructor sets the delete-children flag to false. This flag
     * tells the item whether it shall delete the child items when it is
     * itself deleted. By default the creator of the item is responsible to
     * also delete the child items. (However, the versions of
     * KTreeView::appendChildItem and KTreeView::insertChildItem that do
     * not take a KTreeViewItem set the delete-children flag to true.)
     */
    KTreeViewItem(const QString& theText = QString()); // text can not be null when added to the list!
    KTreeViewItem(const QString& theText, const QPixmap& thePixmap);

    /**
     * Destructor. It destroys its children if this item has been marked
     * with setDeleteChildren(true).
     */
    virtual ~KTreeViewItem();

    /**
     * Appends a new (direct) child item at the end. It does not update
     * administrative data in newChild except for its parent (which is this
     * item) and owner.
     */
    void appendChild(KTreeViewItem* newChild);

    /**
     * Returns a pointer to the child item at the given index in this
     * item's sub tree, or 0 if not found.
     */	
    KTreeViewItem* childAt(int index) const;

    /**
     * Returns the number of child items in this item's sub tree.
     */
    uint childCount() const;

    /**
     * Returns the index in this items sub tree of the given item or -1 if
     * not found. The specified child must not be 0.
     */
    int childIndex(KTreeViewItem* child) const;

    /**
     * Determines whether the specified point is inside the expand button.
     */
    bool expandButtonClicked(const QPoint& coord) const;

    /**
     * Give the item a chance to process the mouse event.
     */
    virtual bool mousePressEvent( const QPoint& coord );

    /**
     * Returns a pointer to the first child item in this item's sub tree, or
     * 0 if none.
     */
    KTreeViewItem* getChild() const;

    /**
     * Returns a pointer to the parent of this item, or 0 if none.
     */
    KTreeViewItem* getParent() const;

    /**
     * Returns a reference to this item's pixmap. If there is no pixmap
     * associated with this item, it will return a reference to a valid,
     * null QPixmap.
     */
    const QPixmap& getPixmap() const;

    /**
     * Returns a pointer to the next item in the same branch below this
     * one, or 0 if none.
     */
    KTreeViewItem* getSibling() const;

    /**
     * Returns this item's text.
     */
    const QString& getText() const;

    /**
     * Indicates whether this item has any children.
     */
    bool hasChild() const;

    /**
     * Indicates whether this item has a parent.
     */
    bool hasParent() const;

    /**
     * Indicates whether this item has a sibling item, that is, an item
     * that would be displayed below it at the same level as this item.
     */
    bool hasSibling() const;

    /**
     * Inserts the a new (direct) child in this item before the child at
     * the specified index (first child is index 0). If there is no child
     * at the specified index, the item is appended. It does not update
     * administrative data in newChild except for its parent (which is this
     * item) and owner.
     */
    void insertChild(int index, KTreeViewItem* newChild);

    /**
     * Indicateds whether the item is expanded, that is, whether the child
     * items (if any) would be visible if this item were visible.
     * 
     * Note: If this function returns true, it does not necessarily indicate that
     * this item is visible or that this item has any children.
     */
    bool isExpanded() const;

    /**
     * Returns true if the item is visible. An item is visible if all its
     * ancestors are expanded.
     */
    bool isVisible() const;

    /**
     * Removes the specified (direct) child from this item and returns
     * true. If it is not a direct child of this item, nothing happens, and
     * false is returned. This function does not update the owning
     * KTreeView.
     */
    bool removeChild(KTreeViewItem* child);

    /**
     * Sets the delayed-expanding flag. If this flag is true, the expanding
     * signal is emitted when the item is about to be expanded. The expand
     * button is always painted for this item, even if it doesn't have
     * children.
     */
    void setDelayedExpanding(bool flag);

    /**
     * Tells the item whether it should delete its children when it is
     * deleted. The default is false, which means that the child items must
     * be deleted explicitly.
     */
    void setDeleteChildren(bool flag);

    void setDrawExpandButton(bool doit);

    void setDrawText(bool doit);

    void setDrawTree(bool doit);

    void setExpanded(bool is);

    /**
     * Sets the item pixmap to the given pixmap. It does not redraw the
     * item or update the owning KTreeView.
     */
    void setPixmap(const QPixmap& pm);

    /**
     * Sets the item text. This function does not redraw the item or update
     * the owning KTreeView.
     */
     void setText(const QString& t);

protected:
    /**
     * Returns the bounding rectangle of the item.
     */
    virtual QRect boundingRect(int indent) const;

    /**
     * Returns the hieght of the item. The default implementation uses font
     * metrics of the owning KTreeView widget.
     */
    virtual int height() const;

    /*
     * Returns the height of the item depending on the passed-in font
     * metrics.
     */
    virtual int height(const QFontMetrics& fm) const;

    /**
     * Paints the item: pixmap, text, expand button, parent branches
     */
    virtual void paint(QPainter* p, int indent,
			const QColorGroup& cg, bool highlighted) const;

    /**
     * paints the expand button
     */
    virtual void paintExpandButton(QPainter* p, int indent, int cellHeight) const;

    /**
     * paints the highlighted text
     */
    virtual void paintHighlight(QPainter* p, int indent,
			const QColorGroup& cg, bool hasFocus,
			Qt::GUIStyle style) const;

    /**
     * paints the item's text
     */
    virtual void paintText(QPainter* p, int indent, int cellHeight,
			   const QColorGroup& cg, bool highlighted) const;

    /**
     * paints the item's tree part.
     */
    virtual void paintTree(QPainter* p, int indent, int cellHeight) const;

    /**
     * Internal function that counts the number of child items.
     */
    void synchNumChildren();
    
    /**
     * Returns the bounding rectangle of the text.
     */
    virtual QRect textBoundingRect(int indent) const;

    /**
     * Returns the width of the item taking into account the specified
     * indentation. The default implementation uses font metrics of the
     * owning KTreeView widget.
     */
    virtual int width(int indent) const;

    /**
     * Returns the width of the item depending on the passed-in font
     * metrics and taking into account the specified indentation.
     */
    virtual int width(int indent, const QFontMetrics& fm) const;

protected:
    /** The KTreeView that this item belongs to */
    KTreeView* owner;
    int numChildren;
    bool doExpandButton;
    bool expanded;
    bool delayedExpanding;
    bool doTree;
    bool doText;
    mutable QRect expandButton;		/* is set in paint() */
    KTreeViewItem* child;
    KTreeViewItem* parent;
    KTreeViewItem* sibling;
    QPixmap pixmap;
    QString text;
    bool deleteChildren;
};

// easier declarations of function prototypes for forEvery type functions

kdat'KTreeViewItem::KTreeViewItem() (./kdeadmin/kdat/ktreeview.cpp:42)

KTreeViewItem::KTreeViewItem(const QString& theText) :
	owner(0),
	numChildren(0),
	doExpandButton(true),
	expanded(false),
	delayedExpanding(false),
	doTree(true),
	doText(true),
	child(0),
	parent(0),
	sibling(0),
	deleteChildren(false)
{
    text = theText;
}

// constructor that takes a pixmap

kdat'KTreeViewItem::KTreeViewItem() (./kdeadmin/kdat/ktreeview.cpp:59)

KTreeViewItem::KTreeViewItem(const QString& theText,
			     const QPixmap& thePixmap) :
	owner(0),
	numChildren(0),
	doExpandButton(true),
	expanded(false),
	delayedExpanding(false),
	doTree(true),
	doText(true),
	child(0),
	parent(0),
	sibling(0),
	deleteChildren(false)
{
    text = theText;
    pixmap = thePixmap;
}

// destructor

kdat'KTreeViewItem::~KTreeViewItem() (./kdeadmin/kdat/ktreeview.cpp:78)

KTreeViewItem::~KTreeViewItem()
{
    if (deleteChildren) {
	// remove the children
	KTreeViewItem* i = child;
	while (i) {
	    KTreeViewItem* d = i;
	    i = i->getSibling();
	    delete d;
	}
    }
}

// appends a direct child

kdat'KTreeViewItem::appendChild() (./kdeadmin/kdat/ktreeview.cpp:92)

void KTreeViewItem::appendChild(KTreeViewItem* newChild)
{
    newChild->parent = this;
    newChild->owner = owner;
    if (!getChild()) {
	child = newChild;
    }
    else {
	KTreeViewItem* lastChild = getChild();
	while (lastChild->hasSibling()) {
	    lastChild = lastChild->getSibling();
	}
	lastChild->sibling = newChild;
    }
    newChild->sibling = 0;
    numChildren++;
}

// returns the bounding rectangle of the item content (not including indent
// and branches) for hit testing

kdat'KTreeViewItem::boundingRect() (./kdeadmin/kdat/ktreeview.cpp:112)

QRect KTreeViewItem::boundingRect(int indent) const
{
    const QFontMetrics& fm = owner->fontMetrics();
    int rectX = indent;
    int rectY = 1;
    int rectW = width(indent, fm) - rectX;
    int rectH = height(fm) - 2;
    return QRect(rectX, rectY, rectW, rectH);
}

// returns the child item at the specified index

kdat'KTreeViewItem::childAt() (./kdeadmin/kdat/ktreeview.cpp:123)

KTreeViewItem* KTreeViewItem::childAt(int index) const
{
    if (!hasChild())
	return 0;
    KTreeViewItem* item = getChild();
    while (index > 0 && item != 0) {
	item = item->getSibling();
	index--;
    }
    return item;
}

// returns the number of children this item has

kdat'KTreeViewItem::childCount() (./kdeadmin/kdat/ktreeview.cpp:136)

uint KTreeViewItem::childCount() const
{
    return numChildren;
}

/* returns the index of the given child item in this item's branch */

kdat'KTreeViewItem::childIndex() (./kdeadmin/kdat/ktreeview.cpp:142)

int KTreeViewItem::childIndex(KTreeViewItem* searched) const
{
    assert(searched != 0);
    int index = 0;
    KTreeViewItem* item = getChild();
    while (item != 0 && item != searched) {
	item = item->getSibling();
	index++;
    }
    return item == 0  ?  -1  :  index;
}

// indicates whether mouse press is in expand button

kdat'KTreeViewItem::expandButtonClicked() (./kdeadmin/kdat/ktreeview.cpp:155)

inline bool KTreeViewItem::expandButtonClicked(const QPoint& coord) const
{
  return expandButton.contains(coord);
}


kdat'KTreeViewItem::mousePressEvent() (./kdeadmin/kdat/ktreeview.cpp:160)

bool KTreeViewItem::mousePressEvent( const QPoint& )
{
    return FALSE;
}

// returns a pointer to first child item

kdat'KTreeViewItem::getChild() (./kdeadmin/kdat/ktreeview.cpp:166)

KTreeViewItem* KTreeViewItem::getChild() const
{
    return child;
}

// returns the parent of this item

kdat'KTreeViewItem::getParent() (./kdeadmin/kdat/ktreeview.cpp:172)

KTreeViewItem* KTreeViewItem::getParent() const
{
    return parent;
}

// returns reference to the item pixmap

kdat'KTreeViewItem::getPixmap() (./kdeadmin/kdat/ktreeview.cpp:178)

const QPixmap& KTreeViewItem::getPixmap() const
{
    return pixmap;
}

// returns the sibling below this item

kdat'KTreeViewItem::getSibling() (./kdeadmin/kdat/ktreeview.cpp:184)

KTreeViewItem* KTreeViewItem::getSibling() const
{
    return sibling;
}

// returns a pointer to the item text

kdat'KTreeViewItem::getText() (./kdeadmin/kdat/ktreeview.cpp:190)

const QString& KTreeViewItem::getText() const
{
    return text;
}

// indicates whether this item has any children

kdat'KTreeViewItem::hasChild() (./kdeadmin/kdat/ktreeview.cpp:196)

bool KTreeViewItem::hasChild() const
{
    return child != 0;
}

// indicates whether this item has a parent

kdat'KTreeViewItem::hasParent() (./kdeadmin/kdat/ktreeview.cpp:202)

bool KTreeViewItem::hasParent() const
{
    return parent != 0;
}

// indicates whether this item has a sibling below it

kdat'KTreeViewItem::hasSibling() (./kdeadmin/kdat/ktreeview.cpp:208)

bool KTreeViewItem::hasSibling() const
{
    return sibling != 0;
}


kdat'KTreeViewItem::height() (./kdeadmin/kdat/ktreeview.cpp:213)

int KTreeViewItem::height() const
{
    assert(owner != 0);
    return height(owner->fontMetrics());
}

// returns the maximum height of text and pixmap including margins
// or -1 if item is empty -- SHOULD NEVER BE -1!

kdat'KTreeViewItem::height() (./kdeadmin/kdat/ktreeview.cpp:221)

int KTreeViewItem::height(const QFontMetrics& fm) const
{
    int maxHeight = pixmap.height();
    int textHeight = fm.ascent() + fm.leading();
    maxHeight = textHeight > maxHeight ? textHeight : maxHeight;
    return maxHeight == 0 ? -1 : maxHeight + 8;
}

// inserts child item at specified index in branch

kdat'KTreeViewItem::insertChild() (./kdeadmin/kdat/ktreeview.cpp:230)

void KTreeViewItem::insertChild(int index, KTreeViewItem* newChild)
{
    if (index < 0) {
	appendChild(newChild);
	return;
    }
    newChild->parent = this;
    newChild->owner = owner;
    if (index == 0) {
	newChild->sibling = getChild();
	child = newChild;
    }
    else {
	KTreeViewItem* prevItem = getChild();
	KTreeViewItem* nextItem = prevItem->getSibling();
	while (--index > 0 && nextItem) {
	    prevItem = nextItem;
	    nextItem = prevItem->getSibling();
	}
	prevItem->sibling = newChild;
	newChild->sibling = nextItem;
    }
    numChildren++;

    if ( owner ) {
        owner->updateVisibleItems();
        owner->update();
    }
}

// indicates whether this item is displayed expanded 
// NOTE: a TRUE response does not necessarily indicate the item 
// has any children

kdat'KTreeViewItem::isExpanded() (./kdeadmin/kdat/ktreeview.cpp:263)

bool KTreeViewItem::isExpanded() const
{
    return expanded;
}

// returns true if all ancestors are expanded

kdat'KTreeViewItem::isVisible() (./kdeadmin/kdat/ktreeview.cpp:269)

bool KTreeViewItem::isVisible() const
{
    for (KTreeViewItem* p = getParent(); p != 0; p = p->getParent()) {
	if (!p->isExpanded())
	    return false;
    }
    return true;
}

// paint this item, including tree branches and expand button

kdat'KTreeViewItem::paint() (./kdeadmin/kdat/ktreeview.cpp:279)

void KTreeViewItem::paint(QPainter* p, int indent, const QColorGroup& cg,
			  bool highlighted) const
{
    assert(getParent() != 0);		/* can't paint root item */

    p->save();
    p->setPen(cg.text());
    p->setBackgroundColor(cg.base());

    int cellHeight = height(p->fontMetrics());

    if (doTree) {
	paintTree(p, indent, cellHeight);
    }

    /*
     * If this item has at least one child and expand button drawing is
     * enabled, set the rect for the expand button for later mouse press
     * bounds checking, and draw the button.
     */
    if (doExpandButton && (child || delayedExpanding)) {
	paintExpandButton(p, indent, cellHeight);
    }

    // now draw the item pixmap and text, if applicable
    int pixmapX = indent;
    int pixmapY = (cellHeight - pixmap.height()) / 2;
    p->drawPixmap(pixmapX, pixmapY, pixmap);

    if (doText) {
	paintText(p, indent, cellHeight, cg, highlighted);
    }
    p->restore();
}


kdat'KTreeViewItem::paintExpandButton() (./kdeadmin/kdat/ktreeview.cpp:314)

void KTreeViewItem::paintExpandButton(QPainter* p, int indent, int cellHeight) const
{
    int parentLeaderX = indent - (22 / 2);
    int cellCenterY = cellHeight / 2;

    expandButton.setRect(parentLeaderX - 4, cellCenterY - 4, 9, 9);
    p->setBrush(Qt::white);
    p->drawRect(expandButton);
    if (expanded) {
	p->drawLine(parentLeaderX - 2, cellCenterY, 
		    parentLeaderX + 2, cellCenterY);
    } else {
	p->drawLine(parentLeaderX - 2, cellCenterY,
		    parentLeaderX + 2, cellCenterY);
	p->drawLine(parentLeaderX, cellCenterY - 2, 
		    parentLeaderX, cellCenterY + 2);
    }
    p->setBrush(Qt::NoBrush);
}

// paint the highlight 

kdat'KTreeViewItem::paintHighlight() (./kdeadmin/kdat/ktreeview.cpp:335)

void KTreeViewItem::paintHighlight(QPainter* p, int indent, const QColorGroup& colorGroup,
				   bool hasFocus, Qt::GUIStyle style) const
{
    QColor fc;
    if (style == Qt::WindowsStyle)
	fc = Qt::darkBlue;			/* hardcoded in Qt */
    else
	fc = colorGroup.text();
    QRect textRect = textBoundingRect(indent);
    int t,l,b,r;
    textRect.coords(&l, &t, &r, &b);
    p->fillRect(textRect, fc);		/* draw highlight background */
    if (hasFocus) {
	if(style == Qt::WindowsStyle) {	/* draw Windows style highlight */
	    textRect.setCoords(l - 1, t - 1, r + 1, b + 1);
	    p->setPen(QPen(Qt::yellow, 0, Qt::DotLine));
	    p->setBackgroundColor(fc);
	    p->setBackgroundMode(Qt::OpaqueMode);
	    p->drawRect(textRect);
	    textRect.setCoords(l - 2, t - 2, r + 2, b + 2);
	    p->setPen(fc);
	    p->drawRect(textRect);
	}
	else {				/* draw Motif style highlight */
	    textRect.setCoords(l - 2, t - 2, r + 2, b + 2);
	    p->drawRect(textRect);
	}
    }
}

// draw the text, highlighted if requested

kdat'KTreeViewItem::paintText() (./kdeadmin/kdat/ktreeview.cpp:366)

void KTreeViewItem::paintText(QPainter* p, int indent, int cellHeight,
			      const QColorGroup& cg, bool highlighted) const
{
    int textX = indent + pixmap.width() + 4;
    int textY = cellHeight - ((cellHeight - p->fontMetrics().ascent() - 
			       p->fontMetrics().leading()) / 2);
    if (highlighted) {
	paintHighlight(p, indent, cg,
		       owner->hasFocus(), owner->style());
	p->setPen(cg.base());
	p->setBackgroundColor(cg.text());
    }
    else {
	p->setPen(cg.text());
	p->setBackgroundColor(cg.base());
    }
    p->drawText(textX, textY, text);
}

// paint the tree structure

kdat'KTreeViewItem::paintTree() (./kdeadmin/kdat/ktreeview.cpp:386)

void KTreeViewItem::paintTree(QPainter* p, int indent, int cellHeight) const
{
    int parentLeaderX = indent - (22 / 2);
    int cellCenterY = cellHeight / 2;
    int cellBottomY = cellHeight - 1;
    int itemLeaderX = indent - 3;

    /*
     * 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 */
	if (prevRoot->hasSibling()) {
	    int sibLeaderX = owner->indentation(prevRoot) - (22 / 2);
	    p->drawLine(sibLeaderX, 0, sibLeaderX, cellBottomY);
	}
	prevRoot = prevRoot->getParent();
    }
}

// removes the given (direct) child from the branch

kdat'KTreeViewItem::removeChild() (./kdeadmin/kdat/ktreeview.cpp:435)

bool KTreeViewItem::removeChild(KTreeViewItem* theChild)
{
    // search item in list of children
    KTreeViewItem* prevItem = 0;
    KTreeViewItem* toRemove = getChild();
    while (toRemove && toRemove != theChild) {
	prevItem = toRemove;
	toRemove = toRemove->getSibling();
    }

    if (toRemove) {
	// found it!
	if (prevItem == 0) {
	    child = toRemove->getSibling();
	} else {
	    prevItem->sibling = toRemove->getSibling();
	}
	numChildren--;
	toRemove->owner = 0;
    }
    assert((numChildren == 0) == (child == 0));

    if ( owner ) {
        owner->updateVisibleItems();
        owner->update();
    }

    return toRemove != 0;
}

// sets the delayed-expanding flag

kdat'KTreeViewItem::setDelayedExpanding() (./kdeadmin/kdat/ktreeview.cpp:466)

void KTreeViewItem::setDelayedExpanding(bool flag)
{
    delayedExpanding = flag;
}

// tells the item whether it shall delete child items

kdat'KTreeViewItem::setDeleteChildren() (./kdeadmin/kdat/ktreeview.cpp:472)

void KTreeViewItem::setDeleteChildren(bool flag)
{
    deleteChildren = flag;
}

// sets the draw expand button flag of this item

kdat'KTreeViewItem::setDrawExpandButton() (./kdeadmin/kdat/ktreeview.cpp:478)

void KTreeViewItem::setDrawExpandButton(bool doit)
{
    doExpandButton = doit;
}

// sets the draw text flag of this item

kdat'KTreeViewItem::setDrawText() (./kdeadmin/kdat/ktreeview.cpp:484)

void KTreeViewItem::setDrawText(bool doit)
{
    doText = doit;
}

// sets the draw tree branch flag of this item

kdat'KTreeViewItem::setDrawTree() (./kdeadmin/kdat/ktreeview.cpp:490)

void KTreeViewItem::setDrawTree(bool doit)
{
    doTree = doit;
}

// sets the expanded flag of this item

kdat'KTreeViewItem::setExpanded() (./kdeadmin/kdat/ktreeview.cpp:496)

void KTreeViewItem::setExpanded(bool is)
{
    expanded = is;
    if ( owner ) {
        owner->updateVisibleItems();
        owner->update();
    }
}

// sets the item pixmap to the given pixmap

kdat'KTreeViewItem::setPixmap() (./kdeadmin/kdat/ktreeview.cpp:506)

void KTreeViewItem::setPixmap(const QPixmap& pm)
{
    pixmap = pm;
    if ( owner ) {
        owner->updateVisibleItems();
        owner->update();
    }
}

// sets the item text to the given string

kdat'KTreeViewItem::setText() (./kdeadmin/kdat/ktreeview.cpp:516)

void KTreeViewItem::setText(const QString& t)
{
    text = t;
    if ( owner ) {
        owner->updateVisibleItems();
        owner->update();
    }
}

// counts the child items and stores the result in numChildren

kdat'KTreeViewItem::synchNumChildren() (./kdeadmin/kdat/ktreeview.cpp:526)

void KTreeViewItem::synchNumChildren()
{
    numChildren = 0;
    KTreeViewItem* item = getChild();
    while (item != 0) {
	numChildren++;
	item = item->getSibling();
    }
}

/*
 * returns the bounding rect of the item text in cell coordinates couldn't
 * get QFontMetrics::boundingRect() to work right so I made my own
 */

kdat'KTreeViewItem::textBoundingRect() (./kdeadmin/kdat/ktreeview.cpp:540)

QRect KTreeViewItem::textBoundingRect(int indent) const
{
    const QFontMetrics& fm = owner->fontMetrics();
    int cellHeight = height(fm);
    int rectX = indent + pixmap.width() + 3;
    int rectY = (cellHeight - fm.ascent() - fm.leading()) / 2 + 2;
    int rectW = fm.width(text) + 1;
    int rectH = fm.ascent() + fm.leading();
    return QRect(rectX, rectY, rectW, rectH);
}

// returns the total width of text and pixmap, including margins, spacing
// and indent, or -1 if empty -- SHOULD NEVER BE -1!

kdat'KTreeViewItem::width() (./kdeadmin/kdat/ktreeview.cpp:553)

int KTreeViewItem::width(int indent) const
{
    return width(indent, owner->fontMetrics());
}


kdat'KTreeViewItem::width() (./kdeadmin/kdat/ktreeview.cpp:558)

int KTreeViewItem::width(int indent, const QFontMetrics& fm) const
{
    int maxWidth = pixmap.width();
    maxWidth += (4 + fm.width(text));
    return maxWidth == 0  ?  -1  :  indent + maxWidth + 3;
}


/*
 * -------------------------------------------------------------------
 *
 * KTreeView
 *
 * -------------------------------------------------------------------
 */

// constructor