20#include "kptrelation.h"
23#include "kptproject.h"
24#include "kptcanvasitem.h"
41Relation::Relation( Node *parent, Node *child, Type type) {
49 m_parent=rel->parent();
58 m_parent->takeDependChildNode( this);
60 m_child->takeDependParentNode( this);
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;
81 if (!m_parent->legalToLink(m_child))
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"));
96 if (!m_parent->addDependChildNode( this)) {
97 kdError()<<k_funcinfo<< "Failed to add relation: Child="<<m_child->name()<< " parent="<<m_parent->name()<<endl;
100 if (!m_child->addDependParentNode( this)) {
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;
The duration class can be used to store a timespan in a convenient format.
This class represents any node in the project, a node can be a project or a subproject or any task.
virtual Node * findNode() const Find the node with my id.
The relation class couples a 2 nodes together which are dependent on each other.
const Duration & lag() const returns the lag.
virtual ~Relation() When deleted the relation will remove itself from the parent- and child nodes lists.
|