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

@@ -65,8 +65,8 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxScrolledWindow(&(*
_accounts[i] = accountIt->name;
_categories = new wxString[user->GetCategoriesNumber()] ;
for(i=0, categoryIt = user->_preferences._categories.begin();
categoryIt != user->_preferences._categories.end();
for(i=0, categoryIt = user->_categories.begin();
categoryIt != user->_categories.end();
categoryIt++, i++)
{
_categories[i] = categoryIt->name ;
@@ -319,7 +319,10 @@ void AccountPanel::ShowMonth(int month, int year)
if (month == -1)
{
monthIt = user->_operations[year]->begin();
month = monthIt->first;
if (user->_operations[year]->size() == 0 && year == curDate.GetYear())
month = curDate.GetMonth();
else
month = monthIt->first;
}
}

View File

@@ -148,7 +148,7 @@ void PreferencesPanel::InitCategories(User* user)
_categoriesGrid->SetColLabelValue(CATEGORY_FONT, _("Font"));
_categoriesGrid->SetColLabelValue(CATEGORY_DELETE, _("Delete"));
for (it=user->_preferences._categories.begin(); it!=user->_preferences._categories.end(); it++, curLine++)
for (it=user->_categories.begin(); it!=user->_categories.end(); it++, curLine++)
{
_categoriesGrid->AppendRows();
@@ -337,11 +337,13 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
}
new_cat.color = _categoriesGrid->GetCellBackgroundColour(row, col);
new_cat.font = _("");
new_cat.parent = _("0");
// Categories modification
if (user->GetCategoriesNumber() && row < user->GetCategoriesNumber())
{
new_cat.id = user->_preferences._categories[row].id;
new_cat.id = user->_categories[row].id;
if (col == CATEGORY_DELETE)
{
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete : \n")+new_cat.name, _("KissCount"), wxYES_NO);
@@ -352,7 +354,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
else
{
_categoriesGrid->DeleteRows(row, 1);
_kiss->DeleteCategory(user->_preferences._categories[row]);
_kiss->DeleteCategory(user->_categories[row]);
}
_wxUI->Layout();
@@ -360,7 +362,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
inModification = false;
return;
}
_kiss->UpdateCategory(user->_preferences._categories[row].name, new_cat);
_kiss->UpdateCategory(new_cat);
}
// New category
else