Browse Source

refactor: Remove using of remove{Friend,Group}

reviewable/pr5471/r3
Diadlo 7 years ago
parent
commit
2b3918b25e
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 27
      src/widget/contentdialogmanager.cpp
  2. 3
      src/widget/contentdialogmanager.h
  3. 2
      src/widget/friendwidget.cpp
  4. 2
      src/widget/groupwidget.cpp
  5. 5
      src/widget/widget.cpp

27
src/widget/contentdialogmanager.cpp

@ -83,33 +83,6 @@ GroupWidget* ContentDialogManager::addGroupToDialog(ContentDialog* dialog, @@ -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.

3
src/widget/contentdialogmanager.h

@ -43,9 +43,6 @@ public: @@ -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);

2
src/widget/friendwidget.cpp

@ -196,7 +196,7 @@ void FriendWidget::removeChatWindow() @@ -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 {

2
src/widget/groupwidget.cpp

@ -123,7 +123,7 @@ void GroupWidget::contextMenuEvent(QContextMenuEvent* event) @@ -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();
}

5
src/widget/widget.cpp

@ -1519,9 +1519,8 @@ void Widget::removeFriend(Friend* f, bool fake) @@ -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) @@ -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…
Cancel
Save