-void BufferWidget::setBuffer(Buffer *buf) {
- ChatWidget *chatWidget;
- if(_chatWidgets.contains(buf->uid())) {
- chatWidget = _chatWidgets[buf->uid()];
- } else {
- chatWidget = new ChatWidget(this);
- chatWidget->init(networkName, bufferName);
- QList<ChatLine *> lines;
- QList<AbstractUiMsg *> msgs = buf->contents();
- foreach(AbstractUiMsg *msg, msgs) {
- lines.append(dynamic_cast<ChatLine*>(msg));
- }
- chatWidget->setContents(lines);
- connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *)));
- connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *)));
- _chatWidgets[buf->uid()] = 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);