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 ***************************************************************************/
28 Buffer::Buffer(BufferInfo bufferid, QObject *parent)
30 _bufferInfo(bufferid),
33 if(bufferid.buffer().isEmpty())
35 else if(isChannelName(bufferid.buffer()))
36 _type = ChannelBuffer;
42 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
43 state->splitterState = s.value("Splitter").toByteArray();
46 emit bufferUpdated(this);
53 s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(networkName).arg(bufferName));
54 s.setValue("Splitter", state->splitterState);
58 emit bufferDestroyed(this);
61 Buffer::Type Buffer::bufferType() const {
65 bool Buffer::isActive() const {
66 // FIXME determine status by checking for a networkInfo objekt
70 BufferInfo Buffer::bufferInfo() const {
74 void Buffer::updateBufferInfo(BufferInfo bufferid) {
75 _bufferInfo = bufferid;
78 uint Buffer::networkId() const {
79 return bufferInfo().networkId();
82 QString Buffer::networkName() const {
83 return bufferInfo().network();
86 QString Buffer::bufferName() const {
87 return bufferInfo().buffer();
90 QString Buffer::displayName() const {
91 if(bufferType() == ServerBuffer)
92 return tr("Status Buffer");
97 QList<AbstractUiMsg *> Buffer::contents() const {
101 QVariantMap Buffer::nickList() const {
102 // FIXME should return a Map or List of IrcUsers in the future
103 return QVariantMap();
106 QString Buffer::topic() const {
107 // FIXME check if we got a networkInfo() object
111 QString Buffer::ownNick() const {
112 // FIXME check if we got a networkInfo() object
116 bool Buffer::isStatusBuffer() const {
117 return bufferType() == ServerBuffer;
120 void Buffer::setActive(bool a) {
123 // emit bufferUpdated(this);
127 void Buffer::appendMsg(const Message &msg) {
128 AbstractUiMsg *m = Client::layoutMsg(msg);
129 layoutedMsgs.append(m);
133 void Buffer::prependMsg(const Message &msg) {
134 layoutQueue.append(msg);
137 bool Buffer::layoutMsg() {
138 if(layoutQueue.count()) {
139 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
140 layoutedMsgs.prepend(m);
141 emit msgPrepended(m);
143 return layoutQueue.count();
146 void Buffer::processUserInput(QString msg) {
147 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
148 emit userInput(_bufferInfo, msg);
153 // void Buffer::setTopic(QString t) {
156 // emit bufferUpdated(this);
159 // void Buffer::addNick(QString nick, QVariantMap props) {
160 // if(nick == ownNick()) setActive(true);
161 // nicks[nick] = props;
162 // emit nickListChanged(nicks);
165 // void Buffer::updateNick(QString nick, QVariantMap props) {
166 // nicks[nick] = props;
167 // emit nickListChanged(nicks);
170 // void Buffer::renameNick(QString oldnick, QString newnick) {
171 // QVariant v = nicks.take(oldnick);
172 // nicks[newnick] = v;
173 // emit nickListChanged(nicks);
176 // void Buffer::removeNick(QString nick) {
177 // if(nick == ownNick()) setActive(false);
178 // nicks.remove(nick);
179 // emit nickListChanged(nicks);
182 // void Buffer::setOwnNick(QString nick) {
184 // emit ownNickSet(nick);