AccountManager: new method to return AccountStatePtr from the name.

It uses the Account displayName to destinguish.
This commit is contained in:
Klaas Freitag 2015-11-12 17:50:00 +01:00
parent aa38f7a4f2
commit 81296fae9d
2 changed files with 15 additions and 0 deletions

View file

@ -215,6 +215,16 @@ AccountPtr AccountManager::load(QSettings& settings)
return acc;
}
AccountStatePtr AccountManager::account(const QString& name)
{
foreach (const auto& acc, _accounts) {
if (acc->account()->displayName() == name) {
return acc;
}
}
return AccountStatePtr();
}
AccountState *AccountManager::addAccount(const AccountPtr& newAccount)
{
auto id = newAccount->id();

View file

@ -58,6 +58,11 @@ public:
*/
QList<AccountStatePtr> accounts() { return _accounts; }
/**
* Return the account state pointer for an account identified by its display name
*/
AccountStatePtr account(const QString& name);
/**
* Delete the AccountState
*/