1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#include "graphhandler.h"
GraphHandler::GraphHandler(IBaseHandler *parent,const char *endTag)
: m_parent(parent)
{
addEndHandler(endTag,this,&GraphHandler::endGraph);
addStartHandler("node",this,&GraphHandler::startNode);
m_nodes.setAutoDelete(TRUE);
}
GraphHandler::~GraphHandler()
{
}
void GraphHandler::startGraph(const QXmlAttributes &)
{
m_parent->setDelegate(this);
}
void GraphHandler::endGraph()
{
m_parent->setDelegate(0);
}
void GraphHandler::startNode(const QXmlAttributes &attrib)
{
NodeHandler *n = new NodeHandler(this);
n->startNode(attrib);
m_nodes.append(n);
}
INodeIterator *GraphHandler::nodes() const
{
return new NodeIterator(*this);
}
//------------------------------------------------------------------------
NodeHandler::NodeHandler(IBaseHandler *parent)
: m_parent(parent)
{
addEndHandler("node",this,&NodeHandler::endNode);
addStartHandler("link",this,&NodeHandler::startLink);
addEndHandler("link",this,&NodeHandler::endLink);
addStartHandler("label",this,&NodeHandler::startLabel);
addEndHandler("label",this,&NodeHandler::endLabel);
}
NodeHandler::~NodeHandler()
{
}
void NodeHandler::startNode(const QXmlAttributes &attrib)
{
m_parent->setDelegate(this);
m_id = attrib.value("id");
}
void NodeHandler::endNode()
{
m_parent->setDelegate(0);
}
void NodeHandler::startLink(const QXmlAttributes &attrib)
{
m_link = attrib.value("id");
}
void NodeHandler::endLink()
{
}
void NodeHandler::startLabel(const QXmlAttributes &/*attrib*/)
{
m_curString="";
}
void NodeHandler::endLabel()
{
m_label = m_curString;
}
|