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()))
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);
60 Buffer::Type Buffer::bufferType() const {
64 bool Buffer::isActive() const {
65 // FIXME determine status by checking for a networkInfo objekt
69 BufferInfo Buffer::bufferInfo() const {
73 void Buffer::updateBufferInfo(BufferInfo bufferid) {
74 _bufferInfo = bufferid;
77 uint Buffer::uid() const {
78 return bufferInfo().uid();
81 uint Buffer::networkId() const {
82 return bufferInfo().networkId();
85 QString Buffer::networkName() const {
86 return bufferInfo().network();
89 QString Buffer::bufferName() const {
90 return bufferInfo().buffer();
93 QString Buffer::displayName() const {
94 if(bufferType() == StatusType)
95 return tr("Status 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);
156 // void Buffer::setTopic(QString t) {
159 // emit bufferUpdated(this);
162 // void Buffer::addNick(QString nick, QVariantMap props) {
163 // if(nick == ownNick()) setActive(true);
164 // nicks[nick] = props;
165 // emit nickListChanged(nicks);
168 // void Buffer::updateNick(QString nick, QVariantMap props) {
169 // nicks[nick] = props;
170 // emit nickListChanged(nicks);
173 // void Buffer::renameNick(QString oldnick, QString newnick) {
174 // QVariant v = nicks.take(oldnick);
175 // nicks[newnick] = v;
176 // emit nickListChanged(nicks);
179 // void Buffer::removeNick(QString nick) {
180 // if(nick == ownNick()) setActive(false);
181 // nicks.remove(nick);
182 // emit nickListChanged(nicks);
185 // void Buffer::setOwnNick(QString nick) {
187 // emit ownNickSet(nick);