Possibility to choose a replacement when delete accounts and categories

This commit is contained in:
2011-02-08 21:17:35 +01:00
parent 1b03559b2b
commit 2b07cb0b30
9 changed files with 299 additions and 240 deletions

View File

@@ -194,18 +194,24 @@ void KissCount::UpdateAccount(Account& ac)
std::sort(_user->_accounts.begin(), _user->_accounts.end(), sortAccounts);
}
void KissCount::DeleteAccount(Account& ac)
void KissCount::DeleteAccount(Account& ac, const wxString& replacement)
{
std::vector<Account>::iterator it;
int i;
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it2;
_db->DeleteAccount(_user, ac);
_db->DeleteAccount(_user, ac, replacement);
for (i=0, it=_user->_accounts.begin(); it !=_user->_accounts.end(); it++, i++)
if (it->id == ac.id)
{
_user->_accounts.erase(_user->_accounts.begin()+i);
break;
}
for (it2= _user->_operations.begin();
it2 != _user->_operations.end();
it2++)
LoadYear(it2->first, true);
}
void KissCount::AddSharedAccount(Account& ac, const wxString& granted)
@@ -253,9 +259,11 @@ void KissCount::UpdateCategory(Category& category)
}
}
void KissCount::DeleteCategory(Category& category)
void KissCount::DeleteCategory(Category& category, const wxString& replacement)
{
_db->DeleteCategory(_user, category);
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
_db->DeleteCategory(_user, category, replacement);
for (int i=0; i<_user->GetCategoriesNumber();i++)
if (_user->_categories[i].id == category.id)
@@ -264,6 +272,11 @@ void KissCount::DeleteCategory(Category& category)
_user->_categoriesFonts.erase(_user->_categoriesFonts.begin()+i);
break;
}
for (it= _user->_operations.begin();
it != _user->_operations.end();
it++)
LoadYear(it->first, true);
}
std::map<int, std::vector<int> > KissCount::GetAllOperations()

View File

@@ -64,7 +64,7 @@ public:
wxString AddAccount(Account& ac);
void UpdateAccount(Account& ac);
void DeleteAccount(Account& ac);
void DeleteAccount(Account& ac, const wxString& replacement);
void AddSharedAccount(Account& ac, const wxString& granted);
void RemoveSharedAccount(Account& ac, const wxString& granted);
std::map<wxString, wxString> getSharedAccountOwners(const wxString& account);
@@ -72,7 +72,7 @@ public:
wxString AddCategory(Category& category);
void UpdateCategory(Category& category);
void DeleteCategory(Category& category);
void DeleteCategory(Category& category, const wxString& replacement);
std::map<int, std::vector<int> > GetAllOperations();