1/* This file is part of the KDE project
2 Copyright (C) 2007 - 2010 Dag Andersen <danders@get2net.dk>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17* Boston, MA 02110-1301, USA.
18*/
19
20#ifndef TASKSTATUSVIEW_H
21#define TASKSTATUSVIEW_H
22
23#include "kplatoui_export.h"
24
25#include "kptitemmodelbase.h"
26
27#include "kptviewbase.h"
28#include "ui_kpttaskstatusviewsettingspanel.h"
29#include "kptitemviewsettup.h"
30#include "ui_kptperformancestatus.h"
31#include "ui_kptperformancestatusviewsettingspanel.h"
32#include "kptnodechartmodel.h"
33
34#include <QSplitter>
35#include <QTableWidget>
36
37#include "KDChartBarDiagram"
38
39
40class QTextBrowser;
41class QItemSelection;
42
43class KoDocument;
44class KoPageLayoutWidget;
45class PrintingHeaderFooter;
46
47class KAction;
48
49namespace KDChart
50{
51 class Chart;
52 class CartesianCoordinatePlane;
53 class CartesianAxis;
54 class Legend;
55};
56
57namespace KPlato
58{
59
60class Project;
61class Node;
62class Task;
63class ScheduleManager;
64class TaskStatusItemModel;
65class NodeItemModel;
66class PerformanceStatusViewSettingsPanel;
67class PerformanceStatusBase;
68
69typedef QList<Node*> NodeList;
70
71class KPLATOUI_EXPORT TaskStatusTreeView : public DoubleTreeViewBase
72{
73 Q_OBJECT
74public:
75 explicit TaskStatusTreeView(QWidget *parent);
76
77 //void setSelectionModel( QItemSelectionModel *selectionModel );
78
79 TaskStatusItemModel *model() const;
80
81 Project *project() const;
82 void setProject( Project *project );
83
84 int defaultWeekday() const { return Qt::Friday; }
85 int weekday() const;
86 void setWeekday( int day );
87
88 int defaultPeriod() const { return 7; }
89 int period() const;
90 void setPeriod( int days );
91
92 int defaultPeriodType() const;
93 int periodType() const;
94 void setPeriodType( int type );
95
96protected:
97 void dragMoveEvent(QDragMoveEvent *event);
98};
99
100
101class KPLATOUI_EXPORT TaskStatusView : public ViewBase
102{
103 Q_OBJECT
104public:
105 TaskStatusView(KoPart *part, KoDocument *doc, QWidget *parent);
106
107 void setupGui();
108 virtual void setProject( Project *project );
109 Project *project() const { return m_view->project(); }
110 using ViewBase::draw;
111 virtual void draw( Project &project );
112
113 TaskStatusItemModel *model() const { return m_view->model(); }
114
115 virtual void updateReadWrite( bool readwrite );
116 virtual Node *currentNode() const;
117
118 /// Loads context info into this view. Reimplement.
119 virtual bool loadContext( const KoXmlElement &/*context*/ );
120 /// Save context info from this view. Reimplement.
121 virtual void saveContext( QDomElement &/*context*/ ) const;
122
123 KoPrintJob *createPrintJob();
124
125signals:
126 void openNode();
127
128public slots:
129 /// Activate/deactivate the gui
130 virtual void setGuiActive( bool activate );
131
132 void setScheduleManager( ScheduleManager *sm );
133
134 virtual void slotRefreshView();
135
136protected slots:
137 virtual void slotOptions();
138
139protected:
140 void updateActionsEnabled( bool on );
141
142private slots:
143 void slotContextMenuRequested( const QModelIndex &index, const QPoint& pos );
144 void slotContextMenuRequested( Node *node, const QPoint& pos );
145 void slotSplitView();
146
147private:
148 Project *m_project;
149 int m_id;
150 TaskStatusTreeView *m_view;
151
152};
153
154//--------------------------------------
155class TaskStatusViewSettingsPanel : public QWidget, public Ui::TaskStatusViewSettingsPanel
156{
157 Q_OBJECT
158public:
159 explicit TaskStatusViewSettingsPanel( TaskStatusTreeView *view, QWidget *parent = 0 );
160
161public slots:
162 void slotOk();
163 void setDefault();
164
165signals:
166 void changed();
167
168private:
169 TaskStatusTreeView *m_view;
170};
171
172class TaskStatusViewSettingsDialog : public SplitItemViewSettupDialog
173{
174 Q_OBJECT
175public:
176 explicit TaskStatusViewSettingsDialog( ViewBase *view, TaskStatusTreeView *treeview, QWidget *parent = 0 );
177
178};
179
180struct PerformanceChartInfo
181{
182 bool showBarChart;
183 bool showLineChart;
184 bool showTableView;
185
186 bool showBaseValues;
187 bool showIndices;
188
189 bool showCost;
190 bool showBCWSCost;
191 bool showBCWPCost;
192 bool showACWPCost;
193
194 bool showEffort;
195 bool showBCWSEffort;
196 bool showBCWPEffort;
197 bool showACWPEffort;
198
199 bool showSpiCost;
200 bool showCpiCost;
201 bool showSpiEffort;
202 bool showCpiEffort;
203
204 bool effortShown() const {
205 return ( showBaseValues && showEffort ) || ( showIndices && ( showSpiEffort || showCpiEffort ) );
206 }
207 bool costShown() const {
208 return ( showBaseValues && showCost ) || ( showIndices && ( showSpiCost || showCpiCost ) );
209 }
210 bool bcwsCost() const { return showBaseValues && showCost && showBCWSCost; }
211 bool bcwpCost() const { return showBaseValues && showCost && showBCWPCost; }
212 bool acwpCost() const { return showBaseValues && showCost && showACWPCost; }
213 bool bcwsEffort() const { return showBaseValues && showEffort && showBCWSEffort; }
214 bool bcwpEffort() const { return showBaseValues && showEffort && showBCWPEffort; }
215 bool acwpEffort() const { return showBaseValues && showEffort && showACWPEffort; }
216
217 bool spiCost() const { return showIndices && showSpiCost; }
218 bool cpiCost() const { return showIndices && showCpiCost; }
219 bool spiEffort() const { return showIndices && showSpiEffort; }
220 bool cpiEffort() const { return showIndices && showCpiEffort; }
221
222 PerformanceChartInfo() {
223 showBarChart = false; showLineChart = true; showTableView = false;
224 showBaseValues = true; showIndices = false;
225 showCost = showBCWSCost = showBCWPCost = showACWPCost = true;
226 showEffort = showBCWSEffort = showBCWPEffort = showACWPEffort = true;
227 showSpiCost = showCost = showSpiEffort = showCpiEffort = true;
228 }
229 bool operator!=( const PerformanceChartInfo &o ) const { return ! operator==( o ); }
230 bool operator==( const PerformanceChartInfo &o ) const {
231 return showBarChart == o.showBarChart && showLineChart == o.showLineChart &&
232 showBaseValues == o.showBaseValues && showIndices == o.showIndices &&
233 showCost == o.showCost &&
234 showBCWSCost == o.showBCWSCost &&
235 showBCWPCost == o.showBCWPCost &&
236 showACWPCost == o.showACWPCost &&
237 showEffort == o.showEffort &&
238 showBCWSEffort == o.showBCWSEffort &&
239 showBCWPEffort == o.showBCWPEffort &&
240 showACWPEffort == o.showACWPEffort &&
241 showSpiCost == o.showSpiCost &&
242 showCpiCost == o.showCpiCost &&
243 showSpiEffort == o.showSpiEffort &&
244 showCpiEffort == o.showCpiEffort;
245 }
246};
247
248//----------------------------------
249class KPLATOUI_EXPORT PerformanceStatusPrintingDialog : public PrintingDialog
250{
251 Q_OBJECT
252public:
253 PerformanceStatusPrintingDialog( ViewBase *view, PerformanceStatusBase *chart, Project *project = 0 );
254 ~PerformanceStatusPrintingDialog() {}
255
256 virtual int documentLastPage() const;
257 virtual QList<QWidget*> createOptionWidgets() const;
258
259protected:
260 virtual void printPage( int pageNumber, QPainter &painter );
261
262private:
263 PerformanceStatusBase *m_chart;
264 Project *m_project;
265};
266
267class PerformanceStatusBase : public QWidget, public Ui::PerformanceStatus
268{
269 Q_OBJECT
270public:
271 explicit PerformanceStatusBase( QWidget *parent );
272
273 void setProject( Project *project );
274 void setScheduleManager( ScheduleManager *sm );
275
276 ChartItemModel *model() const { return const_cast<ChartItemModel*>( &m_chartmodel ); }
277
278 void setupChart();
279 void setChartInfo( const PerformanceChartInfo &info );
280 PerformanceChartInfo chartInfo() const { return m_chartinfo; }
281
282 /// Loads context info into this view. Reimplement.
283 virtual bool loadContext( const KoXmlElement &context );
284 /// Save context info from this view. Reimplement.
285 virtual void saveContext( QDomElement &context ) const;
286
287 /// Create a print job dialog
288 KoPrintJob *createPrintJob( ViewBase *parent );
289
290 void setNodes( const QList<Node*> &nodes );
291
292public slots:
293 void refreshChart();
294
295protected:
296 void contextMenuEvent( QContextMenuEvent *event );
297
298 void createBarChart();
299 void createLineChart();
300 void setEffortValuesVisible( bool visible );
301 void setCostValuesVisible( bool visible );
302
303protected slots:
304 void slotUpdate();
305 void slotLocaleChanged();
306
307private:
308 struct ChartContents {
309 ~ChartContents() {
310 delete effortplane;
311 delete costplane;
312 delete effortdiagram;
313 delete costdiagram;
314 delete dateaxis;
315 delete effortaxis;
316 delete costaxis;
317 }
318 ChartProxyModel costproxy;
319 ChartProxyModel effortproxy;
320
321 KDChart::CartesianCoordinatePlane *effortplane;
322 KDChart::CartesianCoordinatePlane *costplane;
323 KDChart::AbstractDiagram *effortdiagram;
324 KDChart::AbstractDiagram *costdiagram;
325 KDChart::CartesianAxis *effortaxis;
326 KDChart::CartesianAxis *costaxis;
327 KDChart::CartesianAxis *dateaxis;
328
329 ChartProxyModel piproxy;
330 KDChart::CartesianCoordinatePlane *piplane;
331 KDChart::AbstractDiagram *pidiagram;
332 KDChart::CartesianAxis *piaxis;
333 };
334 void setupChart( ChartContents &cc );
335
336private:
337 Project *m_project;
338 ScheduleManager *m_manager;
339 PerformanceChartInfo m_chartinfo;
340
341 ChartItemModel m_chartmodel;
342 KDChart::Legend *m_legend;
343 KDChart::BarDiagram m_legenddiagram;
344 struct ChartContents m_barchart;
345 struct ChartContents m_linechart;
346};
347
348//----------------------------------
349class KPLATOUI_EXPORT ProjectStatusView : public ViewBase
350{
351 Q_OBJECT
352public:
353 ProjectStatusView(KoPart *part, KoDocument *doc, QWidget *parent );
354
355 void setupGui();
356 Project *project() const { return m_project; }
357 virtual void setProject( Project *project );
358
359 /// Loads context info into this view. Reimplement.
360 virtual bool loadContext( const KoXmlElement &/*context*/ );
361 /// Save context info from this view. Reimplement.
362 virtual void saveContext( QDomElement &/*context*/ ) const;
363
364 KoPrintJob *createPrintJob();
365
366public slots:
367 /// Activate/deactivate the gui
368 virtual void setGuiActive( bool activate );
369
370 void setScheduleManager( ScheduleManager *sm );
371
372protected:
373 void updateActionsEnabled( bool on );
374
375protected slots:
376 virtual void slotOptions();
377
378private:
379 Project *m_project;
380 PerformanceStatusBase *m_view;
381};
382
383//----------------------------------
384class PerformanceStatusTreeView : public QSplitter
385{
386 Q_OBJECT
387public:
388 explicit PerformanceStatusTreeView( QWidget *parent );
389
390 NodeItemModel *nodeModel() const;
391 Project *project() const;
392 void setProject( Project *project );
393 void setScheduleManager( ScheduleManager *sm );
394
395 /// Loads context info into this view.
396 virtual bool loadContext( const KoXmlElement &context );
397 /// Save context info from this view.
398 virtual void saveContext( QDomElement &context ) const;
399
400 TreeViewBase *treeView() const { return m_tree; }
401 PerformanceStatusBase *chartView() const { return m_chart; }
402
403 KoPrintJob *createPrintJob( ViewBase *view );
404
405protected slots:
406 void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
407 void resizeSplitters();
408
409private:
410 TreeViewBase *m_tree;
411 PerformanceStatusBase *m_chart;
412};
413
414
415//----------------------------------
416class KPLATOUI_EXPORT PerformanceStatusView : public ViewBase
417{
418 Q_OBJECT
419public:
420 PerformanceStatusView(KoPart *part, KoDocument *doc, QWidget *parent );
421
422 void setupGui();
423 Project *project() const { return m_view->project(); }
424 virtual void setProject( Project *project );
425
426 /// Loads context info into this view. Reimplement.
427 virtual bool loadContext( const KoXmlElement &context );
428 /// Save context info from this view. Reimplement.
429 virtual void saveContext( QDomElement &context ) const;
430
431 Node *currentNode() const;
432
433 KoPrintJob *createPrintJob();
434
435public slots:
436 /// Activate/deactivate the gui
437 virtual void setGuiActive( bool activate );
438
439 void setScheduleManager( ScheduleManager *sm );
440
441protected slots:
442 virtual void slotOptions();
443
444protected:
445 void updateActionsEnabled( bool on );
446
447private slots:
448 void slotContextMenuRequested( Node *node, const QPoint& pos );
449 void slotContextMenuRequested( const QModelIndex &index, const QPoint& pos );
450
451private:
452 PerformanceStatusTreeView *m_view;
453
454};
455
456//--------------------------------------
457class PerformanceStatusViewSettingsPanel : public QWidget, public Ui::PerformanceStatusViewSettingsPanel
458{
459 Q_OBJECT
460public:
461 explicit PerformanceStatusViewSettingsPanel( PerformanceStatusBase *view, QWidget *parent = 0 );
462
463public slots:
464 void slotOk();
465 void setDefault();
466
467signals:
468 void changed();
469
470protected slots:
471 void switchStackWidget();
472
473private:
474 PerformanceStatusBase *m_view;
475};
476
477class PerformanceStatusViewSettingsDialog : public ItemViewSettupDialog
478{
479 Q_OBJECT
480public:
481 explicit PerformanceStatusViewSettingsDialog( PerformanceStatusView *view, PerformanceStatusTreeView *treeview, QWidget *parent = 0 );
482
483};
484
485class ProjectStatusViewSettingsDialog : public KPageDialog
486{
487 Q_OBJECT
488public:
489 explicit ProjectStatusViewSettingsDialog( ViewBase *base, PerformanceStatusBase *view, QWidget *parent = 0 );
490
491protected slots:
492 void slotOk();
493
494private:
495 ViewBase *m_base;
496 KoPageLayoutWidget *m_pagelayout;
497 PrintingHeaderFooter *m_headerfooter;
498};
499
500
501
502} //namespace KPlato
503
504
505#endif
506