kgantt

KGanttRelation.cpp
1//
2// file : KGanttRelation.cpp
3// date : 17 feb 2001
4// changed :
5// author : jh
6//
7
8
9#include "KGanttRelation.h"
10#include "KGanttItem.h"
11
12
13TQPen KGanttRelation::_selectPen(TQColor(255,0,0));
14
15
17 const TQString& text )
18 : TQObject()
20{
21 _from = from;
22 _to = to;
23 _text = text;
24 _pen = TQPen(TQColor(20,20,20),1);
25
26 connect(from, TQ_SIGNAL(destroyed(KGanttItem*)),
27 this, TQ_SLOT(itemDestroyed(KGanttItem*)));
28
29 connect(to, TQ_SIGNAL(destroyed(KGanttItem*)),
30 this, TQ_SLOT(itemDestroyed(KGanttItem*)));
31
32}
33
34
35
36
39{
40#ifdef _DEBUG_
41 printf("-> delete Relation %s \n", getText().latin1() );
42#endif
43
44 emit destroyed(this);
45
46#ifdef _DEBUG_
47 printf("<- delete Relation %s \n", getText().latin1() );
48#endif
49}
50
51
52
55{
56 return _from;
57}
58
59
60
61
65{
66 return _to;
67}
68
69
70
71void
72KGanttRelation::itemDestroyed(KGanttItem* /*item*/)
73{
74 delete this;
75}
76
77
78
79void
80KGanttRelation::setText(const TQString& text)
81
82{
83 if(!_editable) return;
84 if(text != _text) {
85 _text = text;
86 emit changed(this,TextChanged);
87 }
88}
89
90
91
92void
95{
96 if(!_editable) return;
97 if(f != _selected) {
98 _selected = f;
99 if(_selected)
100 emit changed(this, Selected);
101 else
102 emit changed(this, Unselected);
103 }
104}
105
106
107
108
109void
110KGanttRelation::setPen(const TQPen& pen)
111{
112 _pen = pen;
113}
114
115
116
117
118void
119KGanttRelation::dump(TQTextOStream& cout, const TQString& pre)
120{
121 cout << pre << "<Relation. text = [" << _text << "]>\n";
122
123 cout << pre << "| from : " << getFrom()->getText().latin1() << endl;
124 cout << pre << "| to : " << getTo()->getText().latin1() << endl;
125
126 if(_editable)
127 cout << pre << "| - editable " << endl;
128 else
129 cout << pre << "| - not editable " << endl;
130
131 if(_selected)
132 cout << pre << "| - selected " << endl;
133 else
134 cout << pre << "| - not selected " << endl;
135
136 cout << pre << "</Relation>\n";
137
138}
139
140
141TQString
142KGanttRelation::ChangeAsString(Change c)
144{
145 TQString ret;
146
147 /*
148 if(c & StartChanged) ret += "StartChanged, ";
149 if(c & EndChanged) ret += "EndChanged, ";
150 if(c & HeightChanged) ret += "HeightChanged, ";
151 if(c & TotalHeightChanged) ret += "TotalHeightChanged, ";
152 if(c & StyleChanged) ret += "StyleChanged, ";
153 */
154 if(c & TextChanged) ret += "TextChanged, ";
155 /*
156 if(c & ModeChanged) ret += "ModeChanged, ";
157 if(c & MinChanged) ret += "MinChanged, ";
158 if(c & MaxChanged) ret += "MaxChanged, ";
159 if(c & Opened) ret += "Opened, ";
160 if(c & Closed) ret += "Closed, ";
161 if(c & Selected) ret += "Selected, ";
162 if(c & Unselected) ret += "Unselected, ";
163 if(c & Unknown) ret += "Unknown, ";
164 */
165 return ret;
166
167}
168#include "KGanttRelation.moc"
KGanttItem.
Definition: KGanttItem.h:56
TQString getText()
Get text.
Definition: KGanttItem.h:340
void changed(KGanttRelation *, KGanttRelation::Change)
Item has changed.
KGanttRelation(KGanttItem *from, KGanttItem *to, const TQString &text)
Constructor.
void setPen(const TQPen &pen)
Set pen for border.
void dump(TQTextOStream &cout, const TQString &pre)
Dump to cout.
KGanttItem * getFrom()
Get date of starting.
void select(bool f)
Select/unselect item.
@ Selected
Item has been selected.
@ Unselected
Item has been unselected.
TQString getText()
Get text.
void setText(const TQString &text)
Set text.
void destroyed(KGanttRelation *)
Item will be deleted.
~KGanttRelation()
Destructor.
KGanttItem * getTo()
Get date of ending.