From: Marcus Eggenberger Date: Tue, 12 Aug 2008 16:39:05 +0000 (+0200) Subject: the new chatwidget now highlights the first new message since your last visit (curren... X-Git-Tag: 0.3.0~60 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=9d22ec1fd8e8652744e6ea6c91de4a6ec5b2146c the new chatwidget now highlights the first new message since your last visit (currently hardcoded color) --- diff --git a/src/client/messagefilter.cpp b/src/client/messagefilter.cpp index e375b2e7..543d1fc5 100644 --- a/src/client/messagefilter.cpp +++ b/src/client/messagefilter.cpp @@ -29,7 +29,6 @@ MessageFilter::MessageFilter(MessageModel *source, const QList &buffer _bufferList(buffers) { setSourceModel(source); - } QString MessageFilter::idString() const { diff --git a/src/client/messagefilter.h b/src/client/messagefilter.h index 73388428..e767a95e 100644 --- a/src/client/messagefilter.h +++ b/src/client/messagefilter.h @@ -37,7 +37,8 @@ class MessageFilter : public QSortFilterProxyModel { virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; virtual QString idString() const; - + inline bool isSingleBufferFilter() const { return _bufferList.count() == 1; } + private: QList _bufferList; }; diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 793f5ae5..3f806b5c 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -901,6 +901,13 @@ void NetworkModel::removeBuffer(BufferId bufferId) { 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) { diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index c564d7e6..1a9ace38 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -297,7 +297,7 @@ public: 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); diff --git a/src/qtui/chatline.cpp b/src/qtui/chatline.cpp index 3e7167bc..af77b12c 100644 --- a/src/qtui/chatline.cpp +++ b/src/qtui/chatline.cpp @@ -28,6 +28,7 @@ #include "chatitem.h" #include "chatline.h" #include "messagemodel.h" +#include "networkmodel.h" #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) { -// const QAbstractItemModel *model_ = model(); -// if(model_ && row() > 0) { -// MsgId msgId = model_->data(model_->index(row() - 1, 0), MessageModel::MsgIdRole).value(); -// BufferId bufferId = model_->data(model_->index(row() - 1, 0), MessageModel::BufferIdRole).value(); -// qDebug() << msgId; -// } 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)); } + + const QAbstractItemModel *model_ = model(); + if(model_ && row() > 0) { + MsgId msgId = model_->data(model_->index(row() - 1, 0), MessageModel::MsgIdRole).value(); + BufferId bufferId = model_->data(model_->index(row() - 1, 0), MessageModel::BufferIdRole).value(); + 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); + } + } + + } diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 9ac7974d..8bf8adde 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -30,6 +30,7 @@ #include "client.h" #include "clientbacklogmanager.h" #include "columnhandleitem.h" +#include "messagefilter.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), - _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(model); + if(filter) { + _singleBufferScene = filter->isSingleBufferFilter(); + } connect(this, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(rectChanged(const QRectF &))); diff --git a/src/qtui/chatscene.h b/src/qtui/chatscene.h index f44e20bd..ce56f6b2 100644 --- a/src/qtui/chatscene.h +++ b/src/qtui/chatscene.h @@ -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 bool isSingleBufferScene() const { return _singleBufferScene; } public slots: void setWidth(qreal); @@ -87,6 +88,7 @@ class ChatScene : public QGraphicsScene { qreal _width, _height; QAbstractItemModel *_model; QList _lines; + bool _singleBufferScene; ColumnHandleItem *firstColHandle, *secondColHandle; qreal firstColHandlePos, secondColHandlePos; diff --git a/src/uisupport/abstractbuffercontainer.cpp b/src/uisupport/abstractbuffercontainer.cpp index e6b1f14f..364fc4ba 100644 --- a/src/uisupport/abstractbuffercontainer.cpp +++ b/src/uisupport/abstractbuffercontainer.cpp @@ -93,6 +93,6 @@ void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) { _currentBuffer = bufferId; showChatView(bufferId); Client::networkModel()->setBufferActivity(bufferId, Buffer::NoActivity); - Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId()); + // Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId()); setFocus(); }