mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Remove using of remove{Friend,Group}
This commit is contained in:
parent
ee5a7d8e94
commit
2b3918b25e
|
@ -83,33 +83,6 @@ GroupWidget* ContentDialogManager::addGroupToDialog(ContentDialog* dialog,
|
|||
return groupWidget;
|
||||
}
|
||||
|
||||
// TODO: Remove method. Move logic in ContentDialog
|
||||
void ContentDialogManager::removeFriend(int friendId)
|
||||
{
|
||||
auto iter = friendList.find(friendId);
|
||||
if (iter == friendList.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto friendWidget = static_cast<FriendWidget*>(std::get<1>(iter.value()));
|
||||
auto dialog = getFriendDialog(friendId);
|
||||
dialog->removeFriend(friendId);
|
||||
friendList.remove(friendId);
|
||||
}
|
||||
|
||||
void ContentDialogManager::removeGroup(int groupId)
|
||||
{
|
||||
auto iter = friendList.find(groupId);
|
||||
if (iter == friendList.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto groupWidget = static_cast<GroupWidget*>(std::get<1>(iter.value()));
|
||||
auto dialog = getGroupDialog(groupId);
|
||||
dialog->removeGroup(groupId);
|
||||
groupList.remove(groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check, if widget is exists.
|
||||
* @param id User Id.
|
||||
|
|
|
@ -43,9 +43,6 @@ public:
|
|||
ContentDialog* getFriendDialog(int friendId) const;
|
||||
ContentDialog* getGroupDialog(int groupId) const;
|
||||
|
||||
void removeFriend(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
|
||||
FriendWidget* addFriendToDialog(ContentDialog* dialog, std::shared_ptr<FriendChatroom> chatroom, GenericChatForm* form);
|
||||
GroupWidget* addGroupToDialog(ContentDialog* dialog, std::shared_ptr<GroupChatroom> chatroom, GenericChatForm* form);
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ void FriendWidget::removeChatWindow()
|
|||
const auto frnd = chatroom->getFriend();
|
||||
const auto friendId = frnd->getId();
|
||||
ContentDialog* contentDialog = ContentDialogManager::getInstance()->getFriendDialog(friendId);
|
||||
ContentDialogManager::getInstance()->removeFriend(friendId);
|
||||
contentDialog->removeFriend(friendId);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -123,7 +123,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
|||
} else if (selectedItem == removeChatWindow) {
|
||||
// TODO: move to model
|
||||
ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId);
|
||||
ContentDialogManager::getInstance()->removeGroup(groupId);
|
||||
contentDialog->removeGroup(groupId);
|
||||
} else if (selectedItem == setTitle) {
|
||||
editName();
|
||||
}
|
||||
|
|
|
@ -1519,9 +1519,8 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||
contactListWidget->removeFriendWidget(widget);
|
||||
|
||||
ContentDialog* lastDialog = ContentDialogManager::getInstance()->getFriendDialog(friendId);
|
||||
|
||||
if (lastDialog != nullptr) {
|
||||
ContentDialogManager::getInstance()->removeFriend(friendId);
|
||||
lastDialog->removeFriend(friendId);
|
||||
}
|
||||
|
||||
FriendList::removeFriend(friendId, fake);
|
||||
|
@ -1842,7 +1841,7 @@ void Widget::removeGroup(Group* g, bool fake)
|
|||
GroupList::removeGroup(groupId, fake);
|
||||
ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId);
|
||||
if (contentDialog != nullptr) {
|
||||
ContentDialogManager::getInstance()->removeGroup(groupId);
|
||||
contentDialog->removeGroup(groupId);
|
||||
}
|
||||
|
||||
Nexus::getCore()->removeGroup(groupId, fake);
|
||||
|
|
Loading…
Reference in New Issue
Block a user