QTfrontend/chatwidget.cpp
author displacer
Tue, 20 Feb 2007 19:00:46 +0000
changeset 464 7f48321fc38a
parent 463 353c2f830888
child 465 07eca0a2546c
permissions -rw-r--r--
vertical size fix for chatwidget
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);
464
7f48321fc38a vertical size fix for chatwidget
displacer
parents: 463
diff changeset
    13
  mainLayout.setColumnStretch(0, 75);
7f48321fc38a vertical size fix for chatwidget
displacer
parents: 463
diff changeset
    14
  mainLayout.setColumnStretch(1, 25);
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    15
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    16
  chatEditLine = new QLineEdit(this);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    17
  connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    18
463
353c2f830888 fixes last commit problems
displacer
parents: 462
diff changeset
    19
  mainLayout.addWidget(chatEditLine, 1, 0, 1, 2);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    20
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    21
  chatText = new QListWidget(this);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    22
  chatText->setMinimumHeight(10);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    23
  chatText->setMinimumWidth(10);
463
353c2f830888 fixes last commit problems
displacer
parents: 462
diff changeset
    24
  chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    25
  mainLayout.addWidget(chatText, 0, 0);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    26
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    27
  chatNicks = new QListWidget(this);
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    28
  chatNicks->setMinimumHeight(10);
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    29
  chatNicks->setMinimumWidth(10);
463
353c2f830888 fixes last commit problems
displacer
parents: 462
diff changeset
    30
  chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
462
91baab07b79a resizing and grid problems
displacer
parents: 461
diff changeset
    31
  mainLayout.addWidget(chatNicks, 0, 1);
461
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    32
}
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    33
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    34
void HWChatWidget::returnPressed()
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    35
{
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    36
  emit chatLine(chatEditLine->text());
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    37
  chatEditLine->clear();
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    38
}
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    39
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    40
void HWChatWidget::onChatStringFromNet(const QStringList& str)
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    41
{
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    42
  QListWidget* w=chatText;
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    43
  w->addItem(str[0]+": "+str[1]);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    44
  w->scrollToBottom();
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    45
  w->setSelectionMode(QAbstractItemView::NoSelection);
105af110b0e6 chatWidget with layout
displacer
parents:
diff changeset
    46
}