the new chatwidget now highlights the first new message since your last visit (curren...
authorMarcus Eggenberger <egs@quassel-irc.org>
Tue, 12 Aug 2008 16:39:05 +0000 (18:39 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Tue, 12 Aug 2008 16:39:05 +0000 (18:39 +0200)
src/client/messagefilter.cpp
src/client/messagefilter.h
src/client/networkmodel.cpp
src/client/networkmodel.h
src/qtui/chatline.cpp
src/qtui/chatscene.cpp
src/qtui/chatscene.h
src/uisupport/abstractbuffercontainer.cpp

index e375b2e..543d1fc 100644 (file)
@@ -29,7 +29,6 @@ MessageFilter::MessageFilter(MessageModel *source, const QList<BufferId> &buffer
     _bufferList(buffers)
 {
   setSourceModel(source);
     _bufferList(buffers)
 {
   setSourceModel(source);
-
 }
 
 QString MessageFilter::idString() const {
 }
 
 QString MessageFilter::idString() const {
index 7338842..e767a95 100644 (file)
@@ -37,7 +37,8 @@ class MessageFilter : public QSortFilterProxyModel {
 
     virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
     virtual QString idString() const;
 
     virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
     virtual QString idString() const;
-
+    inline bool isSingleBufferFilter() const { return _bufferList.count() == 1; }
+                           
   private:
     QList<BufferId> _bufferList;
 };
   private:
     QList<BufferId> _bufferList;
 };
index 793f5ae..3f806b5 100644 (file)
@@ -901,6 +901,13 @@ void NetworkModel::removeBuffer(BufferId bufferId) {
   buffItem->parent()->removeChild(buffItem);
 }
 
   buffItem->parent()->removeChild(buffItem);
 }
 
+MsgId NetworkModel::lastSeenMsgId(BufferId bufferId) {
+  if(!_bufferItemCache.contains(bufferId))
+    return MsgId();
+
+  return _bufferItemCache[bufferId]->lastSeenMsgId();
+}
+
 void NetworkModel::setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId) {
   BufferItem *bufferItem = findBufferItem(bufferId);
   if(!bufferItem) {
 void NetworkModel::setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId) {
   BufferItem *bufferItem = findBufferItem(bufferId);
   if(!bufferItem) {
index c564d7e..1a9ace3 100644 (file)
@@ -297,7 +297,7 @@ public:
   Buffer::ActivityLevel bufferActivity(const BufferInfo &buffer) const;
 
   QString bufferName(BufferId bufferId);
   Buffer::ActivityLevel bufferActivity(const BufferInfo &buffer) const;
 
   QString bufferName(BufferId bufferId);
-  MsgId lastSeenMsgId(BufferId BufferId);
+  MsgId lastSeenMsgId(BufferId bufferId);
   NetworkId networkId(BufferId bufferId);
   QString networkName(BufferId bufferId);
   BufferInfo::Type bufferType(BufferId bufferId);
   NetworkId networkId(BufferId bufferId);
   QString networkName(BufferId bufferId);
   BufferInfo::Type bufferType(BufferId bufferId);
index 3e7167b..af77b12 100644 (file)
@@ -28,6 +28,7 @@
 #include "chatitem.h"
 #include "chatline.h"
 #include "messagemodel.h"
 #include "chatitem.h"
 #include "chatline.h"
 #include "messagemodel.h"
+#include "networkmodel.h"
 #include "qtui.h"
 
 ChatLine::ChatLine(int row, QAbstractItemModel *model, QGraphicsItem *parent)
 #include "qtui.h"
 
 ChatLine::ChatLine(int row, QAbstractItemModel *model, QGraphicsItem *parent)
@@ -109,12 +110,6 @@ void ChatLine::setHighlighted(bool highlighted) {
 }
 
 void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
 }
 
 void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
-//   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>();
-//     qDebug() << msgId;
-//   }
   if(_selection & Highlighted) {
     painter->fillRect(boundingRect(), QBrush(QtUi::style()->highlightColor()));
   }
   if(_selection & Highlighted) {
     painter->fillRect(boundingRect(), QBrush(QtUi::style()->highlightColor()));
   }
@@ -123,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));
   }
     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);
+    }
+  }
+
+
 }
 }
index 9ac7974..8bf8add 100644 (file)
@@ -30,6 +30,7 @@
 #include "client.h"
 #include "clientbacklogmanager.h"
 #include "columnhandleitem.h"
 #include "client.h"
 #include "clientbacklogmanager.h"
 #include "columnhandleitem.h"
+#include "messagefilter.h"
 #include "qtui.h"
 #include "qtuisettings.h"
 
 #include "qtui.h"
 #include "qtuisettings.h"
 
@@ -37,14 +38,21 @@ const qreal minContentsWidth = 200;
 
 ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, QObject *parent)
   : QGraphicsScene(parent),
 
 ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, QObject *parent)
   : QGraphicsScene(parent),
-  _idString(idString),
-  _model(model)
+    _idString(idString),
+    _width(0),
+    _height(0),
+    _model(model),
+    _singleBufferScene(false),
+    _selectingItem(0),
+    _lastItem(0),
+    _selectionStart(-1),
+    _isSelecting(false),
+    _fetchingBacklog(false)
 {
 {
-  _width = 0;
-  _selectingItem = 0;
-  _isSelecting = false;
-  _selectionStart = -1;
-  _fetchingBacklog = false;
+  MessageFilter *filter = qobject_cast<MessageFilter*>(model);
+  if(filter) {
+    _singleBufferScene = filter->isSingleBufferFilter();
+  }
 
   connect(this, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(rectChanged(const QRectF &)));
 
 
   connect(this, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(rectChanged(const QRectF &)));
 
index f44e20b..ce56f6b 100644 (file)
@@ -50,6 +50,7 @@ class ChatScene : public QGraphicsScene {
     inline BufferId bufferForBacklogFetching() const;
     int sectionByScenePos(int x);
     inline int sectionByScenePos(const QPoint &pos) { return sectionByScenePos(pos.x()); }
     inline BufferId bufferForBacklogFetching() const;
     int sectionByScenePos(int x);
     inline int sectionByScenePos(const QPoint &pos) { return sectionByScenePos(pos.x()); }
+    inline bool isSingleBufferScene() const { return _singleBufferScene; }
 
   public slots:
     void setWidth(qreal);
 
   public slots:
     void setWidth(qreal);
@@ -87,6 +88,7 @@ class ChatScene : public QGraphicsScene {
     qreal _width, _height;
     QAbstractItemModel *_model;
     QList<ChatLine *> _lines;
     qreal _width, _height;
     QAbstractItemModel *_model;
     QList<ChatLine *> _lines;
+    bool _singleBufferScene;
 
     ColumnHandleItem *firstColHandle, *secondColHandle;
     qreal firstColHandlePos, secondColHandlePos;
 
     ColumnHandleItem *firstColHandle, *secondColHandle;
     qreal firstColHandlePos, secondColHandlePos;
index e6b1f14..364fc4b 100644 (file)
@@ -93,6 +93,6 @@ void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) {
   _currentBuffer = bufferId;
   showChatView(bufferId);
   Client::networkModel()->setBufferActivity(bufferId, Buffer::NoActivity);
   _currentBuffer = bufferId;
   showChatView(bufferId);
   Client::networkModel()->setBufferActivity(bufferId, Buffer::NoActivity);
-  Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
+  // Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
   setFocus();
 }
   setFocus();
 }