From 7cd7788aa3c1a9faa1100ebc406faec5a79233b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Quentin?=
 <jquentin@jquentin-laptop-kub2.(none)>
Date: Thu, 26 Mar 2009 11:06:22 -0400
Subject: [PATCH] Before merge.

---
 sflphone_kde/Account.cpp      | 31 ++++++++++++++++---------------
 sflphone_kde/Account.h        |  1 +
 sflphone_kde/ConfigDialog.cpp |  5 +++--
 sflphone_kde/sflphone_const.h |  2 ++
 4 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/sflphone_kde/Account.cpp b/sflphone_kde/Account.cpp
index 202eac12bc..d0ca036b12 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 d37e0931fc..d7157eb1ab 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 ed25275982..334f09deb9 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 5035b68f43..cf39217642 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"
-- 
GitLab