1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel Team *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
26 Buffer::Buffer(QString netname, QString bufname) {
27 Buffer(BufferId(0, netname, bufname));
33 Buffer::Buffer(BufferId bufid) {
35 _networkName = bufid.network();
36 _bufferName = bufid.buffer();
38 if(_bufferName.isEmpty()) type = ServerBuffer;
39 else if(isChannelName(_bufferName)) type = ChannelBuffer;
40 else type = QueryBuffer;
45 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
46 state->splitterState = s.value("Splitter").toByteArray();
49 emit bufferUpdated(this);
56 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
57 s.setValue("Splitter", state->splitterState);
61 emit bufferDestroyed(this);
64 Buffer::Type Buffer::bufferType() const {
68 bool Buffer::isActive() const {
72 QString Buffer::networkName() const {
76 QString Buffer::bufferName() const {
80 QString Buffer::displayName() const {
81 if(bufferType() == ServerBuffer)
82 return tr("Status Buffer");
87 BufferId Buffer::bufferId() const {
91 QList<AbstractUiMsg *> Buffer::contents() const {
95 VarMap Buffer::nickList() const {
99 QString Buffer::topic() const {
103 QString Buffer::ownNick() const {
107 bool Buffer::isStatusBuffer() const {
108 return bufferType() == ServerBuffer;
111 void Buffer::setActive(bool a) {
114 emit bufferUpdated(this);
118 void Buffer::appendMsg(const Message &msg) {
119 AbstractUiMsg *m = Client::layoutMsg(msg);
120 layoutedMsgs.append(m);
124 void Buffer::prependMsg(const Message &msg) {
125 layoutQueue.append(msg);
128 bool Buffer::layoutMsg() {
129 if(layoutQueue.count()) {
130 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
131 layoutedMsgs.prepend(m);
132 emit msgPrepended(m);
134 return layoutQueue.count();
137 void Buffer::processUserInput(QString msg) {
138 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
139 emit userInput(id, msg);
142 void Buffer::setTopic(QString t) {
145 emit bufferUpdated(this);
148 void Buffer::addNick(QString nick, VarMap props) {
149 if(nick == ownNick()) setActive(true);
151 emit nickListChanged(nicks);
154 void Buffer::updateNick(QString nick, VarMap props) {
156 emit nickListChanged(nicks);
159 void Buffer::renameNick(QString oldnick, QString newnick) {
160 QVariant v = nicks.take(oldnick);
162 emit nickListChanged(nicks);
165 void Buffer::removeNick(QString nick) {
166 if(nick == ownNick()) setActive(false);
168 emit nickListChanged(nicks);
171 void Buffer::setOwnNick(QString nick) {
173 emit ownNickSet(nick);
176 /****************************************************************************************/
179 /****************************************************************************************/