Fix a bug : Can't hide default account

This commit is contained in:
Grégory Soutadé 2012-04-28 09:23:38 +02:00
parent 951c41a5f7
commit 43bf2da1f5

View File

@ -638,9 +638,12 @@ void PreferencesPanel::OnAccountDeleteClicked(int id)
if (default_account)
{
user->_accounts[0]._default = true;
user->_accounts[0].hidden = false;
_kiss->UpdateAccount(user->_accounts[0]);
checkBox = qobject_cast<QCheckBox*> (_accountsGrid->cellWidget(0, ACCOUNT_DEFAULT));
checkBox->setCheckState(Qt::Checked);
checkBox = qobject_cast<QCheckBox*> (_accountsGrid->cellWidget(0, ACCOUNT_HIDDEN));
checkBox->setCheckState(Qt::Unchecked);
}
_inModification = false;
@ -666,6 +669,14 @@ void PreferencesPanel::OnAccountHiddenClicked(int id)
row = it-user->_accounts.begin();
account = user->_accounts[row];
if (account._default)
{
QMessageBox::critical(0, _("Error"), _("Default account cannot be hidden"));
checkBox->setCheckState(Qt::Unchecked);
_inModification = false;
return;
}
account.hidden = (checkBox->checkState() == Qt::Checked);
_kiss->UpdateAccount(account);
@ -842,9 +853,13 @@ void PreferencesPanel::OnAccountModified(int row, int col)
// Account modification
if (user->GetAccountsNumber() && row < user->GetAccountsNumber())
{
new_account._default = user->_accounts[row]._default;
new_account.id = user->_accounts[row].id;
new_account.shared = user->_accounts[row].shared;
new_account.is_owner = user->_accounts[row].is_owner;
new_account.blocked = user->_accounts[row].blocked;
new_account._virtual = user->_accounts[row]._virtual;
new_account.hidden = user->_accounts[row].hidden;
if (col == ACCOUNT_NAME)
{