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(BufferId bufid) {
28 _networkName = bufid.network();
29 _bufferName = bufid.buffer();
31 if(_bufferName.isEmpty()) type = ServerBuffer;
32 else if(isChannelName(_bufferName)) type = ChannelBuffer;
33 else type = QueryBuffer;
38 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
39 state->splitterState = s.value("Splitter").toByteArray();
42 emit bufferUpdated(this);
46 //qDebug() << "destroying buffer";
50 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
51 s.setValue("Splitter", state->splitterState);
55 emit bufferDestroyed(this);
58 Buffer::Type Buffer::bufferType() const {
62 bool Buffer::isActive() const {
66 QString Buffer::networkName() const {
70 QString Buffer::bufferName() const {
74 QString Buffer::displayName() const {
75 if(bufferType() == ServerBuffer)
76 return tr("Status Buffer");
81 BufferId Buffer::bufferId() const {
85 QList<AbstractUiMsg *> Buffer::contents() const {
89 VarMap Buffer::nickList() const {
93 QString Buffer::topic() const {
97 QString Buffer::ownNick() const {
101 bool Buffer::isStatusBuffer() const {
102 return bufferType() == ServerBuffer;
105 void Buffer::setActive(bool a) {
108 emit bufferUpdated(this);
112 void Buffer::appendMsg(const Message &msg) {
113 AbstractUiMsg *m = Client::layoutMsg(msg);
114 layoutedMsgs.append(m);
118 void Buffer::prependMsg(const Message &msg) {
119 layoutQueue.append(msg);
122 bool Buffer::layoutMsg() {
123 if(layoutQueue.count()) {
124 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
125 layoutedMsgs.prepend(m);
126 emit msgPrepended(m);
128 return layoutQueue.count();
131 void Buffer::processUserInput(QString msg) {
132 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
133 emit userInput(id, msg);
136 void Buffer::setTopic(QString t) {
139 emit bufferUpdated(this);
142 void Buffer::addNick(QString nick, VarMap props) {
143 if(nick == ownNick()) setActive(true);
145 emit nickListChanged(nicks);
148 void Buffer::updateNick(QString nick, VarMap props) {
150 emit nickListChanged(nicks);
153 void Buffer::renameNick(QString oldnick, QString newnick) {
154 QVariant v = nicks.take(oldnick);
156 emit nickListChanged(nicks);
159 void Buffer::removeNick(QString nick) {
160 if(nick == ownNick()) setActive(false);
162 emit nickListChanged(nicks);
165 void Buffer::setOwnNick(QString nick) {
167 emit ownNickSet(nick);