Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/mymoney/mymoneyreport_p.h
Show All 34 Lines | |||||
35 | // KDE Includes | 35 | // KDE Includes | ||
36 | 36 | | |||
37 | // ---------------------------------------------------------------------------- | 37 | // ---------------------------------------------------------------------------- | ||
38 | // Project Includes | 38 | // Project Includes | ||
39 | 39 | | |||
40 | #include "mymoneyobject_p.h" | 40 | #include "mymoneyobject_p.h" | ||
41 | #include "mymoneyenums.h" | 41 | #include "mymoneyenums.h" | ||
42 | 42 | | |||
43 | namespace Report | | |||
44 | { | | |||
45 | enum class Element { Payee, | | |||
46 | Tag, | | |||
47 | Account, | | |||
48 | Text, | | |||
49 | Type, | | |||
50 | State, | | |||
51 | Number, | | |||
52 | Amount, | | |||
53 | Dates, | | |||
54 | Category, | | |||
55 | AccountGroup | | |||
56 | }; | | |||
57 | uint qHash(const Element key, uint seed) { return ::qHash(static_cast<uint>(key), seed); } | | |||
58 | | ||||
59 | enum class Attribute { ID, Group, Type, Name, Comment, ConvertCurrency, Favorite, | | |||
60 | SkipZero, DateLock, DataLock, MovingAverageDays, | | |||
61 | IncludesActuals, IncludesForecast, IncludesPrice, | | |||
62 | IncludesAveragePrice, IncludesMovingAverage, | | |||
63 | IncludesSchedules, IncludesTransfers, IncludesUnused, | | |||
64 | MixedTime, Investments, Budget, | | |||
65 | ShowRowTotals, ShowColumnTotals, Detail, | | |||
66 | ColumnsAreDays, ChartType, | | |||
67 | ChartCHGridLines, ChartSVGridLines, | | |||
68 | ChartDataLabels, ChartByDefault, | | |||
69 | LogYAxis, ChartLineWidth, ColumnType, RowType, | | |||
70 | DataRangeStart, DataRangeEnd, | | |||
71 | DataMajorTick, DataMinorTick, | | |||
72 | YLabelsPrecision, QueryColumns, | | |||
73 | Tax, Loans, HideTransactions, InvestmentSum, | | |||
74 | SettlementPeriod, ShowSTLTCapitalGains, TermsSeparator, | | |||
75 | Pattern, CaseSensitive, RegEx, InvertText, State, | | |||
76 | From, To, | | |||
77 | // insert new entries above this line | | |||
78 | LastAttribute | | |||
79 | }; | | |||
80 | uint qHash(const Attribute key, uint seed) { return ::qHash(static_cast<uint>(key), seed); } | | |||
81 | } | | |||
82 | | ||||
83 | class MyMoneyReportPrivate : public MyMoneyObjectPrivate | 43 | class MyMoneyReportPrivate : public MyMoneyObjectPrivate | ||
84 | { | 44 | { | ||
85 | public: | 45 | public: | ||
86 | MyMoneyReportPrivate() : | 46 | MyMoneyReportPrivate() : | ||
87 | m_name(QStringLiteral("Unconfigured Pivot Table Report")), | 47 | m_name(QStringLiteral("Unconfigured Pivot Table Report")), | ||
88 | m_detailLevel(eMyMoney::Report::DetailLevel::None), | 48 | m_detailLevel(eMyMoney::Report::DetailLevel::None), | ||
89 | m_investmentSum(eMyMoney::Report::InvestmentSum::Sold), | 49 | m_investmentSum(eMyMoney::Report::InvestmentSum::Sold), | ||
90 | m_hideTransactions(false), | 50 | m_hideTransactions(false), | ||
Show All 37 Lines | |||||
128 | m_currentDateColumn(0), | 88 | m_currentDateColumn(0), | ||
129 | m_settlementPeriod(3), | 89 | m_settlementPeriod(3), | ||
130 | m_showSTLTCapitalGains(false), | 90 | m_showSTLTCapitalGains(false), | ||
131 | m_tseparator(QDate::currentDate().addYears(-1)), | 91 | m_tseparator(QDate::currentDate().addYears(-1)), | ||
132 | m_skipZero(false) | 92 | m_skipZero(false) | ||
133 | { | 93 | { | ||
134 | } | 94 | } | ||
135 | 95 | | |||
136 | static QString getElName(const Report::Element el) | | |||
137 | { | | |||
138 | static const QHash<Report::Element, QString> elNames { | | |||
139 | {Report::Element::Payee, QStringLiteral("PAYEE")}, | | |||
140 | {Report::Element::Tag, QStringLiteral("TAG")}, | | |||
141 | {Report::Element::Account, QStringLiteral("ACCOUNT")}, | | |||
142 | {Report::Element::Text, QStringLiteral("TEXT")}, | | |||
143 | {Report::Element::Type, QStringLiteral("TYPE")}, | | |||
144 | {Report::Element::State, QStringLiteral("STATE")}, | | |||
145 | {Report::Element::Number, QStringLiteral("NUMBER")}, | | |||
146 | {Report::Element::Amount, QStringLiteral("AMOUNT")}, | | |||
147 | {Report::Element::Dates, QStringLiteral("DATES")}, | | |||
148 | {Report::Element::Category, QStringLiteral("CATEGORY")}, | | |||
149 | {Report::Element::AccountGroup, QStringLiteral("ACCOUNTGROUP")} | | |||
150 | }; | | |||
151 | return elNames[el]; | | |||
152 | } | | |||
153 | | ||||
154 | static QString getAttrName(const Report::Attribute attr) | | |||
155 | { | | |||
156 | static const QHash<Report::Attribute, QString> attrNames { | | |||
157 | {Report::Attribute::ID, QStringLiteral("id")}, | | |||
158 | {Report::Attribute::Group, QStringLiteral("group")}, | | |||
159 | {Report::Attribute::Type, QStringLiteral("type")}, | | |||
160 | {Report::Attribute::Name, QStringLiteral("name")}, | | |||
161 | {Report::Attribute::Comment, QStringLiteral("comment")}, | | |||
162 | {Report::Attribute::ConvertCurrency, QStringLiteral("convertcurrency")}, | | |||
163 | {Report::Attribute::Favorite, QStringLiteral("favorite")}, | | |||
164 | {Report::Attribute::SkipZero, QStringLiteral("skipZero")}, | | |||
165 | {Report::Attribute::DateLock, QStringLiteral("datelock")}, | | |||
166 | {Report::Attribute::DataLock, QStringLiteral("datalock")}, | | |||
167 | {Report::Attribute::MovingAverageDays, QStringLiteral("movingaveragedays")}, | | |||
168 | {Report::Attribute::IncludesActuals, QStringLiteral("includesactuals")}, | | |||
169 | {Report::Attribute::IncludesForecast, QStringLiteral("includesforecast")}, | | |||
170 | {Report::Attribute::IncludesPrice, QStringLiteral("includesprice")}, | | |||
171 | {Report::Attribute::IncludesAveragePrice, QStringLiteral("includesaverageprice")}, | | |||
172 | {Report::Attribute::IncludesMovingAverage, QStringLiteral("includesmovingaverage")}, | | |||
173 | {Report::Attribute::IncludesSchedules, QStringLiteral("includeschedules")}, | | |||
174 | {Report::Attribute::IncludesTransfers, QStringLiteral("includestransfers")}, | | |||
175 | {Report::Attribute::IncludesUnused, QStringLiteral("includeunused")}, | | |||
176 | {Report::Attribute::MixedTime, QStringLiteral("mixedtime")}, | | |||
177 | {Report::Attribute::Investments, QStringLiteral("investments")}, | | |||
178 | {Report::Attribute::Budget, QStringLiteral("budget")}, | | |||
179 | {Report::Attribute::ShowRowTotals, QStringLiteral("showrowtotals")}, | | |||
180 | {Report::Attribute::ShowColumnTotals, QStringLiteral("showcolumntotals")}, | | |||
181 | {Report::Attribute::Detail, QStringLiteral("detail")}, | | |||
182 | {Report::Attribute::ColumnsAreDays, QStringLiteral("columnsaredays")}, | | |||
183 | {Report::Attribute::ChartType, QStringLiteral("charttype")}, | | |||
184 | {Report::Attribute::ChartCHGridLines, QStringLiteral("chartchgridlines")}, | | |||
185 | {Report::Attribute::ChartSVGridLines, QStringLiteral("chartsvgridlines")}, | | |||
186 | {Report::Attribute::ChartDataLabels, QStringLiteral("chartdatalabels")}, | | |||
187 | {Report::Attribute::ChartByDefault, QStringLiteral("chartbydefault")}, | | |||
188 | {Report::Attribute::LogYAxis, QStringLiteral("logYaxis")}, | | |||
189 | {Report::Attribute::ChartLineWidth, QStringLiteral("chartlinewidth")}, | | |||
190 | {Report::Attribute::ColumnType, QStringLiteral("columntype")}, | | |||
191 | {Report::Attribute::RowType, QStringLiteral("rowtype")}, | | |||
192 | {Report::Attribute::DataRangeStart, QStringLiteral("dataRangeStart")}, | | |||
193 | {Report::Attribute::DataRangeEnd, QStringLiteral("dataRangeEnd")}, | | |||
194 | {Report::Attribute::DataMajorTick, QStringLiteral("dataMajorTick")}, | | |||
195 | {Report::Attribute::DataMinorTick, QStringLiteral("dataMinorTick")}, | | |||
196 | {Report::Attribute::YLabelsPrecision, QStringLiteral("yLabelsPrecision")}, | | |||
197 | {Report::Attribute::QueryColumns, QStringLiteral("querycolumns")}, | | |||
198 | {Report::Attribute::Tax, QStringLiteral("tax")}, | | |||
199 | {Report::Attribute::Loans, QStringLiteral("loans")}, | | |||
200 | {Report::Attribute::HideTransactions, QStringLiteral("hidetransactions")}, | | |||
201 | {Report::Attribute::InvestmentSum, QStringLiteral("investmentsum")}, | | |||
202 | {Report::Attribute::SettlementPeriod, QStringLiteral("settlementperiod")}, | | |||
203 | {Report::Attribute::ShowSTLTCapitalGains, QStringLiteral("showSTLTCapitalGains")}, | | |||
204 | {Report::Attribute::TermsSeparator, QStringLiteral("tseparator")}, | | |||
205 | {Report::Attribute::Pattern, QStringLiteral("pattern")}, | | |||
206 | {Report::Attribute::CaseSensitive, QStringLiteral("casesensitive")}, | | |||
207 | {Report::Attribute::RegEx, QStringLiteral("regex")}, | | |||
208 | {Report::Attribute::InvertText, QStringLiteral("inverttext")}, | | |||
209 | {Report::Attribute::State, QStringLiteral("state")}, | | |||
210 | {Report::Attribute::From, QStringLiteral("from")}, | | |||
211 | {Report::Attribute::To, QStringLiteral("to")} | | |||
212 | }; | | |||
213 | return attrNames[attr]; | | |||
214 | } | | |||
215 | | ||||
216 | static QHash<eMyMoney::Report::RowType, QString> rowTypesLUT() | | |||
217 | { | | |||
218 | static const QHash<eMyMoney::Report::RowType, QString> lut { | | |||
219 | {eMyMoney::Report::RowType::NoRows, QStringLiteral("none")}, | | |||
220 | {eMyMoney::Report::RowType::AssetLiability, QStringLiteral("assetliability")}, | | |||
221 | {eMyMoney::Report::RowType::ExpenseIncome, QStringLiteral("expenseincome")}, | | |||
222 | {eMyMoney::Report::RowType::Category, QStringLiteral("category")}, | | |||
223 | {eMyMoney::Report::RowType::TopCategory, QStringLiteral("topcategory")}, | | |||
224 | {eMyMoney::Report::RowType::Account, QStringLiteral("account")}, | | |||
225 | {eMyMoney::Report::RowType::Tag, QStringLiteral("tag")}, | | |||
226 | {eMyMoney::Report::RowType::Payee, QStringLiteral("payee")}, | | |||
227 | {eMyMoney::Report::RowType::Month, QStringLiteral("month")}, | | |||
228 | {eMyMoney::Report::RowType::Week, QStringLiteral("week")}, | | |||
229 | {eMyMoney::Report::RowType::TopAccount, QStringLiteral("topaccount")}, | | |||
230 | {eMyMoney::Report::RowType::AccountByTopAccount, QStringLiteral("topaccount-account")}, | | |||
231 | {eMyMoney::Report::RowType::EquityType, QStringLiteral("equitytype")}, | | |||
232 | {eMyMoney::Report::RowType::AccountType, QStringLiteral("accounttype")}, | | |||
233 | {eMyMoney::Report::RowType::Institution, QStringLiteral("institution")}, | | |||
234 | {eMyMoney::Report::RowType::Budget, QStringLiteral("budget")}, | | |||
235 | {eMyMoney::Report::RowType::BudgetActual, QStringLiteral("budgetactual")}, | | |||
236 | {eMyMoney::Report::RowType::Schedule, QStringLiteral("schedule")}, | | |||
237 | {eMyMoney::Report::RowType::AccountInfo, QStringLiteral("accountinfo")}, | | |||
238 | {eMyMoney::Report::RowType::AccountLoanInfo, QStringLiteral("accountloaninfo")}, | | |||
239 | {eMyMoney::Report::RowType::AccountReconcile, QStringLiteral("accountreconcile")}, | | |||
240 | {eMyMoney::Report::RowType::CashFlow, QStringLiteral("cashflow")}, | | |||
241 | }; | | |||
242 | return lut; | | |||
243 | } | | |||
244 | | ||||
245 | static QString reportNames(eMyMoney::Report::RowType textID) | | |||
246 | { | | |||
247 | return rowTypesLUT().value(textID); | | |||
248 | } | | |||
249 | | ||||
250 | static eMyMoney::Report::RowType stringToRowType(const QString &text) | | |||
251 | { | | |||
252 | return rowTypesLUT().key(text, eMyMoney::Report::RowType::Invalid); | | |||
253 | } | | |||
254 | | ||||
255 | static QHash<eMyMoney::Report::ColumnType, QString> columTypesLUT() | | |||
256 | { | | |||
257 | static const QHash<eMyMoney::Report::ColumnType, QString> lut { | | |||
258 | {eMyMoney::Report::ColumnType::NoColumns, QStringLiteral("none")}, | | |||
259 | {eMyMoney::Report::ColumnType::Months, QStringLiteral("months")}, | | |||
260 | {eMyMoney::Report::ColumnType::BiMonths, QStringLiteral("bimonths")}, | | |||
261 | {eMyMoney::Report::ColumnType::Quarters, QStringLiteral("quarters")}, | | |||
262 | // {eMyMoney::Report::ColumnType::, QStringLiteral("4")} | | |||
263 | // {eMyMoney::Report::ColumnType::, QStringLiteral("5")} | | |||
264 | // {eMyMoney::Report::ColumnType::, QStringLiteral("6")} | | |||
265 | {eMyMoney::Report::ColumnType::Weeks, QStringLiteral("weeks")}, | | |||
266 | // {eMyMoney::Report::ColumnType::, QStringLiteral("8")} | | |||
267 | // {eMyMoney::Report::ColumnType::, QStringLiteral("9")} | | |||
268 | // {eMyMoney::Report::ColumnType::, QStringLiteral("10")} | | |||
269 | // {eMyMoney::Report::ColumnType::, QStringLiteral("11")} | | |||
270 | {eMyMoney::Report::ColumnType::Years, QStringLiteral("years")} | | |||
271 | }; | | |||
272 | return lut; | | |||
273 | } | | |||
274 | | ||||
275 | static QString reportNames(eMyMoney::Report::ColumnType textID) | | |||
276 | { | | |||
277 | return columTypesLUT().value(textID); | | |||
278 | } | | |||
279 | | ||||
280 | static eMyMoney::Report::ColumnType stringToColumnType(const QString &text) | | |||
281 | { | | |||
282 | return columTypesLUT().key(text, eMyMoney::Report::ColumnType::Invalid); | | |||
283 | } | | |||
284 | | ||||
285 | static QHash<eMyMoney::Report::QueryColumn, QString> queryColumnsLUT() | | |||
286 | { | | |||
287 | static const QHash<eMyMoney::Report::QueryColumn, QString> lut { | | |||
288 | {eMyMoney::Report::QueryColumn::None, QStringLiteral("none")}, | | |||
289 | {eMyMoney::Report::QueryColumn::Number, QStringLiteral("number")}, | | |||
290 | {eMyMoney::Report::QueryColumn::Payee, QStringLiteral("payee")}, | | |||
291 | {eMyMoney::Report::QueryColumn::Category, QStringLiteral("category")}, | | |||
292 | {eMyMoney::Report::QueryColumn::Tag, QStringLiteral("tag")}, | | |||
293 | {eMyMoney::Report::QueryColumn::Memo, QStringLiteral("memo")}, | | |||
294 | {eMyMoney::Report::QueryColumn::Account, QStringLiteral("account")}, | | |||
295 | {eMyMoney::Report::QueryColumn::Reconciled, QStringLiteral("reconcileflag")}, | | |||
296 | {eMyMoney::Report::QueryColumn::Action, QStringLiteral("action")}, | | |||
297 | {eMyMoney::Report::QueryColumn::Shares, QStringLiteral("shares")}, | | |||
298 | {eMyMoney::Report::QueryColumn::Price, QStringLiteral("price")}, | | |||
299 | {eMyMoney::Report::QueryColumn::Performance, QStringLiteral("performance")}, | | |||
300 | {eMyMoney::Report::QueryColumn::Loan, QStringLiteral("loan")}, | | |||
301 | {eMyMoney::Report::QueryColumn::Balance, QStringLiteral("balance")}, | | |||
302 | {eMyMoney::Report::QueryColumn::CapitalGain, QStringLiteral("capitalgain")} | | |||
303 | }; | | |||
304 | return lut; | | |||
305 | } | | |||
306 | | ||||
307 | static QString reportNamesForQC(eMyMoney::Report::QueryColumn textID) | | |||
308 | { | | |||
309 | return queryColumnsLUT().value(textID); | | |||
310 | } | | |||
311 | | ||||
312 | static eMyMoney::Report::QueryColumn stringToQueryColumn(const QString &text) | | |||
313 | { | | |||
314 | return queryColumnsLUT().key(text, eMyMoney::Report::QueryColumn::End); | | |||
315 | } | | |||
316 | | ||||
317 | static QHash<eMyMoney::Report::DetailLevel, QString> detailLevelLUT() | | |||
318 | { | | |||
319 | static const QHash<eMyMoney::Report::DetailLevel, QString> lut { | | |||
320 | {eMyMoney::Report::DetailLevel::None, QStringLiteral("none")}, | | |||
321 | {eMyMoney::Report::DetailLevel::All, QStringLiteral("all")}, | | |||
322 | {eMyMoney::Report::DetailLevel::Top, QStringLiteral("top")}, | | |||
323 | {eMyMoney::Report::DetailLevel::Group, QStringLiteral("group")}, | | |||
324 | {eMyMoney::Report::DetailLevel::Total, QStringLiteral("total")}, | | |||
325 | {eMyMoney::Report::DetailLevel::End, QStringLiteral("invalid")} | | |||
326 | }; | | |||
327 | return lut; | | |||
328 | } | | |||
329 | | ||||
330 | static QString reportNames(eMyMoney::Report::DetailLevel textID) | | |||
331 | { | | |||
332 | return detailLevelLUT().value(textID); | | |||
333 | } | | |||
334 | | ||||
335 | static eMyMoney::Report::DetailLevel stringToDetailLevel(const QString &text) | | |||
336 | { | | |||
337 | return detailLevelLUT().key(text, eMyMoney::Report::DetailLevel::End); | | |||
338 | } | | |||
339 | | ||||
340 | static QHash<eMyMoney::Report::ChartType, QString> chartTypeLUT() | | |||
341 | { | | |||
342 | static const QHash<eMyMoney::Report::ChartType, QString> lut { | | |||
343 | {eMyMoney::Report::ChartType::None, QStringLiteral("none")}, | | |||
344 | {eMyMoney::Report::ChartType::Line, QStringLiteral("line")}, | | |||
345 | {eMyMoney::Report::ChartType::Bar, QStringLiteral("bar")}, | | |||
346 | {eMyMoney::Report::ChartType::Pie, QStringLiteral("pie")}, | | |||
347 | {eMyMoney::Report::ChartType::Ring, QStringLiteral("ring")}, | | |||
348 | {eMyMoney::Report::ChartType::StackedBar, QStringLiteral("stackedbar")} | | |||
349 | }; | | |||
350 | return lut; | | |||
351 | } | | |||
352 | | ||||
353 | static QString reportNames(eMyMoney::Report::ChartType textID) | | |||
354 | { | | |||
355 | return chartTypeLUT().value(textID); | | |||
356 | } | | |||
357 | | ||||
358 | static eMyMoney::Report::ChartType stringToChartType(const QString &text) | | |||
359 | { | | |||
360 | return chartTypeLUT().key(text, eMyMoney::Report::ChartType::End); | | |||
361 | } | | |||
362 | | ||||
363 | static QHash<int, QString> typeAttributeLUT() | | |||
364 | { | | |||
365 | static const QHash<int, QString> lut { | | |||
366 | {0, QStringLiteral("all")}, | | |||
367 | {1, QStringLiteral("payments")}, | | |||
368 | {2, QStringLiteral("deposits")}, | | |||
369 | {3, QStringLiteral("transfers")}, | | |||
370 | {4, QStringLiteral("none")}, | | |||
371 | }; | | |||
372 | return lut; | | |||
373 | } | | |||
374 | | ||||
375 | static QString typeAttributeToString(int textID) | | |||
376 | { | | |||
377 | return typeAttributeLUT().value(textID); | | |||
378 | } | | |||
379 | | ||||
380 | static int stringToTypeAttribute(const QString &text) | | |||
381 | { | | |||
382 | return typeAttributeLUT().key(text, 4); | | |||
383 | } | | |||
384 | | ||||
385 | static QHash<int, QString> stateAttributeLUT() | | |||
386 | { | | |||
387 | static const QHash<int, QString> lut { | | |||
388 | {0, QStringLiteral("all")}, | | |||
389 | {1, QStringLiteral("notreconciled")}, | | |||
390 | {2, QStringLiteral("cleared")}, | | |||
391 | {3, QStringLiteral("reconciled")}, | | |||
392 | {4, QStringLiteral("frozen")}, | | |||
393 | {5, QStringLiteral("none")} | | |||
394 | }; | | |||
395 | return lut; | | |||
396 | } | | |||
397 | | ||||
398 | static QString stateAttributeToString(int textID) | | |||
399 | { | | |||
400 | return stateAttributeLUT().value(textID); | | |||
401 | } | | |||
402 | | ||||
403 | static int stringToStateAttribute(const QString &text) | | |||
404 | { | | |||
405 | return stateAttributeLUT().key(text, 5); | | |||
406 | } | | |||
407 | | ||||
408 | static QHash<int, QString> dateLockLUT() | | |||
409 | { | | |||
410 | static const QHash<int, QString> lut { | | |||
411 | {0, QStringLiteral("alldates")}, | | |||
412 | {1, QStringLiteral("untiltoday")}, | | |||
413 | {2, QStringLiteral("currentmonth")}, | | |||
414 | {3, QStringLiteral("currentyear")}, | | |||
415 | {4, QStringLiteral("monthtodate")}, | | |||
416 | {5, QStringLiteral("yeartodate")}, | | |||
417 | {6, QStringLiteral("yeartomonth")}, | | |||
418 | {7, QStringLiteral("lastmonth")}, | | |||
419 | {8, QStringLiteral("lastyear")}, | | |||
420 | {9, QStringLiteral("last7days")}, | | |||
421 | {10, QStringLiteral("last30days")}, | | |||
422 | {11, QStringLiteral("last3months")}, | | |||
423 | {12, QStringLiteral("last6months")}, | | |||
424 | {13, QStringLiteral("last12months")}, | | |||
425 | {14, QStringLiteral("next7days")}, | | |||
426 | {15, QStringLiteral("next30days")}, | | |||
427 | {16, QStringLiteral("next3months")}, | | |||
428 | {17, QStringLiteral("next6months")}, | | |||
429 | {18, QStringLiteral("next12months")}, | | |||
430 | {19, QStringLiteral("userdefined")}, | | |||
431 | {20, QStringLiteral("last3tonext3months")}, | | |||
432 | {21, QStringLiteral("last11Months")}, | | |||
433 | {22, QStringLiteral("currentQuarter")}, | | |||
434 | {23, QStringLiteral("lastQuarter")}, | | |||
435 | {24, QStringLiteral("nextQuarter")}, | | |||
436 | {25, QStringLiteral("currentFiscalYear")}, | | |||
437 | {26, QStringLiteral("lastFiscalYear")}, | | |||
438 | {27, QStringLiteral("today")}, | | |||
439 | {28, QStringLiteral("next18months")} | | |||
440 | }; | | |||
441 | return lut; | | |||
442 | } | | |||
443 | | ||||
444 | static QString dateLockAttributeToString(int textID) | | |||
445 | { | | |||
446 | return dateLockLUT().value(textID); | | |||
447 | } | | |||
448 | | ||||
449 | static int stringToDateLockAttribute(const QString &text) | | |||
450 | { | | |||
451 | return dateLockLUT().key(text, 0); | | |||
452 | } | | |||
453 | | ||||
454 | static QHash<eMyMoney::Report::DataLock, QString> dataLockLUT() | | |||
455 | { | | |||
456 | static const QHash<eMyMoney::Report::DataLock, QString> lut { | | |||
457 | {eMyMoney::Report::DataLock::Automatic, QStringLiteral("automatic")}, | | |||
458 | {eMyMoney::Report::DataLock::UserDefined, QStringLiteral("userdefined")} | | |||
459 | }; | | |||
460 | return lut; | | |||
461 | } | | |||
462 | | ||||
463 | static QString reportNames(eMyMoney::Report::DataLock textID) | | |||
464 | { | | |||
465 | return dataLockLUT().value(textID); | | |||
466 | } | | |||
467 | | ||||
468 | static eMyMoney::Report::DataLock stringToDataLockAttribute(const QString &text) | | |||
469 | { | | |||
470 | return dataLockLUT().key(text, eMyMoney::Report::DataLock::DataOptionCount); | | |||
471 | } | | |||
472 | | ||||
473 | static QHash<int, QString> accountTypeAttributeLUT() | | |||
474 | { | | |||
475 | static const QHash<int, QString> lut { | | |||
476 | {0, QStringLiteral("unknown")}, | | |||
477 | {1, QStringLiteral("checkings")}, | | |||
478 | {2, QStringLiteral("savings")}, | | |||
479 | {3, QStringLiteral("cash")}, | | |||
480 | {4, QStringLiteral("creditcard")}, | | |||
481 | {5, QStringLiteral("loan")}, | | |||
482 | {6, QStringLiteral("certificatedep")}, | | |||
483 | {7, QStringLiteral("investment")}, | | |||
484 | {8, QStringLiteral("moneymarket")}, | | |||
485 | {10, QStringLiteral("asset")}, | | |||
486 | {11, QStringLiteral("liability")}, | | |||
487 | {12, QStringLiteral("currency")}, | | |||
488 | {13, QStringLiteral("income")}, | | |||
489 | {14, QStringLiteral("expense")}, | | |||
490 | {15, QStringLiteral("assetloan")}, | | |||
491 | {16, QStringLiteral("stock")}, | | |||
492 | {17, QStringLiteral("equity")}, | | |||
493 | {18, QStringLiteral("invalid")} | | |||
494 | }; | | |||
495 | return lut; | | |||
496 | } | | |||
497 | | ||||
498 | static QString accountTypeAttributeToString(int textID) | | |||
499 | { | | |||
500 | return accountTypeAttributeLUT().value(textID); | | |||
501 | } | | |||
502 | | ||||
503 | static int stringToAccountTypeAttribute(const QString &text) | | |||
504 | { | | |||
505 | return accountTypeAttributeLUT().key(text, 0); | | |||
506 | } | | |||
507 | | ||||
508 | static eMyMoney::Report::ReportType rowTypeToReportType(eMyMoney::Report::RowType rowType) | 96 | static eMyMoney::Report::ReportType rowTypeToReportType(eMyMoney::Report::RowType rowType) | ||
509 | { | 97 | { | ||
510 | static const QHash<eMyMoney::Report::RowType, eMyMoney::Report::ReportType> reportTypes { | 98 | static const QHash<eMyMoney::Report::RowType, eMyMoney::Report::ReportType> reportTypes { | ||
511 | {eMyMoney::Report::RowType::NoRows, eMyMoney::Report::ReportType::NoReport}, | 99 | {eMyMoney::Report::RowType::NoRows, eMyMoney::Report::ReportType::NoReport}, | ||
512 | {eMyMoney::Report::RowType::AssetLiability, eMyMoney::Report::ReportType::PivotTable}, | 100 | {eMyMoney::Report::RowType::AssetLiability, eMyMoney::Report::ReportType::PivotTable}, | ||
513 | {eMyMoney::Report::RowType::ExpenseIncome, eMyMoney::Report::ReportType::PivotTable}, | 101 | {eMyMoney::Report::RowType::ExpenseIncome, eMyMoney::Report::ReportType::PivotTable}, | ||
514 | {eMyMoney::Report::RowType::Category, eMyMoney::Report::ReportType::QueryTable}, | 102 | {eMyMoney::Report::RowType::Category, eMyMoney::Report::ReportType::QueryTable}, | ||
515 | {eMyMoney::Report::RowType::TopCategory, eMyMoney::Report::ReportType::QueryTable}, | 103 | {eMyMoney::Report::RowType::TopCategory, eMyMoney::Report::ReportType::QueryTable}, | ||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |