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

moved history loading to FriendWidget::setAsActiveChatroom()

This commit is contained in:
krepa098 2015-01-07 13:16:09 +01:00
parent debe6903a3
commit 0f52bf3f5c
3 changed files with 12 additions and 3 deletions

View File

@ -40,6 +40,7 @@
FriendWidget::FriendWidget(int FriendId, QString id)
: friendId(FriendId)
, isDefaultAvatar{true}
, historyLoaded{false}
{
avatar->setPixmap(QPixmap(":img/contact.png"), Qt::transparent);
statusPic.setPixmap(QPixmap(":img/status/dot_away.png"));
@ -126,6 +127,16 @@ void FriendWidget::setAsActiveChatroom()
if (isDefaultAvatar)
avatar->setPixmap(QPixmap(":img/contact_dark.png"), Qt::transparent);
if(!historyLoaded)
{
Friend* f = FriendList::findFriend(friendId);
if (Settings::getInstance().getEnableLogging())
{
f->getChatForm()->loadHistory(QDateTime::currentDateTime().addDays(-7), true);
historyLoaded = true;
}
}
}
void FriendWidget::setAsInactiveChatroom()

View File

@ -54,6 +54,7 @@ protected:
public:
int friendId;
bool isDefaultAvatar;
bool historyLoaded;
QPoint dragStartPos;
};

View File

@ -663,9 +663,6 @@ void Widget::addFriend(int friendId, const QString &userId)
QLayout* layout = contactListWidget->getFriendLayout(Status::Offline);
layout->addWidget(newfriend->getFriendWidget());
if (Settings::getInstance().getEnableLogging())
newfriend->getChatForm()->loadHistory(QDateTime::currentDateTime().addDays(-7), true);
connect(newfriend->getFriendWidget(), SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), this, SLOT(onChatroomWidgetClicked(GenericChatroomWidget*)));
connect(newfriend->getFriendWidget(), SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
connect(newfriend->getFriendWidget(), SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));