1
0
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:
sudden6 2018-10-30 23:42:18 +01:00
parent 6cce0dae83
commit 562ef28ab0
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
3 changed files with 8 additions and 8 deletions

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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;