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 private:
00189 friend class KDGanttView;
00190 friend class KDTimeTableWidget;
00191 friend class KDTimeHeaderWidget;
00192 friend class KDListView;
00193 friend class KDGanttViewTaskLink;
00194 friend class KDGanttViewTaskLinkGroup;
00195 friend class KDGanttCanvasView;
00196 friend class KDGanttViewItemDrag;
00197 friend class itemAttributeDialog;
00198
00199 static QString shapeToString( Shape shape );
00200 static Shape stringToShape( const QString& string );
00201 static QString typeToString( Type type );
00202
00203 Type myType;
00204 void initColorAndShapes(Type t);
00205 void resetSubitemVisibility();
00206 virtual void showItem( bool show = true, int coordY = 0 );
00207 virtual void initItem();
00208 int computeHeight();
00209 void showSubItems();
00210 void showSubitemTree( int );
00211 void hideSubtree();
00212 void setCallListViewOnSetOpen( bool call );
00213 bool showNoCross();
00214 void createShape(KDCanvasPolygonItem* &,KDCanvasPolygonItem* &, Shape);
00215 void loadFromDomElement( QDomElement& element );
00216
00217
00218 QString myToolTipText,myWhatsThisText;
00219 void paintBranches ( QPainter * p, const QColorGroup & cg, int w, int y, int h );
00220 bool _displaySubitemsAsGroup;
00221 bool _showNoInformation;
00222 bool _enabled;
00223 bool _callListViewOnSetOpen;
00224 Shape myStartShape,myMiddleShape,myEndShape;
00225 QColor myStartColor,myMiddleColor,myEndColor;
00226 QColor myStartColorHL,myMiddleColorHL,myEndColorHL;
00227 QColor myDefaultColor,myDefaultColorHL;
00228 QColor myTextColor;
00229 bool colorDefined,colorHLDefined;
00230 QPoint getTaskLinkStartCoord(QPoint);
00231 QPoint getTaskLinkEndCoord();
00232 QPoint middleLeft();
00233 QPoint middleRight();
00234 void moveTextCanvas();
00235 void setTextOffset(QPoint p);
00236 bool isMyTextCanvas(QCanvasItem *tc);
00237 QPoint myTextOffset;
00238 QString _name;
00239 bool shapeDefined;
00240 int _priority;
00241 static QDict<KDGanttViewItem> sItemDict;
00242 };
00243
00244
00245 #endif