mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(friend): remove Core dependency
This commit is contained in:
parent
6cce0dae83
commit
562ef28ab0
|
@ -30,8 +30,9 @@ QHash<QByteArray, uint32_t> FriendList::key2id;
|
|||
Friend* FriendList::addFriend(uint32_t friendId, const ToxPk& friendPk)
|
||||
{
|
||||
auto friendChecker = friendList.find(friendId);
|
||||
if (friendChecker != friendList.end())
|
||||
if (friendChecker != friendList.end()) {
|
||||
qWarning() << "addFriend: friendId already taken";
|
||||
}
|
||||
|
||||
QString alias = Settings::getInstance().getFriendAlias(friendPk);
|
||||
Friend* newfriend = new Friend(friendId, friendPk, alias);
|
||||
|
@ -44,8 +45,9 @@ Friend* FriendList::addFriend(uint32_t friendId, const ToxPk& friendPk)
|
|||
Friend* FriendList::findFriend(uint32_t friendId)
|
||||
{
|
||||
auto f_it = friendList.find(friendId);
|
||||
if (f_it != friendList.end())
|
||||
if (f_it != friendList.end()) {
|
||||
return *f_it;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
|
||||
#include "friend.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/model/group.h"
|
||||
#include "src/grouplist.h"
|
||||
#include "src/nexus.h"
|
||||
#include "src/persistence/profile.h"
|
||||
#include "src/widget/form/chatform.h"
|
||||
|
||||
Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias)
|
||||
: userName{Core::getInstance()->getPeerName(friendPk)}
|
||||
Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias, const QString& userName)
|
||||
: userName{userName}
|
||||
, userAlias{userAlias}
|
||||
, friendPk{friendPk}
|
||||
, friendId{friendId}
|
||||
|
@ -35,7 +33,7 @@ Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlia
|
|||
, friendStatus{Status::Offline}
|
||||
{
|
||||
if (userName.isEmpty()) {
|
||||
userName = friendPk.toString();
|
||||
this->userName = friendPk.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class Friend : public Contact
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias);
|
||||
Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias = {}, const QString &userName = {});
|
||||
Friend(const Friend& other) = delete;
|
||||
Friend& operator=(const Friend& other) = delete;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user