Tag management : first version
This commit is contained in:
@@ -145,13 +145,38 @@ bool CSVExportEngine::SaveCategories()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSVExportEngine::SaveTags()
|
||||
{
|
||||
Tag tag;
|
||||
std::map<int, int>::iterator it;
|
||||
QString v;
|
||||
|
||||
*_writer << "Tags" << endl << endl;
|
||||
*_writer << "id;name" << endl;
|
||||
|
||||
for(it=_tags.begin(); it!=_tags.end(); it++)
|
||||
{
|
||||
tag = _user->GetTag(it->first);
|
||||
|
||||
ESCAPE_CHARS(tag.name);
|
||||
|
||||
*_writer << QString::number(tag.id) << ";";
|
||||
*_writer << "\"" << tag.name << "\"" << ";";
|
||||
*_writer << endl;
|
||||
}
|
||||
|
||||
*_writer << endl << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSVExportEngine::SaveOperations(std::vector<Operation>* operations)
|
||||
{
|
||||
std::vector<Operation>::iterator it;
|
||||
QString v;
|
||||
|
||||
*_writer << "Operations" << endl << endl;
|
||||
*_writer << "id;parent;day;month;year;amount;description;category;fix_cost;account;checked;transfert;formula;meta;virtual" << endl;
|
||||
*_writer << "id;parent;day;month;year;amount;description;category;fix_cost;account;checked;transfert;formula;meta;virtual;tag" << endl;
|
||||
|
||||
for(it=operations->begin(); it!=operations->end(); it++)
|
||||
{
|
||||
@@ -172,6 +197,7 @@ bool CSVExportEngine::SaveOperations(std::vector<Operation>* operations)
|
||||
*_writer << it->formula << ";";
|
||||
*_writer << (it->meta ? "1" : "0") << ";";
|
||||
*_writer << (it->_virtual ? "1" : "0");
|
||||
*_writer << QString::number(it->tag) << ";";
|
||||
*_writer << endl;
|
||||
}
|
||||
|
||||
@@ -202,6 +228,7 @@ bool CSVExportEngine::SaveFile(std::vector<Operation>* operations)
|
||||
SaveAccounts();
|
||||
SaveAccountAmounts();
|
||||
SaveCategories();
|
||||
SaveTags();
|
||||
SaveOperations(operations);
|
||||
|
||||
file.flush();
|
||||
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
bool SaveAccounts();
|
||||
bool SaveAccountAmounts();
|
||||
bool SaveCategories();
|
||||
bool SaveTags();
|
||||
bool SaveOperations(std::vector<Operation>* operations);
|
||||
};
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ protected:
|
||||
|
||||
std::map<int, int> _accounts;
|
||||
std::map<int, int> _categories;
|
||||
std::map<int, int> _tags;
|
||||
std::map<AccountAmount, int, AccountAmount> _accountAmounts;
|
||||
};
|
||||
|
||||
|
||||
@@ -133,6 +133,27 @@ bool XMLExportEngine::SaveCategories()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XMLExportEngine::SaveTags()
|
||||
{
|
||||
Tag tag;
|
||||
std::map<int, int>::iterator it;
|
||||
QString v;
|
||||
|
||||
for(it=_tags.begin(); it!=_tags.end(); it++)
|
||||
{
|
||||
tag = _user->GetTag(it->first);
|
||||
|
||||
ESCAPE_CHARS(tag.name);
|
||||
|
||||
_writer->writeStartElement("tag");
|
||||
_writer->writeAttribute("id", QString::number(tag.id));
|
||||
_writer->writeAttribute("name", tag.name);
|
||||
_writer->writeEndElement();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XMLExportEngine::SaveOperations(std::vector<Operation>* operations)
|
||||
{
|
||||
std::vector<Operation>::iterator it;
|
||||
@@ -151,6 +172,7 @@ bool XMLExportEngine::SaveOperations(std::vector<Operation>* operations)
|
||||
_writer->writeAttribute("amount", v.sprintf("%d", it->amount));
|
||||
_writer->writeAttribute("description", it->description);
|
||||
_writer->writeAttribute("category", QString::number(it->category));
|
||||
_writer->writeAttribute("tag", QString::number(it->tag));
|
||||
_writer->writeAttribute("fix_cost", (it->fix_cost ? "1" : "0"));
|
||||
_writer->writeAttribute("account", QString::number(it->account));
|
||||
_writer->writeAttribute("checked", (it->checked ? "1" : "0"));
|
||||
@@ -191,6 +213,7 @@ bool XMLExportEngine::SaveFile(std::vector<Operation>* operations)
|
||||
SaveAccounts();
|
||||
SaveAccountAmounts();
|
||||
SaveCategories();
|
||||
SaveTags();
|
||||
SaveOperations(operations);
|
||||
|
||||
_writer->writeEndElement();
|
||||
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
bool SaveAccounts();
|
||||
bool SaveAccountAmounts();
|
||||
bool SaveCategories();
|
||||
bool SaveTags();
|
||||
bool SaveOperations(std::vector<Operation>* operations);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user