QTfrontend/chatwidget.cpp
author displacer
Tue, 20 Feb 2007 18:40:45 +0000
changeset 462 91baab07b79a
parent 461 105af110b0e6
child 463 353c2f830888
permissions -rw-r--r--
resizing and grid problems
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     1
#include <QListWidget>
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     2
#include <QLineEdit>
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     3
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     4
#include "chatwidget.h"
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     5
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     6
HWChatWidget::HWChatWidget(QWidget* parent) :
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     7
  QWidget(parent),
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     8
  mainLayout(this)
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
     9
{
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    10
  mainLayout.setSpacing(1);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    11
  mainLayout.setMargin(1);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    12
  mainLayout.setSizeConstraint(QLayout::SetMinimumSize);
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    13
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    14
  chatEditLine = new QLineEdit(this);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    15
  connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    16
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    17
  mainLayout.addWidget(chatEditLine, 1, 0); //, 0, 1); //assertion failed!
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    18
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    19
  chatText = new QListWidget(this);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    20
  chatText->setMinimumHeight(10);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    21
  chatText->setMinimumWidth(10);
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    22
  mainLayout.addWidget(chatText, 0, 0);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    23
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    24
  chatNicks = new QListWidget(this);
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    25
  chatNicks->setMinimumHeight(10);
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    26
  chatNicks->setMinimumWidth(10);
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    27
  mainLayout.addWidget(chatNicks, 0, 1);
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    28
}
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    29
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    30
void HWChatWidget::returnPressed()
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    31
{
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    32
  emit chatLine(chatEditLine->text());
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    33
  chatEditLine->clear();
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    34
}
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    35
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    36
void HWChatWidget::onChatStringFromNet(const QStringList& str)
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    37
{
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    38
  QListWidget* w=chatText;
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    39
  w->addItem(str[0]+": "+str[1]);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    40
  w->scrollToBottom();
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    41
  w->setSelectionMode(QAbstractItemView::NoSelection);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    42
}