#else
void Client::recvMessage(const Message &msg) {
-
-
+ //checkForHighlight(msg);
+ _messageModel->insertMessage(msg);
}
#endif /* SPUTDEV */
//recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg)));
}
+#ifdef SPUTDEV
+void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
+ //checkForHighlight(msg);
+ foreach(QVariant v, msgs) {
+ _messageModel->insertMessage(v.value<Message>());
+ }
+}
+
+#else
+
void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
-#ifndef SPUTDEV
Buffer *buffer_ = buffer(bufferId);
if(!buffer_) {
qWarning() << "Client::recvBacklogData(): received Backlog for unknown Buffer:" << bufferId;
if(!layoutTimer->isActive()) {
layoutTimer->start();
}
-#endif
}
+#endif /* SPUTDEV */
void Client::layoutMsg() {
if(layoutQueue.isEmpty()) {
void MessageModel::insertMessage(const Message &msg) {
MsgId id = msg.msgId();
- int idx = indexForId(id); qDebug() << "inserting at" << idx << msg.text();
+ int idx = indexForId(id);
MessageItem *item = createMessageItem(msg);
beginInsertRows(QModelIndex(), idx, idx);
_messageList.insert(idx, item);
}
QVariant MessageItem::data(int column, int role) const {
- if(column < TimestampRole || column > TextRole) return QVariant();
+ if(column < TimestampColumn || column > TextColumn) return QVariant();
switch(role) {
- case MsgIdRole: return _msgId;
- case BufferIdRole: return _bufferId;
- case TypeRole: return _type;
- case FlagsRole: return _flags;
- case TimestampRole: return _timestamp;
+ case MessageModel::MsgIdRole: return QVariant::fromValue<MsgId>(_msgId);
+ case MessageModel::BufferIdRole: return QVariant::fromValue<BufferId>(_bufferId);
+ case MessageModel::TypeRole: return _type;
+ case MessageModel::FlagsRole: return (int)_flags;
+ case MessageModel::TimestampRole: return _timestamp;
default: return QVariant();
}
}
#include "chatline.h"
-Chatline::Chatline(const QMessage &msg) : MessageItem(msg) {
+Chatline::Chatline(const Message &msg) : MessageItem(msg) {
}
+QVariant Chatline::data(int column, int role) const {
+ return MessageItem::data(column, role);
+}
+
+bool Chatline::setData(int column, const QVariant &value, int role) {
+ return false;
+}
#ifndef CHATLINE_H_
#define CHATLINE_H_
+#include "messagemodel.h"
+
class Chatline : public MessageItem {
public:
Chatline(const Message &);
+ //virtual ~Chatline() {};
virtual QVariant data(int column, int role) const;
virtual bool setData(int column, const QVariant &value, int role);
#include "chatlinemodel.h"
+#include "chatline.h"
+
ChatlineModel::ChatlineModel(QObject *parent) : MessageModel(parent) {
MessageItem *ChatlineModel::createMessageItem(const Message &msg) {
- return 0;
+ return new Chatline(msg);
}
}
void ChatScene::appendMsg(AbstractUiMsg * msg) {
+ /*
ChatLine *line = dynamic_cast<ChatLine*>(msg);
Q_ASSERT(line);
_lines.append(line);
addItem(line);
line->setPos(0, _lines.count() * 30);
line->setColumnWidths(80, 80, 400);
+ */
}
void ChatScene::prependMsg(AbstractUiMsg * msg) {
+ /*
ChatLine *line = dynamic_cast<ChatLine*>(msg);
Q_ASSERT(line); qDebug() << "prepending";
_lines.prepend(line);
addItem(line);
line->setPos(0, _lines.count() * 30);
+ */
}
void ChatScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) {
+ /*
qDebug() << "recv" << mouseEvent->scenePos();
ChatLine *line = static_cast<ChatLine*>(itemAt(mouseEvent->scenePos()));
ChatItem *item = static_cast<ChatItem*>(itemAt(mouseEvent->scenePos()));
if(line) {
line->myMousePressEvent(mouseEvent);
} else QGraphicsScene::mousePressEvent(mouseEvent);
+ */
}
}
void ChatView::prependMsg(AbstractUiMsg *msg) {
- ChatLine *line = dynamic_cast<ChatLine*>(msg);
- Q_ASSERT(line);
- prependChatLine(line);
+ //ChatLine *line = dynamic_cast<ChatLine*>(msg);
+ //Q_ASSERT(line);
+ //prependChatLine(line);
}
void ChatView::prependChatLine(ChatLine *line) {
}
void ChatView::appendMsg(AbstractUiMsg *msg) {
- ChatLine *line = dynamic_cast<ChatLine*>(msg);
- Q_ASSERT(line);
- appendChatLine(line);
+ //ChatLine *line = dynamic_cast<ChatLine*>(msg);
+ //Q_ASSERT(line);
+ //appendChatLine(line);
}
void ChatView::appendChatLine(ChatLine *line) {
void ChatView::appendChatLines(QList<ChatLine *> list) {
- foreach(ChatLine *line, list) {
+ //foreach(ChatLine *line, list) {
- }
+ //}
}
void ChatView::setContents(const QList<AbstractUiMsg *> &list) {
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _CHATVIEW_H_
-#define _CHATVIEW_H_
+#ifndef CHATVIEW_H_
+#define CHATVIEW_H_
#include <QGraphicsView>
AbstractUiMsg *MainWin::layoutMsg(const Message &msg) {
#ifdef SPUTDEV
- return new ChatLine(msg);
+ //return new ChatLine(msg);
+ return 0;
#else
return new ChatLineOld(msg);
#endif