OSDN Git Service

Automatically align underspecified tasks boundaries on project boundaries when possible.
[tjqt4port/tj2qt4.git] / taskjuggler / Report.h
1 /*
2  * Report.h - TaskJuggler
3  *
4  * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
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 <qvaluelist.h>
17 #include <qfile.h>
18 #include <qtextstream.h>
19
20 #include "CoreAttributesList.h"
21 #include "RealFormat.h"
22 #include "Interval.h"
23
24 class Project;
25 class CoreAttributes;
26 class Task;
27 class Resource;
28 class TaskList;
29 class ResourceList;
30 class AccountList;
31 class ExpressionTree;
32 class ReportElement;
33
34 /**
35  * @short The base class for all report generating classes.
36  * @author Chris Schlaeger <cs@kde.org>
37  */
38 class Report
39 {
40 public:
41     Report(Project* p, const QString& f, const QString& df, int dl);
42     virtual ~Report();
43
44     virtual const char* getType() const { return "Report"; }
45
46     bool open();
47     bool close();
48
49     QTextStream& stream() { return s; }
50
51     void puts(const QString& str)
52     {
53         s.writeRawBytes(str.data(), str.length());
54     }
55     const Project* getProject() const { return project; }
56     const QString& getFileName() const { return fileName; }
57     QString getFullFileName() const;
58
59     const QString& getDefinitionFile() const { return defFileName; }
60     uint getDefinitionLine() const { return defFileLine; }
61
62     void addScenario(int sc) { scenarios.append(sc); }
63     void clearScenarios() { scenarios.clear(); }
64     size_t getScenarioCount() const { return scenarios.count(); }
65     int getScenario(int sc) const { return scenarios[sc]; }
66
67     void setWeekStartsMonday(bool wsm) { weekStartsMonday = wsm; }
68     bool getWeekStartsMonday() const { return weekStartsMonday; }
69
70     void setShowPIDs(bool sp) { showPIDs = sp; }
71     bool getShowPIDs() const { return showPIDs; }
72
73     void addReportColumn(const QString& c) { columns.append(c); }
74     const QString& columnsAt(uint idx) { return columns[idx]; }
75     void clearColumns() { columns.clear(); }
76
77     void setStart(time_t st) { start = st; }
78     time_t getStart() const { return start; }
79
80     void setEnd(time_t e) { end = e; }
81     time_t getEnd() const { return end; }
82
83     void setPeriod(const Interval& iv)
84     {
85         start = iv.getStart();
86         end = iv.getEnd();
87     }
88
89     void setHeadline(const QString& hl) { headline = hl; }
90     const QString& getHeadline() const { return headline; }
91
92     void setCaption(const QString& c) { caption = c; }
93     const QString& getCaption() const { return caption; }
94
95     bool isHidden(const CoreAttributes* c, ExpressionTree* et) const;
96     bool isRolledUp(const CoreAttributes* c, ExpressionTree* et) const;
97
98     void setHideTask(ExpressionTree* et);
99     ExpressionTree* getHideTask() const { return hideTask; }
100
101     void setHideResource(ExpressionTree* et);
102     ExpressionTree* getHideResource() const { return hideResource; }
103
104     void setHideAccount(ExpressionTree* et);
105     ExpressionTree* getHideAccount() const { return hideAccount; }
106
107     void setRollUpTask(ExpressionTree* et);
108     ExpressionTree* getRollUpTask() const { return rollUpTask; }
109
110     void setRollUpResource(ExpressionTree* et);
111     ExpressionTree* getRollUpResource() const { return rollUpResource; }
112
113     void setRollUpAccount(ExpressionTree* et);
114     ExpressionTree* getRollUpAccount() const { return rollUpAccount; }
115
116     bool setTaskSorting(int sc, int level);
117     int getTaskSorting(int level) const { return taskSortCriteria[level]; }
118
119     bool setResourceSorting(int sc, int level);
120     int getResourceSorting(int level) const
121     {
122         return resourceSortCriteria[level];
123     }
124
125     bool setAccountSorting(int sc, int level);
126     int getAccountSorting(int level) const
127     {
128         return accountSortCriteria[level];
129     }
130
131     void setTaskRoot(const QString& root) { taskRoot = root; }
132     const QString& getTaskRoot() const { return taskRoot; }
133
134     bool setLoadUnit(const QString& u);
135     LoadUnit getLoadUnit() const { return loadUnit; }
136
137     void setTimeFormat(const QString& tf) { timeFormat = tf; }
138     const QString& getTimeFormat() const { return timeFormat; }
139
140     void setShortTimeFormat(const QString& tf) { shortTimeFormat = tf; }
141     const QString& getShortTimeFormat() const { return shortTimeFormat; }
142
143     void setNumberFormat(const RealFormat& rf) { numberFormat = rf; }
144     const RealFormat& getNumberFormat() const { return numberFormat; }
145
146     void setCurrencyFormat(const RealFormat& rf) { currencyFormat = rf; }
147     const RealFormat& getCurrencyFormat() const { return currencyFormat; }
148
149     bool filterTaskList(TaskList& filteredList, const Resource* r,
150                         ExpressionTree* hideExp, ExpressionTree* rollUpExp)
151         const;
152     void sortTaskList(TaskList& filteredList);
153
154     bool filterResourceList(ResourceList& filteredList, const Task* t,
155                             ExpressionTree* hideExp, ExpressionTree* rollUpExp)
156         const;
157     void sortResourceList(ResourceList& filteredList);
158
159     bool filterAccountList(AccountList& filteredList, AccountType at,
160                            ExpressionTree* hideExp, ExpressionTree*
161                            rollUpExp) const;
162     void sortAccountList(AccountList& filteredList);
163
164     void setTimeStamp(bool t)
165     {
166         timeStamp = t;
167     }
168     bool getTimeStamp() const
169     {
170         return timeStamp;
171     }
172
173     virtual bool generate() = 0;
174
175 protected:
176     void errorMessage(const QString& msg);
177
178     /**
179      * This utility function removes the path that matches the taskRoot
180      * variable from the passed taskId.
181      */
182     QString stripTaskRoot(QString taskId) const;
183
184     Project* project;
185     QString fileName;
186
187     /* We store the location of the report definition in case we need it
188      * for error reporting. */
189     QString defFileName;
190     int defFileLine;
191     QFile f;
192     QTextStream s;
193
194     QValueList<int> scenarios;
195
196     bool weekStartsMonday;
197
198     QString headline;
199     QString caption;
200
201     /* The maximum depth of the tree that we have to report in tree-sorting
202      * mode. */
203     uint maxDepthTaskList;
204     uint maxDepthResourceList;
205     uint maxDepthAccountList;
206
207     /* The following variables store values that are not used by the Report
208      * class or its derived classes directly if the class contains
209      * ReportElements. They only contain the default values for the
210      * ReportElements. */
211     QStringList columns;
212     time_t start;
213     time_t end;
214     QString timeFormat;
215     QString shortTimeFormat;
216     RealFormat numberFormat;
217     RealFormat currencyFormat;
218
219     int taskSortCriteria[CoreAttributesList::maxSortingLevel];
220     int resourceSortCriteria[CoreAttributesList::maxSortingLevel];
221     int accountSortCriteria[CoreAttributesList::maxSortingLevel];
222
223     ExpressionTree* hideTask;
224     ExpressionTree* hideResource;
225     ExpressionTree* hideAccount;
226     ExpressionTree* rollUpTask;
227     ExpressionTree* rollUpResource;
228     ExpressionTree* rollUpAccount;
229
230     /* A report can be limited to the sub-tasks of a certain task. The
231      * taskRoot specifies this task. If set it always ends with a '.' if it's
232      * not empty. */
233     QString taskRoot;
234
235     LoadUnit loadUnit;
236
237     bool showPIDs;
238
239     bool timeStamp;
240 } ;
241
242 #endif