d713ec42df1a85d83cf6c53f2c6098ad07ebde7a
[quassel.git] / gui / channelwidget.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005 by The Quassel Team                                *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #include "channelwidget.h"
22 #include "guiproxy.h"
23
24 #include <QtGui>
25 #include <iostream>
26
27 ChannelWidget::ChannelWidget(QWidget *parent) : QWidget(parent) {
28   ui.setupUi(this);
29   //ui.inputEdit->grabKeyboard();
30   ui.inputEdit->setFocus();
31
32 /*  //ui.splitter->
33   ui.textBrowser->setHtml("[17:21] <em>--> Dante has joined #quassel (~hurz@p1af2242.dip.t-dialin.net)</em><br>"
34                           "[17:21] <em>--> Sput has joined #quassel (~Sput42@vincent.mindpool.net)</em><br>"
35                           "[17:23] &lt;<b>Dante</b>&gt; Das sieht ja soweit schonmal Klasse aus!<br>"
36                           "[17:23] &lt;<b>Sput</b>&gt; Find ich auch... schade dass es noch nix tut :p<br>"
37                           "[17:24] &lt;<b>Dante</b>&gt; Das wird sich ja gottseidank bald ändern.<br>"
38                           "[17:24] &lt;<b>Sput</b>&gt; Wollen wir's hoffen :D"
39                           );
40  ui.listWidget->addItem("@Dante");
41  ui.listWidget->addItem("@Sput");
42   */
43   //connect(&core, SIGNAL(outputLine( const QString& )), ui.textBrowser, SLOT(insertPlainText(const QString &)));
44   //connect(ui.lineEdit, SIGNAL(
45   //connect(&core, SIGNAL(outputLine( const QString& )), this, SLOT(lineReceived(const QString &)));
46   connect(ui.inputEdit, SIGNAL(returnPressed()), this, SLOT(enterPressed()));
47   //connect(this, SIGNAL(inputLine( const QString& )), &core, SLOT(inputLine( const QString& )));
48
49   connect(this, SIGNAL(inputLine(QString)), guiProxy, SLOT(gsUserInput(QString)));
50   connect(this, SIGNAL(requestConnect(QString, quint16)), guiProxy, SLOT(gsRequestConnect(QString, quint16)));
51   connect(guiProxy, SIGNAL(csCoreMessage(QString)), this, SLOT(lineReceived(QString)));
52
53   //emit requestConnect("irc.scortum.moep.net", 6668);
54   //emit requestConnect("irc.quakenet.org", 6668);
55 }
56
57 void ChannelWidget::enterPressed() {
58   QString l = ui.inputEdit->text();
59   if(l == "/c") emit requestConnect("irc.quakenet.org", 6668);
60   else emit inputLine(ui.inputEdit->text());
61   ui.inputEdit->clear();
62 }
63
64 void ChannelWidget::lineReceived(QString s) {
65   ui.chatWidget->insertPlainText(s + "\n");
66   ui.chatWidget->ensureCursorVisible();
67 }