* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
+#include <QDebug>
+#include <QtGui>
+#include "chatwidget.h"
+
+ChatWidget::ChatWidget(QWidget *parent) : QTextEdit(parent) {
+
+}
+
+void ChatWidget::setContents(QList<ChatLine *> lines) {
+ clear();
+ appendChatLines(lines);
+
+}
+
+void ChatWidget::prependMsg(AbstractUiMsg *msg) {
+ ChatLine *line = dynamic_cast<ChatLine*>(msg);
+ Q_ASSERT(line);
+ prependChatLine(line);
+}
+
+void ChatWidget::appendMsg(AbstractUiMsg *msg) {
+ ChatLine *line = dynamic_cast<ChatLine*>(msg);
+ Q_ASSERT(line);
+ appendChatLine(line);
+}
+
+void ChatWidget::appendChatLine(ChatLine *line) {
+ append(line->text()); qDebug() << "appending";
+}
+
+void ChatWidget::appendChatLines(QList<ChatLine *> list) {
+ foreach(ChatLine *line, list) {
+ appendChatLine(line);
+ }
+}
+
+void ChatWidget::prependChatLine(ChatLine *line) {
+ qDebug() << "prepending"; return;
+ QTextCursor cursor = textCursor();
+ moveCursor(QTextCursor::Start);
+ insertHtml(line->text());
+ setTextCursor(cursor);
+ QTextCharFormat fmt;
+ fmt.setForeground(QBrush("#eeff33"));
+ QFont font("Courier", 8);
+ font.setFixedPitch(true); qDebug() << font.family();
+ fmt.setFont(font);
+ //fmt.setBackground(QBrush("#112233"));
+ QTextCursor crsor(document());
+ crsor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
+ crsor.select(QTextCursor::Document);
+ crsor.setCharFormat(fmt);
+}
+
+void ChatWidget::prependChatLines(QList<ChatLine *> list) {
+
+
+}