still continuing separation of gui and data and file reorganisation:
[quassel.git] / src / client / buffer.cpp
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 #include "buffer.h"
22 #include "util.h"
23 #include "chatwidget.h"
24 #include "bufferwidget.h"
25
26 /*
27 Buffer::Buffer(QString netname, QString bufname) {
28   Buffer(BufferId(0, netname, bufname));
29
30
31 }
32 */
33
34 Buffer::Buffer(BufferId bufid) {
35   id = bufid;
36   _networkName = bufid.network();
37   _bufferName = bufid.buffer();
38
39   if(_bufferName.isEmpty()) type = ServerBuffer;
40   else if(isChannelName(_bufferName)) type = ChannelBuffer;
41   else type = QueryBuffer;
42
43   active = false;
44 /*
45   QSettings s;
46   s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
47   state->splitterState = s.value("Splitter").toByteArray();
48   s.endGroup();
49   */
50   emit bufferUpdated(this);
51 }
52
53 Buffer::~Buffer() {
54   //delete widget;
55   /*
56   QSettings s;
57   s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
58   s.setValue("Splitter", state->splitterState);
59   s.endGroup();
60 */
61   //delete state;
62   emit bufferDestroyed(this);
63 }
64
65 void Buffer::init() {
66
67
68 }
69
70 QString Buffer::displayName() {
71   if(bufferType() == ServerBuffer)
72     return tr("status");
73   else
74     return bufferName();
75 }
76
77 void Buffer::setActive(bool a) {
78   if(a != active) {
79     active = a;
80     emit bufferUpdated(this);
81   }
82 }
83
84 void Buffer::appendChatLine(ChatLine *line) {
85   lines.append(line);
86   emit chatLineAppended(line);
87 }
88
89 void Buffer::prependChatLine(ChatLine *line) {
90   lines.prepend(line);
91   emit chatLinePrepended(line);
92 }
93
94 void Buffer::processUserInput(QString msg) {
95   // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
96   emit userInput(id, msg);
97 }
98
99 void Buffer::setTopic(QString t) {
100   _topic = t;
101   emit topicSet(t);
102   emit bufferUpdated(this);
103 }
104
105 void Buffer::addNick(QString nick, VarMap props) {
106   if(nick == ownNick()) setActive(true);
107   nicks[nick] = props;
108   emit nickListChanged(nicks);
109 }
110
111 void Buffer::updateNick(QString nick, VarMap props) {
112   nicks[nick] = props;
113   emit nickListChanged(nicks);
114 }
115
116 void Buffer::renameNick(QString oldnick, QString newnick) {
117   QVariant v = nicks.take(oldnick);
118   nicks[newnick] = v;
119   emit nickListChanged(nicks);
120 }
121
122 void Buffer::removeNick(QString nick) {
123   if(nick == ownNick()) setActive(false);
124   nicks.remove(nick);
125   emit nickListChanged(nicks);
126 }
127
128 void Buffer::setOwnNick(QString nick) {
129   _ownNick = nick;
130   emit ownNickSet(nick);
131 }
132
133 /****************************************************************************************/
134
135
136 /****************************************************************************************/
137