1
0
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:
Diadlo 2018-12-24 21:36:46 +03:00
parent ee5a7d8e94
commit 2b3918b25e
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
5 changed files with 4 additions and 35 deletions

View File

@ -83,33 +83,6 @@ GroupWidget* ContentDialogManager::addGroupToDialog(ContentDialog* dialog,
return groupWidget; 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. * @brief Check, if widget is exists.
* @param id User Id. * @param id User Id.

View File

@ -43,9 +43,6 @@ public:
ContentDialog* getFriendDialog(int friendId) const; ContentDialog* getFriendDialog(int friendId) const;
ContentDialog* getGroupDialog(int groupId) 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); FriendWidget* addFriendToDialog(ContentDialog* dialog, std::shared_ptr<FriendChatroom> chatroom, GenericChatForm* form);
GroupWidget* addGroupToDialog(ContentDialog* dialog, std::shared_ptr<GroupChatroom> chatroom, GenericChatForm* form); GroupWidget* addGroupToDialog(ContentDialog* dialog, std::shared_ptr<GroupChatroom> chatroom, GenericChatForm* form);

View File

@ -196,7 +196,7 @@ void FriendWidget::removeChatWindow()
const auto frnd = chatroom->getFriend(); const auto frnd = chatroom->getFriend();
const auto friendId = frnd->getId(); const auto friendId = frnd->getId();
ContentDialog* contentDialog = ContentDialogManager::getInstance()->getFriendDialog(friendId); ContentDialog* contentDialog = ContentDialogManager::getInstance()->getFriendDialog(friendId);
ContentDialogManager::getInstance()->removeFriend(friendId); contentDialog->removeFriend(friendId);
} }
namespace { namespace {

View File

@ -123,7 +123,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
} else if (selectedItem == removeChatWindow) { } else if (selectedItem == removeChatWindow) {
// TODO: move to model // TODO: move to model
ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId); ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId);
ContentDialogManager::getInstance()->removeGroup(groupId); contentDialog->removeGroup(groupId);
} else if (selectedItem == setTitle) { } else if (selectedItem == setTitle) {
editName(); editName();
} }

View File

@ -1519,9 +1519,8 @@ void Widget::removeFriend(Friend* f, bool fake)
contactListWidget->removeFriendWidget(widget); contactListWidget->removeFriendWidget(widget);
ContentDialog* lastDialog = ContentDialogManager::getInstance()->getFriendDialog(friendId); ContentDialog* lastDialog = ContentDialogManager::getInstance()->getFriendDialog(friendId);
if (lastDialog != nullptr) { if (lastDialog != nullptr) {
ContentDialogManager::getInstance()->removeFriend(friendId); lastDialog->removeFriend(friendId);
} }
FriendList::removeFriend(friendId, fake); FriendList::removeFriend(friendId, fake);
@ -1842,7 +1841,7 @@ void Widget::removeGroup(Group* g, bool fake)
GroupList::removeGroup(groupId, fake); GroupList::removeGroup(groupId, fake);
ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId); ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId);
if (contentDialog != nullptr) { if (contentDialog != nullptr) {
ContentDialogManager::getInstance()->removeGroup(groupId); contentDialog->removeGroup(groupId);
} }
Nexus::getCore()->removeGroup(groupId, fake); Nexus::getCore()->removeGroup(groupId, fake);