Fix compiler warnings
[quassel.git] / src / qtui / chatlinemodel.cpp
index 28d77fb..720f9b4 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  ***************************************************************************/
 
 #include "chatlinemodel.h"
+#include "qtui.h"
+#include "qtuistyle.h"
 
-#include "chatlinemodelitem.h"
-
-ChatLineModel::ChatLineModel(QObject *parent) : MessageModel(parent) {
+ChatLineModel::ChatLineModel(QObject *parent)
+  : MessageModel(parent)
+{
   qRegisterMetaType<WrapList>("ChatLineModel::WrapList");
   qRegisterMetaTypeStreamOperators<WrapList>("ChatLineModel::WrapList");
 
+  connect(QtUi::style(), SIGNAL(changed()), SLOT(styleChanged()));
 }
 
-ChatLineModel::~ChatLineModel() {
+// MessageModelItem *ChatLineModel::createMessageModelItem(const Message &msg) {
+//   return new ChatLineModelItem(msg);
+// }
 
+void ChatLineModel::insertMessages__(int pos, const QList<Message> &messages) {
+  for(int i = 0; i < messages.count(); i++) {
+    _messageList.insert(pos, ChatLineModelItem(messages[i]));
+    pos++;
+  }
 }
 
-
-MessageModelItem *ChatLineModel::createMessageModelItem(const Message &msg) {
-  return new ChatLineModelItem(msg);
-
+Message ChatLineModel::takeMessageAt(int i) {
+  Message msg = _messageList[i].message();
+  _messageList.removeAt(i);
+  return msg;
 }
 
+void ChatLineModel::styleChanged() {
+  foreach(ChatLineModelItem item, _messageList) {
+    item.invalidateWrapList();
+  }
+  emit dataChanged(index(0,0), index(rowCount()-1, columnCount()-1));
+}
 
 QDataStream &operator<<(QDataStream &out, const ChatLineModel::WrapList wplist) {
   out << wplist.count();