SPUTDEV compiles again, and the MessageModel now actually is filled with messages...
authorManuel Nickschas <sputnick@quassel-irc.org>
Sat, 26 Apr 2008 01:02:17 +0000 (01:02 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 26 Apr 2008 01:02:17 +0000 (01:02 +0000)
src/client/client.cpp
src/client/messagemodel.cpp
src/qtui/chatline.cpp
src/qtui/chatline.h
src/qtui/chatlinemodel.cpp
src/qtui/chatscene.cpp
src/qtui/chatview.cpp
src/qtui/chatview.h
src/qtui/mainwin.cpp

index 64092dd..5f22eef 100644 (file)
@@ -505,8 +505,8 @@ void Client::recvMessage(const Message &message) {
 #else
 
 void Client::recvMessage(const Message &msg) {
-
-
+  //checkForHighlight(msg);
+  _messageModel->insertMessage(msg);
 }
 
 #endif /* SPUTDEV */
@@ -515,8 +515,17 @@ void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) {
   //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;
@@ -542,8 +551,8 @@ void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) {
   if(!layoutTimer->isActive()) {
     layoutTimer->start();
   }
-#endif
 }
+#endif /* SPUTDEV */
 
 void Client::layoutMsg() {
   if(layoutQueue.isEmpty()) {
index 4e4b264..c41ad97 100644 (file)
@@ -51,7 +51,7 @@ bool MessageModel::setData(const QModelIndex &index, const QVariant &value, int
 
 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);
@@ -95,13 +95,13 @@ MessageItem::~MessageItem() {
 }
 
 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();
   }
 }
index edb89f1..ef59fc4 100644 (file)
 
 #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;
+}
index c16de80..087e2e8 100644 (file)
 #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);
index 9d640d8..09904e2 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "chatlinemodel.h"
 
+#include "chatline.h"
+
 ChatlineModel::ChatlineModel(QObject *parent) : MessageModel(parent) {
 
 
@@ -31,6 +33,6 @@ ChatlineModel::~ChatlineModel() {
 
 
 MessageItem *ChatlineModel::createMessageItem(const Message &msg) {
-  return 0;
+  return new Chatline(msg);
 
 }
index 1d00876..669f746 100644 (file)
@@ -42,23 +42,28 @@ ChatScene::~ChatScene() {
 }
 
 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()));
@@ -66,4 +71,5 @@ void ChatScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) {
   if(line) {
     line->myMousePressEvent(mouseEvent);
   } else  QGraphicsScene::mousePressEvent(mouseEvent);
+  */
 }
index 54ca6f9..db93f07 100644 (file)
@@ -50,9 +50,9 @@ void ChatView::clear()
 }
 
 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) {
@@ -64,9 +64,9 @@ void ChatView::prependChatLines(QList<ChatLine *> clist) {
 }
 
 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) {
@@ -75,9 +75,9 @@ 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) {
index cc627c7..7ae7c8d 100644 (file)
@@ -18,8 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _CHATVIEW_H_
-#define _CHATVIEW_H_
+#ifndef CHATVIEW_H_
+#define CHATVIEW_H_
 
 #include <QGraphicsView>
 
index c0f07a2..5e6cfad 100644 (file)
@@ -487,7 +487,8 @@ void MainWin::setDisconnectedState() {
 
 AbstractUiMsg *MainWin::layoutMsg(const Message &msg) {
 #ifdef SPUTDEV
-  return new ChatLine(msg);
+  //return new ChatLine(msg);
+  return 0;
 #else
   return new ChatLineOld(msg);
 #endif