1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/friendlist.cpp

36 lines
813 B
C++
Raw Normal View History

2014-06-25 04:11:11 +08:00
#include "friend.h"
#include "friendlist.h"
#include <QMenu>
QList<Friend*> FriendList::friendList;
Friend* FriendList::addFriend(int friendId, QString userId)
{
for (Friend* f : friendList)
if (f->friendId == friendId)
qWarning() << "FriendList::addFriend: friendId already taken";
2014-06-25 04:11:11 +08:00
Friend* newfriend = new Friend(friendId, userId);
friendList.append(newfriend);
return newfriend;
}
Friend* FriendList::findFriend(int friendId)
{
for (Friend* f : friendList)
if (f->friendId == friendId)
return f;
return nullptr;
}
void FriendList::removeFriend(int friendId)
{
for (int i=0; i<friendList.size(); i++)
{
if (friendList[i]->friendId == friendId)
{
friendList.removeAt(i);
return;
}
}
}