Change category representation into Database and fix two bug for category deletion and account creation. There is still bugs during account deletion

This commit is contained in:
2010-07-02 21:40:32 +02:00
parent 7bdf6bd1e4
commit e08865e01f
11 changed files with 129 additions and 158 deletions

View File

@@ -139,27 +139,19 @@ wxString KissCount::AddCategory(struct category category)
id = _db->AddCategory(_user, category);
category.id = id;
_user->_preferences._categories.push_back(category);
_user->_categories.push_back(category);
return id;
}
void KissCount::UpdateCategory(wxString oldName, struct category category)
void KissCount::UpdateCategory(struct category category)
{
wxString color;
std::vector<struct category>::iterator it;
color = _("#") ;
color += wxString::Format(_("%02X"), category.color.Red());
color += wxString::Format(_("%02X"), category.color.Green());
color += wxString::Format(_("%02X"), category.color.Blue());
_db->UpdateCategory(_user, oldName, category.name, color);
_db->UpdateCategory(category);
for (int i=0; i<(int)_user->_preferences._categories.size();i++)
if (_user->_preferences._categories[i].name == oldName)
for (int i=0; i<_user->GetCategoriesNumber();i++)
if (_user->_categories[i].id == category.id)
{
_user->_preferences._categories[i] = category;
_user->_categories[i] = category;
break;
}
}
@@ -168,10 +160,10 @@ void KissCount::DeleteCategory(struct category category)
{
_db->DeleteCategory(_user, category);
for (int i=0; i<(int)_user->_preferences._categories.size();i++)
if (_user->_preferences._categories[i].name == category.name)
for (int i=0; i<_user->GetCategoriesNumber();i++)
if (_user->_categories[i].id == category.id)
{
_user->_preferences._categories.erase(_user->_preferences._categories.begin()+i);
_user->_categories.erase(_user->_categories.begin()+i);
break;
}
}

View File

@@ -38,7 +38,7 @@ class KissCount
void DeleteAccount(struct Account ac);
wxString AddCategory(struct category category);
void UpdateCategory(wxString oldName, struct category category);
void UpdateCategory(struct category category);
void DeleteCategory(struct category category);
std::map<int, std::vector<int> > GetAllOperations();