2 * ReportElement.cpp - 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.
13 #include "ReportElement.h"
16 #include "TableCellInfo.h"
17 #include "TjMessageHandler.h"
18 #include "tjlib-internal.h"
20 #include "CoreAttributes.h"
23 #include "ExpressionTree.h"
24 #include "TaskTreeIterator.h"
25 #include "ResourceTreeIterator.h"
26 #include "AccountTreeIterator.h"
27 #include "CustomAttributeDefinition.h"
29 #include <Q3TextStream>
30 #include <Q3ValueList>
32 ReportElement::ReportElement(Report* r, const QString& df, int dl) :
33 ReportElementBase(r, df, dl),
42 timeFormat(r->getTimeFormat()),
43 shortTimeFormat(r->getShortTimeFormat()),
48 resourceSortCriteria(),
49 accountSortCriteria(),
56 taskRoot(r->getTaskRoot()),
57 showPIDs(r->getShowPIDs()),
60 maxDepthResourceList(1),
61 maxDepthAccountList(1)
63 columns.setAutoDelete(true);
64 columnFormat.setAutoDelete(true);
66 numberFormat = r->getNumberFormat();
67 currencyFormat = r->getCurrencyFormat();
69 TableColumnFormat* tcf =
70 new TableColumnFormat(KW("accounts"), this, i18n("Accounts"));
71 tcf->genTaskLine1 = &ReportElement::genCellAccounts;
72 tcf->genTaskLine2 = &ReportElement::genCellAccounts;
73 tcf->hAlign = TableColumnFormat::left;
75 tcf = new TableColumnFormat(KW("seqno"), this, i18n("Seq. No."));
76 tcf->genTaskLine1 = &ReportElement::genCellSequenceNo;
77 tcf->genResourceLine1 = &ReportElement::genCellSequenceNo;
78 tcf->genAccountLine1 = &ReportElement::genCellSequenceNo;
79 tcf->hAlign = TableColumnFormat::right;
81 tcf = new TableColumnFormat(KW("no"), this, i18n("No."));
82 tcf->genTaskLine1 = &ReportElement::genCellNo;
83 tcf->genResourceLine1 = &ReportElement::genCellNo;
84 tcf->genAccountLine1 = &ReportElement::genCellNo;
85 tcf->hAlign = TableColumnFormat::right;
87 tcf = new TableColumnFormat(KW("hierarchno"), this, i18n("No."));
88 tcf->genTaskLine1 = &ReportElement::genCellHierarchNo;
89 tcf->genResourceLine1 = &ReportElement::genCellHierarchNo;
90 tcf->genAccountLine1 = &ReportElement::genCellHierarchNo;
91 tcf->hAlign = TableColumnFormat::left;
93 tcf = new TableColumnFormat(KW("index"), this, i18n("Index"));
94 tcf->genTaskLine1 = &ReportElement::genCellIndex;
95 tcf->genResourceLine1 = &ReportElement::genCellIndex;
96 tcf->genAccountLine1 = &ReportElement::genCellIndex;
97 tcf->hAlign = TableColumnFormat::right;
99 tcf = new TableColumnFormat(KW("hierarchindex"), this, i18n("HierarchIndex"));
100 tcf->genTaskLine1 = &ReportElement::genCellHierarchIndex;
101 tcf->genResourceLine1 = &ReportElement::genCellHierarchIndex;
102 tcf->genAccountLine1 = &ReportElement::genCellHierarchIndex;
103 tcf->hAlign = TableColumnFormat::left;
105 tcf = new TableColumnFormat(KW("hierarchlevel"), this, i18n("HierarchLevel"));
106 tcf->genTaskLine1 = &ReportElement::genCellHierarchLevel;
107 tcf->genResourceLine1 = &ReportElement::genCellHierarchLevel;
108 tcf->genAccountLine1 = &ReportElement::genCellHierarchLevel;
109 tcf->hAlign = TableColumnFormat::left;
111 tcf = new TableColumnFormat(KW("id"), this, i18n("Id"));
112 tcf->genTaskLine1 = &ReportElement::genCellId;
113 tcf->genResourceLine1 = &ReportElement::genCellId;
114 tcf->genAccountLine1 = &ReportElement::genCellId;
115 tcf->hAlign = TableColumnFormat::left;
117 tcf = new TableColumnFormat(KW("name"), this, i18n("Name"));
118 tcf->genTaskLine1 = &ReportElement::genCellName;
119 tcf->genResourceLine1 = &ReportElement::genCellName;
120 tcf->genAccountLine1 = &ReportElement::genCellName;
121 tcf->genSummaryLine1 = &ReportElement::genCellName;
122 tcf->hAlign = TableColumnFormat::left;
125 tcf->expandable = true;
127 tcf = new TableColumnFormat(KW("start"), this, i18n("Start"));
128 tcf->genTaskLine1 = &ReportElement::genCellStart;
129 tcf->genTaskLine2 = &ReportElement::genCellStart;
130 tcf->hAlign = TableColumnFormat::left;
132 tcf = new TableColumnFormat(KW("end"), this, i18n("End"));
133 tcf->genTaskLine1 = &ReportElement::genCellEnd;
134 tcf->genTaskLine2 = &ReportElement::genCellEnd;
135 tcf->hAlign = TableColumnFormat::left;
137 tcf = new TableColumnFormat(KW("minstart"), this, i18n("Min. Start"));
138 tcf->genTaskLine1 = &ReportElement::genCellMinStart;
139 tcf->genTaskLine2 = &ReportElement::genCellMinStart;
140 tcf->hAlign = TableColumnFormat::left;
142 tcf = new TableColumnFormat(KW("maxstart"), this, i18n("Max. Start"));
143 tcf->genTaskLine1 = &ReportElement::genCellMaxStart;
144 tcf->genTaskLine2 = &ReportElement::genCellMaxStart;
145 tcf->hAlign = TableColumnFormat::left;
147 tcf = new TableColumnFormat(KW("minend"), this, i18n("Min. End"));
148 tcf->genTaskLine1 = &ReportElement::genCellMinEnd;
149 tcf->genTaskLine2 = &ReportElement::genCellMinEnd;
150 tcf->hAlign = TableColumnFormat::left;
152 tcf = new TableColumnFormat(KW("maxend"), this, i18n("Max. End"));
153 tcf->genTaskLine1 = &ReportElement::genCellMaxEnd;
154 tcf->genTaskLine2 = &ReportElement::genCellMaxEnd;
155 tcf->hAlign = TableColumnFormat::left;
157 tcf = new TableColumnFormat(KW("startbufferend"), this,
158 i18n("Start Buf. End"));
159 tcf->genTaskLine1 = &ReportElement::genCellStartBufferEnd;
160 tcf->genTaskLine2 = &ReportElement::genCellStartBufferEnd;
161 tcf->hAlign = TableColumnFormat::left;
163 tcf = new TableColumnFormat(KW("endbufferstart"), this,
164 i18n("End Buf. Start"));
165 tcf->genTaskLine1 = &ReportElement::genCellEndBufferStart;
166 tcf->genTaskLine2 = &ReportElement::genCellEndBufferStart;
167 tcf->hAlign = TableColumnFormat::left;
169 tcf = new TableColumnFormat(KW("startbuffer"), this, i18n("Start Buf."));
170 tcf->genTaskLine1 = &ReportElement::genCellStartBuffer;
171 tcf->genTaskLine2 = &ReportElement::genCellStartBuffer;
172 tcf->hAlign = TableColumnFormat::right;
174 tcf = new TableColumnFormat(KW("endbuffer"), this, i18n("End Buf."));
175 tcf->genTaskLine1 = &ReportElement::genCellEndBuffer;
176 tcf->genTaskLine2 = &ReportElement::genCellEndBuffer;
177 tcf->hAlign = TableColumnFormat::right;
179 tcf = new TableColumnFormat(KW("duration"), this, i18n("Duration"));
180 tcf->genTaskLine1 = &ReportElement::genCellDuration;
181 tcf->genTaskLine2 = &ReportElement::genCellDuration;
182 tcf->hAlign = TableColumnFormat::right;
183 tcf->realFormat = numberFormat;
186 tcf = new TableColumnFormat(KW("effort"), this, i18n("Effort"));
187 tcf->genTaskLine1 = &ReportElement::genCellEffort;
188 tcf->genTaskLine2 = &ReportElement::genCellEffort;
189 tcf->genResourceLine1 = &ReportElement::genCellEffort;
190 tcf->genResourceLine2 = &ReportElement::genCellEffort;
191 tcf->hAlign = TableColumnFormat::right;
192 tcf->realFormat = numberFormat;
195 tcf = new TableColumnFormat(KW("freeload"), this, i18n("Free Load"));
196 tcf->genResourceLine1 = &ReportElement::genCellFreeLoad;
197 tcf->genResourceLine2 = &ReportElement::genCellFreeLoad;
198 tcf->hAlign = TableColumnFormat::right;
199 tcf->realFormat = numberFormat;
202 tcf = new TableColumnFormat(KW("utilization"), this, i18n("Utilization"));
203 tcf->genResourceLine1 = &ReportElement::genCellUtilization;
204 tcf->genResourceLine2 = &ReportElement::genCellUtilization;
205 tcf->hAlign = TableColumnFormat::right;
206 tcf->realFormat = numberFormat;
209 tcf = new TableColumnFormat(KW("criticalness"), this, i18n("Criticalness"));
210 tcf->genTaskLine1 = &ReportElement::genCellCriticalness;
211 tcf->genTaskLine2 = &ReportElement::genCellCriticalness;
212 tcf->hAlign = TableColumnFormat::right;
213 tcf->realFormat = numberFormat;
215 tcf = new TableColumnFormat(KW("pathcriticalness"), this,
216 i18n("Path Criticalness"));
217 tcf->genTaskLine1 = &ReportElement::genCellPathCriticalness;
218 tcf->genTaskLine2 = &ReportElement::genCellPathCriticalness;
219 tcf->hAlign = TableColumnFormat::right;
220 tcf->realFormat = numberFormat;
222 tcf = new TableColumnFormat(KW("projectid"), this, i18n("Project ID"));
223 tcf->genTaskLine1 = &ReportElement::genCellProjectId;
224 tcf->hAlign = TableColumnFormat::left;
226 tcf = new TableColumnFormat(KW("projectids"), this, i18n("Project IDs"));
227 tcf->genResourceLine1 = &ReportElement::genCellProjectIDs;
228 tcf->hAlign = TableColumnFormat::left;
229 tcf->expandable = true;
231 tcf = new TableColumnFormat(KW("resources"), this, i18n("Resources"));
232 tcf->genTaskLine1 = &ReportElement::genCellResources;
233 tcf->genTaskLine2 = &ReportElement::genCellResources;
234 tcf->hAlign = TableColumnFormat::left;
235 tcf->fontFactor = 80;
236 tcf->expandable = true;
238 tcf = new TableColumnFormat(KW("responsible"), this, i18n("Responsible"));
239 tcf->genTaskLine1 = &ReportElement::genCellResponsible;
240 tcf->hAlign = TableColumnFormat::left;
241 tcf->expandable = true;
243 tcf = new TableColumnFormat(KW("responsibilities"), this,
244 i18n("Responsibilities"));
245 tcf->genResourceLine1 = &ReportElement::genCellResponsibilities;
246 tcf->hAlign = TableColumnFormat::left;
247 tcf->fontFactor = 80;
248 tcf->expandable = true;
250 tcf = new TableColumnFormat(KW("depends"), this, i18n("Dependencies"));
251 tcf->genTaskLine1 = &ReportElement::genCellDepends;
252 tcf->hAlign = TableColumnFormat::left;
253 tcf->fontFactor = 80;
254 tcf->expandable = true;
256 tcf = new TableColumnFormat(KW("follows"), this, i18n("Followers"));
257 tcf->genTaskLine1 = &ReportElement::genCellFollows;
258 tcf->hAlign = TableColumnFormat::left;
259 tcf->fontFactor = 80;
260 tcf->expandable = true;
262 tcf = new TableColumnFormat(KW("schedule"), this, i18n("Schedule"));
263 tcf->genResourceLine1 = &ReportElement::genCellSchedule;
264 tcf->genResourceLine2 = &ReportElement::genCellSchedule;
265 tcf->hAlign = TableColumnFormat::left;
266 tcf->expandable = true;
268 tcf = new TableColumnFormat(KW("scheduling"), this, i18n("Scheduling"));
269 tcf->genTaskLine1 = &ReportElement::genCellScheduling;
270 tcf->hAlign = TableColumnFormat::left;
271 tcf->expandable = true;
273 tcf = new TableColumnFormat(KW("mineffort"), this, i18n("Min. Effort"));
274 tcf->genResourceLine1 = &ReportElement::genCellMinEffort;
275 tcf->hAlign = TableColumnFormat::right;
276 tcf->realFormat = numberFormat;
278 tcf = new TableColumnFormat(KW("maxeffort"), this, i18n("Max. Effort"));
279 tcf->genResourceLine1 = &ReportElement::genCellMaxEffort;
280 tcf->hAlign = TableColumnFormat::right;
281 tcf->realFormat = numberFormat;
283 tcf = new TableColumnFormat(KW("flags"), this, i18n("Flags"));
284 tcf->genTaskLine1 = &ReportElement::genCellFlags;
285 tcf->genResourceLine1 = &ReportElement::genCellFlags;
286 tcf->hAlign = TableColumnFormat::left;
287 tcf->expandable = true;
289 tcf = new TableColumnFormat(KW("completed"), this, i18n("Completed"));
290 tcf->genTaskLine1 = &ReportElement::genCellCompleted;
291 tcf->genTaskLine2 = &ReportElement::genCellCompleted;
292 tcf->hAlign = TableColumnFormat::right;
295 tcf = new TableColumnFormat(KW("completedeffort"), this,
296 i18n("Compl. Effort"));
297 tcf->genTaskLine1 = &ReportElement::genCellCompletedEffort;
298 tcf->genTaskLine2 = &ReportElement::genCellCompletedEffort;
299 tcf->hAlign = TableColumnFormat::right;
302 tcf = new TableColumnFormat(KW("remainingeffort"), this,
303 i18n("Rem. Effort"));
304 tcf->genTaskLine1 = &ReportElement::genCellRemainingEffort;
305 tcf->genTaskLine2 = &ReportElement::genCellRemainingEffort;
306 tcf->hAlign = TableColumnFormat::right;
309 tcf = new TableColumnFormat(KW("status"), this, i18n("Status"));
310 tcf->genTaskLine1 = &ReportElement::genCellStatus;
311 tcf->genTaskLine2 = &ReportElement::genCellStatus;
312 tcf->hAlign = TableColumnFormat::left;
313 tcf->expandable = true;
315 tcf = new TableColumnFormat(KW("note"), this, i18n("Note"));
316 tcf->genTaskLine1 = &ReportElement::genCellText;
317 tcf->hAlign = TableColumnFormat::left;
318 tcf->fontFactor = 80;
319 tcf->expandable = true;
321 tcf = new TableColumnFormat(KW("statusnote"), this, i18n("Status Note"));
322 tcf->genTaskLine1 = &ReportElement::genCellStatusNote;
323 tcf->hAlign = TableColumnFormat::left;
324 tcf->fontFactor = 80;
325 tcf->expandable = true;
327 tcf = new TableColumnFormat(KW("priority"), this, i18n("Priority"));
328 tcf->genTaskLine1 = &ReportElement::genCellPriority;
329 tcf->hAlign = TableColumnFormat::right;
331 tcf = new TableColumnFormat(KW("reference"), this, i18n("Reference"));
332 tcf->genTaskLine1 = &ReportElement::genCellReference;
333 tcf->hAlign = TableColumnFormat::left;
334 tcf->expandable = true;
336 tcf = new TableColumnFormat(KW("scenario"), this, i18n("Scenario"));
337 tcf->genTaskLine1 = &ReportElement::genCellScenario;
338 tcf->genTaskLine2 = &ReportElement::genCellScenario;
339 tcf->genResourceLine1 = &ReportElement::genCellScenario;
340 tcf->genResourceLine2 = &ReportElement::genCellScenario;
341 tcf->genAccountLine1 = &ReportElement::genCellScenario;
342 tcf->genAccountLine2 = &ReportElement::genCellScenario;
343 tcf->genSummaryLine1 = &ReportElement::genCellScenario;
344 tcf->genSummaryLine2 = &ReportElement::genCellScenario;
345 tcf->hAlign = TableColumnFormat::left;
347 tcf = new TableColumnFormat(KW("efficiency"), this, i18n("Efficiency"));
348 tcf->genResourceLine1 = &ReportElement::genCellEfficiency;
349 tcf->hAlign = TableColumnFormat::right;
351 tcf = new TableColumnFormat(KW("rate"), this, i18n("Rate"));
352 tcf->genHeadLine1 = &ReportElement::genHeadCurrency;
353 tcf->genResourceLine1 = &ReportElement::genCellRate;
354 tcf->hAlign = TableColumnFormat::right;
355 tcf->realFormat = currencyFormat;
357 tcf = new TableColumnFormat(KW("cost"), this, i18n("Cost"));
358 tcf->genHeadLine1 = &ReportElement::genHeadCurrency;
359 tcf->genTaskLine1 = &ReportElement::genCellCost;
360 tcf->genTaskLine2 = &ReportElement::genCellCost;
361 tcf->genResourceLine1 = &ReportElement::genCellCost;
362 tcf->genResourceLine2 = &ReportElement::genCellCost;
363 tcf->hAlign = TableColumnFormat::right;
364 tcf->realFormat = currencyFormat;
367 tcf = new TableColumnFormat(KW("revenue"), this, i18n("Revenue"));
368 tcf->genHeadLine1 = &ReportElement::genHeadCurrency;
369 tcf->genTaskLine1 = &ReportElement::genCellRevenue;
370 tcf->genTaskLine2 = &ReportElement::genCellRevenue;
371 tcf->genResourceLine1 = &ReportElement::genCellRevenue;
372 tcf->genResourceLine2 = &ReportElement::genCellRevenue;
373 tcf->hAlign = TableColumnFormat::right;
374 tcf->realFormat = currencyFormat;
377 tcf = new TableColumnFormat(KW("profit"), this, i18n("Profit"));
378 tcf->genHeadLine1 = &ReportElement::genHeadCurrency;
379 tcf->genTaskLine1 = &ReportElement::genCellProfit;
380 tcf->genTaskLine2 = &ReportElement::genCellProfit;
381 tcf->genResourceLine1 = &ReportElement::genCellProfit;
382 tcf->genResourceLine2 = &ReportElement::genCellProfit;
383 tcf->hAlign = TableColumnFormat::right;
384 tcf->realFormat = currencyFormat;
387 tcf = new TableColumnFormat(KW("total"), this, i18n("Total"));
388 tcf->genHeadLine1 = &ReportElement::genHeadCurrency;
389 tcf->genAccountLine1 = &ReportElement::genCellTotal;
390 tcf->genAccountLine2 = &ReportElement::genCellTotal;
391 tcf->genSummaryLine1 = &ReportElement::genCellSummary;
392 tcf->genSummaryLine2 = &ReportElement::genCellSummary;
393 tcf->hAlign = TableColumnFormat::right;
394 tcf->realFormat = currencyFormat;
397 tcf = new TableColumnFormat(KW("daily"), this, "");
398 tcf->genHeadLine1 = &ReportElement::genHeadDaily1;
399 tcf->genHeadLine2 = &ReportElement::genHeadDaily2;
400 tcf->genTaskLine1 = &ReportElement::genCellDailyTask;
401 tcf->genTaskLine2 = &ReportElement::genCellDailyTask;
402 tcf->genResourceLine1 = &ReportElement::genCellDailyResource;
403 tcf->genResourceLine2 = &ReportElement::genCellDailyResource;
404 tcf->genAccountLine1 = &ReportElement::genCellDailyAccount;
405 tcf->genAccountLine2 = &ReportElement::genCellDailyAccount;
406 tcf->genSummaryLine1 = &ReportElement::genCellSummary;
407 tcf->genSummaryLine2 = &ReportElement::genCellSummary;
408 tcf->hAlign = TableColumnFormat::right;
409 tcf->realFormat = numberFormat;
410 tcf->expandable = true;
412 tcf = new TableColumnFormat(KW("weekly"), this, "");
413 tcf->genHeadLine1 = &ReportElement::genHeadWeekly1;
414 tcf->genHeadLine2 = &ReportElement::genHeadWeekly2;
415 tcf->genTaskLine1 = &ReportElement::genCellWeeklyTask;
416 tcf->genTaskLine2 = &ReportElement::genCellWeeklyTask;
417 tcf->genResourceLine1 = &ReportElement::genCellWeeklyResource;
418 tcf->genResourceLine2 = &ReportElement::genCellWeeklyResource;
419 tcf->genAccountLine1 = &ReportElement::genCellWeeklyAccount;
420 tcf->genAccountLine2 = &ReportElement::genCellWeeklyAccount;
421 tcf->genSummaryLine1 = &ReportElement::genCellSummary;
422 tcf->genSummaryLine2 = &ReportElement::genCellSummary;
423 tcf->hAlign = TableColumnFormat::right;
424 tcf->realFormat = numberFormat;
425 tcf->expandable = true;
427 tcf = new TableColumnFormat(KW("monthly"), this, "");
428 tcf->genHeadLine1 = &ReportElement::genHeadMonthly1;
429 tcf->genHeadLine2 = &ReportElement::genHeadMonthly2;
430 tcf->genTaskLine1 = &ReportElement::genCellMonthlyTask;
431 tcf->genTaskLine2 = &ReportElement::genCellMonthlyTask;
432 tcf->genResourceLine1 = &ReportElement::genCellMonthlyResource;
433 tcf->genResourceLine2 = &ReportElement::genCellMonthlyResource;
434 tcf->genAccountLine1 = &ReportElement::genCellMonthlyAccount;
435 tcf->genAccountLine2 = &ReportElement::genCellMonthlyAccount;
436 tcf->genSummaryLine1 = &ReportElement::genCellSummary;
437 tcf->genSummaryLine2 = &ReportElement::genCellSummary;
438 tcf->hAlign = TableColumnFormat::right;
439 tcf->realFormat = numberFormat;
440 tcf->expandable = true;
442 tcf = new TableColumnFormat(KW("quarterly"), this, "");
443 tcf->genHeadLine1 = &ReportElement::genHeadQuarterly1;
444 tcf->genHeadLine2 = &ReportElement::genHeadQuarterly2;
445 tcf->genTaskLine1 = &ReportElement::genCellQuarterlyTask;
446 tcf->genTaskLine2 = &ReportElement::genCellQuarterlyTask;
447 tcf->genResourceLine1 = &ReportElement::genCellQuarterlyResource;
448 tcf->genResourceLine2 = &ReportElement::genCellQuarterlyResource;
449 tcf->genAccountLine1 = &ReportElement::genCellQuarterlyAccount;
450 tcf->genAccountLine2 = &ReportElement::genCellQuarterlyAccount;
451 tcf->genSummaryLine1 = &ReportElement::genCellSummary;
452 tcf->genSummaryLine2 = &ReportElement::genCellSummary;
453 tcf->hAlign = TableColumnFormat::right;
454 tcf->realFormat = numberFormat;
455 tcf->expandable = true;
457 tcf = new TableColumnFormat(KW("yearly"), this, "");
458 tcf->genHeadLine1 = &ReportElement::genHeadYear;
459 tcf->genTaskLine1 = &ReportElement::genCellYearlyTask;
460 tcf->genTaskLine2 = &ReportElement::genCellYearlyTask;
461 tcf->genResourceLine1 = &ReportElement::genCellYearlyResource;
462 tcf->genResourceLine2 = &ReportElement::genCellYearlyResource;
463 tcf->genAccountLine1 = &ReportElement::genCellYearlyAccount;
464 tcf->genAccountLine2 = &ReportElement::genCellYearlyAccount;
465 tcf->genSummaryLine1 = &ReportElement::genCellSummary;
466 tcf->genSummaryLine2 = &ReportElement::genCellSummary;
467 tcf->hAlign = TableColumnFormat::right;
468 tcf->realFormat = numberFormat;
469 tcf->expandable = true;
471 tcf = new TableColumnFormat(KW("chart"), this, "");
473 addCustomAttributeColumns(r->getProject()->getTaskAttributeDict());
474 addCustomAttributeColumns(r->getProject()->getResourceAttributeDict());
475 addCustomAttributeColumns(r->getProject()->getAccountAttributeDict());
477 // All reports default to just showing the first scenario.
480 for (int i = 0; i < CoreAttributesList::maxSortingLevel; ++i)
482 taskSortCriteria[i] = r->getTaskSorting(i);
483 resourceSortCriteria[i] = r->getResourceSorting(i);
484 accountSortCriteria[i] = r->getAccountSorting(i);
487 hideTask = r->getHideTask() ?
488 new ExpressionTree(*r->getHideTask()) : 0;
489 rollUpTask = r->getRollUpTask() ?
490 new ExpressionTree(*r->getRollUpTask()) : 0;
491 hideResource = r->getHideResource() ?
492 new ExpressionTree(*r->getHideResource()) : 0;
493 rollUpResource = r->getRollUpResource() ?
494 new ExpressionTree(*r->getRollUpResource()) : 0;
495 hideAccount = r->getHideAccount() ?
496 new ExpressionTree(*r->getHideAccount()) : 0;
497 rollUpAccount = r->getRollUpAccount() ?
498 new ExpressionTree(*r->getRollUpAccount()) : 0;
500 loadUnit = r->getLoadUnit();
503 ReportElement::~ReportElement()
508 delete rollUpResource;
510 delete rollUpAccount;
514 ReportElement::s() const
516 return report->stream();
520 ReportElement::isSupportedColumn(const QString& id) const
522 return columnFormat[id] ||
523 report->getProject()->getTaskAttribute(id) ||
524 report->getProject()->getResourceAttribute(id) ||
525 report->getProject()->getAccountAttribute(id);
529 ReportElement::getSupportedColumnList() const
532 Q3DictIterator<TableColumnFormat> it(columnFormat);
533 for ( ; it.current(); ++it)
534 l.append(it.currentKey());
541 ReportElement::addColumn(const TableColumnInfo* c)
546 const TableColumnInfo*
547 ReportElement::columnsAt(uint idx) const
550 for (Q3PtrListIterator<TableColumnInfo> pli(columns); *pli; ++pli, i++)
558 ReportElement::clearColumns()
563 Q3PtrListIterator<TableColumnInfo>
564 ReportElement::getColumnsIterator() const
566 return Q3PtrListIterator<TableColumnInfo>(columns);
570 ReportElement::setTaskSorting(int sc, int level)
572 if (level >= 0 && level < CoreAttributesList::maxSortingLevel)
574 if ((sc == CoreAttributesList::TreeMode && level > 0) ||
575 !TaskList::isSupportedSortingCriteria(sc & 0xFFFF))
577 taskSortCriteria[level] = sc;
585 ReportElement::setResourceSorting(int sc, int level)
587 if (level >= 0 && level < CoreAttributesList::maxSortingLevel)
589 if ((sc == CoreAttributesList::TreeMode && level > 0) ||
590 !ResourceList::isSupportedSortingCriteria(sc & 0xFFFF))
592 resourceSortCriteria[level] = sc;
600 ReportElement::setAccountSorting(int sc, int level)
602 if (level >= 0 && level < CoreAttributesList::maxSortingLevel)
604 if ((sc == CoreAttributesList::TreeMode && level > 0) ||
605 !AccountList::isSupportedSortingCriteria(sc & 0xFFFF))
607 accountSortCriteria[level] = sc;
615 ReportElement::isHidden(const CoreAttributes* c, ExpressionTree* et) const
617 /* Determine whether a CoreAttributes object should be hidden according to
618 * the ExpressionTree et. */
620 /* First check if the object is part of the sub-tree specified by
621 * taskRoot. The check only applies to Task objects. */
622 if (c->getType() == CA_Task && !taskRoot.isEmpty() &&
623 taskRoot != c->getId().left(taskRoot.length()))
628 // If we don't have an ExpressionTree the object is always visible.
632 // Pump all flags into the symbol table.
633 et->clearSymbolTable();
634 QStringList allFlags = report->getProject()->getAllowedFlags();
635 for (QStringList::Iterator ait = allFlags.begin(); ait != allFlags.end();
639 QStringList flags = c->getFlagList();
640 for (QStringList::Iterator it = flags.begin(); it != flags.end(); ++it)
643 et->registerSymbol(*it, 1);
648 et->registerSymbol(*ait, 0);
651 return et->evalAsInt(c) != 0;
655 ReportElement::isRolledUp(const CoreAttributes* c, ExpressionTree* et) const
657 /* Determine wheter a CoreAttributes object should hide all it's
660 /* If we don't have an ExpressionTree the object's descendants are always
665 // Pump all flags into the symbol table.
666 et->clearSymbolTable();
667 QStringList allFlags = report->getProject()->getAllowedFlags();
668 for (QStringList::Iterator ait = allFlags.begin(); ait != allFlags.end();
672 QStringList flags = c->getFlagList();
673 for (QStringList::Iterator it = flags.begin(); it != flags.end(); ++it)
676 et->registerSymbol(*it, 1);
681 et->registerSymbol(*ait, 0);
683 return et->evalAsInt(c) != 0;
687 ReportElement::setHideTask(ExpressionTree* et)
694 ReportElement::setRollUpTask(ExpressionTree* et)
701 ReportElement::setHideResource(ExpressionTree* et)
708 ReportElement::setRollUpResource(ExpressionTree* et)
710 delete rollUpResource;
715 ReportElement::setHideAccount(ExpressionTree* et)
722 ReportElement::setRollUpAccount(ExpressionTree* et)
724 delete rollUpAccount;
729 ReportElement::filterTaskList(TaskList& filteredList, const Resource* r,
730 ExpressionTree* hideExp,
731 ExpressionTree* rollUpExp)
734 /* Create a new list that contains only those tasks that were not
736 filteredList.clear();
737 for (TaskListIterator tli(report->getProject()->getTaskListIterator());
740 bool resourceLoadedInAnyScenario = false;
741 if (r != 0 && (*tli)->isLeaf())
743 Q3ValueList<int>::const_iterator it;
744 for (it = scenarios.begin(); it != scenarios.end(); ++it)
745 if ((*tli)->isBookedResource(*it, r))
747 resourceLoadedInAnyScenario = true;
751 bool taskOverlapsInAnyScenario = false;
752 Interval iv(start, end);
753 Q3ValueList<int>::const_iterator it;
754 for (it = scenarios.begin(); it != scenarios.end(); ++it)
755 if (iv.overlaps(Interval((*tli)->getStart(*it),
756 (*tli)->getEnd(*it) ==
757 (*tli)->getStart(*it) - 1 ?
758 (*tli)->getStart(*it) :
759 (*tli)->getEnd(*it))))
761 taskOverlapsInAnyScenario = true;
765 if (taskOverlapsInAnyScenario &&
766 (r == 0 || resourceLoadedInAnyScenario) &&
767 !isHidden(*tli, hideExp))
769 filteredList.append(tli);
771 if (hideExp && hideExp->getErrorFlag())
774 /* In tasktree sorting mode we need to make sure that we don't hide
775 * parents of shown tasks. */
776 TaskList list = filteredList;
777 if (taskSortCriteria[0] == CoreAttributesList::TreeMode)
779 for (TaskListIterator tli(filteredList); *tli != 0; ++tli)
781 // Do not add the taskRoot task or any of it's parents.
782 for (Task* p = (*tli)->getParent();
783 p != 0 && (p->getId() + "." != taskRoot);
785 if (list.containsRef(p) == 0)
794 /* Now we have to remove all sub tasks of rolled-up tasks
795 * from the filtered list */
796 for (TaskListIterator tli(report->getProject()->getTaskListIterator());
799 if (isRolledUp(*tli, rollUpExp))
800 for (TaskTreeIterator tti(*tli, parentAfterLeaves);
803 filteredList.removeRef(*tti);
804 if (rollUpExp && rollUpExp->getErrorFlag())
812 ReportElement::sortTaskList(TaskList& filteredList) const
814 /* The sorting can only honor the first scenario. Other scenarios are
815 * ignort for the sorting. */
816 filteredList.setSortScenario(scenarios[0]);
818 for (int i = 0; i < CoreAttributesList::maxSortingLevel; i++)
819 filteredList.setSorting(taskSortCriteria[i], i);
824 ReportElement::filterResourceList(ResourceList& filteredList, const Task* t,
825 ExpressionTree* hideExp, ExpressionTree* rollUpExp)
828 /* Create a new list that contains only those resources that were
830 filteredList.clear();
831 for (ResourceListIterator rli(report->getProject()->
832 getResourceListIterator());
835 bool taskLoadedInAnyScenario = false;
836 if (t != 0 && t->isLeaf())
838 Q3ValueList<int>::const_iterator it;
839 for (it = scenarios.begin(); it != scenarios.end(); ++it)
840 if ((*rli)->isAllocated(*it, Interval(start, end), t) > 0.0)
842 taskLoadedInAnyScenario = true;
846 if (!isHidden(*rli, hideExp) &&
847 (t == 0 || taskLoadedInAnyScenario))
849 filteredList.append(*rli);
851 if (hideExp && hideExp->getErrorFlag())
855 /* In resourcetree sorting mode we need to make sure that we don't
856 * hide parents of shown resources. */
857 ResourceList list = filteredList;
858 if (resourceSortCriteria[0] == CoreAttributesList::TreeMode)
860 for (ResourceListIterator rli(filteredList); *rli != 0; ++rli)
862 for (Resource* p = (*rli)->getParent(); p != 0; p = p->getParent())
863 if (list.containsRef(p) == 0)
872 /* Now we have to remove all sub resources of resource in the
873 * roll-up list from the filtered list */
874 for (ResourceListIterator rli(report->getProject()->
875 getResourceListIterator());
878 if (isRolledUp(*rli, rollUpExp))
879 for (ResourceTreeIterator rti(*rli, parentAfterLeaves);
882 filteredList.removeRef(*rti);
883 if (rollUpExp && rollUpExp->getErrorFlag())
891 ReportElement::sortResourceList(ResourceList& filteredList) const
893 for (int i = 0; i < CoreAttributesList::maxSortingLevel; i++)
894 filteredList.setSorting(resourceSortCriteria[i], i);
899 ReportElement::filterAccountList(AccountList& filteredList, AccountType at,
900 ExpressionTree* hideExp, ExpressionTree* rollUpExp)
903 /* Create a new list that contains only those accounts that were not
905 filteredList.clear();
906 for (AccountListIterator ali(report->getProject()->
907 getAccountListIterator());
910 if (!isHidden(*ali, hideExp) && (*ali)->getAcctType() == at)
911 filteredList.append(*ali);
912 if (hideExp && hideExp->getErrorFlag())
916 /* In accounttree sorting mode we need to make sure that we don't hide
917 * parents of shown accounts. */
918 AccountList list = filteredList;
919 if (accountSortCriteria[0] == CoreAttributesList::TreeMode)
921 for (AccountListIterator ali(filteredList); *ali != 0; ++ali)
923 for (Account* p = (*ali)->getParent(); p != 0; p = p->getParent())
924 if (list.containsRef(p) == 0)
933 /* Now we have to remove all sub accounts of account in the roll-up list
934 * from the filtered list */
935 for (AccountListIterator ali(report->getProject()->
936 getAccountListIterator());
939 if (isRolledUp(*ali, rollUpExp))
940 for (AccountTreeIterator ati(*ali, parentAfterLeaves);
943 filteredList.removeRef(*ati);
944 if (rollUpExp && rollUpExp->getErrorFlag())
952 ReportElement::sortAccountList(AccountList& filteredList) const
954 for (int i = 0; i < CoreAttributesList::maxSortingLevel; i++)
955 filteredList.setSorting(accountSortCriteria[i], i);
960 ReportElement::taskRootLevel() const
962 if (taskRoot.isEmpty())
964 Task* task = report->getProject()->
965 getTask(taskRoot.left(taskRoot.length() - 1));
966 return task->treeLevel();
970 ReportElement::errorMessage(const QString& msg)
972 TJMH.errorMessage(msg, defFileName, defFileLine);
976 ReportElement::stripTaskRoot(QString taskId) const
978 if (taskRoot == taskId.left(taskRoot.length()))
979 return taskId.right(taskId.length() - taskRoot.length());
985 ReportElement::addCustomAttributeColumns
986 (const Q3Dict<CustomAttributeDefinition>& cad)
988 for (Q3DictIterator<CustomAttributeDefinition> it(cad); *it; ++it)
990 TableColumnFormat* tcf;
991 tcf = new TableColumnFormat(it.currentKey(), this, (*it)->getName());
992 switch ((*it)->getType())
995 tcf->genTaskLine1 = &ReportElement::genCellReference;
996 tcf->genResourceLine1 = &ReportElement::genCellReference;
997 tcf->genAccountLine1 = &ReportElement::genCellReference;
1000 tcf->genTaskLine1 = &ReportElement::genCellText;
1001 tcf->genResourceLine1 = &ReportElement::genCellText;
1002 tcf->genAccountLine1 = &ReportElement::genCellText;
1003 tcf->fontFactor = 80;
1011 const TableColumnFormat*
1012 ReportElement::getColumnFormat(const QString& key) const
1014 return columnFormat[key];