Add blocked account (mainly for statistics)

Really fix the previous bug
This commit is contained in:
2010-11-01 11:34:39 +01:00
parent 7af9f1d9c2
commit 0832e020c4
11 changed files with 220 additions and 130 deletions

View File

@@ -19,7 +19,7 @@
#include "PreferencesPanel.h"
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_DEFAULT, ACCOUNT_BLOCKED, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
enum {CATEGORY_NAME, CATEGORY_BACKGROUND_COLOR, CATEGORY_FOREGROUND_COLOR, CATEGORY_FONT, CATEGORY_DELETE, NUMBER_COLS_CATEGORY};
enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID, LANGUAGE_ID,
@@ -184,6 +184,7 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetColLabelValue(ACCOUNT_NAME, _("Name"));
_accountsGrid->SetColLabelValue(ACCOUNT_NUMBER, _("Number"));
_accountsGrid->SetColLabelValue(ACCOUNT_DEFAULT, _("Default"));
_accountsGrid->SetColLabelValue(ACCOUNT_BLOCKED, _("Blocked"));
_accountsGrid->SetColLabelValue(ACCOUNT_DELETE, _("Delete"));
_accountsGrid->SetDefaultCellFont(font);
@@ -200,11 +201,15 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetCellEditor(curLine, ACCOUNT_NUMBER, new wxGridCellStarEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
_accountsGrid->SetCellValue(curLine, ACCOUNT_DEFAULT, (it->_default)?wxT("1"):wxT("0"));
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellValue(curLine, ACCOUNT_BLOCKED, (it->blocked)?wxT("1"):wxT("0"));
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
if (!it->is_owner)
@@ -212,6 +217,7 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NAME, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NUMBER, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_BLOCKED, true);
}
}
@@ -219,6 +225,7 @@ void PreferencesPanel::InitAccounts(User* user)
_accountsGrid->AppendRows();
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_BLOCKED, true);
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DELETE, true);
}
@@ -349,6 +356,12 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
else
new_account._default = false;
value = _accountsGrid->GetCellValue(row, ACCOUNT_BLOCKED);
if (value.Length() && value != wxT("0"))
new_account.blocked = true;
else
new_account.blocked = false;
if (col == ACCOUNT_DEFAULT)
{
new_account.id = user->_accounts[row].id;
@@ -375,6 +388,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
if (user->GetAccountsNumber() && row < user->GetAccountsNumber())
{
new_account.id = user->_accounts[row].id;
new_account.shared = user->_accounts[row].shared;
if (col == ACCOUNT_DELETE)
{
@@ -427,14 +441,21 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
return ;
}
new_account.shared = false;
new_account.blocked = false;
_accountsGrid->SetCellRenderer(row, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(row, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
_accountsGrid->SetCellRenderer(row, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
_accountsGrid->SetCellEditor(row, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
_accountsGrid->SetCellAlignment(row, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(row, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetCellAlignment(row, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
_accountsGrid->SetReadOnly(row, ACCOUNT_DEFAULT, false);
_accountsGrid->SetReadOnly(row, ACCOUNT_BLOCKED, false);
_accountsGrid->SetReadOnly(row, ACCOUNT_DELETE, false);
if (!user->GetAccountsNumber())
@@ -447,6 +468,7 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
_accountsGrid->AppendRows();
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DEFAULT, true);
_accountsGrid->SetReadOnly(row+1, ACCOUNT_BLOCKED, true);
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DELETE, true);
_kiss->AddAccount(new_account);