From 4fee43cdeda634554c3a0fa670216d72e27ed28c Mon Sep 17 00:00:00 2001 From: Diadlo Date: Thu, 3 Aug 2017 00:00:30 +0300 Subject: [PATCH] refactor(group): Replace 'renameRequest' signal on Group::titleChanged --- src/widget/friendlistwidget.cpp | 9 +++++++-- src/widget/groupwidget.cpp | 1 - src/widget/groupwidget.h | 1 - 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widget/friendlistwidget.cpp b/src/widget/friendlistwidget.cpp index e88df70a7..6a5a4bf7c 100644 --- a/src/widget/friendlistwidget.cpp +++ b/src/widget/friendlistwidget.cpp @@ -23,8 +23,9 @@ #include "friendwidget.h" #include "groupwidget.h" #include "widget.h" -#include "src/model/friend.h" #include "src/friendlist.h" +#include "src/model/friend.h" +#include "src/model/group.h" #include "src/persistence/settings.h" #include #include @@ -279,7 +280,11 @@ FriendListWidget::Mode FriendListWidget::getMode() const void FriendListWidget::addGroupWidget(GroupWidget* widget) { groupLayout.addSortedWidget(widget); - connect(widget, &GroupWidget::renameRequested, this, &FriendListWidget::renameGroupWidget); + Group* g = widget->getGroup(); + connect(g, &Group::titleChanged, [=](uint32_t groupId, const QString& name) { + Q_UNUSED(groupId); + renameGroupWidget(widget, name); + }); } void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleIndex) diff --git a/src/widget/groupwidget.cpp b/src/widget/groupwidget.cpp index 0a428df13..20ffc8191 100644 --- a/src/widget/groupwidget.cpp +++ b/src/widget/groupwidget.cpp @@ -66,7 +66,6 @@ void GroupWidget::setTitle(const QString& newName) if (!newName.isEmpty()) { Group* g = GroupList::findGroup(groupId); g->setName(newName); - emit renameRequested(this, newName); emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128)); } } diff --git a/src/widget/groupwidget.h b/src/widget/groupwidget.h index 12ad44e60..afb6552e5 100644 --- a/src/widget/groupwidget.h +++ b/src/widget/groupwidget.h @@ -41,7 +41,6 @@ public: signals: void groupWidgetClicked(GroupWidget* widget); - void renameRequested(GroupWidget* widget, const QString& newName); void removeGroup(int groupId); protected: