X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fbufferwidget.cpp;h=a6707053de9cf936f1e74fd66bcdecaea0d57984;hb=9204e98848ab202c0117aa1428fa0ea10b4dcd75;hp=c647461caf9fb072726a40230bc28e90348647f7;hpb=36b2b9680ff608f41c681b8c23865abb06a2464c;p=quassel.git diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index c647461c..a6707053 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-08 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,108 +19,42 @@ ***************************************************************************/ #include "bufferwidget.h" -#include "buffer.h" +#include "chatline.h" #include "chatline-old.h" +#include "chatview.h" #include "chatwidget.h" #include "settings.h" +#include "client.h" -BufferWidget::BufferWidget(QWidget *parent) : QWidget(parent) { - ui.setupUi(this); - connect(ui.inputEdit, SIGNAL(returnPressed()), this, SLOT(enterPressed())); -} - -void BufferWidget::init() { +#include "global.h" +BufferWidget::BufferWidget(QWidget *parent) : AbstractBufferContainer(parent) { + ui.setupUi(this); } BufferWidget::~BufferWidget() { } -void BufferWidget::setBuffer(Buffer *buf) { - /* - ChatView *chatView; - if(_chatViews.contains(buf->uid())) { - chatView = _chatViews[buf->uid()]; +AbstractChatView *BufferWidget::createChatView(BufferId id) { + AbstractChatView *chatView; + if(Global::SPUTDEV) { + chatView = new ChatView(Client::buffer(id), this); } else { - chatView = new ChatView(buf, this); - ui.stackedWidget->addWidget(chatView); - _chatViews[buf->uid()] = chatView; + chatView = new ChatWidget(id, this); } - ui.stackedWidget->setCurrentWidget(chatView); - disconnect(this, SIGNAL(userInput(QString)), 0, 0); - connect(this, SIGNAL(userInput(QString)), buf, SLOT(processUserInput(QString))); - //chatView->setFocusProxy(ui.inputEdit); - ui.inputEdit->setFocus(); - ui.ownNick->clear(); // TODO add nick history + ui.stackedWidget->addWidget(dynamic_cast(chatView)); + dynamic_cast(chatView)->setFocusProxy(this); + return chatView; } - */ - - // ui.ownNick->addItem(state->ownNick); - - ChatWidget *chatWidget; - if(_chatWidgets.contains(buf)) { - chatWidget = _chatWidgets[buf]; - } else { - chatWidget = new ChatWidget(this); - chatWidget->init(buf->networkName(), buf->name()); - QList lines; - QList msgs = buf->contents(); - foreach(AbstractUiMsg *msg, msgs) { - lines.append(dynamic_cast(msg)); - } - chatWidget->setContents(lines); - connect(buf, SIGNAL(destroyed(QObject *)), this, SLOT(bufferDestroyed(QObject *))); - connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); - connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *))); - _chatWidgets[buf] = chatWidget; - ui.stackedWidget->addWidget(chatWidget); - } - ui.stackedWidget->setCurrentWidget(chatWidget); - disconnect(this, SIGNAL(userInput(QString)), 0, 0); - connect(this, SIGNAL(userInput(QString)), buf, SLOT(processUserInput(QString))); - chatWidget->setFocusProxy(ui.inputEdit); - ui.inputEdit->setFocus(); - ui.ownNick->clear(); // TODO add nick history - // ui.ownNick->addItem(state->ownNick); -} - -void BufferWidget::bufferDestroyed(QObject *buf) { - QWidget *widget = _chatWidgets[(Buffer*)buf]; - ui.stackedWidget->removeWidget(widget); - widget->deleteLater(); -} - -void BufferWidget::saveState() { +void BufferWidget::removeChatView(AbstractChatView *view) { + ui.stackedWidget->removeWidget(dynamic_cast(view)); + dynamic_cast(view)->deleteLater(); } -QSize BufferWidget::sizeHint() const { - return QSize(800,400); -} - -void BufferWidget::enterPressed() { - QStringList lines = ui.inputEdit->text().split('\n', QString::SkipEmptyParts); - foreach(QString msg, lines) { - if(msg.isEmpty()) continue; - emit userInput(msg); - } - ui.inputEdit->clear(); -} - -void BufferWidget::setActive(bool act) { - if(act != active) { - active = act; - //renderContents(); - //scrollToEnd(); - } -} - - - -/* -void BufferWidget::displayMsg(Message msg) { - chatWidget->appendMsg(msg); +void BufferWidget::showChatView(AbstractChatView *view) { + if(!view) ui.stackedWidget->setCurrentWidget(ui.page); + else ui.stackedWidget->setCurrentWidget(dynamic_cast(view)); } -*/