20#include "kptrelation.h"
23#include "kptproject.h"
24#include "kptcanvasitem.h"
34Relation::Relation(Node *parent, Node *child, Type type, Duration lag) {
41Relation::Relation(Node *parent, Node *child, Type type) {
48Relation::Relation(Relation *rel) {
49 m_parent=rel->parent();
63void Relation::setType(Type type) {
68bool Relation::load(TQDomElement &element, Project &project) {
69 m_parent = project.
findNode(element.attribute(
"parent-id"));
73 m_child = project.
findNode(element.attribute(
"child-id"));
77 if (m_child == m_parent) {
78 kdDebug()<<k_funcinfo<<
"child == parent"<<endl;
84 TQString tr = element.attribute(
"type");
85 if ( tr ==
"Finish-Start" )
87 else if ( tr ==
"Finish-Finish" )
88 m_type = FinishFinish;
89 else if ( tr ==
"Start-Start" )
94 m_lag = Duration::fromString(element.attribute(
"lag"));
97 kdError()<<k_funcinfo<<
"Failed to add relation: Child="<<m_child->name()<<
" parent="<<m_parent->name()<<endl;
101 m_parent->delDependChildNode(
this,
false);
102 kdError()<<k_funcinfo<<
"Failed to add relation: Child="<<m_child->name()<<
" parent="<<m_parent->name()<<endl;
111void Relation::save(TQDomElement &element)
const {
112 TQDomElement me = element.ownerDocument().createElement(
"relation");
113 element.appendChild(me);
115 me.setAttribute(
"parent-id", m_parent->id());
116 me.setAttribute(
"child-id", m_child->id());
117 TQString type =
"Finish-Start";
120 type =
"Finish-Start";
123 type =
"Finish-Finish";
126 type =
"Start-Start";
129 me.setAttribute(
"type", type);
130 me.setAttribute(
"lag", m_lag.toString());
134void Relation::printDebug(TQCString indent) {
136 kdDebug()<<indent<<
" Parent: "<<m_parent->name()<<endl;
137 kdDebug()<<indent<<
" Child: "<<m_child->name()<<endl;
138 kdDebug()<<indent<<
" Type: "<<m_type<<endl;
virtual void addDependChildNode(Node *node, Relation::Type p=Relation::FinishStart)
Adds relation to both this node and address node.
void takeDependParentNode(Relation *rel)
Takes the relation rel from this node only.
void takeDependChildNode(Relation *rel)
Takes the relation rel from this node only.
virtual Node * findNode() const
Find the node with my id.
bool legalToLink(Node *node)
Check if this node can be linked to node.
virtual void addDependParentNode(Node *node, Relation::Type p=Relation::FinishStart)
Adds relation to both this node and node.
const Duration & lag() const
returns the lag.
virtual ~Relation()
When deleted the relation will remove itself from the parent- and child nodes lists.