Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/plugins/views/reports/core/pivotgrid.cpp
Show All 14 Lines | |||||
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include <pivotgrid.h> | 19 | #include <pivotgrid.h> | ||
20 | 20 | | |||
21 | // ---------------------------------------------------------------------------- | 21 | // ---------------------------------------------------------------------------- | ||
22 | // QT Includes | 22 | // QT Includes | ||
23 | #include <QDomDocument> | ||||
24 | #include <QDomElement> | ||||
25 | #include <QFile> | ||||
26 | #include <QtDebug> | ||||
23 | 27 | | |||
24 | // ---------------------------------------------------------------------------- | 28 | // ---------------------------------------------------------------------------- | ||
25 | // KDE Includes | 29 | // KDE Includes | ||
26 | 30 | | |||
27 | // ---------------------------------------------------------------------------- | 31 | // ---------------------------------------------------------------------------- | ||
28 | // Project Includes | 32 | // Project Includes | ||
29 | 33 | | |||
30 | namespace reports | 34 | namespace reports | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 108 | { | |||
105 | insert(eActual, PivotGridRow(_numcolumns)); | 109 | insert(eActual, PivotGridRow(_numcolumns)); | ||
106 | insert(eBudget, PivotGridRow(_numcolumns)); | 110 | insert(eBudget, PivotGridRow(_numcolumns)); | ||
107 | insert(eBudgetDiff, PivotGridRow(_numcolumns)); | 111 | insert(eBudgetDiff, PivotGridRow(_numcolumns)); | ||
108 | insert(eForecast, PivotGridRow(_numcolumns)); | 112 | insert(eForecast, PivotGridRow(_numcolumns)); | ||
109 | insert(eAverage, PivotGridRow(_numcolumns)); | 113 | insert(eAverage, PivotGridRow(_numcolumns)); | ||
110 | insert(ePrice, PivotGridRow(_numcolumns)); | 114 | insert(ePrice, PivotGridRow(_numcolumns)); | ||
111 | } | 115 | } | ||
112 | 116 | | |||
117 | bool PivotGridRowSet::saveToXml(QDomDocument &doc, QDomElement &el) | ||||
118 | { | ||||
119 | foreach(ERowType type, keys()) { | ||||
120 | (*this)[type].saveToXml(doc, el); | ||||
121 | } | ||||
122 | return true; | ||||
123 | } | ||||
124 | | ||||
113 | PivotGridRowSet PivotGrid::rowSet(QString id) | 125 | PivotGridRowSet PivotGrid::rowSet(QString id) | ||
114 | { | 126 | { | ||
115 | 127 | | |||
116 | //go through the data and get the row that matches the id | 128 | //go through the data and get the row that matches the id | ||
117 | PivotGrid::iterator it_outergroup = begin(); | 129 | PivotGrid::iterator it_outergroup = begin(); | ||
118 | while (it_outergroup != end()) { | 130 | while (it_outergroup != end()) { | ||
119 | PivotOuterGroup::iterator it_innergroup = (*it_outergroup).begin(); | 131 | PivotOuterGroup::iterator it_innergroup = (*it_outergroup).begin(); | ||
120 | while (it_innergroup != (*it_outergroup).end()) { | 132 | while (it_innergroup != (*it_outergroup).end()) { | ||
121 | PivotInnerGroup::iterator it_row = (*it_innergroup).begin(); | 133 | PivotInnerGroup::iterator it_row = (*it_innergroup).begin(); | ||
122 | while (it_row != (*it_innergroup).end()) { | 134 | while (it_row != (*it_innergroup).end()) { | ||
123 | if (it_row.key().id() == id) | 135 | if (it_row.key().id() == id) | ||
124 | return it_row.value(); | 136 | return it_row.value(); | ||
125 | 137 | | |||
126 | ++it_row; | 138 | ++it_row; | ||
127 | } | 139 | } | ||
128 | ++it_innergroup; | 140 | ++it_innergroup; | ||
129 | } | 141 | } | ||
130 | ++it_outergroup; | 142 | ++it_outergroup; | ||
131 | } | 143 | } | ||
132 | return PivotGridRowSet(); | 144 | return PivotGridRowSet(); | ||
133 | } | 145 | } | ||
134 | 146 | | |||
147 | bool PivotGrid::saveToXml(QDomDocument &doc, QDomElement &parent) | ||||
148 | { | ||||
149 | QDomElement el = doc.createElement("PivotGrid"); | ||||
150 | for(PivotGrid::iterator it_outergroup = begin(); it_outergroup != end(); it_outergroup++) { | ||||
151 | QDomElement pog = doc.createElement("PivotOuterGroup"); | ||||
152 | for(PivotOuterGroup::iterator it_innergroup = (*it_outergroup).begin(); it_innergroup != (*it_outergroup).end(); it_innergroup++) { | ||||
153 | QDomElement pig = doc.createElement("PivotInnerGroup"); | ||||
154 | for(PivotInnerGroup::iterator it_row = (*it_innergroup).begin(); it_row != (*it_innergroup).end(); it_row++) { | ||||
155 | pig.setAttribute("account", it_row.key().id()); | ||||
156 | it_row.value().saveToXml(doc, pig); | ||||
157 | } | ||||
158 | pog.appendChild(pig); | ||||
159 | } | ||||
160 | el.appendChild(pog); | ||||
161 | } | ||||
162 | parent.appendChild(el); | ||||
163 | | ||||
164 | return true; | ||||
165 | } | ||||
166 | | ||||
167 | bool PivotGrid::loadFromXml(QDomDocument &doc, QDomElement &parent) | ||||
168 | { | ||||
169 | Q_UNUSED(doc); | ||||
170 | Q_UNUSED(parent); | ||||
171 | return false; | ||||
172 | } | ||||
173 | | ||||
174 | bool PivotInnerGroup::saveToXml(QDomDocument &doc, QDomElement &parent) | ||||
175 | { | ||||
176 | Q_UNUSED(doc); | ||||
177 | Q_UNUSED(parent); | ||||
178 | return true; | ||||
179 | } | ||||
180 | | ||||
181 | bool PivotGridRow::saveToXml(QDomDocument &doc, QDomElement &parent) | ||||
182 | { | ||||
183 | for(int i=0; i < size(); i++) { | ||||
184 | const PivotCell &cell = at(i); | ||||
185 | QDomElement el = doc.createElement("PivotCell"); | ||||
186 | el.setAttribute("value", cell.toDouble()); | ||||
187 | parent.appendChild(el); | ||||
188 | } | ||||
189 | return true; | ||||
190 | } | ||||
191 | | ||||
135 | } // namespace | 192 | } // namespace |