KissCount/model/User.cpp

85 lines
1.7 KiB
C++
Raw Normal View History

2010-05-15 11:21:42 +02:00
#include "User.h"
User::~User()
{
2010-06-03 18:28:38 +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-06-22 12:29:36 +02:00
struct category User::GetCategory(wxString catId)
{
struct category cat;
std::vector<category>::iterator it;
for (it=_preferences._categories.begin(); it !=_preferences._categories.end(); it++)
if (it->id == catId)
return *it;
cat.id = _("0");
return cat;
}
2010-05-24 20:14:15 +02:00
wxString User::GetCategoryName(wxString catId)
{
2010-06-22 12:29:36 +02:00
std::vector<category>::iterator it;
for (it=_preferences._categories.begin(); it !=_preferences._categories.end(); it++)
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-06-22 12:29:36 +02:00
std::vector<category>::iterator it;
for (it=_preferences._categories.begin(); it !=_preferences._categories.end(); it++)
if (it->name == catName)
return it->id;
2010-06-03 18:28:38 +02:00
return _("0") ;
}
2010-05-24 20:14:15 +02:00
wxString User::GetAccountName(wxString accountId)
{
2010-06-21 13:02:02 +02:00
std::vector<Account>::iterator it;
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-06-21 13:02:02 +02:00
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)
if (it->name == accountName)
return it->id;
2010-06-03 18:28:38 +02:00
return _("0") ;
}
2010-05-27 21:09:02 +02:00
int User::GetCategoriesNumber()
{
return _preferences._categories.size();
}
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();
}