From e9e0e35c1267470954e162da26778a0919d1719c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 12 Nov 2014 20:48:45 +0100 Subject: [PATCH] Fix problems in export engine --- src/model/export/CSVExportEngine.cpp | 6 +++--- src/model/export/ExportEngine.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/model/export/CSVExportEngine.cpp b/src/model/export/CSVExportEngine.cpp index 29293fd..2e197dd 100644 --- a/src/model/export/CSVExportEngine.cpp +++ b/src/model/export/CSVExportEngine.cpp @@ -161,7 +161,7 @@ bool CSVExportEngine::SaveTags() ESCAPE_CHARS(tag.name); *_writer << QString::number(tag.id) << ";"; - *_writer << "\"" << tag.name << "\"" << ";"; + *_writer << "\"" << tag.name << "\""; *_writer << endl; } @@ -196,8 +196,8 @@ bool CSVExportEngine::SaveOperations(std::vector* operations) *_writer << QString::number(it->transfert) << ";"; *_writer << it->formula << ";"; *_writer << (it->meta ? "1" : "0") << ";"; - *_writer << (it->_virtual ? "1" : "0"); - *_writer << QString::number(it->tag) << ";"; + *_writer << (it->_virtual ? "1" : "0") << ";"; + *_writer << QString::number(it->tag); *_writer << endl; } diff --git a/src/model/export/ExportEngine.cpp b/src/model/export/ExportEngine.cpp index 441b056..3773f30 100644 --- a/src/model/export/ExportEngine.cpp +++ b/src/model/export/ExportEngine.cpp @@ -40,7 +40,7 @@ bool ExportEngine::HandleFile(const QString& path, User* user, Database* db, Kis bool ExportEngine::SaveFile(std::vector* operations) { int i; - int account, category; + int account, category, tag; AccountAmount accountAmount; int minMonth = -1, minYear = -1; unsigned int maxMonth = -1, maxYear = -1; @@ -51,12 +51,14 @@ bool ExportEngine::SaveFile(std::vector* operations) _accounts.clear(); _categories.clear(); + _tags.clear(); _accountAmounts.clear(); for(i=0; i<(int)operations->size(); i++) { account = (*operations)[i].account; category = (*operations)[i].category; + tag = (*operations)[i].tag; if (minYear == -1 || (int)(*operations)[i].year < minYear) maxYear = minYear = (*operations)[i].year; @@ -78,7 +80,10 @@ bool ExportEngine::SaveFile(std::vector* operations) if (category && !_categories.count(category)) _categories[category]++; - } + + if (tag && !_tags.count(tag)) + _tags[tag]++; +} for(it=_accounts.begin(); it!=_accounts.end(); it++) {