|
|
|
@ -314,20 +314,20 @@ void KTreeViewItem::paint(TQPainter* p, int indent, const TQColorGroup& cg,
|
|
|
|
|
|
|
|
|
|
void KTreeViewItem::paintExpandButton(TQPainter* p, int indent, int cellHeight) const
|
|
|
|
|
{
|
|
|
|
|
int tqparentLeaderX = indent - (22 / 2);
|
|
|
|
|
int parentLeaderX = indent - (22 / 2);
|
|
|
|
|
int cellCenterY = cellHeight / 2;
|
|
|
|
|
|
|
|
|
|
expandButton.setRect(tqparentLeaderX - 4, cellCenterY - 4, 9, 9);
|
|
|
|
|
expandButton.setRect(parentLeaderX - 4, cellCenterY - 4, 9, 9);
|
|
|
|
|
p->setBrush(TQt::white);
|
|
|
|
|
p->drawRect(expandButton);
|
|
|
|
|
if (expanded) {
|
|
|
|
|
p->drawLine(tqparentLeaderX - 2, cellCenterY,
|
|
|
|
|
tqparentLeaderX + 2, cellCenterY);
|
|
|
|
|
p->drawLine(parentLeaderX - 2, cellCenterY,
|
|
|
|
|
parentLeaderX + 2, cellCenterY);
|
|
|
|
|
} else {
|
|
|
|
|
p->drawLine(tqparentLeaderX - 2, cellCenterY,
|
|
|
|
|
tqparentLeaderX + 2, cellCenterY);
|
|
|
|
|
p->drawLine(tqparentLeaderX, cellCenterY - 2,
|
|
|
|
|
tqparentLeaderX, cellCenterY + 2);
|
|
|
|
|
p->drawLine(parentLeaderX - 2, cellCenterY,
|
|
|
|
|
parentLeaderX + 2, cellCenterY);
|
|
|
|
|
p->drawLine(parentLeaderX, cellCenterY - 2,
|
|
|
|
|
parentLeaderX, cellCenterY + 2);
|
|
|
|
|
}
|
|
|
|
|
p->setBrush(TQt::NoBrush);
|
|
|
|
|
}
|
|
|
|
@ -386,7 +386,7 @@ void KTreeViewItem::paintText(TQPainter* p, int indent, int cellHeight,
|
|
|
|
|
// paint the tree structure
|
|
|
|
|
void KTreeViewItem::paintTree(TQPainter* p, int indent, int cellHeight) const
|
|
|
|
|
{
|
|
|
|
|
int tqparentLeaderX = indent - (22 / 2);
|
|
|
|
|
int parentLeaderX = indent - (22 / 2);
|
|
|
|
|
int cellCenterY = cellHeight / 2;
|
|
|
|
|
int cellBottomY = cellHeight - 1;
|
|
|
|
|
int itemLeaderX = indent - 3;
|
|
|
|
@ -396,11 +396,11 @@ void KTreeViewItem::paintTree(TQPainter* p, int indent, int cellHeight) const
|
|
|
|
|
* towards tqparent or sibling.
|
|
|
|
|
*/
|
|
|
|
|
if (tqparent->tqparent != 0 || tqparent->getChild() != this)
|
|
|
|
|
p->drawLine(tqparentLeaderX, 0, tqparentLeaderX, cellCenterY);
|
|
|
|
|
p->drawLine(parentLeaderX, 0, parentLeaderX, cellCenterY);
|
|
|
|
|
|
|
|
|
|
// draw the line down towards sibling
|
|
|
|
|
if (sibling)
|
|
|
|
|
p->drawLine(tqparentLeaderX, cellCenterY, tqparentLeaderX, cellBottomY);
|
|
|
|
|
p->drawLine(parentLeaderX, cellCenterY, parentLeaderX, cellBottomY);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If this item has tqchildren or siblings in the tree or is a child of
|
|
|
|
@ -415,7 +415,7 @@ void KTreeViewItem::paintTree(TQPainter* p, int indent, int cellHeight) const
|
|
|
|
|
*/
|
|
|
|
|
tqparent->getChild() != this)
|
|
|
|
|
{
|
|
|
|
|
p->drawLine(tqparentLeaderX, cellCenterY, itemLeaderX, cellCenterY);
|
|
|
|
|
p->drawLine(parentLeaderX, cellCenterY, itemLeaderX, cellCenterY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -650,10 +650,10 @@ void KTreeView::appendChildItem(const TQString & theText, const TQPixmap& thePix
|
|
|
|
|
void KTreeView::appendChildItem(KTreeViewItem* newItem, int index)
|
|
|
|
|
{
|
|
|
|
|
/* find tqparent item and append new item to tqparent's sub tree */
|
|
|
|
|
KTreeViewItem* tqparentItem = itemAt(index);
|
|
|
|
|
if (!tqparentItem)
|
|
|
|
|
KTreeViewItem* parentItem = itemAt(index);
|
|
|
|
|
if (!parentItem)
|
|
|
|
|
return;
|
|
|
|
|
appendChildItem(tqparentItem, newItem);
|
|
|
|
|
appendChildItem(parentItem, newItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// appends the given item to the tqchildren of the item at the end of the
|
|
|
|
@ -661,10 +661,10 @@ void KTreeView::appendChildItem(KTreeViewItem* newItem, int index)
|
|
|
|
|
void KTreeView::appendChildItem(KTreeViewItem* newItem, const KPath& thePath)
|
|
|
|
|
{
|
|
|
|
|
/* find tqparent item and append new item to tqparent's sub tree */
|
|
|
|
|
KTreeViewItem* tqparentItem = itemAt(thePath);
|
|
|
|
|
if (!tqparentItem)
|
|
|
|
|
KTreeViewItem* parentItem = itemAt(thePath);
|
|
|
|
|
if (!parentItem)
|
|
|
|
|
return;
|
|
|
|
|
appendChildItem(tqparentItem, newItem);
|
|
|
|
|
appendChildItem(parentItem, newItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// indicates whether horizontal scrollbar appears only when needed
|
|
|
|
@ -1321,14 +1321,14 @@ void KTreeView::expandOrCollapse(KTreeViewItem* tqparent)
|
|
|
|
|
{
|
|
|
|
|
bool autoU = autoUpdate();
|
|
|
|
|
setAutoUpdate(false);
|
|
|
|
|
int tqparentIndex = itemRow(tqparent);
|
|
|
|
|
int parentIndex = itemRow(tqparent);
|
|
|
|
|
if (tqparent->isExpanded()) {
|
|
|
|
|
collapseSubTree(tqparent);
|
|
|
|
|
emit collapsed(tqparentIndex);
|
|
|
|
|
emit collapsed(parentIndex);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
expandSubTree(tqparent);
|
|
|
|
|
emit expanded(tqparentIndex);
|
|
|
|
|
emit expanded(parentIndex);
|
|
|
|
|
}
|
|
|
|
|
if (autoU && isVisible())
|
|
|
|
|
tqrepaint();
|
|
|
|
@ -1368,21 +1368,21 @@ void KTreeView::expandSubTree(KTreeViewItem* subRoot)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fix up branch levels out of whack from split/join operations on the tree
|
|
|
|
|
void KTreeView::fixChildren(KTreeViewItem *tqparentItem)
|
|
|
|
|
void KTreeView::fixChildren(KTreeViewItem *parentItem)
|
|
|
|
|
{
|
|
|
|
|
KTreeViewItem* childItem = 0;
|
|
|
|
|
KTreeViewItem* siblingItem = 0;
|
|
|
|
|
// int childBranch = tqparentItem->getBranch() + 1;
|
|
|
|
|
if(tqparentItem->hasChild()) {
|
|
|
|
|
childItem = tqparentItem->getChild();
|
|
|
|
|
// int childBranch = parentItem->getBranch() + 1;
|
|
|
|
|
if(parentItem->hasChild()) {
|
|
|
|
|
childItem = parentItem->getChild();
|
|
|
|
|
// childItem->setBranch(childBranch);
|
|
|
|
|
childItem->owner = tqparentItem->owner;
|
|
|
|
|
childItem->owner = parentItem->owner;
|
|
|
|
|
fixChildren(childItem);
|
|
|
|
|
}
|
|
|
|
|
while(childItem && childItem->hasSibling()) {
|
|
|
|
|
siblingItem = childItem->getSibling();
|
|
|
|
|
// siblingItem->setBranch(childBranch);
|
|
|
|
|
siblingItem->owner = tqparentItem->owner;
|
|
|
|
|
siblingItem->owner = parentItem->owner;
|
|
|
|
|
fixChildren(siblingItem);
|
|
|
|
|
childItem = siblingItem;
|
|
|
|
|
}
|
|
|
|
@ -1483,19 +1483,19 @@ bool KTreeView::insertItem(KTreeViewItem* referenceItem,
|
|
|
|
|
{
|
|
|
|
|
setCellHeight(newItem->height(fontMetrics()));
|
|
|
|
|
}
|
|
|
|
|
KTreeViewItem* tqparentItem;
|
|
|
|
|
KTreeViewItem* parentItem;
|
|
|
|
|
if (referenceItem) {
|
|
|
|
|
tqparentItem = referenceItem->getParent();
|
|
|
|
|
int insertIndex = tqparentItem->childIndex(referenceItem);
|
|
|
|
|
parentItem = referenceItem->getParent();
|
|
|
|
|
int insertIndex = parentItem->childIndex(referenceItem);
|
|
|
|
|
if (!prefix)
|
|
|
|
|
insertIndex++;
|
|
|
|
|
tqparentItem->insertChild(insertIndex, newItem);
|
|
|
|
|
parentItem->insertChild(insertIndex, newItem);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// no reference item, append at end of visible tree
|
|
|
|
|
// need to tqrepaint
|
|
|
|
|
tqparentItem = treeRoot;
|
|
|
|
|
tqparentItem->appendChild(newItem);
|
|
|
|
|
parentItem = treeRoot;
|
|
|
|
|
parentItem->appendChild(newItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set item expansion
|
|
|
|
@ -1508,7 +1508,7 @@ bool KTreeView::insertItem(KTreeViewItem* referenceItem,
|
|
|
|
|
|
|
|
|
|
// if tqrepaint necessary, do it if visible and auto update
|
|
|
|
|
// enabled
|
|
|
|
|
if (newItem->isVisible() || tqparentItem->childCount() == 1) {
|
|
|
|
|
if (newItem->isVisible() || parentItem->childCount() == 1) {
|
|
|
|
|
bool autoU = autoUpdate();
|
|
|
|
|
setAutoUpdate(FALSE);
|
|
|
|
|
updateVisibleItems();
|
|
|
|
@ -1994,10 +1994,10 @@ void KTreeView::takeItem(KTreeViewItem* item)
|
|
|
|
|
cur = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
KTreeViewItem* tqparentItem = item->getParent();
|
|
|
|
|
tqparentItem->removeChild(item);
|
|
|
|
|
KTreeViewItem* parentItem = item->getParent();
|
|
|
|
|
parentItem->removeChild(item);
|
|
|
|
|
item->sibling = 0;
|
|
|
|
|
if (wasVisible || tqparentItem->childCount() == 0) {
|
|
|
|
|
if (wasVisible || parentItem->childCount() == 0) {
|
|
|
|
|
bool autoU = autoUpdate();
|
|
|
|
|
setAutoUpdate(FALSE);
|
|
|
|
|
updateVisibleItems();
|
|
|
|
|