* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+#include <QDebug>
#include "buffer.h"
-#include "util.h"
-#include "chatwidget.h"
-#include "bufferwidget.h"
-
-/*
-Buffer::Buffer(QString netname, QString bufname) {
- Buffer(BufferId(0, netname, bufname));
-
-}
-*/
+#include "client.h"
+#include "util.h"
-Buffer::Buffer(BufferId bufid) {
- id = bufid;
- _networkName = bufid.network();
- _bufferName = bufid.buffer();
- if(_bufferName.isEmpty()) type = ServerBuffer;
- else if(isChannelName(_bufferName)) type = ChannelBuffer;
- else type = QueryBuffer;
+Buffer::Buffer(BufferInfo bufferid, QObject *parent)
+ : QObject(parent),
+ _bufferInfo(bufferid),
+ _active(false)
+{
+ if(bufferid.buffer().isEmpty())
+ _type = StatusType;
+ else if(isChannelName(bufferid.buffer()))
+ _type = ChannelType;
+ else
+ _type = QueryType;
- active = false;
/*
QSettings s;
s.beginGroup(QString("GUI/BufferStates/%1/%2").arg(netname).arg(bufname));
s.endGroup();
*/
//delete state;
- emit bufferDestroyed(this);
}
-void Buffer::init() {
+Buffer::Type Buffer::bufferType() const {
+ return _type;
+}
+bool Buffer::isActive() const {
+ // FIXME determine status by checking for a networkInfo objekt
+ return true;
+}
+BufferInfo Buffer::bufferInfo() const {
+ return _bufferInfo;
}
-QString Buffer::displayName() {
- if(bufferType() == ServerBuffer)
- return tr("status");
- else
- return bufferName();
+void Buffer::updateBufferInfo(BufferInfo bufferid) {
+ _bufferInfo = bufferid;
}
-void Buffer::setActive(bool a) {
- if(a != active) {
- active = a;
- emit bufferUpdated(this);
- }
+uint Buffer::networkId() const {
+ return bufferInfo().networkId();
}
-void Buffer::appendChatLine(ChatLine *line) {
- lines.append(line);
- emit chatLineAppended(line);
+QString Buffer::networkName() const {
+ return bufferInfo().network();
}
-void Buffer::prependChatLine(ChatLine *line) {
- lines.prepend(line);
- emit chatLinePrepended(line);
+QString Buffer::bufferName() const {
+ return bufferInfo().buffer();
}
-void Buffer::processUserInput(QString msg) {
- // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
- emit userInput(id, msg);
+QString Buffer::displayName() const {
+ if(bufferType() == StatusType)
+ return tr("Status Buffer");
+ else
+ return bufferName();
}
-void Buffer::setTopic(QString t) {
- _topic = t;
- emit topicSet(t);
- emit bufferUpdated(this);
+QList<AbstractUiMsg *> Buffer::contents() const {
+ return layoutedMsgs;
+}
+
+QVariantMap Buffer::nickList() const {
+ // FIXME should return a Map or List of IrcUsers in the future
+ return QVariantMap();
}
-void Buffer::addNick(QString nick, VarMap props) {
- if(nick == ownNick()) setActive(true);
- nicks[nick] = props;
- emit nickListChanged(nicks);
+QString Buffer::topic() const {
+ // FIXME check if we got a networkInfo() object
+ return QString();
}
-void Buffer::updateNick(QString nick, VarMap props) {
- nicks[nick] = props;
- emit nickListChanged(nicks);
+QString Buffer::ownNick() const {
+ // FIXME check if we got a networkInfo() object
+ return QString();
}
-void Buffer::renameNick(QString oldnick, QString newnick) {
- QVariant v = nicks.take(oldnick);
- nicks[newnick] = v;
- emit nickListChanged(nicks);
+bool Buffer::isStatusBuffer() const {
+ return bufferType() == StatusType;
}
-void Buffer::removeNick(QString nick) {
- if(nick == ownNick()) setActive(false);
- nicks.remove(nick);
- emit nickListChanged(nicks);
+void Buffer::setActive(bool a) {
+// if(a != active) {
+// active = a;
+// emit bufferUpdated(this);
+// }
}
-void Buffer::setOwnNick(QString nick) {
- _ownNick = nick;
- emit ownNickSet(nick);
+void Buffer::appendMsg(const Message &msg) {
+ AbstractUiMsg *m = Client::layoutMsg(msg);
+ layoutedMsgs.append(m);
+ emit msgAppended(m);
}
-/****************************************************************************************/
+void Buffer::prependMsg(const Message &msg) {
+ layoutQueue.append(msg);
+}
+bool Buffer::layoutMsg() {
+ if(layoutQueue.count()) {
+ AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
+ layoutedMsgs.prepend(m);
+ emit msgPrepended(m);
+ }
+ return layoutQueue.count();
+}
-/****************************************************************************************/
+void Buffer::processUserInput(QString msg) {
+ // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so...
+ emit userInput(_bufferInfo, msg);
+}
+// no longer needed
+// back reference:
+// void Buffer::setTopic(QString t) {
+// _topic = t;
+// emit topicSet(t);
+// emit bufferUpdated(this);
+// }
+
+// void Buffer::addNick(QString nick, QVariantMap props) {
+// if(nick == ownNick()) setActive(true);
+// nicks[nick] = props;
+// emit nickListChanged(nicks);
+// }
+
+// void Buffer::updateNick(QString nick, QVariantMap props) {
+// nicks[nick] = props;
+// emit nickListChanged(nicks);
+// }
+
+// void Buffer::renameNick(QString oldnick, QString newnick) {
+// QVariant v = nicks.take(oldnick);
+// nicks[newnick] = v;
+// emit nickListChanged(nicks);
+// }
+
+// void Buffer::removeNick(QString nick) {
+// if(nick == ownNick()) setActive(false);
+// nicks.remove(nick);
+// emit nickListChanged(nicks);
+// }
+
+// void Buffer::setOwnNick(QString nick) {
+// _ownNick = nick;
+// emit ownNickSet(nick);
+// }