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

fix(chatlog): Don't delete active transfer widget

Fix #3275.
This commit is contained in:
Diadlo 2016-07-30 16:15:52 +03:00
parent 233cc412ac
commit abf7b42324
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 32 additions and 1 deletions

View File

@ -20,6 +20,8 @@
#include "chatlog.h"
#include "chatmessage.h"
#include "chatlinecontent.h"
#include "chatlinecontentproxy.h"
#include "content/filetransferwidget.h"
#include "src/widget/translator.h"
#include <QDebug>
@ -560,11 +562,20 @@ void ChatLog::clear()
{
clearSelection();
QVector<ChatLine::Ptr> savedLines;
for (ChatLine::Ptr l : lines)
l->removeFromScene();
{
if (isActiveFileTransfer(l))
savedLines.push_back(l);
else
l->removeFromScene();
}
lines.clear();
visibleLines.clear();
for (ChatLine::Ptr l : savedLines)
insertChatlineAtBottom(l);
updateSceneRect();
}
@ -850,3 +861,22 @@ void ChatLog::retranslateUi()
copyAction->setText(tr("Copy"));
selectAllAction->setText(tr("Select all"));
}
bool ChatLog::isActiveFileTransfer(ChatLine::Ptr l)
{
int count = l->getColumnCount();
for (int i = 0; i < count; i++)
{
ChatLineContent *content = l->getContent(i);
ChatLineContentProxy *proxy = dynamic_cast<ChatLineContentProxy*>(content);
if (!proxy)
continue;
QWidget *widget = proxy->getWidget();
FileTransferWidget *transferWidget = dynamic_cast<FileTransferWidget*>(widget);
if (transferWidget && transferWidget->isActive())
return true;
}
return false;
}

View File

@ -106,6 +106,7 @@ private slots:
private:
void retranslateUi();
bool isActiveFileTransfer(ChatLine::Ptr l);
private:
enum SelectionMode {