Browse Source

refactor: Remove ChatForm creation from Friend

pull/4542/head
Diadlo 8 years ago
parent
commit
3473090ec1
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 7
      src/friend.cpp
  2. 2
      src/friend.h
  3. 5
      src/widget/widget.cpp
  4. 2
      src/widget/widget.h

7
src/friend.cpp

@ -37,8 +37,6 @@ Friend::Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlia @@ -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 @@ -142,3 +140,8 @@ ChatForm* Friend::getChatForm() const
{
return chatForm;
}
void Friend::setChatForm(ChatForm* form)
{
chatForm = form;
}

2
src/friend.h

@ -57,9 +57,9 @@ public: @@ -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);

5
src/widget/widget.cpp

@ -963,10 +963,11 @@ void Widget::addFriend(int friendId, const ToxPk& friendPk) @@ -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();

2
src/widget/widget.h

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

Loading…
Cancel
Save