-void BufferWidget::setBuffer(Buffer *buf) {
- /*
- ChatView *chatView;
- if(_chatViews.contains(buf->uid())) {
- chatView = _chatViews[buf->uid()];
- } else {
- chatView = new ChatView(buf, this);
- ui.stackedWidget->addWidget(chatView);
- _chatViews[buf->uid()] = chatView;
- }
- 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.ownNick->addItem(state->ownNick);
-
- ChatWidget *chatWidget;
- if(_chatWidgets.contains(buf->uid())) {
- chatWidget = _chatWidgets[buf->uid()];
- } else {
- chatWidget = new ChatWidget(this);
- chatWidget->init(buf->networkName(), buf->name());
- 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);
-}
-
-void BufferWidget::saveState() {
-
-}
-
-QSize BufferWidget::sizeHint() const {
- return QSize(800,400);
+AbstractChatView *BufferWidget::createChatView(BufferId id) {
+ QWidget *chatView;
+#ifdef SPUTDEV
+ chatView = new ChatView(Client::buffer(id), this);
+#else
+ chatView = new ChatWidget(id, this);
+#endif
+ _chatViews[id] = chatView;
+ ui.stackedWidget->addWidget(chatView);
+ chatView->setFocusProxy(this);
+ return dynamic_cast<AbstractChatView*>(chatView);