OSDN Git Service

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