mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Remove using 'Group::getChatForm'
This commit is contained in:
parent
f6bb71db93
commit
0586e65e72
|
@ -183,11 +183,14 @@ FriendWidget* ContentDialog::addFriend(const Friend* frnd, GenericChatForm* form
|
|||
return friendWidget;
|
||||
}
|
||||
|
||||
GroupWidget* ContentDialog::addGroup(int groupId, const QString& name)
|
||||
GroupWidget* ContentDialog::addGroup(const Group* g, GenericChatForm* form)
|
||||
{
|
||||
bool compact = Settings::getInstance().getCompactLayout();
|
||||
const auto groupId = g->getId();
|
||||
const auto name = g->getName();
|
||||
const auto compact = Settings::getInstance().getCompactLayout();
|
||||
GroupWidget* groupWidget = new GroupWidget(groupId, name, compact);
|
||||
groupLayout.addSortedWidget(groupWidget);
|
||||
groupChatForms[groupId] = form;
|
||||
|
||||
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
|
||||
connect(groupWidget, &FriendWidget::newWindowOpened, this, &ContentDialog::openNewDialog);
|
||||
|
@ -719,11 +722,11 @@ void ContentDialog::activate(GenericChatroomWidget* widget)
|
|||
|
||||
const FriendWidget* const friendWidget = qobject_cast<FriendWidget*>(widget);
|
||||
if (friendWidget) {
|
||||
uint32_t friendId = friendWidget->getFriend()->getId();
|
||||
auto friendId = friendWidget->getFriend()->getId();
|
||||
friendChatForms[friendId]->show(contentLayout);
|
||||
} else {
|
||||
GroupWidget* const groupWidget = qobject_cast<GroupWidget*>(widget);
|
||||
groupWidget->setChatForm(contentLayout);
|
||||
auto groupId = widget->getGroup()->getId();
|
||||
groupChatForms[groupId]->show(contentLayout);
|
||||
}
|
||||
|
||||
widget->setAsActiveChatroom();
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
~ContentDialog() override;
|
||||
|
||||
FriendWidget* addFriend(const Friend* f, GenericChatForm* form);
|
||||
GroupWidget* addGroup(int groupId, const QString& name);
|
||||
GroupWidget* addGroup(const Group* g, GenericChatForm* form);
|
||||
void removeFriend(int friendId);
|
||||
void removeGroup(int groupId);
|
||||
bool hasFriendWidget(int friendId, const GenericChatroomWidget* chatroomWidget) const;
|
||||
|
@ -134,6 +134,7 @@ private:
|
|||
static QHash<int, ContactInfo> friendList;
|
||||
static QHash<int, ContactInfo> groupList;
|
||||
QHash<int, GenericChatForm*> friendChatForms;
|
||||
QHash<int, GenericChatForm*> groupChatForms;
|
||||
};
|
||||
|
||||
#endif // CONTENTDIALOG_H
|
||||
|
|
|
@ -207,12 +207,6 @@ Group* GroupWidget::getGroup() const
|
|||
return GroupList::findGroup(groupId);
|
||||
}
|
||||
|
||||
void GroupWidget::setChatForm(ContentLayout* contentLayout)
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->getChatForm()->show(contentLayout);
|
||||
}
|
||||
|
||||
void GroupWidget::resetEventFlags()
|
||||
{
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
|
|
|
@ -34,7 +34,6 @@ public:
|
|||
void resetEventFlags() final override;
|
||||
QString getStatusString() const final override;
|
||||
Group* getGroup() const final override;
|
||||
void setChatForm(ContentLayout* contentLayout);
|
||||
void setName(const QString& name);
|
||||
void editName();
|
||||
|
||||
|
|
|
@ -1138,12 +1138,12 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
|
|||
uint32_t id;
|
||||
GenericChatForm* form;
|
||||
const Friend* frnd = widget->getFriend();
|
||||
const Group* group = widget->getGroup();
|
||||
if (frnd) {
|
||||
id = frnd->getId();
|
||||
form = chatForms[id];
|
||||
} else {
|
||||
Group* g = widget->getGroup();
|
||||
id = g->getId();
|
||||
id = group->getId();
|
||||
form = groupChatForms[id];
|
||||
}
|
||||
|
||||
|
@ -1187,8 +1187,7 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
|
|||
if (frnd) {
|
||||
chatForms[frnd->getId()]->show(contentLayout);
|
||||
} else {
|
||||
GroupWidget* const groupWidget = qobject_cast<GroupWidget*>(widget);
|
||||
groupWidget->setChatForm(contentLayout);
|
||||
groupChatForms[group->getId()]->show(contentLayout);
|
||||
}
|
||||
widget->setAsActiveChatroom();
|
||||
setWindowTitle(widget->getTitle());
|
||||
|
@ -1287,9 +1286,9 @@ void Widget::addGroupDialog(Group* group, ContentDialog* dialog)
|
|||
onAddClicked();
|
||||
}
|
||||
|
||||
GroupWidget* groupWidget = dialog->addGroup(groupId, group->getName());
|
||||
connect(groupWidget, SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||
auto chatForm = groupChatForms[groupId];
|
||||
GroupWidget* groupWidget = dialog->addGroup(group, chatForm);
|
||||
connect(groupWidget, SIGNAL(removeGroup(int)), this, SLOT(removeGroup(int)));
|
||||
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, chatForm, &GroupChatForm::focusInput);
|
||||
|
||||
// Signal transmission from the created `groupWidget` (which shown in
|
||||
|
|
Loading…
Reference in New Issue
Block a user