kplato

kptganttview.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Dag Andersen <danders@get2net.dk>
3 Copyright (C) 2006 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation;
8 version 2 of the License.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KPTGANTTVIEW_H
22#define KPTGANTTVIEW_H
23
24#include "kptcontext.h"
25
26#include <tqsplitter.h>
27#include <tqcursor.h>
28
29class TQLayout;
30class TQListViewItem;
31class TQPoint;
32class TQListView;
33class TQLineEdit;
34class TQSpinBox;
35
36class KDGanttViewSummaryItem;
37class KDGanttViewTaskItem;
38class KDGanttViewEventItem;
39class KDGanttViewItem;
40class KDGanttViewTaskLink;
41
42class KPrinter;
43
44namespace KPlato
45{
46
47class MyKDGanttView;
48class TaskAppointmentsView;
49
50class Node;
51class Task;
52class Project;
53class Relation;
54
55class GanttView : public TQSplitter
56{
57 TQ_OBJECT
58
59
60 public:
61
62 GanttView(TQWidget *parent, bool readWrite=true, const char* name = 0 );
63
64 //~GanttView();
65
66 void setZoom(double zoom);
67
68 void draw(Project &project);
69 void drawChanges(Project &project);
70
74 void drawOnPainter(TQPainter* painter, const TQRect rect);
75
76 Node *currentNode() const;
77
78 void clear();
79 void print(KPrinter &prts);
80
81 void addTaskLink(KDGanttViewTaskLink *link);
82
83 bool exportGantt(TQIODevice* device); // testing
84
85 virtual bool setContext(Context::Ganttview &context, Project &project);
86 virtual void getContext(Context::Ganttview &context) const;
87
88 void setReadWriteMode(bool on);
89 bool isReadWriteMode() const { return m_readWrite; }
90 KDGanttViewItem *currentItem() const { return m_currentItem; }
91
92 bool showNoInformation() const { return m_showNoInformation; }
93
94signals:
95 void enableActions(bool);
96 void modifyRelation(Relation *rel) ;
97 void addRelation(Node *par, Node *child);
98 void modifyRelation(Relation *rel, int linkType) ;
99 void addRelation(Node *par, Node *child, int linkType);
100 void itemDoubleClicked();
101
102 void itemRenamed(Node*, const TQString&);
103
108 void requestPopupMenu(const TQString& menuname, const TQPoint & pos);
109
110public slots:
114 void popupMenuRequested(KDGanttViewItem * item, const TQPoint & pos, int);
115
116 void setShowExpected(bool on) { m_showExpected = on; }
117 void setShowOptimistic(bool on) { m_showOptimistic = on; }
118 void setShowPessimistic(bool on) { m_showPessimistic = on; }
119 void setShowResources(bool on) { m_showResources = on; }
120 void setShowTaskName(bool on) { m_showTaskName = on; }
121 void setShowTaskLinks(bool on) { m_showTaskLinks = on; }
122 void setShowProgress(bool on) { m_showProgress = on; }
123 void setShowPositiveFloat(bool on) { m_showPositiveFloat = on; }
124 void setShowCriticalTasks(bool on) { m_showCriticalTasks = on; }
125 void setShowCriticalPath(bool on) { m_showCriticalPath = on; }
126 void setShowNoInformation(bool on) { m_showNoInformation = on; }
127 void setShowAppointments(bool on) { m_showAppointments = on; }
128
129private slots:
130 void currentItemChanged(KDGanttViewItem *);
131 void slotItemDoubleClicked(TQListViewItem*);
132 void slotItemRenamed(KDGanttViewItem*, int, const TQString&);
133
134 void slotLinkItems(KDGanttViewItem* from, KDGanttViewItem* to, int linkType);
135
136 void slotGvItemClicked(KDGanttViewItem*);
137
138 void slotModifyLink(KDGanttViewTaskLink* link);
139
140protected:
141 int linkTypeToRelation(int linkType);
142 void setRenameEnabled(TQListViewItem *item, bool on);
143private:
144 KDGanttViewItem *findItem(Node *node);
145 KDGanttViewItem *findItem(Node *node, KDGanttViewItem *item);
146 Node *getNode(KDGanttViewItem *item) const;
147 bool isDrawn(KDGanttViewItem *item);
148 void setDrawn(KDGanttViewItem *item, bool state);
149 void resetDrawn(KDGanttViewItem *_item);
150 void removeNotDrawn(KDGanttViewItem *_item);
151 void deleteItem(KDGanttViewItem *item);
152 KDGanttViewItem *correctType(KDGanttViewItem *item, Node *node);
153 void correctPosition(KDGanttViewItem *item, Node *node);
154 KDGanttViewItem *correctParent(KDGanttViewItem *item, Node *node);
155
156 void updateChildren(Node *node);
157 void updateNode(Node *node);
158
159 void modifyChildren(Node *node);
160 void modifyNode(Node *node);
161 void modifyProject(KDGanttViewItem *item, Node *node);
162 void modifySummaryTask(KDGanttViewItem *item, Task *task);
163 void modifyTask(KDGanttViewItem *item, Task *task);
164 void modifyMilestone(KDGanttViewItem *item, Task *task);
165
166 KDGanttViewItem *addNode(KDGanttViewItem *parentItem, Node *node,KDGanttViewItem *after=0);
167
168 KDGanttViewItem *addProject(KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after=0);
169 KDGanttViewItem *addSubProject(KDGanttViewItem *parentItem, Node *node, KDGanttViewItem *after=0);
170 KDGanttViewItem *addSummaryTask(KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after=0);
171 KDGanttViewItem *addTask(KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after=0);
172 KDGanttViewItem *addMilestone(KDGanttViewItem *parentItem, Task *task, KDGanttViewItem *after=0);
173
174 void drawChildren(KDGanttViewItem *item, Node &node);
175 void drawProject(KDGanttViewItem *parentItem, Node *node);
176 void drawSubProject(KDGanttViewItem *parentItem, Node *node);
177 void drawSummaryTask(KDGanttViewItem *parentItem, Task *task);
178 void drawTask(KDGanttViewItem *parentItem, Task *task);
179 void drawMilestone(KDGanttViewItem *parentItem, Task *task);
180
181 void drawRelations();
182 void drawRelations(KDGanttViewItem *item);
183 void drawChildRelations(KDGanttViewItem *item);
184
185 void getContextClosedNodes(Context::Ganttview &context, KDGanttViewItem *item) const;
186
187private:
188 bool m_readWrite;
189 int m_defaultFontSize;
190 KDGanttViewItem *m_currentItem;
191 MyKDGanttView *m_gantt;
192 TaskAppointmentsView *m_taskView;
193 bool m_showExpected;
194 bool m_showOptimistic;
195 bool m_showPessimistic;
196 bool m_showResources;
197 bool m_showTaskName;
198 bool m_showTaskLinks;
199 bool m_showProgress;
200 bool m_showPositiveFloat;
201 bool m_showCriticalTasks;
202 bool m_showCriticalPath;
203 bool m_showNoInformation;
204 bool m_showAppointments;
205 bool m_firstTime;
206 TQPtrList<KDGanttViewTaskLink> m_taskLinks;
207 Project *m_project;
208};
209
210} //KPlato namespace
211
212#endif