2 * XMLReport.cpp - TaskJuggler
4 * Copyright (c) 2002 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 "XMLReport.h"
20 #include "tjlib-internal.h"
25 #include "BookingList.h"
26 #include "Allocation.h"
27 #include "XMLReport.h"
28 #include "ExpressionTree.h"
29 #include "Operation.h"
30 #include "CustomAttributeDefinition.h"
31 #include "TextAttribute.h"
32 #include "ReferenceAttribute.h"
34 static QMap<QString, int> TaskAttributeDict;
55 XMLReport::XMLReport(Project* p, const QString& f,
56 const QString& df, int dl) :
62 if (TaskAttributeDict.empty())
64 TaskAttributeDict[KW("complete")] = TA_COMPLETE;
65 TaskAttributeDict[KW("depends")] = TA_DEPENDS;
66 TaskAttributeDict[KW("duration")] = TA_DURATION;
67 TaskAttributeDict[KW("effort")] = TA_EFFORT;
68 TaskAttributeDict[KW("flags")] = TA_FLAGS;
69 TaskAttributeDict[KW("length")] = TA_LENGTH;
70 TaskAttributeDict[KW("maxend")] = TA_MAXEND;
71 TaskAttributeDict[KW("maxstart")] = TA_MAXSTART;
72 TaskAttributeDict[KW("minend")] = TA_MINEND;
73 TaskAttributeDict[KW("minstart")] = TA_MINSTART;
74 TaskAttributeDict[KW("note")] = TA_NOTE;
75 TaskAttributeDict[KW("priority")] = TA_PRIORITY;
76 TaskAttributeDict[KW("responsible")] = TA_RESPONSIBLE;
77 TaskAttributeDict[KW("status")] = TA_STATUS;
78 TaskAttributeDict[KW("statusnote")] = TA_STATUSNOTE;
79 TaskAttributeDict[KW("account")] = TA_ACCOUNT;
82 hideTask = new ExpressionTree(new Operation(0));
84 hideResource = new ExpressionTree(new Operation(0));
86 hideAccount = new ExpressionTree(new Operation(0));
88 taskSortCriteria[0] = CoreAttributesList::TreeMode;
89 taskSortCriteria[1] = CoreAttributesList::StartUp;
90 taskSortCriteria[2] = CoreAttributesList::EndUp;
91 resourceSortCriteria[0] = CoreAttributesList::TreeMode;
92 resourceSortCriteria[1] = CoreAttributesList::IdUp;
93 accountSortCriteria[0] = CoreAttributesList::TreeMode;
94 accountSortCriteria[1] = CoreAttributesList::IdUp;
96 // All XML reports default to just showing the first scenario.
100 XMLReport::~XMLReport()
106 XMLReport::generate()
111 doc = new QDomDocument
112 ("taskjuggler PUBLIC "
113 "\"-//The TaskJuggler Project//DTD TaskJuggler 2.0//EN\""
114 " \"http://www.taskjuggler.org/dtds/TaskJuggler-2.0.dtd\"");
116 doc->appendChild(doc->createProcessingInstruction
117 ("xml", "version=\"1.0\" encoding=\"UTF-8\" "
118 "standalone=\"no\""));
120 QDomElement tjEl = doc->createElement("taskjuggler");
121 doc->appendChild(tjEl);
125 doc->appendChild(doc->createComment(
126 QString("This file has been generated by TaskJuggler ") +
127 VERSION + " at " + time2ISO(time(0)) + "."));
128 doc->appendChild(doc->createComment(
129 QString("For details about TaskJuggler see ") + TJURL));
132 TaskList filteredTaskList;
133 if (!filterTaskList(filteredTaskList, 0, hideTask, rollUpTask))
135 sortTaskList(filteredTaskList);
137 ResourceList filteredResourceList;
138 if (!filterResourceList(filteredResourceList, 0, hideResource,
141 sortResourceList(filteredResourceList);
143 AccountList filteredAccountList;
144 if (!filterAccountList(filteredAccountList, AllAccounts, hideAccount,
147 sortAccountList(filteredAccountList);
149 if (!generateProjectProperty(&tjEl))
151 if (!generateGlobalVacationList(&tjEl))
153 if (!generateShiftList(&tjEl))
155 if (!generateResourceList(&tjEl, filteredResourceList, filteredTaskList))
157 if (!generateAccountList(&tjEl, filteredAccountList, filteredTaskList))
159 if (!generateTaskList(&tjEl, filteredTaskList, filteredResourceList))
161 if (!generateBookingList(&tjEl, filteredTaskList, filteredResourceList))
164 gzFile zf = gzdopen(dup(f.handle()), "wb");
167 tjWarning(i18n("Cannot open compressed file %1 for writing.")
172 if ((bytes = gzputs(zf, static_cast<const char*>(doc->toCString()))) == 0)
174 tjWarning(i18n("Compression of %1 failed").arg(fileName));
178 if ((zError = gzclose(zf)) != 0)
180 tjWarning(i18n("Closing of file %1 failed: %2").arg(fileName)
181 .arg(gzerror(zf, &zError)));
189 XMLReport::generateProjectProperty(QDomElement* n)
191 QDomElement el = doc->createElement("project");
194 genTextAttr(&el, "id", project->getId());
195 genTextAttr(&el, "name", project->getName());
196 genTextAttr(&el, "version", project->getVersion());
197 genDateElement(&el, "start", getStart());
198 genDateElement(&el, "end", getEnd() + 1);
200 // Generate custom attribute definitions
201 if (!generateCustomAttributeDeclaration
202 (&el, "task", project->getTaskAttributeDict()))
204 if (!generateCustomAttributeDeclaration
205 (&el, "resource", project->getResourceAttributeDict()))
207 if (!generateCustomAttributeDeclaration
208 (&el, "account", project->getAccountAttributeDict()))
211 // Generate date/time related settings
212 genLongAttr(&el, "weekStartMonday",
213 project->getWeekStartsMonday() ? 1 : 0);
214 if (!project->getTimeZone().isEmpty())
215 genTextAttr(&el, "timezone", project->getTimeZone());
216 genDoubleAttr(&el, "dailyWorkingHours",
217 project->getDailyWorkingHours());
218 genDoubleAttr(&el, "yearlyWorkingDays",
219 project->getYearlyWorkingDays());
220 genLongAttr(&el, "timingResolution", project->getScheduleGranularity());
221 genDateElement(&el, "now", project->getNow());
222 genTextAttr(&el, "timeFormat", project->getTimeFormat());
223 genTextAttr(&el, "shortTimeFormat", project->getShortTimeFormat());
225 // Generate currency settings
226 RealFormat rf = project->getCurrencyFormat();
227 QDomElement cfEl = doc->createElement("currencyFormat");
228 el.appendChild(cfEl);
229 genTextAttr(&cfEl, "signPrefix", rf.getSignPrefix());
230 genTextAttr(&cfEl, "signSuffix", rf.getSignSuffix());
231 genTextAttr(&cfEl, "thousandSep", rf.getThousandSep());
232 genTextAttr(&cfEl, "fractionSep", rf.getFractionSep());
233 genLongAttr(&cfEl, "fracDigits", rf.getFracDigits());
234 if (!project->getCurrency().isEmpty())
235 genTextAttr(&el, "currency", project->getCurrency());
237 generateWorkingHours(&el, project->getWorkingHours());
239 generateScenario(&el, project->getScenario(0));
245 XMLReport::generateCustomAttributeDeclaration(QDomElement* parentEl,
246 const QString& propertyName,
247 QDictIterator<CustomAttributeDefinition> it)
251 QDomElement el = doc->createElement("extend");
252 parentEl->appendChild(el);
253 genTextAttr(&el, "property", propertyName);
255 for ( ; it.current(); ++it)
258 switch (it.current()->getType())
264 exElType = "reference";
267 qFatal("XMLReport::generateCustomAttributeDeclaration: "
268 "Unknown CAT %d", it.current()->getType());
271 QDomElement exEl = doc->createElement("extendAttributeDefinition");
272 el.appendChild(exEl);
273 genTextAttr(&exEl, "id", it.currentKey());
274 genTextAttr(&exEl, "name", it.current()->getName());
275 genTextAttr(&exEl, "type", exElType);
282 XMLReport::generateScenario(QDomElement* parentEl, Scenario* scenario)
284 QDomElement el = doc->createElement("scenario");
285 parentEl->appendChild(el);
287 genTextAttr(&el, "id", scenario->getId());
288 genTextAttr(&el, "name", scenario->getName());
289 genTextAttr(&el, "disabled", scenario->getEnabled() ? "0" : "1");
290 genTextAttr(&el, "projectionMode",
291 scenario->getProjectionMode() ? "1" : "0");
293 for (ScenarioListIterator sci(scenario->getSubListIterator());
295 generateScenario(&el, *sci);
301 XMLReport::generateGlobalVacationList(QDomElement* parentNode)
303 VacationList::Iterator vli(project->getVacationListIterator());
307 QDomElement el = doc->createElement("vacationList");
308 parentNode->appendChild(el);
310 for ( ; *vli != 0; ++vli)
312 QDomElement vEl = doc->createElement("vacation");
315 genDateElement(&vEl, "start", (*vli)->getStart());
316 genDateElement(&vEl, "end", (*vli)->getEnd() + 1);
317 genTextAttr(&vEl, "name", (*vli)->getName());
325 XMLReport::generateShiftList(QDomElement* parentNode)
327 QDomElement el = doc->createElement("shiftList");
328 parentNode->appendChild(el);
330 for (ShiftListIterator sli(project->getShiftListIterator());
333 if ((*sli)->getParent() == 0)
334 if (!generateShift(&el, *sli))
342 XMLReport::generateShift(QDomElement* parentEl, const Shift* shift)
344 QDomElement el = doc->createElement("shift");
345 parentEl->appendChild(el);
347 genTextAttr(&el, "id", shift->getId());
348 genTextAttr(&el, "name", shift->getName());
349 generateWorkingHours(&el, shift->getWorkingHours());
351 for (ShiftListIterator sli(shift->getSubListIterator()); *sli; ++sli)
352 if (!generateShift(&el, *sli))
359 XMLReport::generateWorkingHours(QDomElement* parentEl,
360 const QPtrList<Interval>* const* wh)
362 QDomElement el = doc->createElement("workingHours");
363 parentEl->appendChild(el);
365 for (int i = 0; i < 7; ++i)
367 if (wh[i]->isEmpty())
370 QDomElement dayEl = doc->createElement("weekdayWorkingHours");
371 genTextAttr(&dayEl, "weekday", QString().sprintf("%d", i));
372 el.appendChild(dayEl);
373 QPtrListIterator<Interval> it(*wh[i]);
376 QDomElement ivEl = doc->createElement("timeInterval");
377 dayEl.appendChild(ivEl);
378 genTimeElement(&ivEl, "start", (*it)->getStart());
379 genTimeElement(&ivEl, "end", (*it)->getEnd() + 1);
387 XMLReport::generateResourceList(QDomElement* parentNode,
388 ResourceList& filteredResourceList,
389 TaskList& filteredTaskList)
391 QDomElement el = doc->createElement("resourceList");
392 parentNode->appendChild(el);
394 for (ResourceListIterator rli(filteredResourceList); *rli != 0; ++rli)
395 if ((*rli)->getParent() == 0)
396 if (!generateResource(&el, filteredResourceList,
397 filteredTaskList, *rli))
404 XMLReport::generateResource(QDomElement* parentEl,
405 ResourceList& filteredResourceList,
406 TaskList& filteredTaskList,
407 const Resource* resource)
409 QDomElement el = doc->createElement("resource");
410 parentEl->appendChild(el);
412 genTextAttr(&el, "id", resource->getId());
413 genTextAttr(&el, "name", resource->getName());
415 QStringList fl = resource->getFlagList();
416 for (QStringList::Iterator jt = fl.begin(); jt != fl.end(); ++jt)
417 genTextElement(&el, "flag", *jt);
419 for (ResourceListIterator srli(resource->getSubListIterator());
422 if (filteredResourceList.findRef(*srli) >= 0)
424 if (!generateResource(&el, filteredResourceList, filteredTaskList,
430 QPtrListIterator<Interval> vli(resource->getVacationListIterator());
433 QDomElement vlEl = doc->createElement("vacationList");
434 el.appendChild(vlEl);
435 for ( ; *vli != 0; ++vli)
437 QDomElement vEl = doc->createElement("vacation");
438 vlEl.appendChild(vEl);
439 genDateElement(&vEl, "start", (*vli)->getStart());
440 genDateElement(&vEl, "end", (*vli)->getEnd() + 1);
444 generateWorkingHours(&el, resource->getWorkingHours());
445 for (ShiftSelectionList::Iterator sli(*resource->getShiftList()); *sli;
448 QDomElement sSel = doc->createElement("shiftSelection");
449 el.appendChild(sSel);
451 genTextAttr(&sSel, "shiftId", (*sli)->getShift()->getId());
452 genDateElement(&sSel, "start", (*sli)->getPeriod().getStart());
453 genDateElement(&sSel, "end", (*sli)->getPeriod().getEnd() + 1);
460 XMLReport::generateAccountList(QDomElement* parentNode,
461 AccountList& filteredAccountList,
462 TaskList& filteredTaskList)
464 QDomElement el = doc->createElement("accountList");
465 parentNode->appendChild(el);
467 for (AccountListIterator ali(filteredAccountList); *ali != 0; ++ali)
469 if ((*ali)->getParent() == 0)
470 if (!generateAccount(&el, filteredAccountList,
471 filteredTaskList, *ali))
478 XMLReport::generateAccount(QDomElement* parentEl,
479 AccountList& filteredAccountList,
480 TaskList& filteredTaskList,
481 const Account* account)
483 QDomElement el = doc->createElement("account");
484 parentEl->appendChild(el);
486 genTextAttr(&el, "id", account->getId());
487 genTextAttr(&el, "name", account->getName());
489 switch (account->getAcctType())
492 genTextAttr(&el, "type", "cost");
495 genTextAttr(&el, "type", "revenue");
498 qFatal("XMLReport::generateAccount: Unknown AccountType %d",
499 account->getAcctType());
503 for (QStringList::Iterator it = accountAttributes.begin();
504 it != accountAttributes.end(); ++it)
506 if (account->getCustomAttribute(*it))
507 generateCustomAttributeValue(&el, *it, account);
510 for (AccountListIterator srli(account->getSubListIterator());
513 if (filteredAccountList.findRef(*srli) >= 0)
515 if (!generateAccount(&el, filteredAccountList, filteredTaskList,
524 XMLReport::generateTaskList(QDomElement* parentNode, TaskList& filteredTaskList,
527 QDomElement el = doc->createElement("taskList");
528 parentNode->appendChild(el);
530 for (TaskListIterator tli(filteredTaskList); *tli != 0; ++tli)
531 if ((*tli)->getParent() == 0 ||
532 (*tli)->getParent()->getId() + "." == taskRoot)
533 if (!generateTask(&el, filteredTaskList, *tli))
540 XMLReport::generateTask(QDomElement* parentEl, TaskList& filteredTaskList,
543 QDomElement el = doc->createElement("task");
544 parentEl->appendChild(el);
546 QString taskId = task->getId();
547 if (!taskRoot.isEmpty())
548 taskId = stripTaskRoot(taskId);
549 genTextAttr(&el, "id", taskId);
550 genTextAttr(&el, "name", task->getName());
551 genTextAttr(&el, "projectId", task->getProjectId());
553 for (QStringList::Iterator it = taskAttributes.begin();
554 it != taskAttributes.end(); ++it)
556 if (!TaskAttributeDict.contains(*it))
558 if (task->getCustomAttribute(*it))
559 generateCustomAttributeValue(&el, *it, task);
562 switch (TaskAttributeDict[*it])
566 QStringList fl = task->getFlagList();
567 for (QStringList::Iterator jt = fl.begin();
568 jt != fl.end(); ++jt)
570 genTextElement(&el, "flag", *jt);
575 if (!task->getNote().isEmpty())
576 genTextElement(&el, "note", task->getNote());
579 genLongAttr(&el, "priority", task->getPriority());
591 // handled further down as scenario specific value.
594 if (task->getResponsible())
595 genTextAttr(&el, "responsible",
596 task->getResponsible()->getId());
599 generateDepList(&el, filteredTaskList, task,
600 task->getDependsIterator(), true);
601 generateDepList(&el, filteredTaskList, task,
602 task->getPrecedesIterator(), false);
605 if (task->getAccount())
606 genTextAttr(&el, "account",
607 task->getAccount()->getId());
610 qDebug("XMLReport::generateTask(): "
611 "Unknown task attribute %s", (*it).latin1());
617 /* If a container task has sub tasks that are exported as well, we do
618 * not export start/end date for those container tasks. */
619 bool taskHasNoSubTasks = true;
620 for (TaskListIterator stli(task->getSubListIterator());
623 if (filteredTaskList.findRef(*stli) >= 0)
625 taskHasNoSubTasks = false;
626 if (!generateTask(&el, filteredTaskList, *stli))
631 for (QValueListIterator<int> it = scenarios.begin();
632 it != scenarios.end(); ++it)
634 QDomElement scEl = doc->createElement("taskScenario");
635 el.appendChild(scEl);
636 genTextAttr(&scEl, "scenarioId", project->getScenarioId(*it));
638 if (task->getStart(*it))
639 genDateElement(&scEl, "start", task->getStart(*it));
640 if (task->getEnd(*it) && !task->isMilestone())
641 genDateElement(&scEl, "end", task->getEnd(*it) + 1);
642 genLongAttr(&scEl, "criticalpath", task->isOnCriticalPath(*it) ? 1 : 0);
643 genLongAttr(&scEl, "scheduled", task->getScheduled(*it) ? 1 : 0);
645 for (QStringList::Iterator atIt = taskAttributes.begin();
646 atIt != taskAttributes.end(); ++atIt)
648 if (!TaskAttributeDict.contains(*atIt))
650 switch (TaskAttributeDict[*atIt])
653 if (task->getEffort(*it) != 0 &&
654 (task->getStart(*it) == 0 || task->getEnd(*it) == 0))
655 genDoubleAttr(&scEl, "effort", task->getEffort(*it));
658 if (task->getLength(*it) != 0 &&
659 (task->getStart(*it) == 0 || task->getEnd(*it) == 0))
660 genDoubleAttr(&scEl, "length", task->getLength(*it));
663 if (task->getDuration(*it) != 0 &&
664 (task->getStart(*it) == 0 || task->getEnd(*it) == 0))
665 genDoubleAttr(&scEl, "duration",
666 task->getDuration(*it));
669 if (task->getMinStart(*it) != 0)
670 genDateElement(&scEl, "minStart",
671 task->getMinStart(*it));
674 if (task->getMaxStart(*it) != 0)
675 genDateElement(&scEl, "maxStart",
676 task->getMaxStart(*it));
679 if (task->getMinEnd(*it) != 0)
680 genDateElement(&scEl, "minEnd",
681 task->getMinEnd(*it) + 1);
684 if (task->getMaxEnd(*it) != 0)
685 genDateElement(&scEl, "maxEnd",
686 task->getMaxEnd(*it) + 1);
689 genDoubleAttr(&scEl, "complete", task->getComplete(*it));
692 if (task->getStatus(*it) > 0)
693 genLongAttr(&scEl, "status", task->getStatus(*it));
696 if (!task->getStatusNote(*it).isEmpty())
697 genTextElement(&scEl, "statusNote",
698 task->getStatusNote(*it));
704 genLongAttr(&el, "milestone", task->isMilestone() ? 1 : 0);
705 genLongAttr(&el, "asapScheduling",
706 task->getScheduling() == Task::ASAP ? 1 : 0);
708 generateAllocate(&el, task);
714 XMLReport::generateDepList(QDomElement* parentEl, TaskList& filteredTaskList,
716 QPtrListIterator<TaskDependency> depIt,
719 for ( ; *depIt != 0; ++depIt)
721 /* Save current list item since findRef() modifies
722 * it. Remember, we are still iterating the list. */
723 CoreAttributes* curr = filteredTaskList.current();
724 if (filteredTaskList.findRef((*depIt)->getTaskRef()) > -1 &&
725 !(task->getParent() != 0 &&
726 (prev ? task->getParent()->hasPrevious((*depIt)->getTaskRef()) :
727 task->getParent()->hasFollower((*depIt)->getTaskRef()))))
729 QDomElement te= doc->createElement(prev ? "depends" : "precedes");
730 /* Putting the task ID as PCDATA in the depends/precedes element
731 * was a mistake. We now store this information as 'task'
732 * attribute. The PCDATA is now deprecated and should no longer be
733 * used. It will be removed at some point with future versions of
735 te.appendChild(doc->createTextNode
736 (stripTaskRoot(((*depIt)->getTaskRef())->getId())));
737 parentEl->appendChild(te);
739 genTextAttr(&te, "task",
740 stripTaskRoot((*depIt)->getTaskRef()->getId()));
742 for (int sc = 0; sc < project->getMaxScenarios(); ++sc)
743 if ((*depIt)->getGapDuration(sc) != 0 ||
744 (*depIt)->getGapLength(sc) != 0)
746 QDomElement dgs = doc->createElement
747 ("dependencyGapScenario");
749 genTextAttr(&dgs, "scenarioId",
750 project->getScenarioId(sc));
751 if ((*depIt)->getGapDuration(sc) != 0)
752 genLongAttr(&dgs, "gapDuration",
753 (*depIt)->getGapDuration(sc));
754 if ((*depIt)->getGapLength(sc) != 0)
755 genLongAttr(&dgs, "gapLength",
756 (*depIt)->getGapLength(sc));
759 /* Restore current list item to continue
761 filteredTaskList.findRef(curr);
768 XMLReport::generateCustomAttributeValue(QDomElement* parentEl,
770 const CoreAttributes* property)
772 QDomElement el = doc->createElement("customAttribute");
773 parentEl->appendChild(el);
775 genTextAttr(&el, "id", id);
777 const CustomAttribute* ca = property->getCustomAttribute(id);
778 switch (ca->getType())
782 QDomElement cEl = doc->createElement("textAttribute");
785 genTextAttr(&cEl, "text", static_cast<const TextAttribute*>(ca)->getText());
790 QDomElement cEl = doc->createElement("referenceAttribute");
793 const ReferenceAttribute* a =
794 static_cast<const ReferenceAttribute*>(ca);
795 genTextAttr(&cEl, "url", a->getURL());
796 genTextAttr(&cEl, "label", a->getLabel());
801 "generateCustomAttributeValue: "
802 "Unknown CA Type %d",
810 XMLReport::generateAllocate(QDomElement* parentEl, const Task* t)
812 for (QPtrListIterator<Allocation> ai = t->getAllocationIterator();
815 QDomElement el = doc->createElement("allocate");
816 parentEl->appendChild(el);
818 for (QPtrListIterator<Resource> ri = (*ai)->getCandidatesIterator();
821 QDomElement aEl = doc->createElement("candidate");
823 genTextAttr(&aEl, "resourceId", (*ri)->getId());
831 XMLReport::generateBookingList(QDomElement* parentEl,
832 TaskList& filteredTaskList,
833 ResourceList& filteredResourceList)
835 QDomElement el = doc->createElement("bookingList");
836 parentEl->appendChild(el);
838 for (ResourceListIterator rli(filteredResourceList); *rli != 0; ++rli)
840 for (QValueListIterator<int> sit = scenarios.begin();
841 sit != scenarios.end(); ++sit)
843 QDomElement scEl = doc->createElement("resourceBooking");
844 el.appendChild(scEl);
845 genTextAttr(&scEl, "resourceId", (*rli)->getId());
846 genTextAttr(&scEl, "scenarioId", project->getScenarioId(*sit));
848 BookingList bl = (*rli)->getJobs(*sit);
849 bl.setAutoDelete(true);
853 for (BookingList::Iterator bli(bl); *bli != 0; ++bli)
855 if (filteredTaskList.findRef((*bli)->getTask()) >= 0)
857 QDomElement bEl = doc->createElement("booking");
858 scEl.appendChild(bEl);
860 genDateElement(&bEl, "start", (*bli)->getStart());
861 genDateElement(&bEl, "end", (*bli)->getEnd() + 1);
862 genTextAttr(&bEl, "taskId",
863 stripTaskRoot((*bli)->getTask()->getId()));
872 XMLReport::addAccountAttribute(const QString& aa)
876 for (QDictIterator<CustomAttributeDefinition>
877 it(project->getAccountAttributeDict()); *it; ++it)
879 accountAttributes.append(it.currentKey());
885 /* Make sure the 'ta' is a valid attribute name and that we don't
886 * insert it twice into the list. Trying to insert it twice it not an
888 if (project->getAccountAttribute(aa) == 0)
891 if (accountAttributes.findIndex(aa) >= 0)
893 accountAttributes.append(aa);
898 XMLReport::addTaskAttribute(const QString& ta)
902 QMap<QString, int>::ConstIterator it;
903 for (it = TaskAttributeDict.begin(); it != TaskAttributeDict.end();
906 if (taskAttributes.findIndex(it.key()) < 0)
907 taskAttributes.append(it.key());
909 for (QDictIterator<CustomAttributeDefinition>
910 it(project->getTaskAttributeDict()); *it; ++it)
911 taskAttributes.append(it.currentKey());
916 /* Make sure the 'ta' is a valid attribute name and that we don't
917 * insert it twice into the list. Trying to insert it twice it not an
919 if (TaskAttributeDict.find(ta) == TaskAttributeDict.end() &&
920 project->getTaskAttribute(ta) == 0)
923 if (taskAttributes.findIndex(ta) >= 0)
925 taskAttributes.append(ta);
930 XMLReport::genTextAttr(QDomElement* parentEl, const QString& name,
933 QDomAttr at = doc->createAttribute(name);
935 parentEl->setAttributeNode(at);
939 XMLReport::genDoubleAttr(QDomElement* parentEl, const QString& name,
942 QDomAttr at = doc->createAttribute(name);
943 at.setValue(QString::number(val));
944 parentEl->setAttributeNode(at);
948 XMLReport::genLongAttr(QDomElement* parentEl, const QString& name, long val)
950 QDomAttr at = doc->createAttribute(name);
951 at.setValue(QString::number(val));
952 parentEl->setAttributeNode(at);
956 XMLReport::genTextElement(QDomElement* parentEl, const QString& name,
959 QDomElement el = doc->createElement(name);
960 el.appendChild(doc->createTextNode(text));
961 parentEl->appendChild(el);
965 XMLReport::genDateElement(QDomElement* parentEl, const QString& name,
968 QDomElement el = doc->createElement(name);
969 parentEl->appendChild(el);
970 QDomText tEl = doc->createTextNode(QString::number(val));
973 QDomAttr at = doc->createAttribute("humanReadable");
974 at.setValue(time2user(val, timeFormat));
975 el.setAttributeNode(at);
977 parentEl->appendChild(el);
981 XMLReport::genTimeElement(QDomElement* parentEl, const QString& name,
984 QDomElement el = doc->createElement(name);
985 parentEl->appendChild(el);
986 QDomText tEl = doc->createTextNode(QString::number(val));
989 QDomAttr at = doc->createAttribute("humanReadable");
990 at.setValue(time2user(val, shortTimeFormat, false));
991 el.setAttributeNode(at);
993 parentEl->appendChild(el);