Move AccountState::displayName to Account.

This commit is contained in:
Christian Kamm 2015-04-23 14:51:06 +02:00
parent 89bb58ac30
commit 28306e5dfb
5 changed files with 10 additions and 11 deletions

View file

@ -234,12 +234,5 @@ void AccountState::slotCredentialsFetched(AbstractCredentials* credentials)
checkConnectivity();
}
QString AccountState::displayName()
{
auto user = account()->credentials()->user();
auto url = account()->url();
return tr("%1@%2").arg(user, url.host());
}
} // namespace OCC

View file

@ -85,9 +85,6 @@ public:
/// connection status and errors.
void checkConnectivity();
// The name of the account as shown in the toolbar
QString displayName();
private:
void setState(State state);

View file

@ -159,7 +159,7 @@ void SettingsDialog::accountAdded(AccountState *s)
QIcon accountIcon(QLatin1String(":/client/resources/account.png"));
auto toolBar = qobject_cast<QToolBar*>(layout()->menuBar());
Q_ASSERT(toolBar);
auto accountAction = new QAction(accountIcon, s->displayName(), this);
auto accountAction = new QAction(accountIcon, s->account()->displayName(), this);
toolBar->insertAction(toolBar->actions().at(0), accountAction);
accountAction->setCheckable(true);
auto accountSettings = new AccountSettings(s, this);

View file

@ -71,6 +71,12 @@ AccountPtr Account::sharedFromThis()
}
QString Account::displayName() const
{
auto user = _credentials->user();
return tr("%1@%2").arg(user, _url.host());
}
static bool isEqualExceptProtocol(const QUrl &url1, const QUrl &url2)
{
return (url1.host() != url2.host() ||

View file

@ -62,6 +62,9 @@ public:
void setSharedThis(AccountPtr sharedThis);
AccountPtr sharedFromThis();
/// The name of the account as shown in the toolbar
QString displayName() const;
/**
* @brief Checks the Account instance is different from \param other
*