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(BufferInfo bufferid, QObject *parent)
28 _bufferInfo(bufferid),
31 if(bufferid.buffer().isEmpty())
33 else if(isChannelName(bufferid.buffer()))
34 _type = ChannelBuffer;
40 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
41 state->splitterState = s.value("Splitter").toByteArray();
44 emit bufferUpdated(this);
51 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
52 s.setValue("Splitter", state->splitterState);
56 emit bufferDestroyed(this);
59 Buffer::Type Buffer::bufferType() const {
63 bool Buffer::isActive() const {
64 // FIXME determine status by checking for a networkInfo objekt
68 BufferInfo Buffer::bufferInfo() const {
72 void Buffer::updateBufferInfo(BufferInfo bufferid) {
73 _bufferInfo = bufferid;
76 uint Buffer::networkId() const {
77 return bufferInfo().networkId();
80 QString Buffer::networkName() const {
81 return bufferInfo().network();
84 QString Buffer::bufferName() const {
85 return bufferInfo().buffer();
88 QString Buffer::displayName() const {
89 if(bufferType() == ServerBuffer)
90 return tr("Status Buffer");
95 QList<AbstractUiMsg *> Buffer::contents() const {
99 QVariantMap Buffer::nickList() const {
100 // FIXME should return a Map or List of IrcUsers in the future
101 return QVariantMap();
104 QString Buffer::topic() const {
105 // FIXME check if we got a networkInfo() object
109 QString Buffer::ownNick() const {
110 // FIXME check if we got a networkInfo() object
114 bool Buffer::isStatusBuffer() const {
115 return bufferType() == ServerBuffer;
118 void Buffer::setActive(bool a) {
121 // emit bufferUpdated(this);
125 void Buffer::appendMsg(const Message &msg) {
126 AbstractUiMsg *m = Client::layoutMsg(msg);
127 layoutedMsgs.append(m);
131 void Buffer::prependMsg(const Message &msg) {
132 layoutQueue.append(msg);
135 bool Buffer::layoutMsg() {
136 if(layoutQueue.count()) {
137 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
138 layoutedMsgs.prepend(m);
139 emit msgPrepended(m);
141 return layoutQueue.count();
144 void Buffer::processUserInput(QString msg) {
145 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
146 emit userInput(_bufferInfo, msg);
151 // void Buffer::setTopic(QString t) {
154 // emit bufferUpdated(this);
157 // void Buffer::addNick(QString nick, QVariantMap props) {
158 // if(nick == ownNick()) setActive(true);
159 // nicks[nick] = props;
160 // emit nickListChanged(nicks);
163 // void Buffer::updateNick(QString nick, QVariantMap props) {
164 // nicks[nick] = props;
165 // emit nickListChanged(nicks);
168 // void Buffer::renameNick(QString oldnick, QString newnick) {
169 // QVariant v = nicks.take(oldnick);
170 // nicks[newnick] = v;
171 // emit nickListChanged(nicks);
174 // void Buffer::removeNick(QString nick) {
175 // if(nick == ownNick()) setActive(false);
176 // nicks.remove(nick);
177 // emit nickListChanged(nicks);
180 // void Buffer::setOwnNick(QString nick) {
182 // emit ownNickSet(nick);