First pass

This commit is contained in:
2011-08-25 17:45:41 +02:00
parent ed6a7a5fef
commit 991486a042
64 changed files with 1257 additions and 8876 deletions

View File

@@ -44,64 +44,64 @@ void User::InvalidateOperations()
_operations.clear();
}
Category User::GetCategory(const wxString& catId)
Category User::GetCategory(int catId)
{
Category cat;
std::vector<Category>::iterator it = std::find(_categories.begin(), _categories.end(), catId);
if (it !=_categories.end()) return *it;
if (_db->LoadCategory(catId, wxT(""), cat))
if (_db->LoadCategory(catId, "", cat))
return cat;
cat.id = wxT("0");
cat.parent = wxT("0");
cat.id = 0;
cat.parent = 0;
cat.name = _("Unknown");
cat.font = wxT("");
cat.font = "";
cat.backcolor = view::OWN_GREEN;
cat.forecolor = wxColour(0x00, 0x00, 0x00);
return cat;
}
wxString User::GetCategoryName(const wxString& catId)
std::string User::GetCategoryName(int catId)
{
Category cat;
std::vector<Category>::iterator it = std::find(_categories.begin(), _categories.end(), catId);
if (it !=_categories.end()) return it->name;
if (_db->LoadCategory(catId, wxT(""), cat))
if (_db->LoadCategory(catId, "", cat))
return cat.name;
return _("Unknown") ;
}
wxString User::GetCategoryId(const wxString& catName)
int User::GetCategoryId(const std::string& catName)
{
std::vector<Category>::iterator it;
Category cat;
for (it=_categories.begin(); it !=_categories.end(); it++)
if (wxGetTranslation(it->name) == catName)
if (_(it->name) == catName)
return it->id;
if ( _db->LoadCategory(wxT(""), catName, cat))
if ( _db->LoadCategory("", catName, cat))
return cat.id;
return wxT("0") ;
return 0 ;
}
const wxFont User::GetCategoryFont(const wxString& catId)
const QFont User::GetCategoryFont(int catId)
{
wxFont f;
QFont 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))
if (_db->LoadCategory(catId, "", cat))
return KissCount::ExtractFont(cat.font);
return f;
@@ -110,7 +110,7 @@ const wxFont User::GetCategoryFont(const wxString& catId)
void User::AddCategory(const Category& cat)
{
_categories.push_back(cat);
_categoriesFonts.push_back(KissCount::ExtractFont(wxT("")));
_categoriesFonts.push_back(KissCount::ExtractFont(""));
}
void User::UpdateCategory(const Category& cat)
@@ -136,7 +136,7 @@ void User::DeleteCategory(const Category& cat)
}
}
Account User::GetAccount(const wxString& accountId) throw (AccountNotFound)
Account User::GetAccount(int accountId) throw (AccountNotFound)
{
std::vector<Account>::iterator it = std::find(_accounts.begin(), _accounts.end(), accountId);
@@ -146,7 +146,7 @@ Account User::GetAccount(const wxString& accountId) throw (AccountNotFound)
throw AccountNotFound();
}
wxString User::GetAccountName(const wxString& accountId)
std::string User::GetAccountName(int accountId)
{
std::vector<Account>::iterator it = std::find(_accounts.begin(), _accounts.end(), accountId);
@@ -155,14 +155,14 @@ wxString User::GetAccountName(const wxString& accountId)
return _("Unknown") ;
}
wxString User::GetAccountId(const wxString& accountName)
int User::GetAccountId(const std::string& accountName)
{
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)
if (it->name == accountName)
return it->id;
return wxT("0") ;
return 0 ;
}
void User::AddAccount(Account& ac)
@@ -201,17 +201,17 @@ int User::GetOperationsNumber(int month, int year)
return (*_operations[year])[month].size();
}
wxLanguage User::GetLanguage()
std::string User::GetLanguage()
{
wxString res = _preferences[wxT("language")];
long val;
return _preferences["language"];
// long val;
if (!res.Length())
return wxLANGUAGE_ENGLISH ;
// if (!res.Length())
// return wxLANGUAGE_ENGLISH ;
res.ToLong(&val);
// res.ToLong(&val);
return (wxLanguage)val;
// return (wxLanguage)val;
}
void User::LinkOrUnlinkOperation(Operation& op)
@@ -226,13 +226,13 @@ void User::LinkOrUnlinkOperation(Operation& op)
return;
// Not Linked
if (!op.transfert.Length())
if (!op.transfert)
{
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
{
if (it->id != op.id && it->transfert == op.id)
{
it->transfert = wxT("");
it->transfert = 0;
it->_virtual = false;
return;
}
@@ -253,7 +253,7 @@ void User::LinkOrUnlinkOperation(Operation& op)
return;
}
}
op.transfert = wxT("");
op.transfert = 0;
op._virtual = false;
}
}
@@ -261,7 +261,7 @@ void User::LinkOrUnlinkOperation(Operation& op)
bool User::Group(std::vector<Operation>* ops, const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<wxString>::iterator it2;
std::vector<int>::iterator it2;
for (it = ops->begin(); it != ops->end(); it++)
{
@@ -280,9 +280,6 @@ bool User::Group(std::vector<Operation>* ops, const Operation& op)
void User::Group(const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<wxString>::iterator it2;
if (!Group(&(*_operations[op.year])[op.month], op)
&& _db->LoadOperation(this, op.parent))
{
@@ -293,7 +290,7 @@ void User::Group(const Operation& op)
void User::UnGroup(const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<wxString>::iterator it2;
std::vector<int>::iterator it2;
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
{