mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Remove Friend::getChatForm usage from Widget
This commit is contained in:
parent
3473090ec1
commit
72bb70aa74
|
@ -921,7 +921,7 @@ void Widget::reloadHistory()
|
|||
{
|
||||
QDateTime weekAgo = QDateTime::currentDateTime().addDays(-7);
|
||||
for (auto f : FriendList::getAllFriends()) {
|
||||
f->getChatForm()->loadHistory(weekAgo, true);
|
||||
chatForms[f->getFriendId()]->loadHistory(weekAgo, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1061,7 @@ void Widget::onFriendStatusMessageChanged(int friendId, const QString& message)
|
|||
f->setStatusMessage(str);
|
||||
|
||||
friendWidgets[friendId]->setStatusMsg(str);
|
||||
f->getChatForm()->setStatusMessage(str);
|
||||
chatForms[friendId]->setStatusMessage(str);
|
||||
|
||||
ContentDialog::updateFriendStatusMessage(friendId, message);
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ void Widget::onFriendAliasChanged(uint32_t friendId, const QString& alias)
|
|||
bool filter = s == Status::Offline ? filterOffline(criteria) : filterOnline(criteria);
|
||||
friendWidget->searchName(ui->searchContactText->text(), filter);
|
||||
|
||||
ChatForm* friendForm = f->getChatForm();
|
||||
ChatForm* friendForm = chatForms[friendId];
|
||||
friendForm->setName(alias);
|
||||
for (Group* g : GroupList::getAllGroups()) {
|
||||
g->regeneratePeerList();
|
||||
|
@ -1119,10 +1119,10 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
|
|||
|
||||
uint32_t id;
|
||||
GenericChatForm* form;
|
||||
if (widget->getFriend()) {
|
||||
const Friend* f = widget->getFriend();
|
||||
form = f->getChatForm();
|
||||
id = f->getFriendId();
|
||||
const Friend* frnd = widget->getFriend();
|
||||
if (frnd) {
|
||||
form = chatForms[frnd->getFriendId()];
|
||||
id = frnd->getFriendId();
|
||||
} else {
|
||||
Group* g = widget->getGroup();
|
||||
form = g->getChatForm();
|
||||
|
@ -1147,9 +1147,8 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
|
|||
}
|
||||
|
||||
dialog->show();
|
||||
const Friend* frnd = widget->getFriend();
|
||||
|
||||
if (frnd != nullptr) {
|
||||
if (frnd) {
|
||||
addFriendDialog(frnd, dialog);
|
||||
} else {
|
||||
Group* group = widget->getGroup();
|
||||
|
@ -1160,7 +1159,11 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow)
|
|||
dialog->activateWindow();
|
||||
} else {
|
||||
hideMainForms(widget);
|
||||
widget->setChatForm(contentLayout);
|
||||
if (frnd) {
|
||||
chatForms[frnd->getFriendId()]->show(contentLayout);
|
||||
} else {
|
||||
widget->setChatForm(contentLayout);
|
||||
}
|
||||
widget->setAsActiveChatroom();
|
||||
setWindowTitle(widget->getTitle());
|
||||
}
|
||||
|
@ -1195,7 +1198,7 @@ void Widget::onReceiptRecieved(int friendId, int receipt)
|
|||
return;
|
||||
}
|
||||
|
||||
f->getChatForm()->getOfflineMsgEngine()->dischargeReceipt(receipt);
|
||||
chatForms[friendId]->getOfflineMsgEngine()->dischargeReceipt(receipt);
|
||||
}
|
||||
|
||||
void Widget::addFriendDialog(const Friend* frnd, ContentDialog* dialog)
|
||||
|
@ -2021,7 +2024,7 @@ void Widget::onFriendTypingChanged(int friendId, bool isTyping)
|
|||
return;
|
||||
}
|
||||
|
||||
f->getChatForm()->setFriendTyping(isTyping);
|
||||
chatForms[friendId]->setFriendTyping(isTyping);
|
||||
}
|
||||
|
||||
void Widget::onSetShowSystemTray(bool newValue)
|
||||
|
@ -2094,7 +2097,7 @@ void Widget::processOfflineMsgs()
|
|||
if (OfflineMsgEngine::globalMutex.tryLock()) {
|
||||
QList<Friend*> frnds = FriendList::getAllFriends();
|
||||
for (Friend* f : frnds) {
|
||||
f->getChatForm()->getOfflineMsgEngine()->deliverOfflineMsgs();
|
||||
chatForms[f->getFriendId()]->getOfflineMsgEngine()->deliverOfflineMsgs();
|
||||
}
|
||||
|
||||
OfflineMsgEngine::globalMutex.unlock();
|
||||
|
@ -2105,7 +2108,7 @@ void Widget::clearAllReceipts()
|
|||
{
|
||||
QList<Friend*> frnds = FriendList::getAllFriends();
|
||||
for (Friend* f : frnds) {
|
||||
f->getChatForm()->getOfflineMsgEngine()->removeAllReceipts();
|
||||
chatForms[f->getFriendId()]->getOfflineMsgEngine()->removeAllReceipts();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2426,7 +2429,7 @@ void Widget::focusChatInput()
|
|||
{
|
||||
if (activeChatroomWidget) {
|
||||
if (const Friend* f = activeChatroomWidget->getFriend()) {
|
||||
f->getChatForm()->focusInput();
|
||||
chatForms[f->getFriendId()]->focusInput();
|
||||
} else if (Group* g = activeChatroomWidget->getGroup()) {
|
||||
g->getChatForm()->focusInput();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user