mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
properly implement clearing contacts list
This commit is contained in:
parent
2181313d37
commit
7ce7da0776
|
@ -66,3 +66,22 @@ void FriendListWidget::moveWidget(QWidget *w, Status s)
|
|||
mainLayout->removeWidget(w);
|
||||
getFriendLayout(s)->addWidget(w);
|
||||
}
|
||||
|
||||
void clearLayout(QLayout *layout)
|
||||
{
|
||||
QLayoutItem *item;
|
||||
while((item = layout->takeAt(0)))
|
||||
{
|
||||
if (item->layout()) {
|
||||
clearLayout(item->layout());
|
||||
delete item->layout();
|
||||
}
|
||||
delete item->widget();
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void FriendListWidget::clear()
|
||||
{
|
||||
clearLayout(mainLayout);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
signals:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
QHash<int, QLayout*> layouts;
|
||||
|
|
|
@ -137,7 +137,7 @@ Widget::Widget(QWidget *parent)
|
|||
connect(core, SIGNAL(fileUploadFinished(const QString&)), &filesForm, SLOT(onFileUploadComplete(const QString&)));
|
||||
connect(core, &Core::friendAdded, this, &Widget::addFriend);
|
||||
connect(core, &Core::failedToAddFriend, this, &Widget::addFriendFailed);
|
||||
connect(core, &Core::clearFriends, this, &Widget::clearFriends);
|
||||
connect(core, &Core::clearFriends, contactListWidget, &FriendListWidget::clear);
|
||||
connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged);
|
||||
connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged);
|
||||
connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged);
|
||||
|
@ -637,12 +637,6 @@ void Widget::removeFriend(int friendId)
|
|||
removeFriend(FriendList::findFriend(friendId));
|
||||
}
|
||||
|
||||
void Widget::clearFriends()
|
||||
{ // used for dynamic profile loading
|
||||
for (Friend* f : FriendList::friendList)
|
||||
removeFriend(f);
|
||||
}
|
||||
|
||||
void Widget::copyFriendIdToClipboard(int friendId)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(friendId);
|
||||
|
|
|
@ -98,7 +98,6 @@ private slots:
|
|||
void onGroupMessageReceived(int groupnumber, const QString& message, const QString& author);
|
||||
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||
void removeFriend(int friendId);
|
||||
void clearFriends();
|
||||
void copyFriendIdToClipboard(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
void setStatusOnline();
|
||||
|
|
Loading…
Reference in New Issue
Block a user