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::name() const {
90 if(bufferType() == StatusType)
91 return tr("Status Buffer");
93 return bufferInfo().buffer();
96 QList<AbstractUiMsg *> Buffer::contents() const {
100 QVariantMap Buffer::nickList() const {
101 // FIXME should return a Map or List of IrcUsers in the future
102 return QVariantMap();
105 QString Buffer::topic() const {
106 // FIXME check if we got a networkInfo() object
110 QString Buffer::ownNick() const {
111 // FIXME check if we got a networkInfo() object
115 bool Buffer::isStatusBuffer() const {
116 return bufferType() == StatusType;
119 void Buffer::setActive(bool a) {
122 // emit bufferUpdated(this);
126 void Buffer::appendMsg(const Message &msg) {
127 AbstractUiMsg *m = Client::layoutMsg(msg);
128 layoutedMsgs.append(m);
132 void Buffer::prependMsg(const Message &msg) {
133 layoutQueue.append(msg);
136 bool Buffer::layoutMsg() {
137 if(layoutQueue.count()) {
138 AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
139 layoutedMsgs.prepend(m);
140 emit msgPrepended(m);
142 return layoutQueue.count();
145 void Buffer::processUserInput(QString msg) {
146 // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
147 emit userInput(_bufferInfo, msg);
152 // void Buffer::setTopic(QString t) {
155 // emit bufferUpdated(this);
158 // void Buffer::addNick(QString nick, QVariantMap props) {
159 // if(nick == ownNick()) setActive(true);
160 // nicks[nick] = props;
161 // emit nickListChanged(nicks);
164 // void Buffer::updateNick(QString nick, QVariantMap props) {
165 // nicks[nick] = props;
166 // emit nickListChanged(nicks);
169 // void Buffer::renameNick(QString oldnick, QString newnick) {
170 // QVariant v = nicks.take(oldnick);
171 // nicks[newnick] = v;
172 // emit nickListChanged(nicks);
175 // void Buffer::removeNick(QString nick) {
176 // if(nick == ownNick()) setActive(false);
177 // nicks.remove(nick);
178 // emit nickListChanged(nicks);
181 // void Buffer::setOwnNick(QString nick) {
183 // emit ownNickSet(nick);