Add a function to know the user id matching a given account

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This commit is contained in:
Kevin Ottens 2020-10-07 12:27:32 +02:00
parent e3b97b0a04
commit c42f4abd25
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 16 additions and 0 deletions

View file

@ -810,6 +810,20 @@ User *UserModel::currentUser() const
return _users[currentUserId()];
}
int UserModel::findUserIdForAccount(AccountState *account) const
{
const auto it = std::find_if(std::cbegin(_users), std::cend(_users), [=](const User *user) {
return user->account()->id() == account->account()->id();
});
if (it == std::cend(_users)) {
return -1;
}
const auto id = std::distance(std::cbegin(_users), it);
return id;
}
/*-------------------------------------------------------------------------------------*/
ImageProvider::ImageProvider()

View file

@ -107,6 +107,8 @@ public:
User *currentUser() const;
int findUserIdForAccount(AccountState *account) const;
Q_INVOKABLE void fetchCurrentActivityModel();
Q_INVOKABLE void openCurrentAccountLocalFolder();
Q_INVOKABLE void openCurrentAccountTalk();