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

@@ -376,7 +376,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
int row = event.GetRow();
int col = event.GetCol();
static bool inModification = false ;
int i;
int i, a;
if (inModification) return;
@@ -423,15 +423,23 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
_accountsGrid->SetCellValue(row, col, wxT("0"));
return;
}
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete ")+new_account.name, wxT("KissCount"), wxYES_NO);
if (dialog.ShowModal() == wxID_NO)
wxString *accounts = new wxString[user->GetAccountsNumber()];
accounts[0] = _("None");
a = 0;
for(i=0; i < user->GetAccountsNumber(); i++)
if (user->_accounts[i].id != new_account.id)
accounts[++a] = user->_accounts[i].name;
wxSingleChoiceDialog dialog(_wxUI, _("Wich account will replace this one ?"), wxT("KissCount"), user->GetAccountsNumber(), accounts);
if (dialog.ShowModal() == wxID_CANCEL)
{
_accountsGrid->SetCellValue(row, col, wxT("0"));
_accountsGrid->SetCellValue(row, col, wxT("0"));
}
else
else
{
_accountsGrid->DeleteRows(row, 1);
_kiss->DeleteAccount(new_account);
_accountsGrid->DeleteRows(row, 1);
i = dialog.GetSelection();
_kiss->DeleteAccount(new_account, (!i) ? wxT("0") : user->_accounts[i].id);
}
if (user->_accounts.size() == 1)
@@ -591,6 +599,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
int col = event.GetCol();
static bool inModification = false ;
Category new_cat, cat_tmp;
int i, a;
if (inModification) return;
@@ -673,19 +682,25 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
new_cat.id = user->_categories[row].id;
if (col == CATEGORY_DELETE)
{
wxMessageDialog dialog(_wxUI, _("Are you sure want to delete : \n")+new_cat.name, wxT("KissCount"), wxYES_NO);
if (dialog.ShowModal() == wxID_NO)
wxString *categories = new wxString[user->GetCategoriesNumber()];
categories[0] = _("None");
a = 0;
for(i=0; i < user->GetCategoriesNumber(); i++)
if (user->_categories[i].id != new_cat.id)
categories[++a] = user->_categories[i].name;
wxSingleChoiceDialog dialog(_wxUI, _("Wich category will replace this one ?"), wxT("KissCount"), user->GetCategoriesNumber(), categories);
if (dialog.ShowModal() == wxID_CANCEL)
{
_categoriesGrid->SetCellValue(row, col, wxT("0"));
_categoriesGrid->SetCellValue(row, col, wxT("0"));
}
else
else
{
_categoriesGrid->DeleteRows(row, 1);
_kiss->DeleteCategory(user->_categories[row]);
_categoriesGrid->DeleteRows(row, 1);
i = dialog.GetSelection();
_kiss->DeleteCategory(user->_categories[row], (!i) ? wxT("0") : user->_accounts[i].id);
Fit();
_wxUI->NeedReload();
}
Fit();
_wxUI->NeedReload();
inModification = false;
return;
}