KGanttItem.h
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
00042 #include "KGanttRelation.h"
00043
00044
00045
00047
00052
00053 class KGanttItem : public QObject
00055 {
00056
00057 Q_OBJECT
00058
00059
00060 public:
00061
00062 enum Change {
00063 NoChange = 0,
00064 StartChanged = 1,
00065 EndChanged = 2,
00066
00069 HeightChanged = 4,
00070
00075 TotalHeightChanged = 8,
00076
00078 StyleChanged = 16,
00079 TextChanged = 32,
00080 ModeChanged = 64,
00081 MinChanged = 128,
00082 MaxChanged = 256,
00083
00085 Opened = 512,
00086
00088 Closed = 1024,
00089
00091 Selected = 2048,
00092
00094 Unselected = 4096,
00095
00097 Unknown = 8192,
00098
00100 RelationAdded = 16384,
00101
00103 RelationRemoved = 32768
00104
00105 };
00106
00107
00108
00109 enum Style {
00111 DrawNothing = 0,
00112
00114 DrawBorder = 1,
00115
00116
00117 DrawFilled = 2,
00118 DrawText = 4,
00119
00120
00121 DrawHandle = 16,
00122
00124 DrawHandleWSubitems = 32,
00125
00126 DrawAll = 255
00127 };
00128
00129
00130 enum Mode {
00131 Normal,
00132 Rubberband
00133 };
00134
00135
00137
00140 KGanttItem(KGanttItem* parentItem, const QString& text,
00141 const QDateTime& start, const QDateTime& end);
00142
00143
00144
00146
00149 KGanttItem(KGanttItem* parentItem, const QString& text,
00150 const QDateTime& start, long durationMin);
00151
00152
00153
00155
00156
00157
00158 ~KGanttItem();
00159
00160
00161
00163
00164
00165
00166 KGanttRelation* addRelation(KGanttItem* from, KGanttItem* to,
00167 const QString& text);
00168
00169
00170
00171
00173
00176 bool isOpen() {
00177 return _open;
00178 }
00179
00180
00181
00183
00186 void open(bool f);
00187
00188
00189
00191
00197 void setEditable(bool f) {
00198 _editable = f;
00199 }
00200
00201
00202
00204
00207 bool isEditable() {
00208 return _editable;
00209 }
00210
00211
00212
00214
00217 bool isSelected() {
00218 return _selected;
00219 }
00220
00221
00222
00224
00227 void select(bool f);
00228
00229
00230
00232
00238 void setMode(Mode flag);
00239
00240
00241
00243
00246 void setStyle(int flag, bool includeSubitems = false);
00247
00248
00249
00251
00254 int getStyle() {
00255 return _style;
00256 }
00257
00258
00259
00261
00264 void setBrush(const QBrush& brush);
00265
00266
00267
00269
00272 QBrush& getBrush() {
00273 return _brush;
00274 }
00275
00276
00277
00279
00282 QBrush& getSelectBrush() {
00283 return _selectBrush;
00284 }
00285
00286
00287
00289
00292 void setPen(const QPen& pen);
00293
00294
00295
00297
00300 QPen& getPen() {
00301 return _pen;
00302 }
00303
00304
00305
00307
00310 void setTextPen(const QPen& pen) {
00311 _textPen = pen;
00312 }
00313
00314
00315
00317
00320 QPen& getTextPen() {
00321 return _textPen;
00322 }
00323
00324
00325
00327
00330 void setText(const QString& text);
00331
00332
00333
00335
00338 QString getText() { return _text; }
00339
00340
00341
00343
00348 QDateTime getStart();
00349
00350
00351
00353
00356 QDateTime getEnd();
00357
00358
00359
00361
00364 void setStart(const QDateTime& start);
00365
00366
00367
00369
00372 void setEnd(const QDateTime& end);
00373
00374
00375
00377
00381 void setHeight(int h);
00382
00383
00384
00386
00391 int getHeight() {
00392 return _height;
00393 }
00394
00395
00396
00398
00403 int getTotalHeight();
00404
00405
00406
00408
00411 int getWidth();
00412
00413
00414
00416
00419 QPtrList<KGanttItem>& getSubItems() {
00420 return _subitems;
00421 }
00422
00423
00424
00426
00429 QPtrList<KGanttRelation>& getRelations() {
00430 return _relations;
00431 }
00432
00433
00434
00436
00439 void startTransaction(){
00440 blockSignals(true);
00441 }
00442
00443
00444
00446
00451 void endTransaction();
00452
00453
00454
00456
00459 static QString ChangeAsString(Change c);
00460
00461
00462
00463
00465
00468 void dump(QTextOStream& cout, const QString& pre);
00469
00470
00471 signals:
00472
00474
00478 void changed(KGanttItem*, KGanttItem::Change);
00479
00480
00481
00483
00487 void destroyed(KGanttItem*);
00488
00489
00490
00491 private slots:
00492
00493 void subItemChanged(KGanttItem*, KGanttItem::Change);
00494
00495 void removeRelation(KGanttRelation* rel);
00496
00497
00498 private:
00499
00500 void registerItem(KGanttItem* item);
00501 void unregisterItem(KGanttItem* item);
00502
00503 void init(KGanttItem* parentItem, const QString& text,
00504 const QDateTime& start, const QDateTime& end);
00505
00506
00507
00508 Change adjustMinMax();
00509
00510
00511
00512 Change adjustStartEnd();
00513
00514
00515
00516 bool _open;
00517 bool _selected;
00518
00519
00520
00521
00522 bool _editable;
00523
00524 int _height, _style, _mode;
00525
00526
00527 KGanttItem* _parentItem;
00528 QPtrList<KGanttItem> _subitems;
00529 QPtrList<KGanttRelation> _relations;
00530
00531
00532
00533
00534
00535 QDateTime _start, _end, _minDateTime, _maxDateTime;
00536
00537 QString _text;
00538
00539 QBrush _brush;
00540 QPen _pen, _textPen;
00541
00542 static QBrush _selectBrush;
00543
00544
00545 };
00546
00547 #endif
This file is part of the documentation for kgantt Library Version 3.2.2.