Add shared account management

This commit is contained in:
2010-10-24 16:04:56 +02:00
parent d800f23029
commit 28c92d3b28
17 changed files with 655 additions and 237 deletions

View File

@@ -19,6 +19,9 @@
#include "User.h"
User::User(Database* db) : _db(db)
{}
User::~User()
{
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
@@ -41,6 +44,9 @@ Category User::GetCategory(wxString& catId)
if (it->id == catId)
return *it;
if (_db->LoadCategory(catId, wxT(""), cat))
return cat;
cat.id = wxT("0");
cat.parent = wxT("0");
cat.name = _("Unknown");
@@ -53,32 +59,46 @@ Category User::GetCategory(wxString& catId)
wxString User::GetCategoryName(wxString& catId)
{
Category cat;
std::vector<Category>::iterator it;
for (it=_categories.begin(); it !=_categories.end(); it++)
if (it->id == catId)
return it->name;
if (_db->LoadCategory(catId, wxT(""), cat))
return cat.name;
return _("Unknown") ;
}
wxString User::GetCategoryId(wxString& catName)
{
std::vector<Category>::iterator it;
Category cat;
for (it=_categories.begin(); it !=_categories.end(); it++)
if (it->name == catName)
return it->id;
if ( _db->LoadCategory(wxT(""), catName, cat))
return cat.id;
return wxT("0") ;
}
const wxFont& User::GetCategoryFont(wxString& catId)
const wxFont User::GetCategoryFont(wxString& catId)
{
wxFont f;
Category cat;
for (unsigned int i=0; i<_categories.size(); i++)
if (_categories[i].id == catId)
return _categoriesFonts[i];
if (_db->LoadCategory(catId, wxT(""), cat))
return KissCount::ExtractFont(cat.font);
return f;
}
@@ -176,9 +196,14 @@ void User::Group(const Operation& op)
// Already into childs
if (it2 != it->childs.end()) return;
it->childs.push_back(op.id);
break;
return;
}
}
if (_db->LoadOperation(this, op.parent))
{
(*_operations[op.year])[op.month][(*_operations[op.year])[op.month].size()-1].childs.push_back(op.id);
}
}
void User::UnGroup(const Operation& op)