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 <qvaluelist.h>
18 #include <qtextstream.h>
20 #include "CoreAttributesList.h"
21 #include "RealFormat.h"
35 * @short The base class for all report generating classes.
36 * @author Chris Schlaeger <cs@kde.org>
41 Report(Project* p, const QString& f, const QString& df, int dl);
44 virtual const char* getType() const { return "Report"; }
49 QTextStream& stream() { return s; }
51 void puts(const QString& str)
53 s.writeRawBytes(str.data(), str.length());
55 const Project* getProject() const { return project; }
56 const QString& getFileName() const { return fileName; }
57 QString getFullFileName() const;
59 const QString& getDefinitionFile() const { return defFileName; }
60 uint getDefinitionLine() const { return defFileLine; }
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]; }
67 void setWeekStartsMonday(bool wsm) { weekStartsMonday = wsm; }
68 bool getWeekStartsMonday() const { return weekStartsMonday; }
70 void setShowPIDs(bool sp) { showPIDs = sp; }
71 bool getShowPIDs() const { return showPIDs; }
73 void addReportColumn(const QString& c) { columns.append(c); }
74 const QString& columnsAt(uint idx) { return columns[idx]; }
75 void clearColumns() { columns.clear(); }
77 void setStart(time_t st) { start = st; }
78 time_t getStart() const { return start; }
80 void setEnd(time_t e) { end = e; }
81 time_t getEnd() const { return end; }
83 void setPeriod(const Interval& iv)
85 start = iv.getStart();
89 void setHeadline(const QString& hl) { headline = hl; }
90 const QString& getHeadline() const { return headline; }
92 void setCaption(const QString& c) { caption = c; }
93 const QString& getCaption() const { return caption; }
95 bool isHidden(const CoreAttributes* c, ExpressionTree* et) const;
96 bool isRolledUp(const CoreAttributes* c, ExpressionTree* et) const;
98 void setHideTask(ExpressionTree* et);
99 ExpressionTree* getHideTask() const { return hideTask; }
101 void setHideResource(ExpressionTree* et);
102 ExpressionTree* getHideResource() const { return hideResource; }
104 void setHideAccount(ExpressionTree* et);
105 ExpressionTree* getHideAccount() const { return hideAccount; }
107 void setRollUpTask(ExpressionTree* et);
108 ExpressionTree* getRollUpTask() const { return rollUpTask; }
110 void setRollUpResource(ExpressionTree* et);
111 ExpressionTree* getRollUpResource() const { return rollUpResource; }
113 void setRollUpAccount(ExpressionTree* et);
114 ExpressionTree* getRollUpAccount() const { return rollUpAccount; }
116 bool setTaskSorting(int sc, int level);
117 int getTaskSorting(int level) const { return taskSortCriteria[level]; }
119 bool setResourceSorting(int sc, int level);
120 int getResourceSorting(int level) const
122 return resourceSortCriteria[level];
125 bool setAccountSorting(int sc, int level);
126 int getAccountSorting(int level) const
128 return accountSortCriteria[level];
131 void setTaskRoot(const QString& root) { taskRoot = root; }
132 const QString& getTaskRoot() const { return taskRoot; }
134 bool setLoadUnit(const QString& u);
135 LoadUnit getLoadUnit() const { return loadUnit; }
137 void setTimeFormat(const QString& tf) { timeFormat = tf; }
138 const QString& getTimeFormat() const { return timeFormat; }
140 void setShortTimeFormat(const QString& tf) { shortTimeFormat = tf; }
141 const QString& getShortTimeFormat() const { return shortTimeFormat; }
143 void setNumberFormat(const RealFormat& rf) { numberFormat = rf; }
144 const RealFormat& getNumberFormat() const { return numberFormat; }
146 void setCurrencyFormat(const RealFormat& rf) { currencyFormat = rf; }
147 const RealFormat& getCurrencyFormat() const { return currencyFormat; }
149 bool filterTaskList(TaskList& filteredList, const Resource* r,
150 ExpressionTree* hideExp, ExpressionTree* rollUpExp)
152 void sortTaskList(TaskList& filteredList);
154 bool filterResourceList(ResourceList& filteredList, const Task* t,
155 ExpressionTree* hideExp, ExpressionTree* rollUpExp)
157 void sortResourceList(ResourceList& filteredList);
159 bool filterAccountList(AccountList& filteredList, AccountType at,
160 ExpressionTree* hideExp, ExpressionTree*
162 void sortAccountList(AccountList& filteredList);
164 void setTimeStamp(bool t)
168 bool getTimeStamp() const
173 virtual bool generate() = 0;
176 void errorMessage(const QString& msg);
179 * This utility function removes the path that matches the taskRoot
180 * variable from the passed taskId.
182 QString stripTaskRoot(QString taskId) const;
187 /* We store the location of the report definition in case we need it
188 * for error reporting. */
194 QValueList<int> scenarios;
196 bool weekStartsMonday;
201 /* The maximum depth of the tree that we have to report in tree-sorting
203 uint maxDepthTaskList;
204 uint maxDepthResourceList;
205 uint maxDepthAccountList;
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
215 QString shortTimeFormat;
216 RealFormat numberFormat;
217 RealFormat currencyFormat;
219 int taskSortCriteria[CoreAttributesList::maxSortingLevel];
220 int resourceSortCriteria[CoreAttributesList::maxSortingLevel];
221 int accountSortCriteria[CoreAttributesList::maxSortingLevel];
223 ExpressionTree* hideTask;
224 ExpressionTree* hideResource;
225 ExpressionTree* hideAccount;
226 ExpressionTree* rollUpTask;
227 ExpressionTree* rollUpResource;
228 ExpressionTree* rollUpAccount;
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