Skip to content
Snippets Groups Projects
Commit 03d715ca authored by Jérémy Quentin's avatar Jérémy Quentin
Browse files

[#1795] Crashes when adding a new account, checking it and applying

parent 9c97bc4b
Branches
Tags
No related merge requests found
......@@ -53,7 +53,9 @@ const QString account_state_name(QString & s)
//Constructors
Account::Account():accountId(NULL), item(NULL), itemWidget(NULL){}
Account::Account():accountId(NULL), item(NULL), itemWidget(NULL)
{
}
void Account::initAccountItem()
......@@ -90,6 +92,7 @@ void Account::initAccountItemWidget()
{
itemWidget->setState(AccountItemWidget::NotWorking);
}
connect(itemWidget, SIGNAL(checkStateChanged(bool)), this, SLOT(setEnabled(bool)));
}
Account * Account::buildExistingAccountFromId(QString _accountId)
......@@ -147,13 +150,11 @@ MapStringString & Account::getAccountDetails() const
QListWidgetItem * Account::getItem()
{
if(!item) { qDebug() << "null" ; }
return item;
}
AccountItemWidget * Account::getItemWidget()
{
if(itemWidget == NULL) { qDebug() << "null"; }
return itemWidget;
}
......@@ -214,6 +215,12 @@ void Account::setAccountId(QString id)
accountId = new QString(id);
}
void Account::setEnabled(bool checked)
{
qDebug() << "setEnabled = " << checked;
setAccountDetail(ACCOUNT_ENABLED, checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE);
}
void Account::updateState()
{
qDebug() << "updateState";
......
......@@ -31,8 +31,8 @@
const QString account_state_name(QString & s);
class Account{
class Account : public QObject{
Q_OBJECT
private:
QString * accountId;
......@@ -76,6 +76,10 @@ public:
//Operators
bool operator==(const Account&)const;
private slots:
void setEnabled(bool checked);
};
......
......@@ -113,7 +113,8 @@ bool AccountItemWidget::getEnabled()
return checkBox->checkState();
}
void AccountItemWidget::on_checkBox_stateChanged()
void AccountItemWidget::on_checkBox_stateChanged(int state)
{
emit checkStateChanged();
qDebug() << "on_checkBox_stateChanged";
emit checkStateChanged(state == Qt::Checked);
}
......@@ -65,11 +65,11 @@ public:
void updateDisplay();
private slots:
void on_checkBox_stateChanged();
void on_checkBox_stateChanged(int state);
signals:
void checkStateChanged();
void checkStateChanged(bool checked);
};
......
......@@ -109,7 +109,6 @@ void DlgAccounts::saveAccountList()
}
}
qDebug() << currentId << " : " << current.isChecked();
configurationManager.sendRegister(currentId, current.isChecked() ? 1 : 0 );
}
//remove accounts that are in the configurationManager but not in the client
for (int i = 0; i < accountIds.size(); i++)
......@@ -205,7 +204,7 @@ void DlgAccounts::addAccountToAccountList(Account * account)
qDebug() << "addAccountToAccountList";
QListWidgetItem * item = account->getItem();
QWidget * widget = account->getItemWidget();
connect(widget, SIGNAL(checkStateChanged()),
connect(widget, SIGNAL(checkStateChanged(bool)),
this, SLOT(changedAccountList()));
qDebug() << "item->isHidden()" << item->isHidden();
listWidget_accountList->addItem(item);
......@@ -215,6 +214,7 @@ void DlgAccounts::addAccountToAccountList(Account * account)
void DlgAccounts::changedAccountList()
{
qDebug() << "changedAccountList";
accountListHasChanged = true;
emit updateButtons();
toolButton_accountsApply->setEnabled(hasChanged());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment