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 <tqdatetime.h>
00040 #include <tqstring.h>
00041 #include <tqcolor.h>
00042 #include <tqpixmap.h>
00043 #include <tqfont.h>
00044 #include <tqlistview.h>
00045 #include <tqcanvas.h>
00046 #include <tqdom.h>
00047 #include <tqdict.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 TQString& lvtext = TQString::null,
00067 const TQString& name = TQString::null );
00068 KDGanttViewItem( Type type, KDGanttViewItem* parent,
00069 const TQString& lvtext = TQString::null,
00070 const TQString& name = TQString::null );
00071 KDGanttViewItem( Type type, KDGanttView* view, KDGanttViewItem* after,
00072 const TQString& lvtext = TQString::null,
00073 const TQString& name = TQString::null );
00074 KDGanttViewItem( Type type, KDGanttViewItem* parent,
00075 KDGanttViewItem* after,
00076 const TQString& lvtext = TQString::null,
00077 const TQString& name = TQString::null );
00078
00079
00080 bool isVisibleInGanttView;
00081 void updateCanvasItems();
00082 int getCoordY();
00083 TQDateTime myChildStartTime();
00084 TQDateTime myChildEndTime();
00085 void generateAndInsertName( const TQString& 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 TQString textCanvasText;
00094 TQDateTime myStartTime, myEndTime;
00095 bool isHighlighted, isEditable;
00096 int myItemSize;
00097 bool blockUpdating;
00098
00099 void moveTextCanvas(int x, int y);
00100 int myProgress;
00101 TQDateTime myFloatStartTime;
00102 TQDateTime 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 TQDateTime& start );
00122 TQDateTime startTime() const;
00123 virtual void setEndTime( const TQDateTime& end );
00124 TQDateTime endTime() const;
00125
00126 void setText( const TQString& text );
00127 TQString text() const;
00128 void setListViewText( const TQString& text, int column = 0 );
00129 void setListViewText( int column, const TQString& text );
00130 TQString listViewText( int column = 0 ) const;
00131 void setFont( const TQFont& font );
00132 TQFont font() const;
00133 void setTooltipText( const TQString& text );
00134 TQString tooltipText() const;
00135 void setWhatsThisText( const TQString& text );
00136 TQString whatsThisText() const;
00137 void setPixmap( int column, const TQPixmap& pixmap );
00138 void setPixmap( const TQPixmap& pixmap );
00139 const TQPixmap* 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 TQColor& );
00151 TQColor defaultColor() const;
00152 void setColors( const TQColor& start, const TQColor& middle,
00153 const TQColor& end );
00154 void colors( TQColor& start, TQColor& middle, TQColor& end ) const;
00155 void setDefaultHighlightColor( const TQColor& );
00156 TQColor defaultHighlightColor() const;
00157 void setHighlightColors( const TQColor& start, const TQColor& middle,
00158 const TQColor& end );
00159 void highlightColors( TQColor& start, TQColor& middle, TQColor& end ) const;
00160 void setTextColor( const TQColor& color );
00161 TQColor textColor() const;
00162
00163 void setProgress(int percent);
00164 void setFloatStartTime(const TQDateTime &start);
00165 void setFloatEndTime(const TQDateTime &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 TQString& name );
00173 TQString name() const;
00174 static KDGanttViewItem* find( const TQString& name );
00175
00176 void createNode( TQDomDocument& doc,
00177 TQDomElement& parentElement );
00178 static KDGanttViewItem* createFromDomElement( KDGanttView* view,
00179 TQDomElement& element );
00180 static KDGanttViewItem* createFromDomElement( KDGanttView* view,
00181 KDGanttViewItem* previous,
00182 TQDomElement& element );
00183 static KDGanttViewItem* createFromDomElement( KDGanttViewItem* parent,
00184 TQDomElement& element );
00185 static KDGanttViewItem* createFromDomElement( KDGanttViewItem* parent,
00186 KDGanttViewItem* previous,
00187 TQDomElement& 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 TQString shapeToString( Shape shape );
00206 static Shape stringToShape( const TQString& string );
00207 static TQString 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( TQDomElement& element );
00222
00223
00224 TQString myToolTipText,myWhatsThisText;
00225 void paintBranches ( TQPainter * p, const TQColorGroup & 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 TQColor myStartColor,myMiddleColor,myEndColor;
00232 TQColor myStartColorHL,myMiddleColorHL,myEndColorHL;
00233 TQColor myDefaultColor,myDefaultColorHL;
00234 TQColor myTextColor;
00235 bool colorDefined,colorHLDefined;
00236 TQPoint getTaskLinkStartCoord(TQPoint);
00237 TQPoint getTaskLinkEndCoord();
00238 TQPoint middleLeft();
00239 TQPoint middleRight();
00240 void moveTextCanvas();
00241 void setTextOffset(TQPoint p);
00242 bool isMyTextCanvas(TQCanvasItem *tc);
00243 TQPoint myTextOffset;
00244 TQString _name;
00245 bool shapeDefined;
00246 int _priority;
00247 static TQDict<KDGanttViewItem> sItemDict;
00248
00249 bool _isMoveable;
00250 bool _isResizeable;
00251 };
00252
00253
00254 #endif