KissCount/model/User.cpp

89 lines
1.7 KiB
C++
Raw Normal View History

2010-05-15 11:21:42 +02:00
#include "User.h"
User::~User()
{
2010-07-03 11:48:53 +02:00
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
2010-05-15 11:21:42 +02:00
for (it = _operations.begin(); it != _operations.end(); it++)
{
if (_operations[it->first])
{
delete it->second;
}
}
}
2010-05-24 20:14:15 +02:00
2010-07-03 11:48:53 +02:00
Category User::GetCategory(wxString catId)
2010-06-22 12:29:36 +02:00
{
2010-07-03 11:48:53 +02:00
Category cat;
std::vector<Category>::iterator it;
2010-06-22 12:29:36 +02:00
for (it=_categories.begin(); it !=_categories.end(); it++)
2010-06-22 12:29:36 +02:00
if (it->id == catId)
return *it;
2010-07-03 11:19:02 +02:00
cat.id = wxT("0");
cat.parent = wxT("0");
cat.name = _("Unknown");
2010-07-03 11:19:02 +02:00
cat.font = wxT("");
cat.color = wxColour(0xFF, 0xFF, 0xFF);
2010-06-22 12:29:36 +02:00
return cat;
2010-06-22 12:29:36 +02:00
}
2010-05-24 20:14:15 +02:00
wxString User::GetCategoryName(wxString catId)
{
2010-07-03 11:48:53 +02:00
std::vector<Category>::iterator it;
for (it=_categories.begin(); it !=_categories.end(); it++)
2010-06-22 12:29:36 +02:00
if (it->id == catId)
return it->name;
return _("Unknown") ;
2010-05-24 20:14:15 +02:00
}
2010-06-03 18:28:38 +02:00
wxString User::GetCategoryId(wxString catName)
{
2010-07-03 11:48:53 +02:00
std::vector<Category>::iterator it;
for (it=_categories.begin(); it !=_categories.end(); it++)
2010-06-22 12:29:36 +02:00
if (it->name == catName)
return it->id;
2010-06-03 18:28:38 +02:00
2010-07-03 11:19:02 +02:00
return wxT("0") ;
2010-06-03 18:28:38 +02:00
}
2010-05-24 20:14:15 +02:00
wxString User::GetAccountName(wxString accountId)
{
2010-07-03 11:48:53 +02:00
std::vector<Account>::iterator it;
2010-06-21 13:02:02 +02:00
for (it=_accounts.begin(); it !=_accounts.end(); it++)
if (it->id == accountId)
return it->name;
2010-05-24 20:14:15 +02:00
return _("Unknown") ;
}
2010-05-27 21:09:02 +02:00
2010-06-03 18:28:38 +02:00
wxString User::GetAccountId(wxString accountName)
{
2010-07-03 11:48:53 +02:00
std::vector<Account>::iterator it;
2010-06-21 13:02:02 +02:00
for (it=_accounts.begin(); it !=_accounts.end(); it++)
if (it->name == accountName)
return it->id;
2010-06-03 18:28:38 +02:00
2010-07-03 11:19:02 +02:00
return wxT("0") ;
2010-06-03 18:28:38 +02:00
}
2010-05-27 21:09:02 +02:00
int User::GetCategoriesNumber()
{
return _categories.size();
2010-05-27 21:09:02 +02:00
}
2010-06-02 22:14:11 +02:00
int User::GetAccountsNumber()
{
return _accounts.size();
}
int User::GetOperationsNumber(int month, int year)
{
return (*_operations[year])[month].size();
}