- Bug #20 (RPL_NICKNAMEINUSER)
[quassel.git] / gui / buffer.h
index 5df19aa..09f7e02 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005/06 by The Quassel Team                             *
+ *   Copyright (C) 2005-07 by The Quassel Team                             *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 #include <QtCore>
 #include <QtGui>
 
-#include "ui_bufferwidget.h"
-
 #include "global.h"
 #include "message.h"
 
+class ChatWidget;
+class ChatWidgetContents;
 class BufferWidget;
+struct BufferState;
 
+//!\brief Encapsulates the contents of a single channel, query or server status context.
+/** A Buffer maintains a list of existing nicks and their status. New messages can be appended using
+ * displayMsg(). A buffer displays its contents by way of a BufferWidget, which can be shown
+ * (and created on demand) by calling showWidget().
+ */
 class Buffer : public QObject {
   Q_OBJECT
 
   public:
     Buffer(QString network, QString buffer);
     ~Buffer();
+    static void init();
 
+    enum Type { ServerBuffer, ChannelBuffer, QueryBuffer };
+    Type bufferType() { return type; }
     bool isActive() { return active; }
-  public:
-    QWidget *getWidget();
+
+    QString networkName() { return _networkName; }
+    QString bufferName() { return _bufferName; }
+    QList<Message> *contents() { return &_contents; }
+    VarMap nickList() { return nicks; }
+    QString topic() { return _topic; }
+    QString ownNick() { return _ownNick; }
 
   signals:
     void userInput(QString, QString, QString);
-    void nickListChanged(QStringList);
+    void msgDisplayed(Message);
+    void nickListChanged(VarMap nicks);
+    void topicSet(QString topic);
+    void ownNickSet(QString ownNick);
+    void bufferUpdated(Buffer *);
+    void bufferDestroyed(Buffer *);
 
   public slots:
     void setActive(bool active = true);
     void displayMsg(Message);
+    void prependMessages(QList<Message>); // for backlog
     //void recvStatusMsg(QString msg);
     void setTopic(QString);
     //void setNicks(QStringList);
@@ -58,61 +78,20 @@ class Buffer : public QObject {
     void updateNick(QString nick, VarMap props);
     void setOwnNick(QString nick);
 
-    QWidget * showWidget(QWidget *parent = 0);
-    void hideWidget();
-
-    void scrollToEnd();
-
-  private slots:
-    void userInput(QString);
-
-  private:
-    bool active;
-    BufferWidget *widget;
-    VarMap nicks;
-    QString topic;
-    QString ownNick;
-    QString networkName, bufferName;
-
-    QList<Message> contents;
-};
-
-class BufferWidget : public QWidget {
-  Q_OBJECT
-
-  public:
-    BufferWidget(QString netname, QString bufname, bool active, QString ownNick, QList<Message> contents, QWidget *parent = 0);
-
-    void setActive(bool act = true);
-  signals:
-    void userInput(QString);
-
-  public slots:
-    void displayMsg(Message);
-    void updateNickList(VarMap nicks);
-    void setOwnNick(QString ownNick);
-    void setTopic(QString topic);
-    void renderContents();
-    void scrollToEnd();
-
-  private slots:
-    void enterPressed();
-    void itemExpansionChanged(QTreeWidgetItem *);
-    void updateTitle();
+    void processUserInput(QString);
 
   private:
-    Ui::BufferWidget ui;
     bool active;
-    QList<Message> contents;
+    Type type;
 
-    QString stdCol, errorCol, noticeCol, joinCol, quitCol, partCol, kickCol, serverCol, nickCol, inactiveCol;
-    QString CSS;
-    QString networkName;
-    QString bufferName;
+    VarMap nicks;
+    QString _topic;
+    QString _ownNick;
+    QString _networkName, _bufferName;
+    BufferState *state;
 
-    bool opsExpanded, voicedExpanded, usersExpanded;
+    QList<Message> _contents;
 
-    QString htmlFromMsg(Message);
 };
 
 #endif