2 * Report.h - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
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.
16 #include <q3valuelist.h>
18 #include <QTextStream>
22 #include "CoreAttributesList.h"
23 #include "RealFormat.h"
37 * @short The base class for all report generating classes.
38 * @author Chris Schlaeger <cs@kde.org>
43 Report(Project* p, const QString& f, const QString& df, int dl);
46 virtual const char* getType() const { return "Report"; }
51 QTextStream& stream() { return s; }
53 void puts(const QString& str)
57 const Project* getProject() const { return project; }
58 const QString& getFileName() const { return fileName; }
59 QString getFullFileName() const;
61 const QString& getDefinitionFile() const { return defFileName; }
62 uint getDefinitionLine() const { return defFileLine; }
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]; }
69 void setWeekStartsMonday(bool wsm) { weekStartsMonday = wsm; }
70 bool getWeekStartsMonday() const { return weekStartsMonday; }
72 void setShowPIDs(bool sp) { showPIDs = sp; }
73 bool getShowPIDs() const { return showPIDs; }
75 void addReportColumn(const QString& c) { columns.append(c); }
76 const QString& columnsAt(uint idx) { return columns[idx]; }
77 void clearColumns() { columns.clear(); }
79 void setStart(time_t st) { start = st; }
80 time_t getStart() const { return start; }
82 void setEnd(time_t e) { end = e; }
83 time_t getEnd() const { return end; }
85 void setPeriod(const Interval& iv)
87 start = iv.getStart();
91 void setHeadline(const QString& hl) { headline = hl; }
92 const QString& getHeadline() const { return headline; }
94 void setCaption(const QString& c) { caption = c; }
95 const QString& getCaption() const { return caption; }
97 bool isHidden(const CoreAttributes* c, ExpressionTree* et) const;
98 bool isRolledUp(const CoreAttributes* c, ExpressionTree* et) const;
100 void setHideTask(ExpressionTree* et);
101 ExpressionTree* getHideTask() const { return hideTask; }
103 void setHideResource(ExpressionTree* et);
104 ExpressionTree* getHideResource() const { return hideResource; }
106 void setHideAccount(ExpressionTree* et);
107 ExpressionTree* getHideAccount() const { return hideAccount; }
109 void setRollUpTask(ExpressionTree* et);
110 ExpressionTree* getRollUpTask() const { return rollUpTask; }
112 void setRollUpResource(ExpressionTree* et);
113 ExpressionTree* getRollUpResource() const { return rollUpResource; }
115 void setRollUpAccount(ExpressionTree* et);
116 ExpressionTree* getRollUpAccount() const { return rollUpAccount; }
118 bool setTaskSorting(int sc, int level);
119 int getTaskSorting(int level) const { return taskSortCriteria[level]; }
121 bool setResourceSorting(int sc, int level);
122 int getResourceSorting(int level) const
124 return resourceSortCriteria[level];
127 bool setAccountSorting(int sc, int level);
128 int getAccountSorting(int level) const
130 return accountSortCriteria[level];
133 void setTaskRoot(const QString& root) { taskRoot = root; }
134 const QString& getTaskRoot() const { return taskRoot; }
136 bool setLoadUnit(const QString& u);
137 LoadUnit getLoadUnit() const { return loadUnit; }
139 void setTimeFormat(const QString& tf) { timeFormat = tf; }
140 const QString& getTimeFormat() const { return timeFormat; }
142 void setShortTimeFormat(const QString& tf) { shortTimeFormat = tf; }
143 const QString& getShortTimeFormat() const { return shortTimeFormat; }
145 void setNumberFormat(const RealFormat& rf) { numberFormat = rf; }
146 const RealFormat& getNumberFormat() const { return numberFormat; }
148 void setCurrencyFormat(const RealFormat& rf) { currencyFormat = rf; }
149 const RealFormat& getCurrencyFormat() const { return currencyFormat; }
151 bool filterTaskList(TaskList& filteredList, const Resource* r,
152 ExpressionTree* hideExp, ExpressionTree* rollUpExp)
154 void sortTaskList(TaskList& filteredList);
156 bool filterResourceList(ResourceList& filteredList, const Task* t,
157 ExpressionTree* hideExp, ExpressionTree* rollUpExp)
159 void sortResourceList(ResourceList& filteredList);
161 bool filterAccountList(AccountList& filteredList, AccountType at,
162 ExpressionTree* hideExp, ExpressionTree*
164 void sortAccountList(AccountList& filteredList);
166 void setTimeStamp(bool t)
170 bool getTimeStamp() const
175 virtual bool generate() = 0;
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); } ;
182 virtual void inheritValues();
185 void errorMessage(const QString& msg);
188 * This utility function removes the path that matches the taskRoot
189 * variable from the passed taskId.
191 QString stripTaskRoot(QString taskId) const;
196 /* We store the location of the report definition in case we need it
197 * for error reporting. */
203 QList<int> scenarios;
205 bool weekStartsMonday;
210 /* The maximum depth of the tree that we have to report in tree-sorting
212 uint maxDepthTaskList;
213 uint maxDepthResourceList;
214 uint maxDepthAccountList;
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
224 QString shortTimeFormat;
225 RealFormat numberFormat;
226 RealFormat currencyFormat;
228 int taskSortCriteria[CoreAttributesList::maxSortingLevel];
229 int resourceSortCriteria[CoreAttributesList::maxSortingLevel];
230 int accountSortCriteria[CoreAttributesList::maxSortingLevel];
232 ExpressionTree* hideTask;
233 ExpressionTree* hideResource;
234 ExpressionTree* hideAccount;
235 ExpressionTree* rollUpTask;
236 ExpressionTree* rollUpResource;
237 ExpressionTree* rollUpAccount;
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
250 Report* parentReport;
251 Q3PtrList<Report> childrenReport;