• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdehtml
 

tdehtml

  • tdehtml
domtreeview.cpp
1/***************************************************************************
2 domtreeview.cpp
3 -------------------
4
5 copyright : (C) 2001 - The Kafka Team
6 email : kde-kafka@master.kde.org
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "tdehtml_part.h"
19#include "domtreeview.moc"
20#include "xml/dom_nodeimpl.h"
21
22DOMTreeView::DOMTreeView(TQWidget *parent, TDEHTMLPart *currentpart, const char * name) : TDEListView(parent, name)
23{
24 setCaption(name);
25 setRootIsDecorated(true);
26 addColumn("Name");
27 addColumn("Value");
28 addColumn("Renderer");
29 setSorting(-1);
30 part = currentpart;
31 connect(part, TQ_SIGNAL(nodeActivated(const DOM::Node &)), this, TQ_SLOT(showTree(const DOM::Node &)));
32 connect(this, TQ_SIGNAL(clicked(TQListViewItem *)), this, TQ_SLOT(slotItemClicked(TQListViewItem *)));
33 m_nodedict.setAutoDelete(true);
34}
35
36DOMTreeView::~DOMTreeView()
37{
38 disconnect(part);
39}
40
41void DOMTreeView::showTree(const DOM::Node &pNode)
42{
43 if(pNode.isNull() || document != pNode.ownerDocument())
44 {
45 clear();
46 m_itemdict.clear();
47 m_nodedict.clear();
48 if(pNode.isNull())
49 return;
50 else if(pNode.ownerDocument().isNull())
51 recursive(0, pNode);
52 else
53 recursive(0, pNode.ownerDocument());
54 }
55 setCurrentItem(m_itemdict[pNode.handle()]);
56 ensureItemVisible(m_itemdict[pNode.handle()]);
57}
58
59void DOMTreeView::recursive(const DOM::Node &pNode, const DOM::Node &node)
60{
61 TQListViewItem *cur_item;
62 if(pNode.ownerDocument() != document)
63 {
64 TQString val = node.nodeValue().string();
65 if ( val.length() > 20 )
66 val.truncate( 20 );
67 cur_item = new TQListViewItem(static_cast<TQListView *>(this), node.nodeName().string(), val );
68 document = pNode.ownerDocument();
69 }
70 else {
71 TQString val = node.nodeValue().string();
72 if ( val.length() > 20 )
73 val.truncate( 20 );
74 cur_item = new TQListViewItem(m_itemdict[pNode.handle()], node.nodeName().string(), val);
75 }
76
77 if(node.handle())
78 {
79 m_itemdict.insert(node.handle(), cur_item);
80 m_nodedict.insert(cur_item, new DOM::Node(node));
81 }
82
83 DOM::Node cur_child = node.lastChild();
84 while(!cur_child.isNull())
85 {
86 recursive(node, cur_child);
87 cur_child = cur_child.previousSibling();
88 }
89}
90
91void DOMTreeView::slotItemClicked(TQListViewItem *cur_item)
92{
93 DOM::Node *handle = m_nodedict[cur_item];
94 if(handle) {
95 emit part->setActiveNode(*handle);
96 }
97}
DOM::Node
The Node interface is the primary datatype for the entire Document Object Model.
Definition: dom_node.h:275
DOM::Node::previousSibling
Node previousSibling() const
The node immediately preceding this node.
Definition: dom_node.cpp:229
DOM::Node::isNull
bool isNull() const
tests if this Node is 0.
Definition: dom_node.h:892
DOM::Node::nodeValue
DOMString nodeValue() const
The value of this node, depending on its type; see the table above.
Definition: dom_node.cpp:182
DOM::Node::lastChild
Node lastChild() const
The last child of this node.
Definition: dom_node.cpp:223
DOM::Node::ownerDocument
Document ownerDocument() const
The Document object associated with this node.
Definition: dom_node.cpp:247
DOM::Node::nodeName
DOMString nodeName() const
The name of this node, depending on its type; see the table above.
Definition: dom_node.cpp:176
TDEHTMLPart
This class is tdehtml's main class.
Definition: tdehtml_part.h:184
TDEListView
KStdAction::clear
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEStdAccel::name
TQString name(StdAccel id)

tdehtml

Skip menu "tdehtml"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdehtml

Skip menu "tdehtml"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdehtml by doxygen 1.9.4
This website is maintained by Timothy Pearson.