void DOMTreeView::recursive(const DOM::Node &pNode, const DOM::Node &node) { QListViewItem *cur_item; if(pNode.ownerDocument() != document) { QString val = node.nodeValue().string(); if ( val.length() > 20 ) val.truncate( 20 ); cur_item = new QListViewItem(static_cast<QListView *>(this), node.nodeName().string(), val ); document = pNode.ownerDocument(); } else { QString val = node.nodeValue().string(); if ( val.length() > 20 ) val.truncate( 20 ); cur_item = new QListViewItem(m_itemdict[pNode.handle()], node.nodeName().string(), val); } if(node.handle()) { m_itemdict.insert(node.handle(), cur_item); m_nodedict.insert(cur_item, new DOM::Node(node)); } DOM::Node cur_child = node.lastChild(); while(!cur_child.isNull()) { recursive(node, cur_child); cur_child = cur_child.previousSibling(); } }
void DOMTreeView::showRecursive(const DOM::Node &pNode, const DOM::Node &node, uint depth) { DOMListViewItem *cur_item; DOMListViewItem *parent_item = m_itemdict[pNode.handle()]; if (depth > m_maxDepth) { m_maxDepth = depth; } if (depth == 0) { cur_item = new DOMListViewItem(node, m_listView); m_document = pNode.ownerDocument(); } else { cur_item = new DOMListViewItem(node, parent_item); } //kdDebug(90180) << node.nodeName().string() << " [" << depth << "]" << endl; addElement (node, cur_item, false); cur_item->setOpen(depth < m_expansionDepth); if(node.handle()) { m_itemdict.insert(node.handle(), cur_item); } DOM::Node child = node.lastChild(); if (child.isNull()) { DOM::HTMLFrameElement frame = node; if (!frame.isNull()) child = frame.contentDocument().documentElement(); } while(!child.isNull()) { showRecursive(node, child, depth + 1); child = child.previousSibling(); } const DOM::Element element = node; if (!m_bPure) { if (!element.isNull() && !element.firstChild().isNull()) { if(depth == 0) { cur_item = new DOMListViewItem(node, m_listView, cur_item); m_document = pNode.ownerDocument(); } else { cur_item = new DOMListViewItem(node, parent_item, cur_item); } //kdDebug(90180) << "</" << node.nodeName().string() << ">" << endl; addElement(element, cur_item, true); // cur_item->setOpen(depth < m_expansionDepth); } } }