Various stuff, cosmetic fixes, fiddling with IrcUsers and NetworkInfos in Buffers.
[quassel.git] / src / client / buffer.cpp
index 1561428..304d9ec 100644 (file)
 #include "buffer.h"
 
 #include "client.h"
+#include "ircchannel.h"
 #include "util.h"
 
 
 Buffer::Buffer(BufferInfo bufferid, QObject *parent)
   : QObject(parent),
     _bufferInfo(bufferid),
-    _active(false)
+    _active(false),
+    _ircChannel(0)
 {
   if(bufferid.buffer().isEmpty())
-    _type = ServerBuffer;
+    _type = StatusType;
   else if(isChannelName(bufferid.buffer()))
-    _type = ChannelBuffer;
+    _type = ChannelType;
   else
-    _type = QueryBuffer;
+    _type = QueryType;
 
 /*
   QSettings s;
@@ -55,7 +57,6 @@ Buffer::~Buffer() {
   s.endGroup();
 */
   //delete state;
-  emit bufferDestroyed(this);
 }
 
 Buffer::Type Buffer::bufferType() const {
@@ -75,6 +76,10 @@ void Buffer::updateBufferInfo(BufferInfo bufferid) {
   _bufferInfo = bufferid;
 }
 
+uint Buffer::uid() const {
+  return bufferInfo().uid();
+}
+
 uint Buffer::networkId() const {
   return bufferInfo().networkId();
 }
@@ -83,15 +88,11 @@ QString Buffer::networkName() const {
   return bufferInfo().network();
 }
 
-QString Buffer::bufferName() const {
-  return bufferInfo().buffer();
-}
-
-QString Buffer::displayName() const {
-  if(bufferType() == ServerBuffer)
+QString Buffer::name() const {
+  if(bufferType() == StatusType)
     return tr("Status Buffer");
   else
-    return bufferName();
+    return bufferInfo().buffer();
 }
 
 QList<AbstractUiMsg *> Buffer::contents() const {
@@ -114,7 +115,7 @@ QString Buffer::ownNick() const {
 }
 
 bool Buffer::isStatusBuffer() const {
-   return bufferType() == ServerBuffer;
+   return bufferType() == StatusType;
 }
 
 void Buffer::setActive(bool a) {
@@ -148,6 +149,21 @@ void Buffer::processUserInput(QString msg) {
   emit userInput(_bufferInfo, msg);
 }
 
+IrcChannel *Buffer::ircChannel() const {
+  return _ircChannel;
+}
+
+void Buffer::setIrcChannel(IrcChannel *ircchan) {
+  if(_ircChannel) {
+    disconnect(_ircChannel, 0, this, 0);
+    // TODO: remove model etc
+  }
+  _ircChannel = ircchan;
+  if(_ircChannel) {
+    connect(_ircChannel, SIGNAL(destroyed()), this, SLOT(setIrcChannel()));
+  }
+}
+
 // no longer needed
 // back reference:
 // void Buffer::setTopic(QString t) {