Fixed annoying bug where the nicklist wouldn't be shown sometimes because of an incon...
[quassel.git] / src / client / buffer.cpp
index b82a695..023263b 100644 (file)
 #include "buffer.h"
 
 #include "client.h"
+#include "ircchannel.h"
+#include "nickmodel.h"
 #include "util.h"
 
 
 Buffer::Buffer(BufferInfo bufferid, QObject *parent)
   : QObject(parent),
     _bufferInfo(bufferid),
-    _active(false)
+    _active(false),
+    _ircChannel(0), _nickModel(0)
 {
   if(bufferid.buffer().isEmpty())
     _type = StatusType;
@@ -37,6 +40,7 @@ Buffer::Buffer(BufferInfo bufferid, QObject *parent)
   else
     _type = QueryType;
 
+  _nickModel = new NickModel(0, this);
 /*
   QSettings s;
   s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
@@ -74,6 +78,10 @@ void Buffer::updateBufferInfo(BufferInfo bufferid) {
   _bufferInfo = bufferid;
 }
 
+uint Buffer::uid() const {
+  return bufferInfo().uid();
+}
+
 uint Buffer::networkId() const {
   return bufferInfo().networkId();
 }
@@ -82,15 +90,11 @@ QString Buffer::networkName() const {
   return bufferInfo().network();
 }
 
-QString Buffer::bufferName() const {
-  return bufferInfo().buffer();
-}
-
-QString Buffer::displayName() const {
+QString Buffer::name() const {
   if(bufferType() == StatusType)
     return tr("Status Buffer");
   else
-    return bufferName();
+    return bufferInfo().buffer();
 }
 
 QList<AbstractUiMsg *> Buffer::contents() const {
@@ -147,6 +151,25 @@ void Buffer::processUserInput(QString msg) {
   emit userInput(_bufferInfo, msg);
 }
 
+NickModel *Buffer::nickModel() const {
+  return _nickModel;
+}
+
+IrcChannel *Buffer::ircChannel() const {
+  return _ircChannel;
+}
+
+void Buffer::setIrcChannel(IrcChannel *ircchan) {
+  if(_ircChannel) {
+    disconnect(_ircChannel, 0, this, 0);
+  }
+  _ircChannel = ircchan;
+  if(_ircChannel) {
+    connect(_ircChannel, SIGNAL(destroyed()), this, SLOT(setIrcChannel()));
+  }
+  _nickModel->setIrcChannel(ircChannel());
+}
+
 // no longer needed
 // back reference:
 // void Buffer::setTopic(QString t) {