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 ***************************************************************************/
25 #include "ircchannel.h"
26 #include "nickmodel.h"
30 Buffer::Buffer(BufferInfo bufferid, QObject *parent)
32 _bufferInfo(bufferid),
34 _ircChannel(0), _nickModel(0)
36 if(bufferid.buffer().isEmpty())
38 else if(isChannelName(bufferid.buffer()))
43 _nickModel = new NickModel(0, this);
46 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
47 state->splitterState = s.value("Splitter").toByteArray();
50 emit bufferUpdated(this);
57 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
58 s.setValue("Splitter", state->splitterState);
64 Buffer::Type Buffer::bufferType() const {
68 bool Buffer::isActive() const {
69 // FIXME determine status by checking for a networkInfo objekt
73 BufferInfo Buffer::bufferInfo() const {
77 void Buffer::updateBufferInfo(BufferInfo bufferid) {
78 _bufferInfo = bufferid;
81 uint Buffer::uid() const {
82 return bufferInfo().uid();
85 uint Buffer::networkId() const {
86 return bufferInfo().networkId();
89 QString Buffer::networkName() const {
90 return bufferInfo().network();
93 QString Buffer::name() const {
94 if(bufferType() == StatusType)
95 return tr("Status Buffer");
97 return bufferInfo().buffer();
100 QList<AbstractUiMsg *> Buffer::contents() const {
104 QVariantMap Buffer::nickList() const {
105 // FIXME should return a Map or List of IrcUsers in the future
106 return QVariantMap();
109 QString Buffer::topic() const {
110 // FIXME check if we got a networkInfo() object
114 QString Buffer::ownNick() const {
115 // FIXME check if we got a networkInfo() object
119 bool Buffer::isStatusBuffer() const {
120 return bufferType() == StatusType;
123 void Buffer::setActive(bool a) {
126 // emit bufferUpdated(this);
130 void Buffer::appendMsg(const Message &msg) {
131 AbstractUiMsg *m = Client::layoutMsg(msg);
132 layoutedMsgs.append(m);
136 void Buffer::prependMsg(const Message &msg) {
137 layoutQueue.append(msg);
140 bool Buffer::layoutMsg() {
141 if(layoutQueue.count()) {
142 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
143 layoutedMsgs.prepend(m);
144 emit msgPrepended(m);
146 return layoutQueue.count();
149 void Buffer::processUserInput(QString msg) {
150 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
151 emit userInput(_bufferInfo, msg);
154 NickModel *Buffer::nickModel() const {
158 IrcChannel *Buffer::ircChannel() const {
162 void Buffer::setIrcChannel(IrcChannel *ircchan) {
164 disconnect(_ircChannel, 0, this, 0);
166 _ircChannel = ircchan;
168 connect(_ircChannel, SIGNAL(destroyed()), this, SLOT(setIrcChannel()));
170 _nickModel->setIrcChannel(ircChannel());
175 // void Buffer::setTopic(QString t) {
178 // emit bufferUpdated(this);
181 // void Buffer::addNick(QString nick, QVariantMap props) {
182 // if(nick == ownNick()) setActive(true);
183 // nicks[nick] = props;
184 // emit nickListChanged(nicks);
187 // void Buffer::updateNick(QString nick, QVariantMap props) {
188 // nicks[nick] = props;
189 // emit nickListChanged(nicks);
192 // void Buffer::renameNick(QString oldnick, QString newnick) {
193 // QVariant v = nicks.take(oldnick);
194 // nicks[newnick] = v;
195 // emit nickListChanged(nicks);
198 // void Buffer::removeNick(QString nick) {
199 // if(nick == ownNick()) setActive(false);
200 // nicks.remove(nick);
201 // emit nickListChanged(nicks);
204 // void Buffer::setOwnNick(QString nick) {
206 // emit ownNickSet(nick);