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 <qobject.h>
00036 #include <qdatetime.h>
00037 #include <qtextstream.h>
00038 #include <qptrlist.h>
00039 #include <qpainter.h>
00040
00041 #include <kdepimmacros.h>
00042
00043 #include "KGanttRelation.h"
00044
00045
00046
00048
00053
00054 class KDE_EXPORT KGanttItem : public QObject
00056 {
00057
00058 Q_OBJECT
00059
00060
00061 public:
00062
00063 enum Change {
00064 NoChange = 0,
00065 StartChanged = 1,
00066 EndChanged = 2,
00067
00070 HeightChanged = 4,
00071
00076 TotalHeightChanged = 8,
00077
00079 StyleChanged = 16,
00080 TextChanged = 32,
00081 ModeChanged = 64,
00082 MinChanged = 128,
00083 MaxChanged = 256,
00084
00086 Opened = 512,
00087
00089 Closed = 1024,
00090
00092 Selected = 2048,
00093
00095 Unselected = 4096,
00096
00098 Unknown = 8192,
00099
00101 RelationAdded = 16384,
00102
00104 RelationRemoved = 32768
00105
00106 };
00107
00108
00109
00110 enum Style {
00112 DrawNothing = 0,
00113
00115 DrawBorder = 1,
00116
00117
00118 DrawFilled = 2,
00119 DrawText = 4,
00120
00121
00122 DrawHandle = 16,
00123
00125 DrawHandleWSubitems = 32,
00126
00127 DrawAll = 255
00128 };
00129
00130
00131 enum Mode {
00132 Normal,
00133 Rubberband
00134 };
00135
00136
00138
00141 KGanttItem(KGanttItem* parentItem, const QString& text,
00142 const QDateTime& start, const QDateTime& end);
00143
00144
00145
00147
00150 KGanttItem(KGanttItem* parentItem, const QString& text,
00151 const QDateTime& start, long durationMin);
00152
00153
00154
00156
00157
00158
00159 ~KGanttItem();
00160
00161
00162
00164
00165
00166
00167 KGanttRelation* addRelation(KGanttItem* from, KGanttItem* to,
00168 const QString& text);
00169
00170
00171
00172
00174
00177 bool isOpen() {
00178 return _open;
00179 }
00180
00181
00182
00184
00187 void open(bool f);
00188
00189
00190
00192
00198 void setEditable(bool f) {
00199 _editable = f;
00200 }
00201
00202
00203
00205
00208 bool isEditable() {
00209 return _editable;
00210 }
00211
00212
00213
00215
00218 bool isSelected() {
00219 return _selected;
00220 }
00221
00222
00223
00225
00228 void select(bool f);
00229
00230
00231
00233
00239 void setMode(Mode flag);
00240
00241
00242
00244
00247 void setStyle(int flag, bool includeSubitems = false);
00248
00249
00250
00252
00255 int getStyle() {
00256 return _style;
00257 }
00258
00259
00260
00262
00265 void setBrush(const QBrush& brush);
00266
00267
00268
00270
00273 QBrush& getBrush() {
00274 return _brush;
00275 }
00276
00277
00278
00280
00283 QBrush& getSelectBrush() {
00284 return _selectBrush;
00285 }
00286
00287
00288
00290
00293 void setPen(const QPen& pen);
00294
00295
00296
00298
00301 QPen& getPen() {
00302 return _pen;
00303 }
00304
00305
00306
00308
00311 void setTextPen(const QPen& pen) {
00312 _textPen = pen;
00313 }
00314
00315
00316
00318
00321 QPen& getTextPen() {
00322 return _textPen;
00323 }
00324
00325
00326
00328
00331 void setText(const QString& text);
00332
00333
00334
00336
00339 QString getText() { return _text; }
00340
00341
00342
00344
00349 QDateTime getStart();
00350
00351
00352
00354
00357 QDateTime getEnd();
00358
00359
00360
00362
00365 void setStart(const QDateTime& start);
00366
00367
00368
00370
00373 void setEnd(const QDateTime& end);
00374
00375
00376
00378
00382 void setHeight(int h);
00383
00384
00385
00387
00392 int getHeight() {
00393 return _height;
00394 }
00395
00396
00397
00399
00404 int getTotalHeight();
00405
00406
00407
00409
00412 int getWidth();
00413
00414
00415
00417
00420 QPtrList<KGanttItem>& getSubItems() {
00421 return _subitems;
00422 }
00423
00424
00425
00427
00430 QPtrList<KGanttRelation>& getRelations() {
00431 return _relations;
00432 }
00433
00434
00435
00437
00440 void startTransaction(){
00441 blockSignals(true);
00442 }
00443
00444
00445
00447
00452 void endTransaction();
00453
00454
00455
00457
00460 static QString ChangeAsString(Change c);
00461
00462
00463
00464
00466
00469 void dump(QTextOStream& cout, const QString& pre);
00470
00471
00472 signals:
00473
00475
00479 void changed(KGanttItem*, KGanttItem::Change);
00480
00481
00482
00484
00488 void destroyed(KGanttItem*);
00489
00490
00491
00492 private slots:
00493
00494 void subItemChanged(KGanttItem*, KGanttItem::Change);
00495
00496 void removeRelation(KGanttRelation* rel);
00497
00498
00499 private:
00500
00501 void registerItem(KGanttItem* item);
00502 void unregisterItem(KGanttItem* item);
00503
00504 void init(KGanttItem* parentItem, const QString& text,
00505 const QDateTime& start, const QDateTime& end);
00506
00507
00508
00509 Change adjustMinMax();
00510
00511
00512
00513 Change adjustStartEnd();
00514
00515
00516
00517 bool _open;
00518 bool _selected;
00519
00520
00521
00522
00523 bool _editable;
00524
00525 int _height, _style, _mode;
00526
00527
00528 KGanttItem* _parentItem;
00529 QPtrList<KGanttItem> _subitems;
00530 QPtrList<KGanttRelation> _relations;
00531
00532
00533
00534
00535
00536 QDateTime _start, _end, _minDateTime, _maxDateTime;
00537
00538 QString _text;
00539
00540 QBrush _brush;
00541 QPen _pen, _textPen;
00542
00543 static QBrush _selectBrush;
00544
00545
00546 };
00547
00548 #endif