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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user