OSDN Git Service

- Added better status reporting functions.
[tjqt4port/tj2qt4.git] / taskjuggler / Report.h
1 /*
2  * Report.h - TaskJuggler
3  *
4  * Copyright (c) 2001, 2002 by Chris Schlaeger <cs@suse.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * $Id$
11  */
12
13 #ifndef _Report_h_
14 #define _Report_h_
15
16 #include <stdio.h>
17 #include <time.h>
18 #include <stdarg.h>
19
20 #include <qstring.h>
21 #include <qstringlist.h>
22 #include <qcolor.h>
23 #include <qfile.h>
24 #include <qtextstream.h>
25
26 #include <Account.h>
27
28 class Project;
29 class Task;
30 class Resource;
31 class Account;
32 class TaskList;
33 class ResourceList;
34 class AccountList;
35 class ExpressionTree;
36
37 #include "CoreAttributes.h"
38
39 /**
40  * @short The base class for all report generating classes.
41  * @author Chris Schlaeger <cs@suse.de>
42  */
43 class Report
44 {
45 public:
46         Report(Project* p, const QString& f, time_t s, time_t e,
47                    const QString& df, int dl);
48         virtual ~Report();
49
50         void setWeekStartsMonday(bool wsm) { weekStartsMonday = wsm; }
51
52         void setShowActual(bool s) { showActual = s; }
53         bool getShowActual() const { return showActual; }
54
55         void setHidePlan(bool s) { hidePlan = s; }
56         void setShowPIDs(bool s) { showPIDs = s; }
57
58         void addReportColumn(const QString& c) { columns.append(c); }
59         const QString& columnsAt(uint idx) { return columns[idx]; }
60         void clearColumns() { columns.clear(); }
61
62         void setStart(time_t s) { start = s; }
63         time_t getStart() const { return start; }
64         
65         void setEnd(time_t e) { end = e; }
66         time_t getEnd() const { return end; }
67
68         void setHeadline(const QString& hl) { headline = hl; }
69         void setCaption(const QString& c) { caption = c; }
70
71         bool isHidden(CoreAttributes* c, ExpressionTree* et);
72         bool isRolledUp(CoreAttributes* c, ExpressionTree* et);
73
74         void setHideTask(ExpressionTree* et);
75
76         void setRollUpTask(ExpressionTree* et);
77         bool isTaskRolledUp(Task* t);
78
79         void setHideResource(ExpressionTree* et);
80
81         void setHideAccount(ExpressionTree* et);
82
83         void setRollUpResource(ExpressionTree* et);
84         bool isResourceRolledUp(Resource* t);
85
86         void setRollUpAccount(ExpressionTree* et);
87
88         bool setTaskSorting(int sc, int level);
89         bool setResourceSorting(int sc, int level);
90         bool setAccountSorting(int sc, int level);
91
92         void setTaskRoot(const QString& root) { taskRoot = root; }
93         const QString& getTaskRoot() const { return taskRoot; }
94
95         enum LoadUnit { minutes, hours, days, weeks, months, years, shortAuto,
96                 longAuto };
97
98         bool setLoadUnit(const QString& u);
99
100         void setTimeFormat(const QString& tf) { timeFormat = tf; }
101         void setShortTimeFormat(const QString& tf) { shortTimeFormat = tf; }
102
103         Report() { }
104
105         bool open();
106
107         void filterTaskList(TaskList& filteredList, Resource* r);
108         void sortTaskList(TaskList& filteredList);
109
110         void filterResourceList(ResourceList& filteredList, Task* t = 0);
111         void sortResourceList(ResourceList& filteredList);
112
113         void filterAccountList(AccountList& filteredList, Account::AccountType at);
114         void sortAccountList(AccountList& filteredList);
115
116         QString scaledLoad(double t);
117 protected:
118         void warningMsg(const char* msg, ... );
119
120         /**
121          * This utility function removes the path that matches the taskRoot
122          * variable from the passed taskId.
123          */
124         QString stripTaskRoot(QString taskId) const;
125         
126         Project* project;
127         bool weekStartsMonday;
128         QString fileName;
129         QStringList columns;
130         time_t start;
131         time_t end;
132
133         QString timeFormat;
134         QString shortTimeFormat;
135         
136         /* We store the location of the report definition in case we need it
137          * for error reporting. */
138         QString defFileName;
139         int defFileLine;
140         
141         QString headline;
142         QString caption;
143
144         int taskSortCriteria[CoreAttributesList::maxSortingLevel];
145         int resourceSortCriteria[CoreAttributesList::maxSortingLevel];
146         int accountSortCriteria[CoreAttributesList::maxSortingLevel];
147
148         QFile f;
149         QTextStream s;
150         ExpressionTree* hideTask;
151         ExpressionTree* hideResource;
152         ExpressionTree* hideAccount;
153         ExpressionTree* rollUpTask;
154         ExpressionTree* rollUpResource;
155         ExpressionTree* rollUpAccount;
156
157         /* A report can be limited to the sub-tasks of a certain task. The 
158          * taskRoot specifies this task. If set it always ends with a '.'. */
159         QString taskRoot;
160         
161         LoadUnit loadUnit;
162
163         /* The maximum of the tree that we have to report in tree-sorting mode. */
164         uint maxDepthTaskList;
165         uint maxDepthResourceList;
166         uint maxDepthAccountList;
167         
168         bool hidePlan;
169         bool showActual;
170         bool showPIDs;
171 } ;
172
173 #endif