20#include "kptcontext.h"
30 : currentEstimateType(0),
37bool Context::load(TQDomElement &element) {
38 currentView = element.attribute(
"current-view");
39 currentEstimateType = element.attribute(
"estimate-type").toInt();
40 currentSchedule = element.attribute(
"current-schedule").toLong();
41 actionViewExpected = element.attribute(
"view-expected").toInt();
42 actionViewOptimistic = element.attribute(
"view-optimistic").toInt();
43 actionViewPessimistic = element.attribute(
"view-pessimistic").toInt();
45 TQDomNodeList list = element.childNodes();
46 for (
unsigned int i=0; i<list.count(); ++i) {
47 if (list.item(i).isElement()) {
48 TQDomElement e = list.item(i).toElement();
49 if (e.tagName() ==
"gantt-view") {
50 ganttview.ganttviewsize = e.attribute(
"ganttview-size").toInt();
51 ganttview.taskviewsize = e.attribute(
"taskview-size").toInt();
52 ganttview.currentNode = e.attribute(
"current-node");
53 ganttview.showResources = e.attribute(
"show-resources").toInt();
54 ganttview.showTaskName = e.attribute(
"show-taskname").toInt();
55 ganttview.showTaskLinks = e.attribute(
"show-tasklinks").toInt();
56 ganttview.showProgress = e.attribute(
"show-progress").toInt();
57 ganttview.showPositiveFloat = e.attribute(
"show-positivefloat").toInt();
58 ganttview.showCriticalTasks = e.attribute(
"show-criticaltasks").toInt();
59 ganttview.showCriticalPath = e.attribute(
"show-criticalpath").toInt();
60 ganttview.showNoInformation = e.attribute(
"show-noinformation").toInt();
62 TQDomNodeList list = e.childNodes();
63 for (
unsigned int i=0; i<list.count(); ++i) {
64 if (list.item(i).isElement()) {
65 TQDomElement g = list.item(i).toElement();
66 if (g.tagName() ==
"closed-nodes") {
67 TQDomNodeList list = g.childNodes();
68 for (
unsigned int i=0; i<list.count(); ++i) {
69 if (list.item(i).isElement()) {
70 TQDomElement ei = list.item(i).toElement();
71 if (ei.tagName() ==
"node") {
72 ganttview.closedNodes.append(ei.attribute(
"id"));
79 }
else if (e.tagName() ==
"accounts-view") {
80 accountsview.accountsviewsize = e.attribute(
"accountsview-size").toInt();
81 accountsview.periodviewsize = e.attribute(
"periodview-size").toInt();
82 accountsview.date = TQDate::fromString(e.attribute(
"date"), TQt::ISODate);
83 accountsview.period = e.attribute(
"period").toInt();
84 accountsview.cumulative = e.attribute(
"cumulative").toInt();
86 TQDomNodeList list = e.childNodes();
87 for (
unsigned int i=0; i<list.count(); ++i) {
88 if (list.item(i).isElement()) {
89 TQDomElement g = list.item(i).toElement();
90 if (g.tagName() ==
"closed-items") {
91 TQDomNodeList list = g.childNodes();
92 for (
unsigned int i=0; i<list.count(); ++i) {
93 if (list.item(i).isElement()) {
94 TQDomElement ei = list.item(i).toElement();
95 if (ei.tagName() ==
"account") {
96 accountsview.closedItems.append(ei.attribute(
"name"));
104 kdError()<<k_funcinfo<<
"Unknown tag: "<<e.tagName()<<endl;
112void Context::save(TQDomElement &element)
const {
113 TQDomElement me = element.ownerDocument().createElement(
"context");
114 element.appendChild(me);
115 me.setAttribute(
"current-view", currentView);
116 me.setAttribute(
"estimate-type", currentEstimateType);
117 me.setAttribute(
"current-schedule", currentSchedule);
118 me.setAttribute(
"view-expected", actionViewExpected);
119 me.setAttribute(
"view-optimistic", actionViewOptimistic);
120 me.setAttribute(
"view-pessimistic", actionViewPessimistic);
122 TQDomElement g = me.ownerDocument().createElement(
"gantt-view");
124 g.setAttribute(
"ganttview-size", ganttview.ganttviewsize);
125 g.setAttribute(
"taskview-size", ganttview.taskviewsize);
126 g.setAttribute(
"current-node", ganttview.currentNode);
127 g.setAttribute(
"show-resources", ganttview.showResources);
128 g.setAttribute(
"show-taskname", ganttview.showTaskName);
129 g.setAttribute(
"show-tasklinks", ganttview.showTaskLinks);
130 g.setAttribute(
"show-progress", ganttview.showProgress);
131 g.setAttribute(
"show-positivefloat", ganttview.showPositiveFloat);
132 g.setAttribute(
"show-criticaltasks", ganttview.showCriticalTasks);
133 g.setAttribute(
"show-criticalpath", ganttview.showCriticalPath);
134 g.setAttribute(
"show-noinformation", ganttview.showNoInformation);
135 if (!ganttview.closedNodes.isEmpty()) {
136 TQDomElement e = g.ownerDocument().createElement(
"closed-nodes");
138 for (TQStringList::ConstIterator it = ganttview.closedNodes.begin(); it != ganttview.closedNodes.end(); ++it) {
139 TQDomElement c = e.ownerDocument().createElement(
"node");
141 c.setAttribute(
"id", (*it));
145 TQDomElement a = me.ownerDocument().createElement(
"accounts-view");
147 a.setAttribute(
"accountsview-size", accountsview.accountsviewsize);
148 a.setAttribute(
"periodview-size", accountsview.periodviewsize);
149 a.setAttribute(
"date", accountsview.date.toString(TQt::ISODate));
150 a.setAttribute(
"period", accountsview.period);
151 a.setAttribute(
"cumulative", accountsview.cumulative);
152 if (!accountsview.closedItems.isEmpty()) {
153 TQDomElement e = a.ownerDocument().createElement(
"closed-items");
155 for (TQStringList::ConstIterator it = accountsview.closedItems.begin(); it != accountsview.closedItems.end(); ++it) {
156 TQDomElement c = e.ownerDocument().createElement(
"account");
158 c.setAttribute(
"name", (*it));