From 11e75104f4af97f967337553f13c780672e1172c Mon Sep 17 00:00:00 2001 From: Diadlo Date: Wed, 2 Aug 2017 23:45:43 +0300 Subject: [PATCH] refactor(group): Don't pass widget on model change --- src/model/group.cpp | 6 +++--- src/model/group.h | 4 ++-- src/widget/contentdialog.cpp | 11 ++++++----- src/widget/contentdialog.h | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/model/group.cpp b/src/model/group.cpp index 207bbe869..2cdad5e4b 100644 --- a/src/model/group.cpp +++ b/src/model/group.cpp @@ -64,13 +64,13 @@ void Group::updatePeer(int peerId, QString name) } else { widget->onUserListChanged(); chatForm->onUserListChanged(); - emit userListChanged(getGroupWidget()); + emit userListChanged(groupId, toxids); } } void Group::setName(const QString& name) { - emit titleChanged(this->getGroupWidget()); + emit titleChanged(groupId, name); } QString Group::getName() const @@ -110,7 +110,7 @@ void Group::regeneratePeerList() widget->onUserListChanged(); chatForm->onUserListChanged(); - emit userListChanged(getGroupWidget()); + emit userListChanged(groupId, toxids); } bool Group::isAvGroupchat() const diff --git a/src/model/group.h b/src/model/group.h index 29b37cf84..8b0be6056 100644 --- a/src/model/group.h +++ b/src/model/group.h @@ -63,8 +63,8 @@ public: QString resolveToxId(const ToxPk& id) const; signals: - void titleChanged(GroupWidget* widget); - void userListChanged(GroupWidget* widget); + void titleChanged(uint32_t groupId, const QString& title); + void userListChanged(uint32_t groupId, const QMap& toxids); private: GroupWidget* widget; diff --git a/src/widget/contentdialog.cpp b/src/widget/contentdialog.cpp index 554385eee..406b1a167 100644 --- a/src/widget/contentdialog.cpp +++ b/src/widget/contentdialog.cpp @@ -754,14 +754,15 @@ void ContentDialog::updateFriendWidget(uint32_t friendId, QString alias) /** * @brief Update group widget name and 'status'. - * @param w Group widget to update. + * @param groupId Id of group to update. */ -void ContentDialog::updateGroupWidget(GroupWidget* w) +void ContentDialog::updateGroupWidget(uint32_t groupId) { - ContactInfo info = groupList.find(w->groupId).value(); - GroupWidget* widget = static_cast(std::get<1>(info)); + Group* g = GroupList::findGroup(groupId); + QString name = g->getName(); - QString name = w->getName(); + ContactInfo info = groupList.find(groupId).value(); + GroupWidget* widget = static_cast(std::get<1>(info)); widget->setName(name); widget->onUserListChanged(); } diff --git a/src/widget/contentdialog.h b/src/widget/contentdialog.h index c786affd2..7de1e35ea 100644 --- a/src/widget/contentdialog.h +++ b/src/widget/contentdialog.h @@ -103,7 +103,7 @@ private slots: void activate(GenericChatroomWidget* widget); void openNewDialog(GenericChatroomWidget* widget); void updateFriendWidget(uint32_t friendId, QString alias); - void updateGroupWidget(GroupWidget* w); + void updateGroupWidget(uint32_t groupId); void onGroupchatPositionChanged(bool top); private: