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