00001
00002
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
00036 #ifndef KDGANTTVIEWITEM_H
00037 #define KDGANTTVIEWITEM_H
00038
00039 #include <qdatetime.h>
00040 #include <qstring.h>
00041 #include <qcolor.h>
00042 #include <qpixmap.h>
00043 #include <qfont.h>
00044 #include <qlistview.h>
00045 #include <qcanvas.h>
00046 #include <qdom.h>
00047 #include <qdict.h>
00048
00049 class KDGanttView;
00050 class KDTimeTableWidget;
00051 class KDTimeHeaderWidget;
00052 class KDGanttViewTaskLink;
00053 class KDCanvasLine;
00054 class KDCanvasText;
00055 class KDCanvasPolygonItem;
00056 class KDGanttViewTaskLinkGroup;
00057
00058 class KDGanttViewItem : public QListViewItem
00059 {
00060 public:
00061 enum Type { Event, Task, Summary };
00062 enum Shape { TriangleDown, TriangleUp, Diamond, Square, Circle };
00063
00064 protected:
00065 KDGanttViewItem( Type type, KDGanttView* view,
00066 const QString& lvtext = QString::null,
00067 const QString& name = QString::null );
00068 KDGanttViewItem( Type type, KDGanttViewItem* parent,
00069 const QString& lvtext = QString::null,
00070 const QString& name = QString::null );
00071 KDGanttViewItem( Type type, KDGanttView* view, KDGanttViewItem* after,
00072 const QString& lvtext = QString::null,
00073 const QString& name = QString::null );
00074 KDGanttViewItem( Type type, KDGanttViewItem* parent,
00075 KDGanttViewItem* after,
00076 const QString& lvtext = QString::null,
00077 const QString& name = QString::null );
00078
00079
00080 bool isVisibleInGanttView;
00081 void updateCanvasItems();
00082 int getCoordY();
00083 QDateTime myChildStartTime();
00084 QDateTime myChildEndTime();
00085 void generateAndInsertName( const QString& name );
00086 KDCanvasLine * startLine, *endLine,
00087 * startLineBack, *endLineBack, *actualEnd ;
00088 KDCanvasPolygonItem* startShape,* midShape, *endShape, *progressShape,
00089 * startShapeBack,* midShapeBack, *endShapeBack,
00090 * floatStartShape, * floatEndShape;
00091 KDGanttView* myGanttView;
00092 KDCanvasText* textCanvas;
00093 QString textCanvasText;
00094 QDateTime myStartTime, myEndTime;
00095 bool isHighlighted, isEditable;
00096 int myItemSize;
00097 bool blockUpdating;
00098
00099 void moveTextCanvas(int x, int y);
00100 int myProgress;
00101 QDateTime myFloatStartTime;
00102 QDateTime myFloatEndTime;
00103
00104 public:
00105 virtual ~KDGanttViewItem();
00106
00107 Type type() const;
00108 void setEnabled( bool on );
00109 bool enabled () const;
00110 virtual void setOpen( bool o );
00111 void setItemVisible( bool on );
00112 bool itemVisible () const;
00113 void setEditable( bool editable );
00114 bool editable() const;
00115 void setShowNoInformation( bool show );
00116 bool showNoInformation();
00117 void setDisplaySubitemsAsGroup( bool show );
00118 bool displaySubitemsAsGroup() const;
00119 void setPriority( int prio );
00120 int priority();
00121 virtual void setStartTime( const QDateTime& start );
00122 QDateTime startTime() const;
00123 virtual void setEndTime( const QDateTime& end );
00124 QDateTime endTime() const;
00125
00126 void setText( const QString& text );
00127 QString text() const;
00128 void setListViewText( const QString& text, int column = 0 );
00129 void setListViewText( int column, const QString& text );
00130 QString listViewText( int column = 0 ) const;
00131 void setFont( const QFont& font );
00132 QFont font() const;
00133 void setTooltipText( const QString& text );
00134 QString tooltipText() const;
00135 void setWhatsThisText( const QString& text );
00136 QString whatsThisText() const;
00137 void setPixmap( int column, const QPixmap& pixmap );
00138 void setPixmap( const QPixmap& pixmap );
00139 const QPixmap* pixmap( int column = 0 ) const;
00140
00141 void setHighlight( bool );
00142 bool highlight() const;
00143
00144 bool subitemIsCalendar() const;
00145
00146
00147
00148 void setShapes( Shape start, Shape middle, Shape end );
00149 void shapes( Shape& start, Shape& middle, Shape& end ) const;
00150 void setDefaultColor( const QColor& );
00151 QColor defaultColor() const;
00152 void setColors( const QColor& start, const QColor& middle,
00153 const QColor& end );
00154 void colors( QColor& start, QColor& middle, QColor& end ) const;
00155 void setDefaultHighlightColor( const QColor& );
00156 QColor defaultHighlightColor() const;
00157 void setHighlightColors( const QColor& start, const QColor& middle,
00158 const QColor& end );
00159 void highlightColors( QColor& start, QColor& middle, QColor& end ) const;
00160 void setTextColor( const QColor& color );
00161 QColor textColor() const;
00162
00163 void setProgress(int percent);
00164 void setFloatStartTime(const QDateTime &start);
00165 void setFloatEndTime(const QDateTime &end);
00166
00167 KDGanttViewItem* firstChild() const;
00168 KDGanttViewItem* nextSibling() const;
00169 KDGanttViewItem* parent() const;
00170 KDGanttViewItem* itemAbove();
00171 KDGanttViewItem* itemBelow( bool includeDisabled = true );
00172 KDGanttViewItem* getChildByName( const QString& name );
00173 QString name() const;
00174 static KDGanttViewItem* find( const QString& name );
00175
00176 void createNode( QDomDocument& doc,
00177 QDomElement& parentElement );
00178 static KDGanttViewItem* createFromDomElement( KDGanttView* view,
00179 QDomElement& element );
00180 static KDGanttViewItem* createFromDomElement( KDGanttView* view,
00181 KDGanttViewItem* previous,
00182 QDomElement& element );
00183 static KDGanttViewItem* createFromDomElement( KDGanttViewItem* parent,
00184 QDomElement& element );
00185 static KDGanttViewItem* createFromDomElement( KDGanttViewItem* parent,
00186 KDGanttViewItem* previous,
00187 QDomElement& element );
00188
00189 void setMoveable( bool m );
00190 bool isMoveable() const;
00191 void setResizeable( bool r );
00192 bool isResizeable() const;
00193
00194 private:
00195 friend class KDGanttView;
00196 friend class KDTimeTableWidget;
00197 friend class KDTimeHeaderWidget;
00198 friend class KDListView;
00199 friend class KDGanttViewTaskLink;
00200 friend class KDGanttViewTaskLinkGroup;
00201 friend class KDGanttCanvasView;
00202 friend class KDGanttViewItemDrag;
00203 friend class itemAttributeDialog;
00204
00205 static QString shapeToString( Shape shape );
00206 static Shape stringToShape( const QString& string );
00207 static QString typeToString( Type type );
00208
00209 Type myType;
00210 void initColorAndShapes(Type t);
00211 void resetSubitemVisibility();
00212 virtual void showItem( bool show = true, int coordY = 0 );
00213 virtual void initItem();
00214 int computeHeight();
00215 void showSubItems();
00216 void showSubitemTree( int );
00217 void hideSubtree();
00218 void setCallListViewOnSetOpen( bool call );
00219 bool showNoCross();
00220 void createShape(KDCanvasPolygonItem* &,KDCanvasPolygonItem* &, Shape);
00221 void loadFromDomElement( QDomElement& element );
00222
00223
00224 QString myToolTipText,myWhatsThisText;
00225 void paintBranches ( QPainter * p, const QColorGroup & cg, int w, int y, int h );
00226 bool _displaySubitemsAsGroup;
00227 bool _showNoInformation;
00228 bool _enabled;
00229 bool _callListViewOnSetOpen;
00230 Shape myStartShape,myMiddleShape,myEndShape;
00231 QColor myStartColor,myMiddleColor,myEndColor;
00232 QColor myStartColorHL,myMiddleColorHL,myEndColorHL;
00233 QColor myDefaultColor,myDefaultColorHL;
00234 QColor myTextColor;
00235 bool colorDefined,colorHLDefined;
00236 QPoint getTaskLinkStartCoord(QPoint);
00237 QPoint getTaskLinkEndCoord();
00238 QPoint middleLeft();
00239 QPoint middleRight();
00240 void moveTextCanvas();
00241 void setTextOffset(QPoint p);
00242 bool isMyTextCanvas(QCanvasItem *tc);
00243 QPoint myTextOffset;
00244 QString _name;
00245 bool shapeDefined;
00246 int _priority;
00247 static QDict<KDGanttViewItem> sItemDict;
00248
00249 bool _isMoveable;
00250 bool _isResizeable;
00251 };
00252
00253
00254 #endif