X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fbufferwidget.cpp;h=bc10ca54d20af011ae7a721014c838c9ac01e2c5;hp=a6707053de9cf936f1e74fd66bcdecaea0d57984;hb=8ff7242c289343d53d1a0d7ca507096cb944cafb;hpb=2684aa5295d12e4f7c66b3011fc8b1819f3d1cbb diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index a6707053..bc10ca54 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -19,8 +19,6 @@ ***************************************************************************/ #include "bufferwidget.h" -#include "chatline.h" -#include "chatline-old.h" #include "chatview.h" #include "chatwidget.h" #include "settings.h" @@ -37,24 +35,28 @@ BufferWidget::~BufferWidget() { } AbstractChatView *BufferWidget::createChatView(BufferId id) { - AbstractChatView *chatView; - if(Global::SPUTDEV) { - chatView = new ChatView(Client::buffer(id), this); - } else { - chatView = new ChatWidget(id, this); - } - ui.stackedWidget->addWidget(dynamic_cast(chatView)); - dynamic_cast(chatView)->setFocusProxy(this); - return chatView; + 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(chatView); } -void BufferWidget::removeChatView(AbstractChatView *view) { - ui.stackedWidget->removeWidget(dynamic_cast(view)); - dynamic_cast(view)->deleteLater(); +void BufferWidget::removeChatView(BufferId id) { + QWidget *view = _chatViews.value(id, 0); + if(!view) return; + ui.stackedWidget->removeWidget(view); + view->deleteLater(); + _chatViews.take(id); } -void BufferWidget::showChatView(AbstractChatView *view) { - if(!view) ui.stackedWidget->setCurrentWidget(ui.page); - else ui.stackedWidget->setCurrentWidget(dynamic_cast(view)); +void BufferWidget::showChatView(BufferId id) { + if(!id.isValid()) ui.stackedWidget->setCurrentWidget(ui.page); + else ui.stackedWidget->setCurrentWidget(_chatViews.value(id)); }