- 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:
+ enum Activity {
+ NoActivity = 0x00,
+ OtherActivity = 0x01,
+ NewMessage = 0x02,
+ Highlight = 0x40
+ };
+ Q_DECLARE_FLAGS(ActivityLevel, Activity)
+
+ Buffer(BufferInfo, QObject *parent = 0);
+
+ BufferInfo bufferInfo() const;
+ const QList<AbstractUiMsg *> &contents() const;
+ inline bool isVisible() const { return _isVisible; }
+ inline MsgId lastSeenMsg() const { return _lastSeenMsg; }
+ inline ActivityLevel activityLevel() const { return _activityLevel; }
+
+signals:
+ void msgAppended(AbstractUiMsg *);
+ void msgPrepended(AbstractUiMsg *);
+ void layoutQueueEmpty();
+
+public slots:
+ void appendMsg(const Message &);
+ void prependMsg(const Message &);
+ bool layoutMsg();
+ void setVisible(bool visible);
+ void setLastSeenMsg(const MsgId &msgId);
+ void setActivityLevel(ActivityLevel level);
+
+private:
+ BufferInfo _bufferInfo;
+ bool _isVisible;
+ MsgId _lastSeenMsg;
+ ActivityLevel _activityLevel;
+
+ QLinkedList<Message> layoutQueue;
+ QList<AbstractUiMsg *> layoutedMsgs;
+
+ void updateActivityLevel(const Message &msg);