QTfrontend/chatwidget.cpp
changeset 461 105af110b0e6
child 462 91baab07b79a
equal deleted inserted replaced
460:3242b42ecad4 461:105af110b0e6
       
     1 #include <QListWidget>
       
     2 #include <QLineEdit>
       
     3 
       
     4 #include "chatwidget.h"
       
     5 
       
     6 HWChatWidget::HWChatWidget(QWidget* parent) :
       
     7   QWidget(parent),
       
     8   mainLayout(this)
       
     9 {
       
    10   mainLayout.setSpacing(1);
       
    11   mainLayout.setMargin(1);
       
    12 
       
    13   chatEditLine = new QLineEdit(this);
       
    14   connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
       
    15 
       
    16   mainLayout.addWidget(chatEditLine, 1, 0);
       
    17   
       
    18   chatText = new QListWidget(this);
       
    19   chatText->setMinimumHeight(10);
       
    20   mainLayout.addWidget(chatText, 0, 0);
       
    21 }
       
    22 
       
    23 void HWChatWidget::returnPressed()
       
    24 {
       
    25   emit chatLine(chatEditLine->text());
       
    26   chatEditLine->clear();
       
    27 }
       
    28 
       
    29 void HWChatWidget::onChatStringFromNet(const QStringList& str)
       
    30 {
       
    31   QListWidget* w=chatText;
       
    32   w->addItem(str[0]+": "+str[1]);
       
    33   w->scrollToBottom();
       
    34   w->setSelectionMode(QAbstractItemView::NoSelection);
       
    35 }