Browse Source

Improve chat form performance

Should help with #266
pull/292/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
7e577359fd
  1. 7
      widget/chatareawidget.cpp
  2. 6
      widget/tool/chataction.cpp

7
widget/chatareawidget.cpp

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

6
widget/tool/chataction.cpp

@ -43,14 +43,14 @@ QString ChatAction::QImage2base64(const QImage &img)
QString ChatAction::getName() QString ChatAction::getName()
{ {
if (isMe) 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 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 ChatAction::getDate()
{ {
QString res = "<div class=date>" + date + "</div>"; QString res = date;
return res; return res;
} }

Loading…
Cancel
Save