diff --git a/sflphone_kde/Account.cpp b/sflphone_kde/Account.cpp index 202eac12bc1bbae277b6c5cea07022c8246ad167..d0ca036b12842152dc0ce171d34b955520021643 100644 --- a/sflphone_kde/Account.cpp +++ b/sflphone_kde/Account.cpp @@ -71,7 +71,7 @@ void Account::initAccountItem() setItemText(getAccountDetail(*(new QString(ACCOUNT_ALIAS)))); itemWidget = new QWidget(); QCheckBox * checkbox = new QCheckBox(itemWidget); - checkbox->setObjectName("checkbox"); + checkbox->setObjectName(QString(ACCOUNT_ITEM_CHECKBOX)); checkbox->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); //QLabel* name = new QLabel(getAccountDetail(*(new QString(ACCOUNT_ALIAS))), itemWidget); //QLabel* name = new QLabel("", itemWidget); @@ -139,6 +139,11 @@ bool Account::isNew() return(!accountId); } +bool Account::isChecked() +{ + return itemWidget->findChild<QCheckBox *>(QString(ACCOUNT_ITEM_CHECKBOX))->checkState() == Qt::Checked; +} + QString & Account::getAccountId() { return *accountId; @@ -170,25 +175,21 @@ QString Account::getStateName(QString & state) QColor Account::getStateColor() { - if(item->checkState() == Qt::Checked) - { - if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) - return Qt::darkGreen; - return Qt::red; - } - return Qt::black; + if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_UNREGISTERED) + return Qt::black; + if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) + return Qt::darkGreen; + return Qt::red; } QString Account::getStateColorName() { - if(item->checkState() == Qt::Checked) - { - if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) - return "darkGreen"; - return "red"; - } - return "black"; + if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_UNREGISTERED) + return "black"; + if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) + return "darkGreen"; + return "red"; } QString Account::getAccountDetail(QString & param) diff --git a/sflphone_kde/Account.h b/sflphone_kde/Account.h index d37e0931fc25fdec975d04095a0a98e4e16d6228..d7157eb1ab5802685f0f9f1eab8fc2f48e696eaf 100644 --- a/sflphone_kde/Account.h +++ b/sflphone_kde/Account.h @@ -27,6 +27,7 @@ public: //Getters bool isNew(); + bool isChecked(); QString & getAccountId(); MapStringString & getAccountDetails(); QListWidgetItem * getItem(); diff --git a/sflphone_kde/ConfigDialog.cpp b/sflphone_kde/ConfigDialog.cpp index ed252759822a592c582a12f16660136c2d771447..334f09deb9c4f1d886a6c819b140499621e0512c 100644 --- a/sflphone_kde/ConfigDialog.cpp +++ b/sflphone_kde/ConfigDialog.cpp @@ -230,8 +230,9 @@ void ConfigurationDialog::saveOptions() void ConfigurationDialog::loadAccountList() { + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); //ask for the list of accounts ids to the configurationManager - QStringList accountIds = ConfigurationManagerInterfaceSingleton::getInstance().getAccountList().value(); + QStringList accountIds = configurationManager.getAccountList().value(); //create the AccountList object with the ids accountList = new AccountList(accountIds); //initialize the QListWidget object with the AccountList @@ -276,7 +277,7 @@ void ConfigurationDialog::saveAccountList() currentId = QString(current.getAccountId()); } } - configurationManager.sendRegister(currentId, (current.getItem()->checkState() == Qt::Checked) ? 1 : 0 ); + 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++) diff --git a/sflphone_kde/sflphone_const.h b/sflphone_kde/sflphone_const.h index 5035b68f43e9c1ce600c62fb17a54fc21a663e46..cf3921764259763e8a01d6df4833387b8724b667 100644 --- a/sflphone_kde/sflphone_const.h +++ b/sflphone_kde/sflphone_const.h @@ -100,6 +100,8 @@ #define ACCOUNT_STATE_ERROR_CONF_STUN "ERROR_CONF_STUN" #define ACCOUNT_STATE_ERROR_EXIST_STUN "ERROR_EXIST_STUN" +#define ACCOUNT_ITEM_CHECKBOX "checkbox" + #define CALL_STATE_CHANGE_HUNG_UP "HUNGUP" #define CALL_STATE_CHANGE_RINGING "RINGING" #define CALL_STATE_CHANGE_CURRENT "CURRENT"