mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 06:55:59 +03:00
Add method to get user pointer in UserModel by AccountState pointer
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
29cc9c06f9
commit
10989fa810
2 changed files with 17 additions and 2 deletions
|
@ -1526,6 +1526,21 @@ User *UserModel::currentUser() const
|
||||||
return _users[currentUserId()];
|
return _users[currentUserId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
User *UserModel::findUserForAccount(AccountState *account) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(account);
|
||||||
|
|
||||||
|
const auto it = std::find_if(_users.cbegin(), _users.cend(), [account](const User *user) {
|
||||||
|
return user->account()->id() == account->account()->id();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it == _users.cend()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
int UserModel::findUserIdForAccount(AccountState *account) const
|
int UserModel::findUserIdForAccount(AccountState *account) const
|
||||||
{
|
{
|
||||||
const auto it = std::find_if(std::cbegin(_users), std::cend(_users), [=](const User *user) {
|
const auto it = std::find_if(std::cbegin(_users), std::cend(_users), [=](const User *user) {
|
||||||
|
|
|
@ -210,8 +210,8 @@ public:
|
||||||
[[nodiscard]] QImage avatarById(const int id) const;
|
[[nodiscard]] QImage avatarById(const int id) const;
|
||||||
|
|
||||||
[[nodiscard]] User *currentUser() const;
|
[[nodiscard]] User *currentUser() const;
|
||||||
|
[[nodiscard]] User *findUserForAccount(AccountState *account) const;
|
||||||
int findUserIdForAccount(AccountState *account) const;
|
[[nodiscard]] int findUserIdForAccount(AccountState *account) const;
|
||||||
|
|
||||||
Q_INVOKABLE int numUsers();
|
Q_INVOKABLE int numUsers();
|
||||||
Q_INVOKABLE QString currentUserServer();
|
Q_INVOKABLE QString currentUserServer();
|
||||||
|
|
Loading…
Reference in a new issue