Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(chatlog): Don't delete active transfer widget
Browse files Browse the repository at this point in the history
Fix #3275.
  • Loading branch information
Diadlo committed Jul 31, 2016
1 parent 233cc41 commit abf7b42
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/chatlog/chatlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/chatlog/chatlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private slots:

private:
void retranslateUi();
bool isActiveFileTransfer(ChatLine::Ptr l);

private:
enum SelectionMode {
Expand Down

0 comments on commit abf7b42

Please sign in to comment.