fa2e4724e860a18fa8f01e333419a3f516d260ab
[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 uid() const;
65   uint networkId() const;
66   
67   QString networkName() const;
68   QString bufferName() const;
69   QString displayName() const;
70   
71   QList<AbstractUiMsg *> contents() const;
72   
73   QVariantMap nickList() const;
74   QString topic() const;
75   QString ownNick() const;
76
77 signals:
78   void userInput(const BufferInfo &, QString);
79   void nickListChanged(QVariantMap nicks);
80   void topicSet(QString topic);
81   void ownNickSet(QString ownNick);
82   void bufferUpdated(Buffer *);
83
84   void msgAppended(AbstractUiMsg *);
85   void msgPrepended(AbstractUiMsg *);
86   void layoutQueueEmpty();
87
88 public slots:
89   void setActive(bool active = true);
90   void appendMsg(const Message &);
91   void prependMsg(const Message &);
92   bool layoutMsg();
93
94   // no longer needed
95 //   void setTopic(QString);
96 //   //void setNicks(QStringList);
97 //   void addNick(QString nick, QVariantMap props);
98 //   void renameNick(QString oldnick, QString newnick);
99 //   void removeNick(QString nick);
100 //   void updateNick(QString nick, QVariantMap props);
101 //  void setOwnNick(QString nick);
102
103   void processUserInput(QString);
104
105 private:
106   BufferInfo _bufferInfo;
107   bool _active;
108   Type _type;
109   BufferState *state;
110
111   QList<Message> layoutQueue;
112   QList<AbstractUiMsg *> layoutedMsgs;
113
114 };
115 Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
116
117 #endif