kdgantt

KDGanttViewItem.h
1/*
2 $Id: KDGanttViewItem.h 369055 2004-12-07 13:56:58Z danders $
3 KDGantt - a multi-platform charting engine
4*/
5
6/****************************************************************************
7 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
8 **
9 ** This file is part of the KDGantt library.
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 as published by the Free Software
13 ** Foundation and appearing in the file LICENSE.GPL included in the
14 ** packaging of this file.
15 **
16 ** Licensees holding valid commercial KDGantt licenses may use this file in
17 ** accordance with the KDGantt Commercial License Agreement provided with
18 ** the Software.
19 **
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 **
23 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
24 ** information about KDGantt Commercial License Agreements.
25 **
26 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
27 ** licensing are not clear to you.
28 **
29 ** As a special exception, permission is given to link this program
30 ** with any edition of TQt, and distribute the resulting executable,
31 ** without including the source code for TQt in the source distribution.
32 **
33 **********************************************************************/
34
35
36#ifndef KDGANTTVIEWITEM_H
37#define KDGANTTVIEWITEM_H
38
39#include <tqdatetime.h>
40#include <tqstring.h>
41#include <tqcolor.h>
42#include <tqpixmap.h>
43#include <tqfont.h>
44#include <tqlistview.h>
45#include <tqcanvas.h>
46#include <tqdom.h>
47#include <tqdict.h>
48
49class KDGanttView;
50class KDTimeTableWidget;
51class KDTimeHeaderWidget;
53class KDCanvasLine;
54class KDCanvasText;
55class KDCanvasPolygonItem;
57
58class KDGanttViewItem : public TQListViewItem
59{
60public:
61 enum Type { Event, Task, Summary };
62 enum Shape { TriangleDown, TriangleUp, Diamond, Square, Circle };
63
64protected:
65 KDGanttViewItem( Type type, KDGanttView* view,
66 const TQString& lvtext = TQString(),
67 const TQString& name = TQString() );
69 const TQString& lvtext = TQString(),
70 const TQString& name = TQString() );
72 const TQString& lvtext = TQString(),
73 const TQString& name = TQString() );
75 KDGanttViewItem* after,
76 const TQString& lvtext = TQString(),
77 const TQString& name = TQString() );
78
79 //bool _isCalendar;
81 void updateCanvasItems();
82 int getCoordY();
83 TQDateTime myChildStartTime();
84 TQDateTime myChildEndTime();
85 void generateAndInsertName( const TQString& name );
86 KDCanvasLine * startLine, *endLine,
88 KDCanvasPolygonItem* startShape,* midShape, *endShape, *progressShape,
90 * floatStartShape, * floatEndShape;
91 KDGanttView* myGanttView;
92 KDCanvasText* textCanvas;
98
99 void moveTextCanvas(int x, int y);
100 int myProgress;
101 TQDateTime myFloatStartTime;
102 TQDateTime myFloatEndTime;
103
104public:
105 virtual ~KDGanttViewItem();
106
107 Type type() const;
108 void setEnabled( bool on );
109 bool enabled () const;
110 virtual void setOpen( bool o );
111 void setItemVisible( bool on );
112 bool itemVisible () const;
113 void setEditable( bool editable );
114 bool editable() const;
115 void setShowNoInformation( bool show );
116 bool showNoInformation();
117 void setDisplaySubitemsAsGroup( bool show );
118 bool displaySubitemsAsGroup() const;
119 void setPriority( int prio );
120 int priority();
121 virtual void setStartTime( const TQDateTime& start );
122 TQDateTime startTime() const;
123 virtual void setEndTime( const TQDateTime& end );
124 TQDateTime endTime() const;
125
126 void setText( const TQString& text );
127 TQString text() const;
128 void setListViewText( const TQString& text, int column = 0 );
129 void setListViewText( int column, const TQString& text );
130 TQString listViewText( int column = 0 ) const;
131 void setFont( const TQFont& font );
132 TQFont font() const;
133 void setTooltipText( const TQString& text );
134 TQString tooltipText() const;
135 void setWhatsThisText( const TQString& text );
136 TQString whatsThisText() const;
137 void setPixmap( int column, const TQPixmap& pixmap );
138 void setPixmap( const TQPixmap& pixmap );
139 const TQPixmap* pixmap( int column = 0 ) const;
140
141 void setHighlight( bool );
142 bool highlight() const;
143
144 bool subitemIsCalendar() const;
145 //void setIsCalendar( bool );
146 //bool isCalendar( ) const;
147
148 void setShapes( Shape start, Shape middle, Shape end );
149 void shapes( Shape& start, Shape& middle, Shape& end ) const;
150 void setDefaultColor( const TQColor& );
151 TQColor defaultColor() const;
152 void setColors( const TQColor& start, const TQColor& middle,
153 const TQColor& end );
154 void colors( TQColor& start, TQColor& middle, TQColor& end ) const;
155 void setDefaultHighlightColor( const TQColor& );
156 TQColor defaultHighlightColor() const;
157 void setHighlightColors( const TQColor& start, const TQColor& middle,
158 const TQColor& end );
159 void highlightColors( TQColor& start, TQColor& middle, TQColor& end ) const;
160 void setTextColor( const TQColor& color );
161 TQColor textColor() const;
162
163 void setProgress(int percent);
164 void setFloatStartTime(const TQDateTime &start);
165 void setFloatEndTime(const TQDateTime &end);
166
169 KDGanttViewItem* parent() const;
171 KDGanttViewItem* itemBelow( bool includeDisabled = true );
172 KDGanttViewItem* getChildByName( const TQString& name );
173 TQString name() const;
174 static KDGanttViewItem* find( const TQString& name );
175
176 void createNode( TQDomDocument& doc,
177 TQDomElement& parentElement );
178 static KDGanttViewItem* createFromDomElement( KDGanttView* view,
179 TQDomElement& element );
180 static KDGanttViewItem* createFromDomElement( KDGanttView* view,
181 KDGanttViewItem* previous,
182 TQDomElement& element );
184 TQDomElement& element );
186 KDGanttViewItem* previous,
187 TQDomElement& element );
188private:
189 friend class KDGanttView;
190 friend class KDTimeTableWidget;
191 friend class KDTimeHeaderWidget;
192 friend class KDListView;
193 friend class KDGanttViewTaskLink;
194 friend class KDGanttViewTaskLinkGroup;
195 friend class KDGanttCanvasView;
196 friend class KDGanttViewItemDrag;
197 friend class itemAttributeDialog;
198
199 static TQString shapeToString( Shape shape );
200 static Shape stringToShape( const TQString& string );
201 static TQString typeToString( Type type );
202
203 Type myType;
204 void initColorAndShapes(Type t);
205 void resetSubitemVisibility();
206 virtual void showItem( bool show = true, int coordY = 0 );
207 virtual void initItem();
208 int computeHeight();
209 void showSubItems();
210 void showSubitemTree( int );
211 void hideSubtree();
212 void setCallListViewOnSetOpen( bool call );
213 bool showNoCross();
214 void createShape(KDCanvasPolygonItem* &,KDCanvasPolygonItem* &, Shape);
215 void loadFromDomElement( TQDomElement& element );
216
217 //TQFont myFont;
218 TQString myToolTipText,myWhatsThisText;
219 void paintBranches ( TQPainter * p, const TQColorGroup & cg, int w, int y, int h );
220 bool _displaySubitemsAsGroup;
221 bool _showNoInformation;
222 bool _enabled;
223 bool _callListViewOnSetOpen;
224 Shape myStartShape,myMiddleShape,myEndShape;
225 TQColor myStartColor,myMiddleColor,myEndColor;
226 TQColor myStartColorHL,myMiddleColorHL,myEndColorHL;
227 TQColor myDefaultColor,myDefaultColorHL;
228 TQColor myTextColor;
229 bool colorDefined,colorHLDefined;
230 TQPoint getTaskLinkStartCoord(TQPoint);
231 TQPoint getTaskLinkEndCoord();
232 TQPoint middleLeft();
233 TQPoint middleRight();
234 void moveTextCanvas();
235 void setTextOffset(TQPoint p);
236 bool isMyTextCanvas(TQCanvasItem *tc);
237 TQPoint myTextOffset;
238 TQString _name;
239 bool shapeDefined;
240 int _priority;
241 static TQDict<KDGanttViewItem> sItemDict;
242};
243
244
245#endif
void setTextColor(const TQColor &color)
KDGanttView * myGanttView
TQString listViewText(int column=0) const
TQColor defaultColor() const
void setFont(const TQFont &font)
void setTooltipText(const TQString &text)
KDCanvasPolygonItem * midShapeBack
TQString textCanvasText
TQDateTime myStartTime
void setText(const TQString &text)
KDGanttViewItem * getChildByName(const TQString &name)
void setItemVisible(bool on)
const TQPixmap * pixmap(int column=0) const
void setShowNoInformation(bool show)
KDGanttViewItem * itemBelow(bool includeDisabled=true)
TQFont font() const
virtual void setEndTime(const TQDateTime &end)
void moveTextCanvas(int x, int y)
void setPriority(int prio)
KDCanvasPolygonItem * startShape
KDGanttViewItem * itemAbove()
virtual void setStartTime(const TQDateTime &start)
void setEditable(bool editable)
KDCanvasPolygonItem * startShapeBack
void generateAndInsertName(const TQString &name)
static KDGanttViewItem * find(const TQString &name)
void setEnabled(bool on)
TQString whatsThisText() const
void setColors(const TQColor &start, const TQColor &middle, const TQColor &end)
void createNode(TQDomDocument &doc, TQDomElement &parentElement)
KDCanvasLine * startLine
KDGanttViewItem * nextSibling() const
KDGanttViewItem * parent() const
TQDateTime myChildStartTime()
TQDateTime endTime() const
TQString tooltipText() const
TQDateTime myEndTime
bool editable() const
bool itemVisible() const
KDCanvasLine * endLineBack
TQColor defaultHighlightColor() const
void setFloatStartTime(const TQDateTime &start)
void highlightColors(TQColor &start, TQColor &middle, TQColor &end) const
TQString text() const
void setPixmap(int column, const TQPixmap &pixmap)
static KDGanttViewItem * createFromDomElement(KDGanttView *view, TQDomElement &element)
void setProgress(int percent)
void setShapes(Shape start, Shape middle, Shape end)
void colors(TQColor &start, TQColor &middle, TQColor &end) const
KDCanvasLine * startLineBack
void setFloatEndTime(const TQDateTime &end)
void setDisplaySubitemsAsGroup(bool show)
bool displaySubitemsAsGroup() const
KDGanttViewItem * firstChild() const
void setDefaultColor(const TQColor &)
void setHighlightColors(const TQColor &start, const TQColor &middle, const TQColor &end)
void setListViewText(const TQString &text, int column=0)
TQColor textColor() const
KDCanvasPolygonItem * midShape
TQDateTime myChildEndTime()
KDCanvasPolygonItem * endShapeBack
TQDateTime startTime() const
bool subitemIsCalendar() const
KDCanvasText * textCanvas
TQString name() const
KDGanttViewItem(Type type, KDGanttView *view, const TQString &lvtext=TQString(), const TQString &name=TQString())
void setWhatsThisText(const TQString &text)
KDCanvasLine * endLine
KDCanvasLine * actualEnd
bool highlight() const
void shapes(Shape &start, Shape &middle, Shape &end) const
void setDefaultHighlightColor(const TQColor &)
virtual void setOpen(bool o)
KDCanvasPolygonItem * endShape