/***************************************************************************
- * Copyright (C) 2005-07 by The Quassel Team *
+ * Copyright (C) 2005-08 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
+ * (at your option) version 3. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#ifndef _BUFFER_H_
#define _BUFFER_H_
-#include <QtCore>
-#include <QtGui>
+class AbstractUiMsg;
+class IrcChannel;
+class NickModel;
+
+struct BufferState;
-#include "chatwidget.h"
-#include "global.h"
#include "message.h"
+#include "bufferinfo.h"
-class ChatWidget;
-class ChatLine;
-class ChatWidgetContents;
-class BufferWidget;
-struct BufferState;
+#include <QVariantMap>
//!\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().
+/** A Buffer maintains a list of existing nicks and their status.
*/
class Buffer : public QObject {
Q_OBJECT
- public:
- //Buffer(QString network, QString buffer);
- Buffer(BufferId);
- ~Buffer();
- static void init();
-
- enum Type { ServerBuffer, ChannelBuffer, QueryBuffer };
-
- enum Activity {
- NoActivity = 0x00,
- OtherActivity = 0x01,
- NewMessage = 0x02,
- Highlight = 0x40
- };
- Q_DECLARE_FLAGS(ActivityLevel, Activity)
-
- Type bufferType() { return type; }
- bool isActive() { return active; }
-
- QString networkName() { return _networkName; }
- QString bufferName() { return _bufferName; }
- QString displayName();
- BufferId bufferId() { return id; }
- QList<ChatLine *> contents() { return lines; }
- VarMap nickList() { return nicks; }
- QString topic() { return _topic; }
- QString ownNick() { return _ownNick; }
- bool isStatusBuffer() { return bufferType() == ServerBuffer; }
-
- signals:
- void userInput(BufferId, QString);
- //void msgDisplayed(Message);
- void chatLineAppended(ChatLine *);
- void chatLinePrepended(ChatLine *);
- 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 appendChatLine(ChatLine *);
- void prependChatLine(ChatLine *);
- //void prependChatLines(QList<ChatLine *>);
- //void recvStatusMsg(QString msg);
- void setTopic(QString);
- //void setNicks(QStringList);
- void addNick(QString nick, VarMap props);
- void renameNick(QString oldnick, QString newnick);
- void removeNick(QString nick);
- void updateNick(QString nick, VarMap props);
- void setOwnNick(QString nick);
-
- void processUserInput(QString);
-
- private:
- BufferId id;
- bool active;
- Type type;
-
- VarMap nicks;
- QString _topic;
- QString _ownNick;
- QString _networkName, _bufferName;
- BufferState *state;
-
- //QList<Message> _contents;
- QList<ChatLine *> lines;
+public:
+ Buffer(BufferInfo, QObject *parent = 0);
+ virtual ~Buffer();
+
+ enum Type {
+ StatusType,
+ ChannelType,
+ QueryType
+ };
+
+ enum Activity {
+ NoActivity = 0x00,
+ OtherActivity = 0x01,
+ NewMessage = 0x02,
+ Highlight = 0x40
+ };
+ Q_DECLARE_FLAGS(ActivityLevel, Activity)
+
+ bool isStatusBuffer() const;
+ Type bufferType() const;
+ bool isActive() const;
+
+ BufferInfo bufferInfo() const;
+ void updateBufferInfo(BufferInfo bufferid);
+
+ BufferId uid() const;
+ NetworkId networkId() const;
+
+ QString networkName() const;
+ QString name() const;
+
+ QList<AbstractUiMsg *> contents() const;
+
+ QVariantMap nickList() const;
+ QString topic() const;
+ QString ownNick() const;
+
+ //! Returns a pointer to the associated IrcChannel object for the buffer.
+ /** A buffer has an IrcChannel object only if it is a channel buffer
+ * (i.e. bufferType() == ChannelType), and if it is active at the moment.
+ * \returns A pointer to the associated IrcChannel object, if the buffer is a channel and online; 0 else.
+ */
+ IrcChannel *ircChannel() const;
+ NickModel *nickModel() const;
+
+signals:
+ void userInput(const BufferInfo &, QString);
+ void nickListChanged(QVariantMap nicks);
+ void topicSet(QString topic);
+ void ownNickSet(QString ownNick);
+ void bufferUpdated(Buffer *);
+
+ void msgAppended(AbstractUiMsg *);
+ void msgPrepended(AbstractUiMsg *);
+ void layoutQueueEmpty();
+
+public slots:
+ void setActive(bool active = true);
+ void appendMsg(const Message &);
+ void prependMsg(const Message &);
+ bool layoutMsg();
+ void setIrcChannel(IrcChannel *chan = 0);
+
+ // no longer needed
+// void setTopic(QString);
+// //void setNicks(QStringList);
+// void addNick(QString nick, QVariantMap props);
+// void renameNick(QString oldnick, QString newnick);
+// void removeNick(QString nick);
+// void updateNick(QString nick, QVariantMap props);
+// void setOwnNick(QString nick);
+
+ void processUserInput(QString);
+
+private:
+ BufferInfo _bufferInfo;
+ bool _active;
+ Type _type;
+ BufferState *state;
+ QPointer<IrcChannel> _ircChannel;
+ QPointer<NickModel> _nickModel;
+
+ QList<Message> layoutQueue;
+ QList<AbstractUiMsg *> layoutedMsgs;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
#endif