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);
49 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
50 s.setValue("Splitter", state->splitterState);
54 emit bufferDestroyed(this);
57 Buffer::Type Buffer::bufferType() const {
61 bool Buffer::isActive() const {
65 QString Buffer::networkName() const {
69 QString Buffer::bufferName() const {
73 QString Buffer::displayName() const {
74 if(bufferType() == ServerBuffer)
75 return tr("Status Buffer");
80 BufferId Buffer::bufferId() const {
84 QList<AbstractUiMsg *> Buffer::contents() const {
88 VarMap Buffer::nickList() const {
92 QString Buffer::topic() const {
96 QString Buffer::ownNick() const {
100 bool Buffer::isStatusBuffer() const {
101 return bufferType() == ServerBuffer;
104 void Buffer::setActive(bool a) {
107 emit bufferUpdated(this);
111 void Buffer::appendMsg(const Message &msg) {
112 AbstractUiMsg *m = Client::layoutMsg(msg);
113 layoutedMsgs.append(m);
117 void Buffer::prependMsg(const Message &msg) {
118 layoutQueue.append(msg);
121 bool Buffer::layoutMsg() {
122 if(layoutQueue.count()) {
123 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
124 layoutedMsgs.prepend(m);
125 emit msgPrepended(m);
127 return layoutQueue.count();
130 void Buffer::processUserInput(QString msg) {
131 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
132 emit userInput(id, msg);
135 void Buffer::setTopic(QString t) {
138 emit bufferUpdated(this);
141 void Buffer::addNick(QString nick, VarMap props) {
142 if(nick == ownNick()) setActive(true);
144 emit nickListChanged(nicks);
147 void Buffer::updateNick(QString nick, VarMap props) {
149 emit nickListChanged(nicks);
152 void Buffer::renameNick(QString oldnick, QString newnick) {
153 QVariant v = nicks.take(oldnick);
155 emit nickListChanged(nicks);
158 void Buffer::removeNick(QString nick) {
159 if(nick == ownNick()) setActive(false);
161 emit nickListChanged(nicks);
164 void Buffer::setOwnNick(QString nick) {
166 emit ownNickSet(nick);