kgantt

KGanttItem.h
1 #ifndef _KGANTTITEM_H_
2 #define _KGANTTITEM_H_
3 
4 /*
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 
21  author : jh, jochen@ifb.bv.tu-berlin.de
22 
23  file : KGanttItem.h
24  date : 26 oct 2000
25 
26 
27  changelog : 26 dec 2000, jh
28  09 jan 2001, jh - added signal destroyed(xTQTask*)
29 
30  11 jan 2001, jh changed to kde : xTQTask -> KGanttItem
31 
32 */
33 
34 
35 #include <tqobject.h>
36 #include <tqdatetime.h>
37 #include <tqtextstream.h>
38 #include <tqptrlist.h>
39 #include <tqpainter.h>
40 
41 #include <tdemacros.h>
42 
43 #include "KGanttRelation.h"
44 
45 
46 
48 
54 class TDE_EXPORT KGanttItem : public TQObject
56 {
57 
58  TQ_OBJECT
59 
60 
61 
62 public:
63 
64  enum Change {
65  NoChange = 0,
66  StartChanged = 1,
67  EndChanged = 2,
68 
71  HeightChanged = 4,
72 
77  TotalHeightChanged = 8,
78 
80  StyleChanged = 16,
81  TextChanged = 32,
82  ModeChanged = 64,
83  MinChanged = 128,
84  MaxChanged = 256,
85 
87  Opened = 512,
88 
90  Closed = 1024,
91 
93  Selected = 2048,
94 
96  Unselected = 4096,
97 
99  Unknown = 8192,
100 
102  RelationAdded = 16384,
103 
105  RelationRemoved = 32768
106 
107  };
108 
109 
110 
111  enum Style {
113  DrawNothing = 0,
114 
116  DrawBorder = 1,
117 
118  // Fill item with brush.
119  DrawFilled = 2,
120  DrawText = 4,
121 
122  // Draw handlke for opening/closing item.
123  DrawHandle = 16,
124 
126  DrawHandleWSubitems = 32,
127 
128  DrawAll = 255
129  };
130 
131 
132  enum Mode {
133  Normal,
134  Rubberband
135  };
136 
137 
139 
142  KGanttItem(KGanttItem* parentItem, const TQString& text,
143  const TQDateTime& start, const TQDateTime& end);
144 
145 
146 
148 
151  KGanttItem(KGanttItem* parentItem, const TQString& text,
152  const TQDateTime& start, long durationMin);
153 
154 
155 
157  /*
158  * Emits signal destroyed(KGanttItem* this).
159  */
160  ~KGanttItem();
161 
162 
163 
165  /*
166  *
167  */
168  KGanttRelation* addRelation(KGanttItem* from, KGanttItem* to,
169  const TQString& text);
170 
171 
172 
173 
175 
178  bool isOpen() {
179  return _open;
180  }
181 
182 
183 
185 
188  void open(bool f);
189 
190 
191 
193 
199  void setEditable(bool f) {
200  _editable = f;
201  }
202 
203 
204 
206 
209  bool isEditable() {
210  return _editable;
211  }
212 
213 
214 
216 
219  bool isSelected() {
220  return _selected;
221  }
222 
223 
224 
226 
229  void select(bool f);
230 
231 
232 
234 
240  void setMode(Mode flag);
241 
242 
243 
245 
248  void setStyle(int flag, bool includeSubitems = false);
249 
250 
251 
253 
256  int getStyle() {
257  return _style;
258  }
259 
260 
261 
263 
266  void setBrush(const TQBrush& brush);
267 
268 
269 
271 
274  TQBrush& getBrush() {
275  return _brush;
276  }
277 
278 
279 
281 
284  TQBrush& getSelectBrush() {
285  return _selectBrush;
286  }
287 
288 
289 
291 
294  void setPen(const TQPen& pen);
295 
296 
297 
299 
302  TQPen& getPen() {
303  return _pen;
304  }
305 
306 
307 
309 
312  void setTextPen(const TQPen& pen) {
313  _textPen = pen;
314  }
315 
316 
317 
319 
322  TQPen& getTextPen() {
323  return _textPen;
324  }
325 
326 
327 
329 
332  void setText(const TQString& text);
333 
334 
335 
337 
340  TQString getText() { return _text; }
341 
342 
343 
345 
350  TQDateTime getStart();
351 
352 
353 
355 
358  TQDateTime getEnd();
359 
360 
361 
363 
366  void setStart(const TQDateTime& start);
367 
368 
369 
371 
374  void setEnd(const TQDateTime& end);
375 
376 
377 
379 
383  void setHeight(int h);
384 
385 
386 
388 
393  int getHeight() {
394  return _height;
395  }
396 
397 
398 
400 
405  int getTotalHeight();
406 
407 
408 
410 
413  int getWidth();
414 
415 
416 
418 
421  TQPtrList<KGanttItem>& getSubItems() {
422  return _subitems;
423  }
424 
425 
426 
428 
431  TQPtrList<KGanttRelation>& getRelations() {
432  return _relations;
433  }
434 
435 
436 
438 
442  blockSignals(true);
443  }
444 
445 
446 
448 
453  void endTransaction();
454 
455 
456 
458 
461  static TQString ChangeAsString(Change c);
462 
463 
464 
465 
467 
470  void dump(TQTextOStream& cout, const TQString& pre);
471 
472 
473 signals:
474 
476 
481 
482 
483 
485 
490 
491 
492 
493 private slots:
494 
495  void subItemChanged(KGanttItem*, KGanttItem::Change);
496 
497  void removeRelation(KGanttRelation* rel);
498 
499 
500 private:
501 
502  void registerItem(KGanttItem* item);
503  void unregisterItem(KGanttItem* item);
504 
505  void init(KGanttItem* parentItem, const TQString& text,
506  const TQDateTime& start, const TQDateTime& end);
507 
508 
509  // set min/max date and time according to subitems
510  Change adjustMinMax();
511 
512  /* if min < start set start to _min,
513  if max > end set end to max */
514  Change adjustStartEnd();
515 
516 
517  // is item open/closed
518  bool _open;
519  bool _selected;
520 
521 
522  // is this item editable by the user, if it is false, invoking
523  // of some methods has no effect
524  bool _editable;
525 
526  int _height, _style, _mode;
527 
528 
529  KGanttItem* _parentItem;
530  TQPtrList<KGanttItem> _subitems;
531  TQPtrList<KGanttRelation> _relations;
532 
533 
534  // start/end date.
535  // start must always be earlier then _minDateTime
536  // end must always be later then _maxDateTime
537  TQDateTime _start, _end, _minDateTime, _maxDateTime;
538 
539  TQString _text;
540 
541  TQBrush _brush;
542  TQPen _pen, _textPen;
543 
544  static TQBrush _selectBrush;
545 
546 
547 };
548 
549 #endif
KGanttItem.
Definition: KGanttItem.h:56
TQPtrList< KGanttItem > & getSubItems()
Get list of subitems.
Definition: KGanttItem.h:421
void destroyed(KGanttItem *)
Item will be deleted.
void startTransaction()
Start a transaction.
Definition: KGanttItem.h:441
bool isOpen()
Returns true if item is open (subitems has to be drawn)
Definition: KGanttItem.h:178
TQBrush & getSelectBrush()
Get brush which has to be used for drawing this item as selected.
Definition: KGanttItem.h:284
int getHeight()
Get height.
Definition: KGanttItem.h:393
bool isEditable()
Returns if item is editable.
Definition: KGanttItem.h:209
TQString getText()
Get text.
Definition: KGanttItem.h:340
void changed(KGanttItem *, KGanttItem::Change)
Item has changed.
TQBrush & getBrush()
Get brush that is used for filling the item.
Definition: KGanttItem.h:274
void setEditable(bool f)
Set item editable or not.
Definition: KGanttItem.h:199
TQPtrList< KGanttRelation > & getRelations()
Get list of relations.
Definition: KGanttItem.h:431
bool isSelected()
Returns true if item is selected.
Definition: KGanttItem.h:219
int getStyle()
Get drawing style.
Definition: KGanttItem.h:256
KGanttRelation.