X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fbufferwidget.cpp;h=51c551c3328a97dde609021d002f4dd3cc4e30b6;hp=0ebcffbfbf605eb3ff8ce6a9f0e53b2eefc123eb;hb=d298e7275374e2da41b0ed9ef1080464a77c8cf1;hpb=e9f87d7542d4a9fe0e9c63dec96e93d270667ecd diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 0ebcffbf..51c551c3 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -20,6 +20,7 @@ #include "bufferwidget.h" #include "buffer.h" +#include "chatline.h" #include "chatline-old.h" #include "chatwidget.h" #include "settings.h" @@ -28,6 +29,8 @@ #include "network.h" #include "networkmodel.h" +#include "global.h" + BufferWidget::BufferWidget(QWidget *parent) : QWidget(parent), _bufferModel(0), @@ -51,7 +54,7 @@ void BufferWidget::setModel(BufferModel *bufferModel) { if(bufferModel) { connect(bufferModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); + this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); } } @@ -63,7 +66,7 @@ void BufferWidget::setSelectionModel(QItemSelectionModel *selectionModel) { if(selectionModel) { connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - this, SLOT(currentChanged(QModelIndex, QModelIndex))); + this, SLOT(currentChanged(QModelIndex, QModelIndex))); } } @@ -90,7 +93,7 @@ void BufferWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, in for(int i = start; i <= end; i++) { QVariant variant = parent.child(i,0).data(NetworkModel::BufferIdRole); if(!variant.isValid()) - continue; + continue; BufferId bufferId = qVariantValue(variant); removeBuffer(bufferId); @@ -122,6 +125,7 @@ void BufferWidget::setCurrentBuffer(BufferId bufferId) { } ChatWidget *chatWidget = 0; + ChatView *chatView = 0; Buffer *buf = Client::buffer(bufferId); if(!buf) { qWarning() << "BufferWidget::setBuffer(BufferId): Can't show unknown Buffer:" << bufferId; @@ -129,25 +133,47 @@ void BufferWidget::setCurrentBuffer(BufferId bufferId) { } Buffer *prevBuffer = Client::buffer(currentBuffer()); if(prevBuffer) prevBuffer->setVisible(false); - if(_chatWidgets.contains(bufferId)) { - chatWidget = _chatWidgets[bufferId]; + if(Global::SPUTDEV) { + if(_chatViews.contains(bufferId)) { + chatView = _chatViews[bufferId]; + } else { + chatView = new ChatView(buf, this); + //chatView->init(bufferId); + QList lines; + QList msgs = buf->contents(); + foreach(AbstractUiMsg *msg, msgs) { + lines.append(dynamic_cast(msg)); + } + chatView->setContents(lines); + connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatView, SLOT(appendMsg(AbstractUiMsg *))); + connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatView, SLOT(prependMsg(AbstractUiMsg *))); + _chatViews[bufferId] = chatView; + ui.stackedWidget->addWidget(chatView); + chatView->setFocusProxy(this); + } + _currentBuffer = bufferId; + ui.stackedWidget->setCurrentWidget(chatView); } else { - chatWidget = new ChatWidget(this); - chatWidget->init(bufferId); - QList lines; - QList msgs = buf->contents(); - foreach(AbstractUiMsg *msg, msgs) { - lines.append(dynamic_cast(msg)); + if(_chatWidgets.contains(bufferId)) { + chatWidget = _chatWidgets[bufferId]; + } else { + chatWidget = new ChatWidget(this); + chatWidget->init(bufferId); + QList lines; + QList msgs = buf->contents(); + foreach(AbstractUiMsg *msg, msgs) { + lines.append(dynamic_cast(msg)); + } + chatWidget->setContents(lines); + connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); + connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *))); + _chatWidgets[bufferId] = chatWidget; + ui.stackedWidget->addWidget(chatWidget); + chatWidget->setFocusProxy(this); } - chatWidget->setContents(lines); - connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); - connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *))); - _chatWidgets[bufferId] = chatWidget; - ui.stackedWidget->addWidget(chatWidget); - chatWidget->setFocusProxy(this); + _currentBuffer = bufferId; + ui.stackedWidget->setCurrentWidget(chatWidget); } - _currentBuffer = bufferId; - ui.stackedWidget->setCurrentWidget(chatWidget); buf->setVisible(true); setFocus(); }