kdgantt

KDGanttViewItem.h
1 /*
2  $Id$
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 
49 class KDGanttView;
50 class KDTimeTableWidget;
51 class KDTimeHeaderWidget;
53 class KDCanvasLine;
54 class KDCanvasText;
55 class KDCanvasPolygonItem;
57 
58 class KDGanttViewItem : public TQListViewItem
59 {
60 public:
61  enum Type { Event, Task, Summary };
62  enum Shape { TriangleDown, TriangleUp, Diamond, Square, Circle };
63 
64 protected:
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;
92  KDCanvasText* textCanvas;
93  TQString textCanvasText;
94  TQDateTime myStartTime, myEndTime;
98 
99  void moveTextCanvas(int x, int y);
100  int myProgress;
101  TQDateTime myFloatStartTime;
102  TQDateTime myFloatEndTime;
103 
104 public:
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 
167  KDGanttViewItem* firstChild() const;
168  KDGanttViewItem* nextSibling() const;
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 );
179  TQDomElement& element );
181  KDGanttViewItem* previous,
182  TQDomElement& element );
184  TQDomElement& element );
186  KDGanttViewItem* previous,
187  TQDomElement& element );
188 
189  void setMoveable( bool m );
190  bool isMoveable() const;
191  void setResizeable( bool r );
192  bool isResizeable() const;
193 
194 private:
195  friend class KDGanttView;
196  friend class KDTimeTableWidget;
197  friend class KDTimeHeaderWidget;
198  friend class KDListView;
199  friend class KDGanttViewTaskLink;
200  friend class KDGanttViewTaskLinkGroup;
201  friend class KDGanttCanvasView;
202  friend class KDGanttViewItemDrag;
203  friend class itemAttributeDialog;
204 
205  static TQString shapeToString( Shape shape );
206  static Shape stringToShape( const TQString& string );
207  static TQString typeToString( Type type );
208 
209  Type myType;
210  void initColorAndShapes(Type t);
211  void resetSubitemVisibility();
212  virtual void showItem( bool show = true, int coordY = 0 );
213  virtual void initItem();
214  int computeHeight();
215  void showSubItems();
216  void showSubitemTree( int );
217  void hideSubtree();
218  void setCallListViewOnSetOpen( bool call );
219  bool showNoCross();
220  void createShape(KDCanvasPolygonItem* &,KDCanvasPolygonItem* &, Shape);
221  void loadFromDomElement( TQDomElement& element );
222 
223  //TQFont myFont;
224  TQString myToolTipText,myWhatsThisText;
225  void paintBranches ( TQPainter * p, const TQColorGroup & cg, int w, int y, int h );
226  bool _displaySubitemsAsGroup;
227  bool _showNoInformation;
228  bool _enabled;
229  bool _callListViewOnSetOpen;
230  Shape myStartShape,myMiddleShape,myEndShape;
231  TQColor myStartColor,myMiddleColor,myEndColor;
232  TQColor myStartColorHL,myMiddleColorHL,myEndColorHL;
233  TQColor myDefaultColor,myDefaultColorHL;
234  TQColor myTextColor;
235  bool colorDefined,colorHLDefined;
236  TQPoint getTaskLinkStartCoord(TQPoint);
237  TQPoint getTaskLinkEndCoord();
238  TQPoint middleLeft();
239  TQPoint middleRight();
240  void moveTextCanvas();
241  void setTextOffset(TQPoint p);
242  bool isMyTextCanvas(TQCanvasItem *tc);
243  TQPoint myTextOffset;
244  TQString _name;
245  bool shapeDefined;
246  int _priority;
247  static TQDict<KDGanttViewItem> sItemDict;
248 
249  bool _isMoveable;
250  bool _isResizeable;
251 };
252 
253 
254 #endif
Drag and drop of KD Gantt items.
void setTextColor(const TQColor &color)
KDCanvasPolygonItem * midShapeBack
TQString listViewText(int column=0) const
TQColor defaultColor() const
void setFont(const TQFont &font)
void setTooltipText(const TQString &text)
KDCanvasLine * endLine
KDCanvasText * textCanvas
TQString textCanvasText
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
KDCanvasPolygonItem * startShape
KDCanvasPolygonItem * midShape
virtual void setEndTime(const TQDateTime &end)
TQDateTime myStartTime
void moveTextCanvas(int x, int y)
void setPriority(int prio)
KDGanttViewItem * itemAbove()
virtual void setStartTime(const TQDateTime &start)
void setHighlight(bool)
void setEditable(bool editable)
void generateAndInsertName(const TQString &name)
static KDGanttViewItem * find(const TQString &name)
KDCanvasLine * actualEnd
KDCanvasPolygonItem * endShapeBack
KDCanvasLine * endLineBack
void setEnabled(bool on)
TQString whatsThisText() const
void setColors(const TQColor &start, const TQColor &middle, const TQColor &end)
void createNode(TQDomDocument &doc, TQDomElement &parentElement)
KDCanvasPolygonItem * startShapeBack
KDGanttViewItem * nextSibling() const
KDGanttViewItem * parent() const
TQDateTime myChildStartTime()
TQDateTime endTime() const
bool enabled() const
TQString tooltipText() const
KDGanttView * myGanttView
bool editable() const
bool itemVisible() const
KDCanvasLine * startLineBack
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
void setFloatEndTime(const TQDateTime &end)
void setDisplaySubitemsAsGroup(bool show)
bool displaySubitemsAsGroup() const
KDGanttViewItem * firstChild() const
TQDateTime myEndTime
void setDefaultColor(const TQColor &)
KDCanvasLine * startLine
void setHighlightColors(const TQColor &start, const TQColor &middle, const TQColor &end)
void setListViewText(const TQString &text, int column=0)
TQColor textColor() const
TQDateTime myChildEndTime()
TQDateTime startTime() const
bool subitemIsCalendar() const
TQString name() const
KDGanttViewItem(Type type, KDGanttView *view, const TQString &lvtext=TQString(), const TQString &name=TQString())
void setWhatsThisText(const TQString &text)
KDCanvasPolygonItem * endShape
bool highlight() const
void shapes(Shape &start, Shape &middle, Shape &end) const
void setDefaultHighlightColor(const TQColor &)
virtual void setOpen(bool o)
virtual ~KDGanttViewItem()