kplato

kptganttview.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Dag Andersen <danders@get2net.dk>
00003    Copyright (C) 2006 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation;
00008    version 2 of the License.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KPTGANTTVIEW_H
00022 #define KPTGANTTVIEW_H
00023 
00024 #include "kptcontext.h"
00025 
00026 #include <qsplitter.h>
00027 #include <qcursor.h>
00028 
00029 class QLayout;
00030 class QListViewItem;
00031 class QPoint;
00032 class QListView;
00033 class QLineEdit;
00034 class QSpinBox;
00035 
00036 class KDGanttViewSummaryItem;
00037 class KDGanttViewTaskItem;
00038 class KDGanttViewEventItem;
00039 class KDGanttViewItem;
00040 class KDGanttViewTaskLink;
00041 
00042 class KPrinter;
00043 
00044 namespace KPlato
00045 {
00046 
00047 class MyKDGanttView;
00048 class TaskAppointmentsView;
00049 
00050 class Node;
00051 class Task;
00052 class Project;
00053 class Relation;
00054 
00055 class GanttView : public QSplitter
00056 {
00057     Q_OBJECT
00058 
00059  public:
00060 
00061     GanttView(QWidget *parent, bool readWrite=true, const char* name = 0  );
00062 
00063     //~GanttView();
00064 
00065     void setZoom(double zoom);
00066 
00067     void draw(Project &project);
00068     void drawChanges(Project &project);
00069     
00073     void drawOnPainter(QPainter* painter, const QRect rect);
00074 
00075     Node *currentNode() const;
00076 
00077     void clear();
00078     void print(KPrinter &prts);
00079 
00080     void addTaskLink(KDGanttViewTaskLink *link);
00081     
00082     bool exportGantt(QIODevice* device); // testing
00083     
00084     virtual bool setContext(Context::Ganttview &context, Project &project);
00085     virtual void getContext(Context::Ganttview &context) const;
00086     
00087     void setReadWriteMode(bool on);
00088     bool isReadWriteMode() const { return m_readWrite; }
00089     KDGanttViewItem *currentItem() const { return m_currentItem; }
00090     
00091     bool showNoInformation() const { return m_showNoInformation; }
00092 
00093 signals:
00094     void enableActions(bool);
00095     void modifyRelation(Relation *rel) ;
00096     void addRelation(Node *par, Node *child);
00097     void modifyRelation(Relation *rel, int linkType) ;
00098     void addRelation(Node *par, Node *child, int linkType);
00099     void itemDoubleClicked();
00100     
00101     void itemRenamed(Node*, const QString&);
00102     
00107     void requestPopupMenu(const QString& menuname, const QPoint & pos);
00108     
00109 public slots:
00113     void popupMenuRequested(KDGanttViewItem * item, const QPoint & pos, int);
00114 
00115     void setShowExpected(bool on) { m_showExpected = on; }
00116     void setShowOptimistic(bool on) { m_showOptimistic = on; }
00117     void setShowPessimistic(bool on) { m_showPessimistic = on; }
00118     void setShowResources(bool on) { m_showResources = on; }
00119     void setShowTaskName(bool on) { m_showTaskName = on; }
00120     void setShowTaskLinks(bool on) { m_showTaskLinks = on; }
00121     void setShowProgress(bool on) { m_showProgress = on; }
00122     void setShowPositiveFloat(bool on) { m_showPositiveFloat = on; }
00123     void setShowCriticalTasks(bool on) { m_showCriticalTasks = on; }
00124     void setShowCriticalPath(bool on) { m_showCriticalPath = on; }
00125     void setShowNoInformation(bool on) { m_showNoInformation = on; }
00126     void setShowAppointments(bool on) { m_showAppointments = on; }
00127     
00128 private slots:
00129     void currentItemChanged(KDGanttViewItem *);
00130     void slotItemDoubleClicked(QListViewItem*);
00131     void slotItemRenamed(KDGanttViewItem*, int, const QString&);
00132     
00133     void slotLinkItems(KDGanttViewItem* from, KDGanttViewItem* to, int linkType);
00134     
00135     void slotGvItemClicked(KDGanttViewItem*);
00136     
00137     void slotModifyLink(KDGanttViewTaskLink* link);
00138 
00139 protected:
00140     int linkTypeToRelation(int linkType);
00141     void setRenameEnabled(QListViewItem *item, bool on);
00142 private:
00143     KDGanttViewItem *findItem(Node *node);
00144     KDGanttViewItem *findItem(Node *node, KDGanttViewItem *item);
00145     Node *getNode(KDGanttViewItem *item) const;
00146     bool isDrawn(KDGanttViewItem *item);
00147     void setDrawn(KDGanttViewItem *item, bool state);
00148     void resetDrawn(KDGanttViewItem *_item);
00149     void removeNotDrawn(KDGanttViewItem *_item);
00150     void deleteItem(KDGanttViewItem *item);
00151     KDGanttViewItem *correctType(KDGanttViewItem *item, Node *node);
00152     void correctPosition(KDGanttViewItem *item, Node *node);
00153     KDGanttViewItem *correctParent(KDGanttViewItem *item, Node *node);
00154 
00155     void updateChildren(Node *node);
00156     void updateNode(Node *node);
00157     
00158     void modifyChildren(Node *node);
00159     void modifyNode(Node *node);    
00160     void modifyProject(KDGanttViewItem *item, Node *node);
00161     void modifySummaryTask(KDGanttViewItem *item, Task *task);
00162     void modifyTask(KDGanttViewItem *item, Task *task);
00163     void modifyMilestone(KDGanttViewItem *item, Task *task);
00164     
00165     KDGanttViewItem *addNode(KDGanttViewItem *parentItem, Node *node,KDGanttViewItem *after=0);
00166     
00167     KDGanttViewItem *addProject(KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after=0);
00168     KDGanttViewItem *addSubProject(KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after=0);
00169     KDGanttViewItem *addSummaryTask(KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after=0);
00170     KDGanttViewItem *addTask(KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after=0);
00171     KDGanttViewItem *addMilestone(KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after=0);
00172     
00173     void drawChildren(KDGanttViewItem *item, Node &node);
00174     void drawProject(KDGanttViewItem *parentItem, Node *node);
00175     void drawSubProject(KDGanttViewItem *parentItem, Node *node);
00176     void drawSummaryTask(KDGanttViewItem *parentItem, Task *task);
00177     void drawTask(KDGanttViewItem *parentItem, Task *task);
00178     void drawMilestone(KDGanttViewItem *parentItem, Task *task);
00179 
00180     void drawRelations();
00181     void drawRelations(KDGanttViewItem *item);
00182     void drawChildRelations(KDGanttViewItem *item);
00183 
00184     void getContextClosedNodes(Context::Ganttview &context, KDGanttViewItem *item) const;
00185     
00186 private:
00187     bool m_readWrite;
00188     int m_defaultFontSize;
00189     KDGanttViewItem *m_currentItem;
00190     MyKDGanttView *m_gantt;
00191     TaskAppointmentsView *m_taskView;
00192     bool m_showExpected;
00193     bool m_showOptimistic;
00194     bool m_showPessimistic;
00195     bool m_showResources;
00196     bool m_showTaskName;
00197     bool m_showTaskLinks;
00198     bool m_showProgress;
00199     bool m_showPositiveFloat;
00200     bool m_showCriticalTasks;
00201     bool m_showCriticalPath;
00202     bool m_showNoInformation;
00203     bool m_showAppointments;
00204     bool m_firstTime;
00205     QPtrList<KDGanttViewTaskLink> m_taskLinks;
00206     Project *m_project;
00207 };
00208 
00209 }  //KPlato namespace
00210 
00211 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys