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

remove duplicate code

This commit is contained in:
dubslow 2014-09-28 12:57:27 -05:00
parent c05497b420
commit 7735973d94
4 changed files with 2 additions and 27 deletions

View File

@ -1014,7 +1014,7 @@ void Core::loadFriends()
if (nameSize > 0) {
uint8_t *name = new uint8_t[nameSize];
if (tox_get_name(tox, ids[i], name) == nameSize) {
emit friendUsernameLoaded(ids[i], CString::toString(name, nameSize));
emit friendUsernameChanged(ids[i], CString::toString(name, nameSize));
}
delete[] name;
}
@ -1023,7 +1023,7 @@ void Core::loadFriends()
if (statusMessageSize > 0) {
uint8_t *statusMessage = new uint8_t[statusMessageSize];
if (tox_get_status_message(tox, ids[i], statusMessage, statusMessageSize) == statusMessageSize) {
emit friendStatusMessageLoaded(ids[i], CString::toString(statusMessage, statusMessageSize));
emit friendStatusMessageChanged(ids[i], CString::toString(statusMessage, statusMessageSize));
}
delete[] statusMessage;
}

3
core.h
View File

@ -109,9 +109,6 @@ signals:
void friendAvatarChanged(int friendId, const QPixmap& pic);
void friendAvatarRemoved(int friendId);
void friendStatusMessageLoaded(int friendId, const QString& message);
void friendUsernameLoaded(int friendId, const QString& username);
void friendAddressGenerated(const QString& friendAddress);
void friendRemoved(int friendId);

View File

@ -198,8 +198,6 @@ Widget::Widget(QWidget *parent)
connect(core, &Core::friendUsernameChanged, this, &Widget::onFriendUsernameChanged);
connect(core, &Core::friendStatusChanged, this, &Widget::onFriendStatusChanged);
connect(core, &Core::friendStatusMessageChanged, this, &Widget::onFriendStatusMessageChanged);
connect(core, &Core::friendUsernameLoaded, this, &Widget::onFriendUsernameLoaded);
connect(core, &Core::friendStatusMessageLoaded, this, &Widget::onFriendStatusMessageLoaded);
connect(core, &Core::friendRequestReceived, this, &Widget::onFriendRequestReceived);
connect(core, &Core::friendMessageReceived, this, &Widget::onFriendMessageReceived);
connect(core, &Core::groupInviteReceived, this, &Widget::onGroupInviteReceived);
@ -525,24 +523,6 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username)
f->setName(username);
}
void Widget::onFriendStatusMessageLoaded(int friendId, const QString& message)
{
Friend* f = FriendList::findFriend(friendId);
if (!f)
return;
f->setStatusMessage(message);
}
void Widget::onFriendUsernameLoaded(int friendId, const QString& username)
{
Friend* f = FriendList::findFriend(friendId);
if (!f)
return;
f->setName(username);
}
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
{
hideMainForms();

View File

@ -92,8 +92,6 @@ private slots:
void onFriendStatusChanged(int friendId, Status status);
void onFriendStatusMessageChanged(int friendId, const QString& message);
void onFriendUsernameChanged(int friendId, const QString& username);
void onFriendStatusMessageLoaded(int friendId, const QString& message);
void onFriendUsernameLoaded(int friendId, const QString& username);
void onChatroomWidgetClicked(GenericChatroomWidget *);
void onFriendMessageReceived(int friendId, const QString& message);
void onFriendRequestReceived(const QString& userId, const QString& message);