1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel IRC Development Team *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #include "mainwidget.h"
24 #include "chatwidget.h"
26 MainWidget::MainWidget(QWidget *parent) : QWidget(parent) {
29 // ui.bufferLeft->setIcon(QIcon(":icon/left"));
30 // ui.bufferRight->setIcon(QIcon(":icon/right"));
31 //ui.bufferLeft->setIconSize(QSize(10, 10));
32 //ui.bufferRight->setIconSize(QSize(10, 10));
33 //ui.bufferLeft->setMaximumSize(QSize(10,10));
34 //ui.bufferRight->setMaximumSize(QSize(10,10));
37 MainWidget::~MainWidget() {
43 void MainWidget::setBuffer(Buffer *buf) {
44 // TODO update topic if changed; handle status buffer display
45 QString title = QString("%1 (%2): \"%3\"").arg(buf->displayName()).arg(buf->networkName()).arg(buf->topic());
46 ui.topicBar->setContents(title);
48 //ui.chatWidget->setStyleSheet("div { color: #777777; }");
49 //ui.chatWidget->setHtml("<style type=\"text/css\">.foo { color: #777777; } .bar { font-style: italic }</style>"
50 // "<div class=\"foo\">foo</div> <div class=\"bar\">bar</div> baz");
51 //ui.chatWidget->moveCursor(QTextCursor::End);
52 //ui.chatWidget->insertHtml("<div class=\"foo\"> brumm</div>");
54 ChatWidget *chatWidget;
55 if(!chatWidgets.contains(buf)) {
56 chatWidget = new ChatWidget(this);
57 QList<ChatLine *> lines;
58 QList<AbstractUiMsg *> msgs = buf->contents();
59 foreach(AbstractUiMsg *msg, msgs) {
60 lines.append(dynamic_cast<ChatLine*>(msg));
62 chatWidget->setContents(lines);
63 connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *)));
64 connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *)));
65 //connect(buf, SIGNAL(topicSet(QString)), this, SLOT(setTopic(QString)));
66 //connect(buf, SIGNAL(ownNickSet(QString)), this, SLOT(setOwnNick(QString)));
67 ui.stack->addWidget(chatWidget);
68 chatWidgets.insert(buf, chatWidget);
69 ui.stack->addWidget(chatWidget);
70 } else chatWidget = chatWidgets[buf];
71 ui.stack->setCurrentWidget(chatWidget);