Tag management : first version

This commit is contained in:
2014-11-10 11:54:28 +01:00
parent 899dc3db71
commit 57d4b90182
32 changed files with 868 additions and 60 deletions

View File

@@ -84,6 +84,9 @@ bool XMLImportEngine::startElement (const QString& namespaceURI, const QString&
else if (qName == "category")
LoadCategory(attrs);
else if (qName == "tag")
LoadTag(attrs);
else if (qName == "operation")
LoadOperation(attrs);
else
@@ -201,6 +204,32 @@ void XMLImportEngine::LoadCategory(const QXmlAttributes& attrs)
_unresolvedCategories.push_back(cat);
}
void XMLImportEngine::LoadTag(const QXmlAttributes& attrs)
{
QString name;
int id;
Tag tag;
static int unknownTag = 0;
tag.name = name = attrs.value("name");
tag.id = id = attrs.value("id").toInt();
UNESCAPE_CHARS(tag.name);
try
{
int tagId = _user->GetTagId(name);
_tags[id] = tagId;
return;
}
catch(User::TagNotFound e)
{}
_tags[id] = --unknownTag;
_unresolvedTags.push_back(tag);
}
void XMLImportEngine::LoadOperation(const QXmlAttributes& attrs)
{
Operation op;
@@ -213,6 +242,7 @@ void XMLImportEngine::LoadOperation(const QXmlAttributes& attrs)
op.amount = attrs.value("amount").toInt();
op.description = attrs.value("description");
op.category = attrs.value("category").toInt();
op.tag = attrs.value("tag").toInt();
op.fix_cost = (attrs.value("fix_cost") == "1");
op.account = attrs.value("account").toInt();
op.checked = (attrs.value("checked") == "1");