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