rename of bufferview.ui according to new naming scheme
[quassel.git] / gui / 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 #include <QtCore>
25 #include <QtGui>
26
27 #include "chatwidget.h"
28 #include "global.h"
29 #include "message.h"
30
31 class ChatWidget;
32 class ChatLine;
33 class ChatWidgetContents;
34 class BufferWidget;
35 struct BufferState;
36
37 //!\brief Encapsulates the contents of a single channel, query or server status context.
38 /** A Buffer maintains a list of existing nicks and their status. New messages can be appended using
39  * displayMsg(). A buffer displays its contents by way of a BufferWidget, which can be shown
40  * (and created on demand) by calling showWidget().
41  */
42 class Buffer : public QObject {
43   Q_OBJECT
44
45   public:
46     //Buffer(QString network, QString buffer);
47     Buffer(BufferId);
48     ~Buffer();
49     static void init();
50
51     enum Type { ServerBuffer, ChannelBuffer, QueryBuffer };
52     Type bufferType() { return type; }
53     bool isActive() { return active; }
54
55     QString networkName() { return _networkName; }
56     QString bufferName() { return _bufferName; }
57     BufferId bufferId() { return id; }
58     QList<ChatLine *> contents() { return lines; }
59     VarMap nickList() { return nicks; }
60     QString topic() { return _topic; }
61     QString ownNick() { return _ownNick; }
62
63   signals:
64     void userInput(BufferId, QString);
65     //void msgDisplayed(Message);
66     void chatLineAppended(ChatLine *);
67     void chatLinePrepended(ChatLine *);
68     void nickListChanged(VarMap nicks);
69     void topicSet(QString topic);
70     void ownNickSet(QString ownNick);
71     void bufferUpdated(Buffer *);
72     void bufferDestroyed(Buffer *);
73
74   public slots:
75     void setActive(bool active = true);
76     //void displayMsg(Message);
77     //void prependMessages(QList<Message>); // for backlog
78     void appendChatLine(ChatLine *);
79     void prependChatLine(ChatLine *);
80     //void prependChatLines(QList<ChatLine *>);
81     //void recvStatusMsg(QString msg);
82     void setTopic(QString);
83     //void setNicks(QStringList);
84     void addNick(QString nick, VarMap props);
85     void renameNick(QString oldnick, QString newnick);
86     void removeNick(QString nick);
87     void updateNick(QString nick, VarMap props);
88     void setOwnNick(QString nick);
89
90     void processUserInput(QString);
91
92   private:
93     BufferId id;
94     bool active;
95     Type type;
96
97     VarMap nicks;
98     QString _topic;
99     QString _ownNick;
100     QString _networkName, _bufferName;
101     BufferState *state;
102
103     //QList<Message> _contents;
104     QList<ChatLine *> lines;
105
106 };
107
108 #endif