kdgantt

KDGanttViewItem.h

00001 /* -*- Mode: C++ -*-
00002    $Id: KDGanttViewItem.h 369055 2004-12-07 13:56:58Z danders $
00003    KDGantt - a multi-platform charting engine
00004 */
00005 
00006 /****************************************************************************
00007  ** Copyright (C)  2002-2004 Klarälvdalens Datakonsult AB.  All rights reserved.
00008  **
00009  ** This file is part of the KDGantt library.
00010  **
00011  ** This file may be distributed and/or modified under the terms of the
00012  ** GNU General Public License version 2 as published by the Free Software
00013  ** Foundation and appearing in the file LICENSE.GPL included in the
00014  ** packaging of this file.
00015  **
00016  ** Licensees holding valid commercial KDGantt licenses may use this file in
00017  ** accordance with the KDGantt Commercial License Agreement provided with
00018  ** the Software.
00019  **
00020  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00021  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00022  **
00023  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
00024  **   information about KDGantt Commercial License Agreements.
00025  **
00026  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00027  ** licensing are not clear to you.
00028  **
00029  ** As a special exception, permission is given to link this program
00030  ** with any edition of Qt, and distribute the resulting executable,
00031  ** without including the source code for Qt in the source distribution.
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   //bool _isCalendar;
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   //void setIsCalendar( bool );
00146   //bool isCalendar( ) const;
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     //QFont myFont;
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
KDE Home | KDE Accessibility Home | Description of Access Keys