00001 #ifndef _KGANTTITEM_H_
00002 #define _KGANTTITEM_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <tqobject.h>
00036 #include <tqdatetime.h>
00037 #include <tqtextstream.h>
00038 #include <tqptrlist.h>
00039 #include <tqpainter.h>
00040
00041 #include <tdepimmacros.h>
00042
00043 #include "KGanttRelation.h"
00044
00045
00046
00048
00053
00054 class KDE_EXPORT KGanttItem : public TQObject
00056 {
00057
00058 Q_OBJECT
00059
00060
00061
00062 public:
00063
00064 enum Change {
00065 NoChange = 0,
00066 StartChanged = 1,
00067 EndChanged = 2,
00068
00071 HeightChanged = 4,
00072
00077 TotalHeightChanged = 8,
00078
00080 StyleChanged = 16,
00081 TextChanged = 32,
00082 ModeChanged = 64,
00083 MinChanged = 128,
00084 MaxChanged = 256,
00085
00087 Opened = 512,
00088
00090 Closed = 1024,
00091
00093 Selected = 2048,
00094
00096 Unselected = 4096,
00097
00099 Unknown = 8192,
00100
00102 RelationAdded = 16384,
00103
00105 RelationRemoved = 32768
00106
00107 };
00108
00109
00110
00111 enum Style {
00113 DrawNothing = 0,
00114
00116 DrawBorder = 1,
00117
00118
00119 DrawFilled = 2,
00120 DrawText = 4,
00121
00122
00123 DrawHandle = 16,
00124
00126 DrawHandleWSubitems = 32,
00127
00128 DrawAll = 255
00129 };
00130
00131
00132 enum Mode {
00133 Normal,
00134 Rubberband
00135 };
00136
00137
00139
00142 KGanttItem(KGanttItem* parentItem, const TQString& text,
00143 const TQDateTime& start, const TQDateTime& end);
00144
00145
00146
00148
00151 KGanttItem(KGanttItem* parentItem, const TQString& text,
00152 const TQDateTime& start, long durationMin);
00153
00154
00155
00157
00158
00159
00160 ~KGanttItem();
00161
00162
00163
00165
00166
00167
00168 KGanttRelation* addRelation(KGanttItem* from, KGanttItem* to,
00169 const TQString& text);
00170
00171
00172
00173
00175
00178 bool isOpen() {
00179 return _open;
00180 }
00181
00182
00183
00185
00188 void open(bool f);
00189
00190
00191
00193
00199 void setEditable(bool f) {
00200 _editable = f;
00201 }
00202
00203
00204
00206
00209 bool isEditable() {
00210 return _editable;
00211 }
00212
00213
00214
00216
00219 bool isSelected() {
00220 return _selected;
00221 }
00222
00223
00224
00226
00229 void select(bool f);
00230
00231
00232
00234
00240 void setMode(Mode flag);
00241
00242
00243
00245
00248 void setStyle(int flag, bool includeSubitems = false);
00249
00250
00251
00253
00256 int getStyle() {
00257 return _style;
00258 }
00259
00260
00261
00263
00266 void setBrush(const TQBrush& brush);
00267
00268
00269
00271
00274 TQBrush& getBrush() {
00275 return _brush;
00276 }
00277
00278
00279
00281
00284 TQBrush& getSelectBrush() {
00285 return _selectBrush;
00286 }
00287
00288
00289
00291
00294 void setPen(const TQPen& pen);
00295
00296
00297
00299
00302 TQPen& getPen() {
00303 return _pen;
00304 }
00305
00306
00307
00309
00312 void setTextPen(const TQPen& pen) {
00313 _textPen = pen;
00314 }
00315
00316
00317
00319
00322 TQPen& getTextPen() {
00323 return _textPen;
00324 }
00325
00326
00327
00329
00332 void setText(const TQString& text);
00333
00334
00335
00337
00340 TQString getText() { return _text; }
00341
00342
00343
00345
00350 TQDateTime getStart();
00351
00352
00353
00355
00358 TQDateTime getEnd();
00359
00360
00361
00363
00366 void setStart(const TQDateTime& start);
00367
00368
00369
00371
00374 void setEnd(const TQDateTime& end);
00375
00376
00377
00379
00383 void setHeight(int h);
00384
00385
00386
00388
00393 int getHeight() {
00394 return _height;
00395 }
00396
00397
00398
00400
00405 int getTotalHeight();
00406
00407
00408
00410
00413 int getWidth();
00414
00415
00416
00418
00421 TQPtrList<KGanttItem>& getSubItems() {
00422 return _subitems;
00423 }
00424
00425
00426
00428
00431 TQPtrList<KGanttRelation>& getRelations() {
00432 return _relations;
00433 }
00434
00435
00436
00438
00441 void startTransaction(){
00442 blockSignals(true);
00443 }
00444
00445
00446
00448
00453 void endTransaction();
00454
00455
00456
00458
00461 static TQString ChangeAsString(Change c);
00462
00463
00464
00465
00467
00470 void dump(TQTextOStream& cout, const TQString& pre);
00471
00472
00473 signals:
00474
00476
00480 void changed(KGanttItem*, KGanttItem::Change);
00481
00482
00483
00485
00489 void destroyed(KGanttItem*);
00490
00491
00492
00493 private slots:
00494
00495 void subItemChanged(KGanttItem*, KGanttItem::Change);
00496
00497 void removeRelation(KGanttRelation* rel);
00498
00499
00500 private:
00501
00502 void registerItem(KGanttItem* item);
00503 void unregisterItem(KGanttItem* item);
00504
00505 void init(KGanttItem* parentItem, const TQString& text,
00506 const TQDateTime& start, const TQDateTime& end);
00507
00508
00509
00510 Change adjustMinMax();
00511
00512
00513
00514 Change adjustStartEnd();
00515
00516
00517
00518 bool _open;
00519 bool _selected;
00520
00521
00522
00523
00524 bool _editable;
00525
00526 int _height, _style, _mode;
00527
00528
00529 KGanttItem* _parentItem;
00530 TQPtrList<KGanttItem> _subitems;
00531 TQPtrList<KGanttRelation> _relations;
00532
00533
00534
00535
00536
00537 TQDateTime _start, _end, _minDateTime, _maxDateTime;
00538
00539 TQString _text;
00540
00541 TQBrush _brush;
00542 TQPen _pen, _textPen;
00543
00544 static TQBrush _selectBrush;
00545
00546
00547 };
00548
00549 #endif