Actually... I have nearly no clue what the changes in this revision are. Since most...
[quassel.git] / src / client / buffer.h
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by The Quassel Team                             *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _BUFFER_H_
22 #define _BUFFER_H_
23
24 class AbstractUiMsg;
25
26 struct BufferState;
27
28 #include "message.h"
29 #include "bufferinfo.h"
30
31 #include <QVariantMap>
32
33 //!\brief Encapsulates the contents of a single channel, query or server status context.
34 /** A Buffer maintains a list of existing nicks and their status.
35  */
36 class Buffer : public QObject {
37   Q_OBJECT
38
39 public:
40   Buffer(BufferInfo, QObject *parent = 0);
41   virtual ~Buffer();
42
43   enum Type {
44     StatusType,
45     ChannelType,
46     QueryType
47   };
48
49   enum Activity {
50     NoActivity = 0x00,
51     OtherActivity = 0x01,
52     NewMessage = 0x02,
53     Highlight = 0x40
54   };
55   Q_DECLARE_FLAGS(ActivityLevel, Activity)
56
57   bool isStatusBuffer() const;
58   Type bufferType() const;
59   bool isActive() const;
60
61   BufferInfo bufferInfo() const;
62   void updateBufferInfo(BufferInfo bufferid);
63   
64   uint networkId() const;
65   
66   QString networkName() const;
67   QString bufferName() const;
68   QString displayName() const;
69   
70   QList<AbstractUiMsg *> contents() const;
71   
72   QVariantMap nickList() const;
73   QString topic() const;
74   QString ownNick() const;
75
76 signals:
77   void userInput(const BufferInfo &, QString);
78   void nickListChanged(QVariantMap nicks);
79   void topicSet(QString topic);
80   void ownNickSet(QString ownNick);
81   void bufferUpdated(Buffer *);
82
83   void msgAppended(AbstractUiMsg *);
84   void msgPrepended(AbstractUiMsg *);
85   void layoutQueueEmpty();
86
87 public slots:
88   void setActive(bool active = true);
89   void appendMsg(const Message &);
90   void prependMsg(const Message &);
91   bool layoutMsg();
92
93   // no longer needed
94 //   void setTopic(QString);
95 //   //void setNicks(QStringList);
96 //   void addNick(QString nick, QVariantMap props);
97 //   void renameNick(QString oldnick, QString newnick);
98 //   void removeNick(QString nick);
99 //   void updateNick(QString nick, QVariantMap props);
100 //  void setOwnNick(QString nick);
101
102   void processUserInput(QString);
103
104 private:
105   BufferInfo _bufferInfo;
106   bool _active;
107   Type _type;
108   BufferState *state;
109
110   QList<Message> layoutQueue;
111   QList<AbstractUiMsg *> layoutedMsgs;
112
113 };
114 Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
115
116 #endif