1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(group): Don't pass widget on model change

This commit is contained in:
Diadlo 2017-08-02 23:45:43 +03:00
parent 9495a411cb
commit 11e75104f4
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 12 additions and 11 deletions

View File

@ -64,13 +64,13 @@ void Group::updatePeer(int peerId, QString name)
} else { } else {
widget->onUserListChanged(); widget->onUserListChanged();
chatForm->onUserListChanged(); chatForm->onUserListChanged();
emit userListChanged(getGroupWidget()); emit userListChanged(groupId, toxids);
} }
} }
void Group::setName(const QString& name) void Group::setName(const QString& name)
{ {
emit titleChanged(this->getGroupWidget()); emit titleChanged(groupId, name);
} }
QString Group::getName() const QString Group::getName() const
@ -110,7 +110,7 @@ void Group::regeneratePeerList()
widget->onUserListChanged(); widget->onUserListChanged();
chatForm->onUserListChanged(); chatForm->onUserListChanged();
emit userListChanged(getGroupWidget()); emit userListChanged(groupId, toxids);
} }
bool Group::isAvGroupchat() const bool Group::isAvGroupchat() const

View File

@ -63,8 +63,8 @@ public:
QString resolveToxId(const ToxPk& id) const; QString resolveToxId(const ToxPk& id) const;
signals: signals:
void titleChanged(GroupWidget* widget); void titleChanged(uint32_t groupId, const QString& title);
void userListChanged(GroupWidget* widget); void userListChanged(uint32_t groupId, const QMap<QByteArray, QString>& toxids);
private: private:
GroupWidget* widget; GroupWidget* widget;

View File

@ -754,14 +754,15 @@ void ContentDialog::updateFriendWidget(uint32_t friendId, QString alias)
/** /**
* @brief Update group widget name and 'status'. * @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(); Group* g = GroupList::findGroup(groupId);
GroupWidget* widget = static_cast<GroupWidget*>(std::get<1>(info)); QString name = g->getName();
QString name = w->getName(); ContactInfo info = groupList.find(groupId).value();
GroupWidget* widget = static_cast<GroupWidget*>(std::get<1>(info));
widget->setName(name); widget->setName(name);
widget->onUserListChanged(); widget->onUserListChanged();
} }

View File

@ -103,7 +103,7 @@ private slots:
void activate(GenericChatroomWidget* widget); void activate(GenericChatroomWidget* widget);
void openNewDialog(GenericChatroomWidget* widget); void openNewDialog(GenericChatroomWidget* widget);
void updateFriendWidget(uint32_t friendId, QString alias); void updateFriendWidget(uint32_t friendId, QString alias);
void updateGroupWidget(GroupWidget* w); void updateGroupWidget(uint32_t groupId);
void onGroupchatPositionChanged(bool top); void onGroupchatPositionChanged(bool top);
private: private: