Use new emacs indentation rules (4 spaces instead of tabs and braces position)~
This commit is contained in:
@@ -1,150 +1,150 @@
|
||||
/*
|
||||
Copyright 2010 Grégory Soutadé
|
||||
Copyright 2010 Grégory Soutadé
|
||||
|
||||
This file is part of KissCount.
|
||||
This file is part of KissCount.
|
||||
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "User.h"
|
||||
|
||||
User::~User()
|
||||
{
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
|
||||
|
||||
for (it = _operations.begin(); it != _operations.end(); it++)
|
||||
for (it = _operations.begin(); it != _operations.end(); it++)
|
||||
{
|
||||
if (_operations[it->first])
|
||||
if (_operations[it->first])
|
||||
{
|
||||
delete it->second;
|
||||
delete it->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Category User::GetCategory(wxString& catId)
|
||||
{
|
||||
Category cat;
|
||||
std::vector<Category>::iterator it;
|
||||
Category cat;
|
||||
std::vector<Category>::iterator it;
|
||||
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (it->id == catId)
|
||||
return *it;
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (it->id == catId)
|
||||
return *it;
|
||||
|
||||
cat.id = wxT("0");
|
||||
cat.parent = wxT("0");
|
||||
cat.name = _("Unknown");
|
||||
cat.font = wxT("");
|
||||
cat.color = wxColour(0xFF, 0xFF, 0xFF);
|
||||
cat.id = wxT("0");
|
||||
cat.parent = wxT("0");
|
||||
cat.name = _("Unknown");
|
||||
cat.font = wxT("");
|
||||
cat.color = wxColour(0xFF, 0xFF, 0xFF);
|
||||
|
||||
return cat;
|
||||
return cat;
|
||||
}
|
||||
|
||||
wxString User::GetCategoryName(wxString& catId)
|
||||
{
|
||||
std::vector<Category>::iterator it;
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (it->id == catId)
|
||||
return it->name;
|
||||
std::vector<Category>::iterator it;
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (it->id == catId)
|
||||
return it->name;
|
||||
|
||||
return _("Unknown") ;
|
||||
return _("Unknown") ;
|
||||
}
|
||||
|
||||
wxString User::GetCategoryId(wxString& catName)
|
||||
{
|
||||
std::vector<Category>::iterator it;
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (it->name == catName)
|
||||
return it->id;
|
||||
std::vector<Category>::iterator it;
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (it->name == catName)
|
||||
return it->id;
|
||||
|
||||
return wxT("0") ;
|
||||
return wxT("0") ;
|
||||
}
|
||||
|
||||
wxString User::GetAccountName(const wxString& accountId)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->id == accountId)
|
||||
return it->name;
|
||||
std::vector<Account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->id == accountId)
|
||||
return it->name;
|
||||
|
||||
return _("Unknown") ;
|
||||
return _("Unknown") ;
|
||||
}
|
||||
|
||||
wxString User::GetAccountId(wxString& accountName)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->name == accountName)
|
||||
return it->id;
|
||||
std::vector<Account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->name == accountName)
|
||||
return it->id;
|
||||
|
||||
return wxT("0") ;
|
||||
return wxT("0") ;
|
||||
}
|
||||
|
||||
int User::GetCategoriesNumber()
|
||||
{
|
||||
return _categories.size();
|
||||
return _categories.size();
|
||||
}
|
||||
|
||||
int User::GetAccountsNumber()
|
||||
{
|
||||
return _accounts.size();
|
||||
return _accounts.size();
|
||||
}
|
||||
|
||||
int User::GetOperationsNumber(int month, int year)
|
||||
{
|
||||
return (*_operations[year])[month].size();
|
||||
return (*_operations[year])[month].size();
|
||||
}
|
||||
|
||||
wxLanguage User::GetLanguage()
|
||||
{
|
||||
wxString res = _preferences[wxT("language")];
|
||||
long val;
|
||||
wxString res = _preferences[wxT("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)
|
||||
{
|
||||
std::vector<Operation>::iterator it;
|
||||
std::vector<Operation>::iterator it;
|
||||
|
||||
// Not Linked
|
||||
if (!op.transfert.Length())
|
||||
// Not Linked
|
||||
if (!op.transfert.Length())
|
||||
{
|
||||
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
|
||||
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)
|
||||
if (it->id != op.id && it->transfert == op.id)
|
||||
{
|
||||
it->transfert = wxT("");
|
||||
return;
|
||||
it->transfert = wxT("");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Linked
|
||||
else
|
||||
// Linked
|
||||
else
|
||||
{
|
||||
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
|
||||
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
|
||||
{
|
||||
if (it->id != op.id && it->id == op.transfert)
|
||||
if (it->id != op.id && it->id == op.transfert)
|
||||
{
|
||||
it->transfert = op.id;
|
||||
return;
|
||||
it->transfert = op.id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
op.transfert = wxT("");
|
||||
op.transfert = wxT("");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user