the new chatwidget now highlights the first new message since your last visit (curren...
[quassel.git] / src / qtui / chatline.cpp
index 0e4df22..af77b12 100644 (file)
 #include <QtGui>
 
 #include "bufferinfo.h"
+#include "buffersyncer.h"
+#include "client.h"
 #include "chatitem.h"
 #include "chatline.h"
+#include "messagemodel.h"
+#include "networkmodel.h"
 #include "qtui.h"
 
 ChatLine::ChatLine(int row, QAbstractItemModel *model, QGraphicsItem *parent)
@@ -114,4 +118,18 @@ void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
     QRectF selectRect(left, 0, width() - left, height());
     painter->fillRect(selectRect, QApplication::palette().brush(QPalette::Highlight));
   }
+
+  const QAbstractItemModel *model_ = model();
+  if(model_ && row() > 0) {
+    MsgId msgId = model_->data(model_->index(row() - 1, 0), MessageModel::MsgIdRole).value<MsgId>();
+    BufferId bufferId = model_->data(model_->index(row() - 1, 0), MessageModel::BufferIdRole).value<BufferId>();
+    if(msgId == Client::networkModel()->lastSeenMsgId(bufferId) && chatScene()->isSingleBufferScene()) {
+      QLinearGradient gradient(0, 0, 0, height());
+      gradient.setColorAt(0, Qt::transparent);
+      gradient.setColorAt(1, Qt::red);
+      painter->fillRect(boundingRect(), gradient);
+    }
+  }
+
+
 }