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"
29 Buffer::Buffer(BufferInfo bufferid, QObject *parent)
31 _bufferInfo(bufferid),
35 if(bufferid.buffer().isEmpty())
37 else if(isChannelName(bufferid.buffer()))
44 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
45 state->splitterState = s.value("Splitter").toByteArray();
48 emit bufferUpdated(this);
55 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
56 s.setValue("Splitter", state->splitterState);
62 Buffer::Type Buffer::bufferType() const {
66 bool Buffer::isActive() const {
67 // FIXME determine status by checking for a networkInfo objekt
71 BufferInfo Buffer::bufferInfo() const {
75 void Buffer::updateBufferInfo(BufferInfo bufferid) {
76 _bufferInfo = bufferid;
79 uint Buffer::uid() const {
80 return bufferInfo().uid();
83 uint Buffer::networkId() const {
84 return bufferInfo().networkId();
87 QString Buffer::networkName() const {
88 return bufferInfo().network();
91 QString Buffer::name() const {
92 if(bufferType() == StatusType)
93 return tr("Status Buffer");
95 return bufferInfo().buffer();
98 QList<AbstractUiMsg *> Buffer::contents() const {
102 QVariantMap Buffer::nickList() const {
103 // FIXME should return a Map or List of IrcUsers in the future
104 return QVariantMap();
107 QString Buffer::topic() const {
108 // FIXME check if we got a networkInfo() object
112 QString Buffer::ownNick() const {
113 // FIXME check if we got a networkInfo() object
117 bool Buffer::isStatusBuffer() const {
118 return bufferType() == StatusType;
121 void Buffer::setActive(bool a) {
124 // emit bufferUpdated(this);
128 void Buffer::appendMsg(const Message &msg) {
129 AbstractUiMsg *m = Client::layoutMsg(msg);
130 layoutedMsgs.append(m);
134 void Buffer::prependMsg(const Message &msg) {
135 layoutQueue.append(msg);
138 bool Buffer::layoutMsg() {
139 if(layoutQueue.count()) {
140 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
141 layoutedMsgs.prepend(m);
142 emit msgPrepended(m);
144 return layoutQueue.count();
147 void Buffer::processUserInput(QString msg) {
148 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
149 emit userInput(_bufferInfo, msg);
152 IrcChannel *Buffer::ircChannel() const {
156 void Buffer::setIrcChannel(IrcChannel *ircchan) {
158 disconnect(_ircChannel, 0, this, 0);
159 // TODO: remove model etc
161 _ircChannel = ircchan;
163 connect(_ircChannel, SIGNAL(destroyed()), this, SLOT(setIrcChannel()));
169 // void Buffer::setTopic(QString t) {
172 // emit bufferUpdated(this);
175 // void Buffer::addNick(QString nick, QVariantMap props) {
176 // if(nick == ownNick()) setActive(true);
177 // nicks[nick] = props;
178 // emit nickListChanged(nicks);
181 // void Buffer::updateNick(QString nick, QVariantMap props) {
182 // nicks[nick] = props;
183 // emit nickListChanged(nicks);
186 // void Buffer::renameNick(QString oldnick, QString newnick) {
187 // QVariant v = nicks.take(oldnick);
188 // nicks[newnick] = v;
189 // emit nickListChanged(nicks);
192 // void Buffer::removeNick(QString nick) {
193 // if(nick == ownNick()) setActive(false);
194 // nicks.remove(nick);
195 // emit nickListChanged(nicks);
198 // void Buffer::setOwnNick(QString nick) {
200 // emit ownNickSet(nick);