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)
|
|
|
|
{
|
2014-06-28 02:24:00 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|