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

refactor: Pass Friend in ContentDialog::addFriend

friendId and name (old parameters) can be getted from Friend
This commit is contained in:
Diadlo 2017-07-26 12:39:54 +03:00
parent 90a262e9b5
commit 1a0a1d6949
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 9 additions and 8 deletions

View File

@ -120,7 +120,7 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
if (friendWidget != nullptr) {
Friend* f = friendWidget->getFriend();
dialog->addFriend(friendWidget->friendId, f->getDisplayedName());
dialog->addFriend(f);
}
}
for (int i = 0; i < friendOfflineLayout()->count(); ++i) {
@ -129,7 +129,7 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
if (friendWidget != nullptr) {
Friend* f = friendWidget->getFriend();
dialog->addFriend(friendWidget->friendId, f->getDisplayedName());
dialog->addFriend(f);
}
}

View File

@ -161,11 +161,12 @@ ContentDialog::~ContentDialog()
Translator::unregister(this);
}
FriendWidget* ContentDialog::addFriend(int friendId, QString id)
FriendWidget* ContentDialog::addFriend(Friend* frnd)
{
bool compact = Settings::getInstance().getCompactLayout();
FriendWidget* friendWidget = new FriendWidget(friendId, id, compact);
Friend* frnd = friendWidget->getFriend();
uint32_t friendId = frnd->getFriendId();
QString name = frnd->getDisplayedName();
FriendWidget* friendWidget = new FriendWidget(friendId, name, compact);
friendLayout->addFriendWidget(friendWidget, frnd->getStatus());
ChatForm* form = frnd->getChatForm();

View File

@ -52,7 +52,7 @@ public:
ContentDialog(SettingsWidget* settingsWidget, QWidget* parent = 0);
~ContentDialog();
FriendWidget* addFriend(int friendId, QString id);
FriendWidget* addFriend(Friend* f);
GroupWidget* addGroup(int groupId, const QString& name);
void removeFriend(int friendId);
void removeGroup(int groupId);

View File

@ -961,9 +961,9 @@ void Widget::onCallEnd(uint32_t friendId)
void Widget::addFriend(int friendId, const ToxPk& friendPk)
{
Friend* newfriend = FriendList::addFriend(friendId, friendPk);
QString name = newfriend->getDisplayedName();
bool compact = Settings::getInstance().getCompactLayout();
FriendWidget* widget = new FriendWidget(friendId, name, compact);
ChatForm* friendForm = newfriend->getChatForm();
@ -1208,7 +1208,7 @@ void Widget::addFriendDialog(Friend* frnd, ContentDialog* dialog)
onAddClicked();
}
FriendWidget* friendWidget = dialog->addFriend(frnd->getFriendId(), frnd->getDisplayedName());
FriendWidget* friendWidget = dialog->addFriend(frnd);
friendWidget->setStatusMsg(widget->getStatusMsg());