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

refactor: Remove ChatForm creation from Friend

This commit is contained in:
Diadlo 2017-05-07 23:53:39 +03:00
parent ad58c1767b
commit 3473090ec1
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 11 additions and 5 deletions

View File

@ -37,8 +37,6 @@ Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlia
if (userName.isEmpty()) {
userName = friendPk.toString();
}
chatForm = new ChatForm(this);
}
Friend::~Friend()
@ -142,3 +140,8 @@ ChatForm* Friend::getChatForm() const
{
return chatForm;
}
void Friend::setChatForm(ChatForm* form)
{
chatForm = form;
}

View File

@ -57,9 +57,9 @@ public:
Status getStatus() const;
ChatForm* getChatForm() const;
void setChatForm(ChatForm* form);
signals:
// TODO: move signals to DB object
void nameChanged(uint32_t friendId, const QString& name);
void aliasChanged(uint32_t friendId, QString alias);
void statusChanged(uint32_t friendId, Status status);

View File

@ -963,10 +963,11 @@ void Widget::addFriend(int friendId, const ToxPk& friendPk)
Friend* newfriend = FriendList::addFriend(friendId, friendPk);
bool compact = Settings::getInstance().getCompactLayout();
FriendWidget* widget = new FriendWidget(newfriend, compact);
ChatForm* friendForm = newfriend->getChatForm();
ChatForm* friendForm = new ChatForm(newfriend);
newfriend->setChatForm(friendForm);
friendWidgets[friendId] = widget;
chatForms[friendId] = friendForm;
newfriend->loadHistory();
const Settings& s = Settings::getInstance();

View File

@ -38,6 +38,7 @@ namespace Ui {
class MainWindow;
}
class ChatForm;
class GenericChatroomWidget;
class FriendWidget;
class Group;
@ -293,6 +294,7 @@ private:
int icon_size;
QMap<int, FriendWidget*> friendWidgets;
QMap<int, ChatForm*> chatForms;
#ifdef Q_OS_MAC
QAction* fileMenu;