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

Improve chat form performance

Should help with #266
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-09-12 21:38:38 +02:00
parent 983260e836
commit 7e577359fd
2 changed files with 6 additions and 7 deletions

View File

@ -20,6 +20,7 @@
#include <QDesktopServices>
#include <QTextTable>
#include <QAbstractTextDocumentLayout>
#include <QCoreApplication>
ChatAreaWidget::ChatAreaWidget(QWidget *parent) :
QTextBrowser(parent)
@ -104,15 +105,13 @@ void ChatAreaWidget::insertMessage(ChatAction *msgAction)
checkSlider();
int row = chatTextTable->rows() - 1;
// chatTextTable->cellAt(row,0).firstCursorPosition().setBlockFormat(nameFormat);
// chatTextTable->cellAt(row,2).firstCursorPosition().setBlockFormat(dateFormat);
QTextCursor cur = chatTextTable->cellAt(row,1).firstCursorPosition();
cur.clearSelection();
cur.setKeepPositionOnInsert(true);
chatTextTable->appendRows(1);
chatTextTable->cellAt(row,0).firstCursorPosition().insertHtml(msgAction->getName());
chatTextTable->cellAt(row,1).firstCursorPosition().insertHtml(msgAction->getMessage());
chatTextTable->cellAt(row,2).firstCursorPosition().insertHtml(msgAction->getDate());
chatTextTable->appendRows(1);
chatTextTable->cellAt(row,2).firstCursorPosition().insertText(msgAction->getDate());
msgAction->setTextCursor(cur);

View File

@ -43,14 +43,14 @@ QString ChatAction::QImage2base64(const QImage &img)
QString ChatAction::getName()
{
if (isMe)
return QString("<table width=100% cellspacing=0><tr><td align=right><div class=name_me>" + toHtmlChars(name) + "</div></td></tr></table>");
return QString("<div class=name_me>" + toHtmlChars(name) + "</div>");
else
return QString("<table width=100% cellspacing=0><tr><td align=right><div class=name>" + toHtmlChars(name) + "</div></td></tr></table>");
return QString("<div class=name>" + toHtmlChars(name) + "</div>");
}
QString ChatAction::getDate()
{
QString res = "<div class=date>" + date + "</div>";
QString res = date;
return res;
}