activated()->triggered()
[quassel.git] / gui / buffer.h
1 /***************************************************************************
2  *   Copyright (C) 2005/06 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 "ui_bufferwidget.h"
28
29 #include "global.h"
30 #include "message.h"
31
32 class BufferWidget;
33
34 class Buffer : public QObject {
35   Q_OBJECT
36
37   public:
38     Buffer(QString network, QString buffer);
39     ~Buffer();
40
41     bool isActive() { return active; }
42   public:
43     QWidget *getWidget();
44
45   signals:
46     void userInput(QString, QString, QString);
47     void nickListChanged(QStringList);
48
49   public slots:
50     void setActive(bool active = true);
51     void displayMsg(Message);
52     //void recvStatusMsg(QString msg);
53     void setTopic(QString);
54     //void setNicks(QStringList);
55     void addNick(QString nick, VarMap props);
56     void renameNick(QString oldnick, QString newnick);
57     void removeNick(QString nick);
58     void updateNick(QString nick, VarMap props);
59     void setOwnNick(QString nick);
60
61     QWidget * showWidget(QWidget *parent = 0);
62     void hideWidget();
63
64     void scrollToEnd();
65
66   private slots:
67     void userInput(QString);
68
69   private:
70     bool active;
71     BufferWidget *widget;
72     VarMap nicks;
73     QString topic;
74     QString ownNick;
75     QString networkName, bufferName;
76
77     QList<Message> contents;
78 };
79
80 class BufferWidget : public QWidget {
81   Q_OBJECT
82
83   public:
84     BufferWidget(QString netname, QString bufname, bool active, QString ownNick, QList<Message> contents, QWidget *parent = 0);
85
86     void setActive(bool act = true);
87   signals:
88     void userInput(QString);
89
90   public slots:
91     void displayMsg(Message);
92     void updateNickList(VarMap nicks);
93     void setOwnNick(QString ownNick);
94     void setTopic(QString topic);
95     void renderContents();
96     void scrollToEnd();
97
98   private slots:
99     void enterPressed();
100     void itemExpansionChanged(QTreeWidgetItem *);
101     void updateTitle();
102
103   private:
104     Ui::BufferWidget ui;
105     bool active;
106     QList<Message> contents;
107
108     QString stdCol, errorCol, noticeCol, joinCol, quitCol, partCol, kickCol, serverCol, nickCol, inactiveCol;
109     QString CSS;
110     QString networkName;
111     QString bufferName;
112
113     bool opsExpanded, voicedExpanded, usersExpanded;
114
115     QString htmlFromMsg(Message);
116 };
117
118 #endif