00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KPTGANTTVIEW_H
00022 #define KPTGANTTVIEW_H
00023
00024 #include "kptview.h"
00025 #include "kptcontext.h"
00026
00027 #include <KDGanttViewItem.h>
00028
00029 #include <QList>
00030
00031 class QLayout;
00032 class Q3ListViewItem;
00033 class QPoint;
00034 class Q3ListView;
00035 class QLineEdit;
00036 class QSpinBox;
00037 class QSplitter;
00038
00039 class KDGanttViewSummaryItem;
00040 class KDGanttViewTaskItem;
00041 class KDGanttViewEventItem;
00042 class KDGanttViewTaskLink;
00043
00044 class KAction;
00045 class KPrinter;
00046
00047 namespace KPlato
00048 {
00049
00050 class MyKDGanttView;
00051 class TaskAppointmentsView;
00052
00053 class Node;
00054 class Task;
00055 class Project;
00056 class Relation;
00057
00058 class GanttView : public ViewBase
00059 {
00060 Q_OBJECT
00061
00062 public:
00063
00064 GanttView( QWidget *parent, bool readWrite = true, const char* name = 0 );
00065
00066
00067
00068 virtual void setZoom( double zoom );
00069 void show();
00070 virtual void draw( Project &project );
00071 virtual void drawChanges();
00072 virtual void drawChanges( Project &project );
00073
00077 void drawOnPainter( QPainter* painter, const QRect rect );
00078
00079 Node *currentNode() const;
00080
00081 void clear();
00082 void print( KPrinter &prts );
00083
00084 void addTaskLink( KDGanttViewTaskLink *link );
00085
00086 bool exportGantt( QIODevice* device );
00087
00088 virtual bool setContext( Context::Ganttview &context, Project &project );
00089 virtual void getContext( Context::Ganttview &context ) const;
00090
00091 void setReadWriteMode( bool on );
00092 bool isReadWriteMode() const { return m_readWrite; }
00093 KDGanttViewItem *currentItem() const { return m_currentItem; }
00094
00095 bool showNoInformation() const { return m_showNoInformation; }
00096
00097 signals:
00098 void enableActions( bool );
00099 void modifyRelation( Relation *rel ) ;
00100 void addRelation( Node *par, Node *child );
00101 void modifyRelation( Relation *rel, int linkType ) ;
00102 void addRelation( Node *par, Node *child, int linkType );
00103 void itemDoubleClicked();
00104
00105 void itemRenamed( Node*, const QString& );
00106
00111 void requestPopupMenu( const QString& menuname, const QPoint & pos );
00112
00113 public slots:
00117 void popupMenuRequested( KDGanttViewItem * item, const QPoint & pos, int );
00118
00119 void setShowExpected( bool on ) { m_showExpected = on; }
00120 void setShowOptimistic( bool on ) { m_showOptimistic = on; }
00121 void setShowPessimistic( bool on ) { m_showPessimistic = on; }
00122 void setShowResources( bool on ) { m_showResources = on; }
00123 void setShowTaskName( bool on ) { m_showTaskName = on; }
00124 void setShowTaskLinks( bool on );
00125 void setShowProgress( bool on ) { m_showProgress = on; }
00126 void setShowPositiveFloat( bool on ) { m_showPositiveFloat = on; }
00127 void setShowCriticalTasks( bool on ) { m_showCriticalTasks = on; }
00128 void setShowCriticalPath( bool on ) { m_showCriticalPath = on; }
00129 void setShowNoInformation( bool on ) { m_showNoInformation = on; }
00130 void setShowAppointments( bool on ) { m_showAppointments = on; }
00131
00132 private slots:
00133 void currentItemChanged( KDGanttViewItem * );
00134 void slotItemDoubleClicked( KDGanttViewItem* );
00135 void slotItemRenamed( KDGanttViewItem*, int, const QString& );
00136
00137 void slotCreateTaskLink( KDGanttViewItem* from, KDGanttViewItem::Connector fc, KDGanttViewItem* to, KDGanttViewItem::Connector tc );
00138
00139 void slotGvItemClicked( KDGanttViewItem* );
00140
00141 void slotModifyLink( KDGanttViewTaskLink* link );
00142
00143 protected:
00144 int linkTypeToRelation( KDGanttViewItem::Connector fc, KDGanttViewItem::Connector tc );
00145 void setRenameEnabled( Q3ListViewItem *item, bool on );
00146 private:
00147 KDGanttViewItem *findItem( Node *node );
00148 KDGanttViewItem *findItem( Node *node, KDGanttViewItem *item );
00149 Node *getNode( KDGanttViewItem *item ) const;
00150 bool isDrawn( KDGanttViewItem *item );
00151 void setDrawn( KDGanttViewItem *item, bool state );
00152 void resetDrawn( KDGanttViewItem *_item );
00153 void removeNotDrawn( KDGanttViewItem *_item );
00154 void deleteItem( KDGanttViewItem *item );
00155 KDGanttViewItem *correctType( KDGanttViewItem *item, Node *node );
00156 void correctPosition( KDGanttViewItem *item, Node *node );
00157 KDGanttViewItem *correctParent( KDGanttViewItem *item, Node *node );
00158
00159 void updateChildren( Node *node );
00160 void updateNode( Node *node );
00161
00162 void modifyChildren( Node *node );
00163 void modifyNode( Node *node );
00164 void modifyProject( KDGanttViewItem *item, Node *node );
00165 void modifySummaryTask( KDGanttViewItem *item, Task *task );
00166 void modifyTask( KDGanttViewItem *item, Task *task );
00167 void modifyMilestone( KDGanttViewItem *item, Task *task );
00168
00169 KDGanttViewItem *addNode( KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after = 0 );
00170
00171 KDGanttViewItem *addProject( KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after = 0 );
00172 KDGanttViewItem *addSubProject( KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after = 0 );
00173 KDGanttViewItem *addSummaryTask( KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after = 0 );
00174 KDGanttViewItem *addTask( KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after = 0 );
00175 KDGanttViewItem *addMilestone( KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after = 0 );
00176
00177 void drawChildren( KDGanttViewItem *item, Node &node );
00178 void drawProject( KDGanttViewItem *parentItem, Node *node );
00179 void drawSubProject( KDGanttViewItem *parentItem, Node *node );
00180 void drawSummaryTask( KDGanttViewItem *parentItem, Task *task );
00181 void drawTask( KDGanttViewItem *parentItem, Task *task );
00182 void drawMilestone( KDGanttViewItem *parentItem, Task *task );
00183
00184 void drawRelations();
00185 void drawRelations( KDGanttViewItem *item );
00186 void drawChildRelations( KDGanttViewItem *item );
00187
00188 void getContextClosedNodes( Context::Ganttview &context, KDGanttViewItem *item ) const;
00189
00190 private:
00191 bool m_readWrite;
00192 int m_defaultFontSize;
00193 KDGanttViewItem *m_currentItem;
00194 QSplitter *m_splitter;
00195 MyKDGanttView *m_gantt;
00196 TaskAppointmentsView *m_taskView;
00197 bool m_showExpected;
00198 bool m_showOptimistic;
00199 bool m_showPessimistic;
00200 bool m_showResources;
00201 bool m_showTaskName;
00202 bool m_showTaskLinks;
00203 bool m_showProgress;
00204 bool m_showPositiveFloat;
00205 bool m_showCriticalTasks;
00206 bool m_showCriticalPath;
00207 bool m_showNoInformation;
00208 bool m_showAppointments;
00209 bool m_firstTime;
00210 Q3PtrList<KDGanttViewTaskLink> m_taskLinks;
00211 Project *m_project;
00212 };
00213
00214 }
00215
00216 #endif