kgantt Library API Documentation

KGanttItem.h

00001 #ifndef _KGANTTITEM_H_ 00002 #define _KGANTTITEM_H_ 00003 00004 /* 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, USA. 00020 00021 author : jh, jochen@ifb.bv.tu-berlin.de 00022 00023 file : KGanttItem.h 00024 date : 26 oct 2000 00025 00026 00027 changelog : 26 dec 2000, jh 00028 09 jan 2001, jh - added signal destroyed(xQTask*) 00029 00030 11 jan 2001, jh changed to kde : xQTask -> KGanttItem 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 // Fill item with brush. 00117 DrawFilled = 2, 00118 DrawText = 4, 00119 00120 // Draw handlke for opening/closing item. 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 * Emits signal destroyed(KGanttItem* this). 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 // set min/max date and time according to subitems 00508 Change adjustMinMax(); 00509 00510 /* if min < start set start to _min, 00511 if max > end set end to max */ 00512 Change adjustStartEnd(); 00513 00514 00515 // is item open/closed 00516 bool _open; 00517 bool _selected; 00518 00519 00520 // is this item editable by the user, if it is false, invoking 00521 // of some methods has no effect 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 // start/end date. 00533 // start must always be earlier then _minDateTime 00534 // end must always be later then _maxDateTime 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
KDE Logo
This file is part of the documentation for kgantt Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:42 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003