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

refactor(groupwidget): Move updatTitle in GroupWidget

Also, remove unused now slot ContentDialog::updateGroupWidget
This commit is contained in:
Diadlo 2017-08-06 13:08:11 +03:00
parent 47cf113868
commit 1e90106a08
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 8 additions and 22 deletions

View File

@ -191,8 +191,6 @@ GroupWidget* ContentDialog::addGroup(int groupId, const QString& name)
groupLayout.addSortedWidget(groupWidget);
Group* group = groupWidget->getGroup();
connect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget);
connect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget);
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
connect(groupWidget, &FriendWidget::newWindowOpened, this, &ContentDialog::openNewDialog);
@ -244,11 +242,6 @@ void ContentDialog::removeGroup(int groupId)
{
Group* group = GroupList::findGroup(groupId);
if (group) {
disconnect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget);
disconnect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget);
}
auto iter = groupList.find(groupId);
if (iter == groupList.end()) {
return;
@ -752,20 +745,6 @@ void ContentDialog::updateFriendWidget(uint32_t friendId, QString alias)
friendLayout->addFriendWidget(friendWidget, status);
}
/**
* @brief Update group widget name and 'status'.
* @param groupId Id of group to update.
*/
void ContentDialog::updateGroupWidget(uint32_t groupId)
{
Group* g = GroupList::findGroup(groupId);
QString name = g->getName();
ContactInfo info = groupList.find(groupId).value();
GroupWidget* widget = static_cast<GroupWidget*>(std::get<1>(info));
widget->setName(name);
}
/**
* @brief Handler of `groupchatPositionChanged` action.
* Move group layout on the top or on the buttom.

View File

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

View File

@ -53,6 +53,7 @@ GroupWidget::GroupWidget(int groupId, const QString& name, bool compact)
setAcceptDrops(true);
Group* g = GroupList::findGroup(groupId);
connect(g, &Group::titleChanged, this, &GroupWidget::updateTitle);
connect(g, &Group::userListChanged, this, &GroupWidget::updateUserCount);
connect(nameLabel, &CroppingLabel::editFinished, this, &GroupWidget::setTitle);
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
@ -69,6 +70,12 @@ void GroupWidget::setTitle(const QString& newName)
g->setName(newName);
}
void GroupWidget::updateTitle(uint32_t groupId, const QString& newName)
{
Q_UNUSED(groupId);
nameLabel->setText(newName);
}
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
{
if (!active)

View File

@ -53,6 +53,7 @@ protected:
private slots:
void retranslateUi();
void setTitle(const QString& newName);
void updateTitle(uint32_t groupId, const QString& newName);
void updateUserCount();
public: