KissCount/model/User.cpp

65 lines
1.4 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
wxString User::GetCategoryName(wxString catId)
{
if (_preferences._categories.find(catId) == _preferences._categories.end())
return _("Unknown") ;
return _preferences._categories[catId];
}
2010-06-03 18:28:38 +02:00
wxString User::GetCategoryId(wxString catName)
{
std::map<wxString, wxString>::iterator it;
for (it=_preferences._categories.begin(); it !=_preferences._categories.end(); it++)
if (it->second == catName)
return it->first;
return _("0") ;
}
2010-05-24 20:14:15 +02:00
wxString User::GetAccountName(wxString accountId)
{
if (_accounts.find(accountId) == _accounts.end())
return _("Unknown") ;
return _accounts[accountId].name;
}
2010-05-27 21:09:02 +02:00
2010-06-03 18:28:38 +02:00
wxString User::GetAccountId(wxString accountName)
{
std::map<wxString, wxString>::iterator it;
for (it=_preferences._categories.begin(); it !=_preferences._categories.end(); it++)
if (it->second == accountName)
return it->first;
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();
}