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

refactor(circlewidget): Get Friend from FriendWidget

This commit is contained in:
Diadlo 2017-07-26 12:18:09 +03:00
parent 6ba24b65ca
commit 90a262e9b5
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -200,7 +200,7 @@ void CircleWidget::onExpand()
void CircleWidget::onAddFriendWidget(FriendWidget* w)
{
Friend* f = FriendList::findFriend(w->friendId);
Friend* f = w->getFriend();
ToxPk toxId = f->getPublicKey();
Settings::getInstance().setFriendCircleID(toxId, id);
}
@ -210,26 +210,30 @@ void CircleWidget::updateID(int index)
// For when a circle gets destroyed, another takes its id.
// This function updates all friends widgets for this new id.
if (id == index)
if (id == index) {
return;
}
id = index;
circleList[id] = this;
for (int i = 0; i < friendOnlineLayout()->count(); ++i) {
FriendWidget* friendWidget =
qobject_cast<FriendWidget*>(friendOnlineLayout()->itemAt(i)->widget());
const QWidget* w = friendOnlineLayout()->itemAt(i)->widget();
const FriendWidget* friendWidget = qobject_cast<const FriendWidget*>(w);
if (friendWidget != nullptr)
Settings::getInstance()
.setFriendCircleID(FriendList::findFriend(friendWidget->friendId)->getPublicKey(), id);
if (friendWidget) {
const Friend* f = friendWidget->getFriend();
Settings::getInstance().setFriendCircleID(f->getPublicKey(), id);
}
}
for (int i = 0; i < friendOfflineLayout()->count(); ++i) {
FriendWidget* friendWidget =
qobject_cast<FriendWidget*>(friendOfflineLayout()->itemAt(i)->widget());
if (friendWidget != nullptr)
Settings::getInstance()
.setFriendCircleID(FriendList::findFriend(friendWidget->friendId)->getPublicKey(), id);
for (int i = 0; i < friendOfflineLayout()->count(); ++i) {
const QWidget* w = friendOfflineLayout()->itemAt(i)->widget();
const FriendWidget* friendWidget = qobject_cast<const FriendWidget*>(w);
if (friendWidget) {
const Friend* f = friendWidget->getFriend();
Settings::getInstance().setFriendCircleID(f->getPublicKey(), id);
}
}
}