kplato

kptrelation.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Thomas Zander zander@kde.org
00003    Copyright (C) 2004 Dag Andersen <danders@get2net.dk>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KPTRELATION_H
00022 #define KPTRELATION_H
00023 
00024 #include "kptduration.h"
00025 
00026 #include <qstring.h>
00027 
00028 class QCanvas;
00029 class QDomElement;
00030 
00031 namespace KPlato
00032 {
00033 
00034 class Node;
00035 class Project;
00036 class PertCanvas;
00037 
00045 class Relation {
00046 public:
00047     enum Type { FinishStart, FinishFinish, StartStart };
00048 
00049     Relation(Node *parent, Node *child, Type type, Duration lag);
00050     Relation(Node *parent=0, Node *child=0, Type type=FinishStart);
00051     Relation(Relation *rel);
00052     
00057     virtual ~Relation();
00058 
00059     void setType(Type );
00060     Type type() const { return m_type; }
00061 
00066     const Duration &lag() const { return m_lag; }
00067     void setLag(Duration lag) { m_lag = lag; }
00068 
00072     Node *parent() const { return m_parent; }
00076     Node *child() const { return m_child; }
00077 
00078     enum Result {
00079         SUCCESS = 0l,
00080         HASCHILDREN = 1l,
00081         NOTIMPL = 2l
00082     };
00083 
00084     bool load(QDomElement &element, Project &project);
00085     void save(QDomElement &element) const;
00086     
00087 protected: // variables
00088     Node *m_parent;
00089     Node *m_child;
00090     Type m_type;
00091     Duration m_lag;
00092 
00093 private:
00094     QString m_parentId;
00095     
00096 #ifndef NDEBUG
00097 public:
00098     void printDebug(QCString indent);
00099 #endif
00100 
00101 };
00102 
00103 class ProxyRelation : public Relation
00104 {
00105 public:
00106     ProxyRelation(Node *parent, Node *child, Relation::Type type, Duration lag) 
00107     : Relation(parent, child, type, lag) 
00108     {}
00109 
00110     ~ProxyRelation() { m_parent = 0; m_child = 0;}
00111 };
00112 
00113 }  //KPlato namespace
00114 
00115 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys