From 92bd5ce8cf7d4e1e801d15bc6829ac6323968d94 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com> Date: Fri, 22 Jun 2012 12:08:33 -0400 Subject: [PATCH] [ #12352 ] Fix adding account --- kde/src/conf/dlgaccounts.cpp | 1 + kde/src/lib/Account.cpp | 15 ++++++++++++++- kde/src/lib/Account.h | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/kde/src/conf/dlgaccounts.cpp b/kde/src/conf/dlgaccounts.cpp index 645568ce76..b94a89b622 100755 --- a/kde/src/conf/dlgaccounts.cpp +++ b/kde/src/conf/dlgaccounts.cpp @@ -575,6 +575,7 @@ void DlgAccounts::on_button_accountAdd_clicked() QString itemName = QInputDialog::getText(this, "New account", "Enter new account's alias"); itemName = itemName.simplified(); if (!itemName.isEmpty()) { + AccountList::getInstance()->addAccount(itemName); int r = listView_accountList->model()->rowCount() - 1; listView_accountList->setCurrentIndex(listView_accountList->model()->index(r,0)); frame2_editAccounts->setEnabled(true); diff --git a/kde/src/lib/Account.cpp b/kde/src/lib/Account.cpp index 3cc6cf8867..e25fc86621 100644 --- a/kde/src/lib/Account.cpp +++ b/kde/src/lib/Account.cpp @@ -71,7 +71,7 @@ const QString& account_state_name(const QString& s) } //account_state_name ///Constructors -Account::Account():m_pAccountId(NULL),m_pAccountDetails(NULL) +Account::Account():m_pAccountId(NULL),m_pAccountDetails(NULL),m_Temporary(false) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); connect(&callManager,SIGNAL(registrationStateChanged(QString,QString,int)),this,SLOT(accountChanged(QString,QString,int))); @@ -198,6 +198,12 @@ bool Account::isRegistered() const return (getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED); } +///If this account is really part of the model or just "in progress" that can be canceled +bool Account::isTemporary() const +{ + return m_Temporary; +} + ///Return the model index of this item QModelIndex Account::getIndex() { @@ -266,6 +272,12 @@ void Account::setEnabled(bool checked) setAccountDetail(ACCOUNT_ENABLED, checked ? REGISTRATION_ENABLED_TRUE : REGISTRATION_ENABLED_FALSE); } +///Set if the account is temporary (work in progress, can be cancelled) +void Account::setTemporary(bool value) +{ + m_Temporary = value; +} + /***************************************************************************** * * * Mutator * @@ -286,6 +298,7 @@ void Account::updateState() ///Save the current account to the daemon void Account::save() { + if (isTemporary()) return; ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); if (isNew()) { MapStringString details = getAccountDetails(); diff --git a/kde/src/lib/Account.h b/kde/src/lib/Account.h index f03ce62af7..5ea7d5ea88 100644 --- a/kde/src/lib/Account.h +++ b/kde/src/lib/Account.h @@ -53,6 +53,7 @@ class LIB_EXPORT Account : public QObject { const QString& getAlias() const; bool isEnabled() const; bool isRegistered() const; + bool isTemporary() const; QModelIndex getIndex() ; QString getStateColorName() const; Qt::GlobalColor getStateColor() const; @@ -134,6 +135,7 @@ class LIB_EXPORT Account : public QObject { void setAccountId (const QString& id ); void setAccountDetails (const MapStringString& m ); void setAccountDetail (const QString& param, const QString& val ); + void setTemporary (const bool value ); #ifdef ENABLE_VIDEO void setActiveVideoCodecList(QList<VideoCodec*> codecs); QList<VideoCodec*> getActiveVideoCodecList(); @@ -228,6 +230,9 @@ class LIB_EXPORT Account : public QObject { private slots: void accountChanged(QString accountId,QString stateName, int state); + private: + bool m_Temporary; + signals: ///The account state (Invalif,Trying,Registered) changed void stateChanged(QString state); -- GitLab